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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"

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

config "github.com/pipe-cd/pipecd/pkg/configv1"
)
Expand Down Expand Up @@ -48,6 +49,10 @@ type KubernetesApplicationSpec struct {
// name: replication-controller-name
Workloads []K8sResourceReference `json:"workloads"`

// Which resource should be considered as the Service of application.
// Empty means the first Service resource will be used.
Service K8sResourceReference `json:"service"`

// The label will be configured to variant manifests used to distinguish them.
VariantLabel KubernetesVariantLabel `json:"variantLabel"`

Expand All @@ -56,14 +61,17 @@ type KubernetesApplicationSpec struct {

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
}

Expand Down Expand Up @@ -173,3 +181,62 @@ type KubernetesMultiTargetDeployTarget struct {
Name string `json:"name"`
Labels map[string]string `json:"labels"`
}

// K8sCanaryRolloutStageOptions contains all configurable values for a K8S_CANARY_ROLLOUT stage.
type K8sCanaryRolloutStageOptions struct {
// How many pods for CANARY workloads.
// An integer value can be specified to indicate an absolute value of pod number.
// Or a string suffixed by "%" to indicate a percentage value compared to the pod number of PRIMARY.
// Default is 1 pod.
Replicas unit.Replicas `json:"replicas"`
// Suffix that should be used when naming the CANARY variant's resources.
// Default is "canary".
Suffix string `json:"suffix" default:"canary"`
// Whether the CANARY service should be created.
CreateService bool `json:"createService"`
// List of patches used to customize manifests for CANARY variant.
Patches []K8sResourcePatch `json:"patches"`
}

// K8sCanaryCleanStageOptions contains all configurable values for a K8S_CANARY_CLEAN stage.
type K8sCanaryCleanStageOptions struct{}

// K8sResourcePatch represents a patch operation for a Kubernetes resource.
type K8sResourcePatch struct {
// The target of the patch operation.
Target K8sResourcePatchTarget `json:"target"`
// The operations to be performed on the target.
Ops []K8sResourcePatchOp `json:"ops"`
}

// K8sResourcePatchTarget represents the target of a patch operation for a Kubernetes resource.
type K8sResourcePatchTarget struct {
// The reference to the Kubernetes resource.
K8sResourceReference
// In case you want to manipulate the YAML or JSON data specified in a field
// of the manifest, specify that field's path. The string value of that field
// will be used as input for the patch operations.
// Otherwise, the whole manifest will be the target of patch operations.
DocumentRoot string `json:"documentRoot"`
}

// K8sResourcePatchOpName represents the name of a patch operation for a Kubernetes resource.
type K8sResourcePatchOpName string

const (
// K8sResourcePatchOpYAMLReplace is the name of the patch operation that replaces the target with a new YAML document.
K8sResourcePatchOpYAMLReplace K8sResourcePatchOpName = "yaml-replace"
)

// K8sResourcePatchOp represents a patch operation for a Kubernetes resource.
type K8sResourcePatchOp struct {
// The operation type.
// Currently, only "yaml-replace" is supported.
// Default is "yaml-replace".
Op K8sResourcePatchOpName `json:"op" default:"yaml-replace"`
// The path string pointing to the manipulated field.
// E.g. "$.spec.foos[0].bar"
Path string `json:"path"`
// The value string whose content will be used as new value for the field.
Value string `json:"value"`
}
Loading
Loading