Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion pkg/app/pipedv1/plugin/kubernetes/config/baseline.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@

package config

import "github.com/pipe-cd/piped-plugin-sdk-go/unit"
import (
"encoding/json"

"github.com/creasty/defaults"
"github.com/pipe-cd/piped-plugin-sdk-go/unit"
)

// K8sBaselineRolloutStageOptions contains all configurable values for a K8S_BASELINE_ROLLOUT stage.
type K8sBaselineRolloutStageOptions struct {
Expand All @@ -30,6 +35,19 @@ type K8sBaselineRolloutStageOptions struct {
CreateService bool `json:"createService"`
}

func (o *K8sBaselineRolloutStageOptions) UnmarshalJSON(data []byte) error {
type alias K8sBaselineRolloutStageOptions
var a alias
if err := json.Unmarshal(data, &a); err != nil {
return err
}
*o = K8sBaselineRolloutStageOptions(a)
if err := defaults.Set(o); err != nil {
return err
}
return nil
}

// K8sBaselineCleanStageOptions contains all configurable values for a K8S_BASELINE_CLEAN stage.
type K8sBaselineCleanStageOptions struct {
}
20 changes: 19 additions & 1 deletion pkg/app/pipedv1/plugin/kubernetes/config/canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@

package config

import "github.com/pipe-cd/piped-plugin-sdk-go/unit"
import (
"encoding/json"

"github.com/creasty/defaults"
"github.com/pipe-cd/piped-plugin-sdk-go/unit"
)

// K8sCanaryRolloutStageOptions contains all configurable values for a K8S_CANARY_ROLLOUT stage.
type K8sCanaryRolloutStageOptions struct {
Expand All @@ -32,6 +37,19 @@ type K8sCanaryRolloutStageOptions struct {
Patches []K8sResourcePatch
}

func (o *K8sCanaryRolloutStageOptions) UnmarshalJSON(data []byte) error {
type alias K8sCanaryRolloutStageOptions
var a alias
if err := json.Unmarshal(data, &a); err != nil {
return err
}
*o = K8sCanaryRolloutStageOptions(a)
if err := defaults.Set(o); err != nil {
return err
}
return nil
}

// K8sCanaryCleanStageOptions contains all configurable values for a K8S_CANARY_CLEAN stage.
type K8sCanaryCleanStageOptions struct {
}
19 changes: 19 additions & 0 deletions pkg/app/pipedv1/plugin/kubernetes/config/primary.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@

package config

import (
"encoding/json"

"github.com/creasty/defaults"
)

// K8sPrimaryRolloutStageOptions contains all configurable values for a K8S_PRIMARY_ROLLOUT stage.
type K8sPrimaryRolloutStageOptions struct {
// Suffix that should be used when naming the PRIMARY variant's resources.
Expand All @@ -26,3 +32,16 @@ type K8sPrimaryRolloutStageOptions struct {
// Whether the resources that are no longer defined in Git should be removed or not.
Prune bool `json:"prune"`
}

func (o *K8sPrimaryRolloutStageOptions) UnmarshalJSON(data []byte) error {
type alias K8sPrimaryRolloutStageOptions
var a alias
if err := json.Unmarshal(data, &a); err != nil {
return err
}
*o = K8sPrimaryRolloutStageOptions(a)
if err := defaults.Set(o); err != nil {
return err
}
return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ type KubernetesApplicationSpec struct {
// TODO: Define fields for KubernetesApplicationSpec.
}

func (s *KubernetesApplicationSpec) UnmarshalJSON(data []byte) error {
type alias KubernetesApplicationSpec
var a alias
if err := json.Unmarshal(data, &a); err != nil {
return err
}
*s = KubernetesApplicationSpec(a)
if err := defaults.Set(s); err != nil {
return err
}
return nil
}

func (s *KubernetesApplicationSpec) Validate() error {
// TODO: Validate KubernetesApplicationSpec fields.
return nil
Expand Down
Loading