From fce42c306f6fde799667cb5e2b9c5eadf1762a06 Mon Sep 17 00:00:00 2001 From: Philipp Pixel Date: Mon, 20 Jan 2025 14:03:19 +0100 Subject: [PATCH] #1 Change dogu target state to string type, change target state type This was changed during the extraction and was most likely a mistake. The original code used string here. --- bpcore/core.go | 2 +- v2/blueprintMaskV1/serializer_test.go | 8 ++++---- v2/blueprintV2/serializer_test.go | 8 ++++---- v2/entities/targetDogu.go | 6 ++---- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/bpcore/core.go b/bpcore/core.go index 77fff8a..91981c4 100644 --- a/bpcore/core.go +++ b/bpcore/core.go @@ -56,7 +56,7 @@ type TargetState int const ( // TargetStatePresent is the default state. If selected the chosen item must be present after the blueprint was // applied. - TargetStatePresent = iota + TargetStatePresent TargetState = iota // TargetStateAbsent sets the state of the item to absent. If selected the chosen item must be absent after the // blueprint was applied. TargetStateAbsent diff --git a/v2/blueprintMaskV1/serializer_test.go b/v2/blueprintMaskV1/serializer_test.go index 15af9ec..b795ff3 100644 --- a/v2/blueprintMaskV1/serializer_test.go +++ b/v2/blueprintMaskV1/serializer_test.go @@ -38,8 +38,8 @@ func TestSerializeBlueprintMask_ok(t *testing.T) { args{spec: BlueprintMaskV1{ GeneralBlueprintMask: bpcore.GeneralBlueprintMask{API: bpcore.MaskV1}, Dogus: []MaskTargetDogu{ - {Name: "official/nginx", Version: version1_2_0_1.String(), TargetState: bpcore.TargetStatePresent}, - {Name: "premium/jira", Version: version3_0_2_2.String(), TargetState: bpcore.TargetStateAbsent}, + {Name: "official/nginx", Version: version1_2_0_1.String(), TargetState: bpcore.TargetStatePresent.String()}, + {Name: "premium/jira", Version: version3_0_2_2.String(), TargetState: bpcore.TargetStateAbsent.String()}, }, }}, `{"blueprintMaskApi":"v1","blueprintMaskId":"","dogus":[{"name":"official/nginx","version":"1.2.0-1","targetState":"present"},{"name":"premium/jira","version":"3.0.2-2","targetState":"absent"}]}`, @@ -79,8 +79,8 @@ func TestDeserializeBlueprintMask_ok(t *testing.T) { BlueprintMaskV1{ GeneralBlueprintMask: bpcore.GeneralBlueprintMask{API: bpcore.MaskV1}, Dogus: []MaskTargetDogu{ - {Name: "official/nginx", Version: version1_2_0_1.String(), TargetState: bpcore.TargetStatePresent}, - {Name: "premium/jira", Version: version3_0_2_2.String(), TargetState: bpcore.TargetStateAbsent}, + {Name: "official/nginx", Version: version1_2_0_1.String(), TargetState: bpcore.TargetStatePresent.String()}, + {Name: "premium/jira", Version: version3_0_2_2.String(), TargetState: bpcore.TargetStateAbsent.String()}, }}, assert.NoError, }, diff --git a/v2/blueprintV2/serializer_test.go b/v2/blueprintV2/serializer_test.go index c5b401c..2030e40 100644 --- a/v2/blueprintV2/serializer_test.go +++ b/v2/blueprintV2/serializer_test.go @@ -43,10 +43,10 @@ func TestSerializeBlueprint_ok(t *testing.T) { GeneralBlueprint: bpcore.GeneralBlueprint{API: bpcore.V2}, Dogus: []entities.TargetDogu{ { - Name: "official/nginx", Version: v1201, TargetState: bpcore.TargetStatePresent, PlatformConfig: entities.PlatformConfig{ResourceConfig: entities.ResourceConfig{MinVolumeSize: "2Gi"}, ReverseProxyConfig: entities.ReverseProxyConfig{MaxBodySize: "2Gi", AdditionalConfig: "additional", RewriteTarget: "/"}}, + Name: "official/nginx", Version: v1201, TargetState: bpcore.TargetStatePresent.String(), PlatformConfig: entities.PlatformConfig{ResourceConfig: entities.ResourceConfig{MinVolumeSize: "2Gi"}, ReverseProxyConfig: entities.ReverseProxyConfig{MaxBodySize: "2Gi", AdditionalConfig: "additional", RewriteTarget: "/"}}, }, { - Name: "premium/jira", Version: v2341, TargetState: bpcore.TargetStateAbsent, + Name: "premium/jira", Version: v2341, TargetState: bpcore.TargetStateAbsent.String(), }, }, }}, @@ -183,8 +183,8 @@ func TestDeserializeBlueprint_ok(t *testing.T) { BlueprintV2{ GeneralBlueprint: bpcore.GeneralBlueprint{API: bpcore.V2}, Dogus: []entities.TargetDogu{ - {Name: "official/nginx", Version: v1201, TargetState: bpcore.TargetStatePresent}, - {Name: "premium/jira", Version: v2341, TargetState: bpcore.TargetStateAbsent}, + {Name: "official/nginx", Version: v1201, TargetState: bpcore.TargetStatePresent.String()}, + {Name: "premium/jira", Version: v2341, TargetState: bpcore.TargetStateAbsent.String()}, }}, assert.NoError, }, diff --git a/v2/entities/targetDogu.go b/v2/entities/targetDogu.go index f14c230..6e74ca3 100644 --- a/v2/entities/targetDogu.go +++ b/v2/entities/targetDogu.go @@ -1,7 +1,5 @@ package entities -import "github.com/cloudogu/blueprint-lib/bpcore" - // TargetDogu defines a Dogu, its version, and the installation state in which it is supposed to be after a blueprint // was applied. type TargetDogu struct { @@ -11,8 +9,8 @@ type TargetDogu struct { // otherwise it is optional and is not going to be interpreted. Version string `json:"version"` // TargetState defines a state of installation of this dogu. Optional field, but defaults to "TargetStatePresent" - TargetState bpcore.TargetState `json:"targetState"` - PlatformConfig PlatformConfig `json:"platformConfig,omitempty"` + TargetState string `json:"targetState"` + PlatformConfig PlatformConfig `json:"platformConfig,omitempty"` } type ResourceConfig struct {