File tree Expand file tree Collapse file tree 4 files changed +70
-2
lines changed
kubernetes_multicluster/config Expand file tree Collapse file tree 4 files changed +70
-2
lines changed Original file line number Diff line number Diff line change 1414
1515package config
1616
17- import "github.com/pipe-cd/piped-plugin-sdk-go/unit"
17+ import (
18+ "encoding/json"
19+
20+ "github.com/creasty/defaults"
21+ "github.com/pipe-cd/piped-plugin-sdk-go/unit"
22+ )
1823
1924// K8sBaselineRolloutStageOptions contains all configurable values for a K8S_BASELINE_ROLLOUT stage.
2025type K8sBaselineRolloutStageOptions struct {
@@ -30,6 +35,19 @@ type K8sBaselineRolloutStageOptions struct {
3035 CreateService bool `json:"createService"`
3136}
3237
38+ func (o * K8sBaselineRolloutStageOptions ) UnmarshalJSON (data []byte ) error {
39+ type alias K8sBaselineRolloutStageOptions
40+ var a alias
41+ if err := json .Unmarshal (data , & a ); err != nil {
42+ return err
43+ }
44+ * o = K8sBaselineRolloutStageOptions (a )
45+ if err := defaults .Set (o ); err != nil {
46+ return err
47+ }
48+ return nil
49+ }
50+
3351// K8sBaselineCleanStageOptions contains all configurable values for a K8S_BASELINE_CLEAN stage.
3452type K8sBaselineCleanStageOptions struct {
3553}
Original file line number Diff line number Diff line change 1414
1515package config
1616
17- import "github.com/pipe-cd/piped-plugin-sdk-go/unit"
17+ import (
18+ "encoding/json"
19+
20+ "github.com/creasty/defaults"
21+ "github.com/pipe-cd/piped-plugin-sdk-go/unit"
22+ )
1823
1924// K8sCanaryRolloutStageOptions contains all configurable values for a K8S_CANARY_ROLLOUT stage.
2025type K8sCanaryRolloutStageOptions struct {
@@ -32,6 +37,19 @@ type K8sCanaryRolloutStageOptions struct {
3237 Patches []K8sResourcePatch
3338}
3439
40+ func (o * K8sCanaryRolloutStageOptions ) UnmarshalJSON (data []byte ) error {
41+ type alias K8sCanaryRolloutStageOptions
42+ var a alias
43+ if err := json .Unmarshal (data , & a ); err != nil {
44+ return err
45+ }
46+ * o = K8sCanaryRolloutStageOptions (a )
47+ if err := defaults .Set (o ); err != nil {
48+ return err
49+ }
50+ return nil
51+ }
52+
3553// K8sCanaryCleanStageOptions contains all configurable values for a K8S_CANARY_CLEAN stage.
3654type K8sCanaryCleanStageOptions struct {
3755}
Original file line number Diff line number Diff line change 1414
1515package config
1616
17+ import (
18+ "encoding/json"
19+
20+ "github.com/creasty/defaults"
21+ )
22+
1723// K8sPrimaryRolloutStageOptions contains all configurable values for a K8S_PRIMARY_ROLLOUT stage.
1824type K8sPrimaryRolloutStageOptions struct {
1925 // Suffix that should be used when naming the PRIMARY variant's resources.
@@ -26,3 +32,16 @@ type K8sPrimaryRolloutStageOptions struct {
2632 // Whether the resources that are no longer defined in Git should be removed or not.
2733 Prune bool `json:"prune"`
2834}
35+
36+ func (o * K8sPrimaryRolloutStageOptions ) UnmarshalJSON (data []byte ) error {
37+ type alias K8sPrimaryRolloutStageOptions
38+ var a alias
39+ if err := json .Unmarshal (data , & a ); err != nil {
40+ return err
41+ }
42+ * o = K8sPrimaryRolloutStageOptions (a )
43+ if err := defaults .Set (o ); err != nil {
44+ return err
45+ }
46+ return nil
47+ }
Original file line number Diff line number Diff line change @@ -54,6 +54,19 @@ type KubernetesApplicationSpec struct {
5454 // TODO: Define fields for KubernetesApplicationSpec.
5555}
5656
57+ func (s * KubernetesApplicationSpec ) UnmarshalJSON (data []byte ) error {
58+ type alias KubernetesApplicationSpec
59+ var a alias
60+ if err := json .Unmarshal (data , & a ); err != nil {
61+ return err
62+ }
63+ * s = KubernetesApplicationSpec (a )
64+ if err := defaults .Set (s ); err != nil {
65+ return err
66+ }
67+ return nil
68+ }
69+
5770func (s * KubernetesApplicationSpec ) Validate () error {
5871 // TODO: Validate KubernetesApplicationSpec fields.
5972 return nil
You can’t perform that action at this time.
0 commit comments