From 10ef972655aef16090c657877b88238fdb412234 Mon Sep 17 00:00:00 2001 From: Nick Santos Date: Mon, 5 Dec 2022 20:02:28 -0500 Subject: [PATCH] cluster: fix a bug in k3d 5.4+ (#266) Signed-off-by: Nick Santos Signed-off-by: Nick Santos --- .circleci/config.yml | 2 +- pkg/api/k3dv1alpha4/types.go | 6 +++++- pkg/api/k3dv1alpha4/zz_generated.deepcopy.go | 17 +++++++++++++++++ pkg/cluster/admin_k3d_test.go | 3 ++- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 491846b..16b3781 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -59,7 +59,7 @@ jobs: sudo mv ./kind-linux-amd64 /usr/local/bin/kind - run: | set -ex - export TAG=v5.2.2 + export TAG=v5.4.6 curl -s https://raw.githubusercontent.com/rancher/k3d/main/install.sh | bash - run: | set -ex diff --git a/pkg/api/k3dv1alpha4/types.go b/pkg/api/k3dv1alpha4/types.go index c378f18..dcdf96e 100644 --- a/pkg/api/k3dv1alpha4/types.go +++ b/pkg/api/k3dv1alpha4/types.go @@ -13,6 +13,10 @@ type TypeMeta struct { APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"` } +type ObjectMeta struct { + Name string `mapstructure:"name,omitempty" json:"name,omitempty" yaml:"name,omitempty"` +} + type VolumeWithNodeFilters struct { Volume string `mapstructure:"volume" yaml:"volume,omitempty" json:"volume,omitempty"` NodeFilters []string `mapstructure:"nodeFilters" yaml:"nodeFilters,omitempty" json:"nodeFilters,omitempty"` @@ -94,7 +98,7 @@ type SimpleConfigRegistries struct { // SimpleConfig describes the toplevel k3d configuration file. type SimpleConfig struct { TypeMeta `yaml:",inline"` - Name string `mapstructure:"name" yaml:"name,omitempty" json:"name,omitempty"` + ObjectMeta `mapstructure:"metadata" yaml:"metadata,omitempty" json:"metadata,omitempty"` Servers int `mapstructure:"servers" yaml:"servers,omitempty" json:"servers,omitempty"` //nolint:lll // default 1 Agents int `mapstructure:"agents" yaml:"agents,omitempty" json:"agents,omitempty"` //nolint:lll // default 0 ExposeAPI SimpleExposureOpts `mapstructure:"kubeAPI" yaml:"kubeAPI,omitempty" json:"kubeAPI,omitempty"` diff --git a/pkg/api/k3dv1alpha4/zz_generated.deepcopy.go b/pkg/api/k3dv1alpha4/zz_generated.deepcopy.go index 6fc9a0e..908aaa9 100644 --- a/pkg/api/k3dv1alpha4/zz_generated.deepcopy.go +++ b/pkg/api/k3dv1alpha4/zz_generated.deepcopy.go @@ -84,6 +84,22 @@ func (in *LabelWithNodeFilters) DeepCopy() *LabelWithNodeFilters { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ObjectMeta) DeepCopyInto(out *ObjectMeta) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ObjectMeta. +func (in *ObjectMeta) DeepCopy() *ObjectMeta { + if in == nil { + return nil + } + out := new(ObjectMeta) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PortWithNodeFilters) DeepCopyInto(out *PortWithNodeFilters) { *out = *in @@ -109,6 +125,7 @@ func (in *PortWithNodeFilters) DeepCopy() *PortWithNodeFilters { func (in *SimpleConfig) DeepCopyInto(out *SimpleConfig) { *out = *in out.TypeMeta = in.TypeMeta + out.ObjectMeta = in.ObjectMeta out.ExposeAPI = in.ExposeAPI if in.Volumes != nil { in, out := &in.Volumes, &out.Volumes diff --git a/pkg/cluster/admin_k3d_test.go b/pkg/cluster/admin_k3d_test.go index e2f96a6..6a922f0 100644 --- a/pkg/cluster/admin_k3d_test.go +++ b/pkg/cluster/admin_k3d_test.go @@ -57,7 +57,8 @@ func TestK3DStartFlagsV5(t *testing.T) { }, f.runner.LastArgs) assert.Equal(t, f.runner.LastStdin, `kind: Simple apiVersion: k3d.io/v1alpha4 -name: my-cluster +metadata: + name: my-cluster network: bar registries: use: