Skip to content

Commit

Permalink
#1 Change dogu target state to string type, change target state type
Browse files Browse the repository at this point in the history
This was changed during the extraction and was most likely a mistake.
The original code used string here.
  • Loading branch information
ppxl committed Jan 20, 2025
1 parent 8a6a754 commit fce42c3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion bpcore/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions v2/blueprintMaskV1/serializer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}]}`,
Expand Down Expand Up @@ -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,
},
Expand Down
8 changes: 4 additions & 4 deletions v2/blueprintV2/serializer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
},
}},
Expand Down Expand Up @@ -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,
},
Expand Down
6 changes: 2 additions & 4 deletions v2/entities/targetDogu.go
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit fce42c3

Please sign in to comment.