From f910ed86bb67c696fc17bb7cf0bfc39ce032ac5d Mon Sep 17 00:00:00 2001 From: Matias Frank Jensen Date: Wed, 24 Apr 2024 10:36:00 +0200 Subject: [PATCH 1/2] :sparkles: Update the platform CRDs --- cmd/rig-proto-gen/main.go | 1 + docs/docs/api/platform-api.md | 18 +------------ pkg/api/platform/v1/types.go | 26 ++++++++++++++++--- pkg/api/platform/v1/zz_generated.deepcopy.go | 23 +++++++++++++--- .../k8s.io/api/autoscaling/v2/generated.proto | 1 + .../pkg/api/resource/generated.proto | 1 + proto/rig/platform/v1/generated.proto | 12 ++++++++- proto/rig/v1alpha2/generated.proto | 1 + 8 files changed, 57 insertions(+), 26 deletions(-) diff --git a/cmd/rig-proto-gen/main.go b/cmd/rig-proto-gen/main.go index ba96f78e5..b345b0878 100644 --- a/cmd/rig-proto-gen/main.go +++ b/cmd/rig-proto-gen/main.go @@ -35,6 +35,7 @@ var ( } compiledTypes = []any{ v1.CapsuleStar{}, + v1.CapsuleEnvironment{}, v1.Environment{}, v1.Project{}, } diff --git a/docs/docs/api/platform-api.md b/docs/docs/api/platform-api.md index a8687a850..62adccd05 100644 --- a/docs/docs/api/platform-api.md +++ b/docs/docs/api/platform-api.md @@ -7904,23 +7904,7 @@ Empty response for updating users settings for the Rig project. | name | [string](#string) | | | | project | [string](#string) | | | | capsuleBase | [CapsuleSpecExtension](#platform-v1-CapsuleSpecExtension) | | | -| environments | [CapsuleStar.EnvironmentsEntry](#platform-v1-CapsuleStar-EnvironmentsEntry) | repeated | | - - - - - - - - -### CapsuleStar.EnvironmentsEntry - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| key | [string](#string) | | | -| value | [CapsuleSpecExtension](#platform-v1-CapsuleSpecExtension) | | | +| environments | [string](#string) | repeated | | diff --git a/pkg/api/platform/v1/types.go b/pkg/api/platform/v1/types.go index dd99bacf9..6afb7e876 100644 --- a/pkg/api/platform/v1/types.go +++ b/pkg/api/platform/v1/types.go @@ -60,12 +60,30 @@ type CapsuleStar struct { metav1.TypeMeta `json:",inline"` // Name,Project is unique Name string `json:"name" protobuf:"3"` - // Project references an existing Project2 type with the given name - // Will throw an error (in the platform) if the project does not exist + // Project references an existing Project type with the given name + // Will throw an error (in the platform) if the Project does not exist Project string `json:"project" protobuf:"4"` // Capsule-level defaults - CapsuleBase CapsuleSpecExtension `json:"capsuleBase" protobuf:"5"` - Environments map[string]CapsuleSpecExtension `json:"environments" protobuf:"6"` + CapsuleBase CapsuleSpecExtension `json:"capsuleBase" protobuf:"5"` + Environments []string `json:"environments" protobuf:"6"` +} + +// +kubebuilder:object:root=true + +type CapsuleEnvironment struct { + metav1.TypeMeta `json:",inline"` + // Name,Project,Environment is unique + // Project,Name referes to an existing CapsuleStar type with the given name and project + // Will throw an error (in the platform) if the CapsuleStar does not exist + Name string `json:"name" protobuf:"3"` + // Project references an existing Project type with the given name + // Will throw an error (in the platform) if the Project does not exist + Project string `json:"project" protobuf:"4"` + // Environment references an existing Environment type with the given name + // Will throw an error (in the platform) if the Environment does not exist + // The environment also needs to be present in the parent CapsuleStar + Environment string `json:"environment" protobuf:"5"` + Spec CapsuleSpecExtension `json:"spec" protobuf:"6"` } type CapsuleSpecExtension struct { diff --git a/pkg/api/platform/v1/zz_generated.deepcopy.go b/pkg/api/platform/v1/zz_generated.deepcopy.go index 18454abc3..222f607a3 100644 --- a/pkg/api/platform/v1/zz_generated.deepcopy.go +++ b/pkg/api/platform/v1/zz_generated.deepcopy.go @@ -9,6 +9,23 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CapsuleEnvironment) DeepCopyInto(out *CapsuleEnvironment) { + *out = *in + out.TypeMeta = in.TypeMeta + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CapsuleEnvironment. +func (in *CapsuleEnvironment) DeepCopy() *CapsuleEnvironment { + if in == nil { + return nil + } + out := new(CapsuleEnvironment) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CapsuleSpecExtension) DeepCopyInto(out *CapsuleSpecExtension) { *out = *in @@ -73,10 +90,8 @@ func (in *CapsuleStar) DeepCopyInto(out *CapsuleStar) { in.CapsuleBase.DeepCopyInto(&out.CapsuleBase) if in.Environments != nil { in, out := &in.Environments, &out.Environments - *out = make(map[string]CapsuleSpecExtension, len(*in)) - for key, val := range *in { - (*out)[key] = *val.DeepCopy() - } + *out = make([]string, len(*in)) + copy(*out, *in) } } diff --git a/proto/rig/k8s.io/api/autoscaling/v2/generated.proto b/proto/rig/k8s.io/api/autoscaling/v2/generated.proto index cc20c2e92..52e83a799 100644 --- a/proto/rig/k8s.io/api/autoscaling/v2/generated.proto +++ b/proto/rig/k8s.io/api/autoscaling/v2/generated.proto @@ -7,3 +7,4 @@ message CrossVersionObjectReference { string name = 2; string apiVersion = 3; } + diff --git a/proto/rig/k8s.io/apimachinery/pkg/api/resource/generated.proto b/proto/rig/k8s.io/apimachinery/pkg/api/resource/generated.proto index 633d1053f..3af9c5051 100644 --- a/proto/rig/k8s.io/apimachinery/pkg/api/resource/generated.proto +++ b/proto/rig/k8s.io/apimachinery/pkg/api/resource/generated.proto @@ -5,3 +5,4 @@ package k8s.io.apimachinery.pkg.api.resource; message Quantity { string string = 1; } + diff --git a/proto/rig/platform/v1/generated.proto b/proto/rig/platform/v1/generated.proto index a217f08e8..6de47e023 100644 --- a/proto/rig/platform/v1/generated.proto +++ b/proto/rig/platform/v1/generated.proto @@ -10,7 +10,7 @@ message CapsuleStar { string name = 3; string project = 4; CapsuleSpecExtension capsuleBase = 5; - map environments = 6; + repeated string environments = 6; } message CapsuleSpecExtension { @@ -33,6 +33,15 @@ message ConfigFile { bool isSecret = 3; } +message CapsuleEnvironment { + string kind = 1; + string apiVersion = 2; + string name = 3; + string project = 4; + string environment = 5; + CapsuleSpecExtension spec = 6; +} + message Environment { string kind = 1; string apiVersion = 2; @@ -55,3 +64,4 @@ message Project { repeated string environments = 4; ProjEnvCapsuleBase capsuleBase = 5; } + diff --git a/proto/rig/v1alpha2/generated.proto b/proto/rig/v1alpha2/generated.proto index 29a1fb551..e2712b8e3 100644 --- a/proto/rig/v1alpha2/generated.proto +++ b/proto/rig/v1alpha2/generated.proto @@ -123,3 +123,4 @@ message JobCommand { string command = 1; repeated string args = 2; } + From 397855b7ee8ba7907b8987a9fef1ecc176c780e1 Mon Sep 17 00:00:00 2001 From: Matias Frank Jensen Date: Wed, 24 Apr 2024 10:43:05 +0200 Subject: [PATCH 2/2] fix --- docs/docs/api/platform-api.md | 20 +++++++++++++++++++ pkg/api/platform/v1/zz_generated.deepcopy.go | 8 ++++++++ .../k8s.io/api/autoscaling/v2/generated.proto | 1 - .../pkg/api/resource/generated.proto | 1 - proto/rig/platform/v1/generated.proto | 1 - proto/rig/v1alpha2/generated.proto | 1 - 6 files changed, 28 insertions(+), 4 deletions(-) diff --git a/docs/docs/api/platform-api.md b/docs/docs/api/platform-api.md index 62adccd05..f5f8bbbca 100644 --- a/docs/docs/api/platform-api.md +++ b/docs/docs/api/platform-api.md @@ -7834,6 +7834,26 @@ Empty response for updating users settings for the Rig project. + + +### CapsuleEnvironment + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| kind | [string](#string) | | | +| apiVersion | [string](#string) | | | +| name | [string](#string) | | | +| project | [string](#string) | | | +| environment | [string](#string) | | | +| spec | [CapsuleSpecExtension](#platform-v1-CapsuleSpecExtension) | | | + + + + + + ### CapsuleSpecExtension diff --git a/pkg/api/platform/v1/zz_generated.deepcopy.go b/pkg/api/platform/v1/zz_generated.deepcopy.go index 222f607a3..ad94ad3f2 100644 --- a/pkg/api/platform/v1/zz_generated.deepcopy.go +++ b/pkg/api/platform/v1/zz_generated.deepcopy.go @@ -26,6 +26,14 @@ func (in *CapsuleEnvironment) DeepCopy() *CapsuleEnvironment { return out } +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CapsuleEnvironment) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CapsuleSpecExtension) DeepCopyInto(out *CapsuleSpecExtension) { *out = *in diff --git a/proto/rig/k8s.io/api/autoscaling/v2/generated.proto b/proto/rig/k8s.io/api/autoscaling/v2/generated.proto index 52e83a799..cc20c2e92 100644 --- a/proto/rig/k8s.io/api/autoscaling/v2/generated.proto +++ b/proto/rig/k8s.io/api/autoscaling/v2/generated.proto @@ -7,4 +7,3 @@ message CrossVersionObjectReference { string name = 2; string apiVersion = 3; } - diff --git a/proto/rig/k8s.io/apimachinery/pkg/api/resource/generated.proto b/proto/rig/k8s.io/apimachinery/pkg/api/resource/generated.proto index 3af9c5051..633d1053f 100644 --- a/proto/rig/k8s.io/apimachinery/pkg/api/resource/generated.proto +++ b/proto/rig/k8s.io/apimachinery/pkg/api/resource/generated.proto @@ -5,4 +5,3 @@ package k8s.io.apimachinery.pkg.api.resource; message Quantity { string string = 1; } - diff --git a/proto/rig/platform/v1/generated.proto b/proto/rig/platform/v1/generated.proto index 6de47e023..6f7a59959 100644 --- a/proto/rig/platform/v1/generated.proto +++ b/proto/rig/platform/v1/generated.proto @@ -64,4 +64,3 @@ message Project { repeated string environments = 4; ProjEnvCapsuleBase capsuleBase = 5; } - diff --git a/proto/rig/v1alpha2/generated.proto b/proto/rig/v1alpha2/generated.proto index e2712b8e3..29a1fb551 100644 --- a/proto/rig/v1alpha2/generated.proto +++ b/proto/rig/v1alpha2/generated.proto @@ -123,4 +123,3 @@ message JobCommand { string command = 1; repeated string args = 2; } -