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
4 changes: 2 additions & 2 deletions examples/cloudrun/bluegreen/.pipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ spec:
stages:
# Deploy workloads of the new version.
# But this is still receiving no traffic.
- name: CLOUDRUN_NEW_VERSION_ROLLOUT
- name: CLOUDRUN_CANARY_ROLLOUT
# Change the traffic routing state where
# the new version will receive 100% of the traffic as soon as possible.
# This is known as blue-green strategy.
- name: CLOUDRUN_TRAFFIC_ROUTING
with:
newVersion: 100
canary: 100
# Optional: We can also add an ANALYSIS stage to verify the new version.
# If this stage finds any not good metrics of the new version,
# a rollback process to the previous version will be executed.
Expand Down
6 changes: 3 additions & 3 deletions examples/cloudrun/canary/.pipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ spec:
stages:
# Deploy workloads of the new version.
# But this is still receiving no traffic.
- name: CLOUDRUN_NEW_VERSION_ROLLOUT
- name: CLOUDRUN_CANARY_ROLLOUT
# Change the traffic routing state where
# the new version will receive the specified percentage of traffic.
# This is known as multi-phase canary strategy.
- name: CLOUDRUN_TRAFFIC_ROUTING
with:
newVersion: 10
canary: 10
# Optional: We can also add an ANALYSIS stage to verify the new version.
# If this stage finds any not good metrics of the new version,
# a rollback process to the previous version will be executed.
Expand All @@ -23,4 +23,4 @@ spec:
# thre new version will receive 100% of the traffic.
- name: CLOUDRUN_TRAFFIC_ROUTING
with:
newVersion: 100
canary: 100
4 changes: 2 additions & 2 deletions examples/lambda/bluegreen/.pipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ spec:
stages:
# Deploy workloads of the new version.
# But this is still receiving no traffic.
- name: LAMBDA_NEW_VERSION_ROLLOUT
- name: LAMBDA_CANARY_ROLLOUT
# Change the traffic routing state where
# the new version will receive 100% of the traffic as soon as possible.
# This is known as blue-green strategy.
- name: LAMBDA_TRAFFIC_ROUTING
with:
newVersion: 100
canary: 100
# Optional: We can also add an ANALYSIS stage to verify the new version.
# If this stage finds any not good metrics of the new version,
# a rollback process to the previous version will be executed.
Expand Down
6 changes: 3 additions & 3 deletions examples/lambda/canary/.pipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ spec:
stages:
# Deploy workloads of the new version.
# But this is still receiving no traffic.
- name: LAMBDA_NEW_VERSION_ROLLOUT
- name: LAMBDA_CANARY_ROLLOUT
# Change the traffic routing state where
# the new version will receive the specified percentage of traffic.
# This is known as multi-phase canary strategy.
- name: LAMBDA_TRAFFIC_ROUTING
with:
newVersion: 10
canary: 10
# Optional: We can also add an ANALYSIS stage to verify the new version.
# If this stage finds any not good metrics of the new version,
# a rollback process to the previous version will be executed.
Expand All @@ -27,4 +27,4 @@ spec:
# thre new version will receive 100% of the traffic.
- name: LAMBDA_TRAFFIC_ROUTING
with:
newVersion: 100
canary: 100
1 change: 1 addition & 0 deletions examples/lambda/simple/.pipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: LambdaApp
spec:
input:
# Where to fetch the source code to create lambda package.
# If the source code is inside the same repository "git" and "ref" can be omitted.
git: git@github.com:org/source-repo.git
path: lambdas/demoapp
ref: v1.0.0
60 changes: 55 additions & 5 deletions pkg/config/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,28 @@ type PipelineStage struct {
Desc string
Timeout Duration

WaitStageOptions *WaitStageOptions
WaitApprovalStageOptions *WaitApprovalStageOptions
AnalysisStageOptions *AnalysisStageOptions
WaitStageOptions *WaitStageOptions
WaitApprovalStageOptions *WaitApprovalStageOptions
AnalysisStageOptions *AnalysisStageOptions

K8sPrimaryRolloutStageOptions *K8sPrimaryRolloutStageOptions
K8sCanaryRolloutStageOptions *K8sCanaryRolloutStageOptions
K8sCanaryCleanStageOptions *K8sCanaryCleanStageOptions
K8sBaselineRolloutStageOptions *K8sBaselineRolloutStageOptions
K8sBaselineCleanStageOptions *K8sBaselineCleanStageOptions
K8sTrafficRoutingStageOptions *K8sTrafficRoutingStageOptions
TerraformPlanStageOptions *TerraformPlanStageOptions
TerraformApplyStageOptions *TerraformApplyStageOptions

TerraformSyncStageOptions *TerraformSyncStageOptions
TerraformPlanStageOptions *TerraformPlanStageOptions
TerraformApplyStageOptions *TerraformApplyStageOptions

CloudRunSyncStageOptions *CloudRunSyncStageOptions
CloudRunCanaryRolloutStageOptions *CloudRunCanaryRolloutStageOptions
CloudRunTrafficRoutingStageOptions *CloudRunTrafficRoutingStageOptions

LambdaSyncStageOptions *LambdaSyncStageOptions
LambdaCanaryRolloutStageOptions *LambdaCanaryRolloutStageOptions
LambdaTrafficRoutingStageOptions *LambdaTrafficRoutingStageOptions
}

type genericPipelineStage struct {
Expand Down Expand Up @@ -127,6 +138,12 @@ func (s *PipelineStage) UnmarshalJSON(data []byte) error {
if len(gs.With) > 0 {
err = json.Unmarshal(gs.With, s.K8sTrafficRoutingStageOptions)
}

case model.StageTerraformSync:
s.TerraformSyncStageOptions = &TerraformSyncStageOptions{}
if len(gs.With) > 0 {
err = json.Unmarshal(gs.With, s.TerraformSyncStageOptions)
}
case model.StageTerraformPlan:
s.TerraformPlanStageOptions = &TerraformPlanStageOptions{}
if len(gs.With) > 0 {
Expand All @@ -137,6 +154,39 @@ func (s *PipelineStage) UnmarshalJSON(data []byte) error {
if len(gs.With) > 0 {
err = json.Unmarshal(gs.With, s.TerraformApplyStageOptions)
}

case model.StageCloudRunSync:
s.CloudRunSyncStageOptions = &CloudRunSyncStageOptions{}
if len(gs.With) > 0 {
err = json.Unmarshal(gs.With, s.CloudRunSyncStageOptions)
}
case model.StageCloudRunCanaryRollout:
s.CloudRunCanaryRolloutStageOptions = &CloudRunCanaryRolloutStageOptions{}
if len(gs.With) > 0 {
err = json.Unmarshal(gs.With, s.CloudRunCanaryRolloutStageOptions)
}
case model.StageCloudRunTrafficRouting:
s.CloudRunTrafficRoutingStageOptions = &CloudRunTrafficRoutingStageOptions{}
if len(gs.With) > 0 {
err = json.Unmarshal(gs.With, s.CloudRunTrafficRoutingStageOptions)
}

case model.StageLambdaSync:
s.LambdaSyncStageOptions = &LambdaSyncStageOptions{}
if len(gs.With) > 0 {
err = json.Unmarshal(gs.With, s.LambdaSyncStageOptions)
}
case model.StageLambdaCanaryRollout:
s.LambdaCanaryRolloutStageOptions = &LambdaCanaryRolloutStageOptions{}
if len(gs.With) > 0 {
err = json.Unmarshal(gs.With, s.LambdaCanaryRolloutStageOptions)
}
case model.StageLambdaTrafficRouting:
s.LambdaTrafficRoutingStageOptions = &LambdaTrafficRoutingStageOptions{}
if len(gs.With) > 0 {
err = json.Unmarshal(gs.With, s.LambdaTrafficRoutingStageOptions)
}

default:
err = fmt.Errorf("unsupported stage name: %s", s.Name)
}
Expand Down
60 changes: 60 additions & 0 deletions pkg/config/deployment_cloudrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,63 @@
// limitations under the License.

package config

// CloudRunDeploymentSpec represents a deployment configuration for CloudRun application.
type CloudRunDeploymentSpec struct {
Input CloudRunDeploymentInput `json:"input"`
QuickSync CloudRunSyncStageOptions `json:"quickSync"`
Pipeline *DeploymentPipeline `json:"pipeline"`
}

func (s *CloudRunDeploymentSpec) GetStage(index int32) (PipelineStage, bool) {
if s.Pipeline == nil {
return PipelineStage{}, false
}
if int(index) >= len(s.Pipeline.Stages) {
return PipelineStage{}, false
}
return s.Pipeline.Stages[index], true
}

// Validate returns an error if any wrong configuration value was found.
func (s *CloudRunDeploymentSpec) Validate() error {
return nil
}

type CloudRunDeploymentInput struct {
image string `json:"image"`
// Automatically reverts all changes from all stages when one of them failed.
// Default is true.
AutoRollback bool `json:"autoRollback"`
}

// CloudRunSyncStageOptions contains all configurable values for a CLOUDRUN_SYNC stage.
type CloudRunSyncStageOptions struct {
}

// CloudRunCanaryRolloutStageOptions contains all configurable values for a CLOUDRUN_CANARY_ROLLOUT stage.
type CloudRunCanaryRolloutStageOptions struct {
}

// CloudRunTrafficRoutingStageOptions contains all configurable values for a CLOUDRUN_TRAFFIC_ROUTING stage.
type CloudRunTrafficRoutingStageOptions struct {
// Which variant should receive all traffic.
// This can be either "primary" or "canary".
All string `json:"all"`
// The percentage of traffic should be routed to PRIMARY variant.
Primary int `json:"primary"`
// The percentage of traffic should be routed to CANARY variant.
Canary int `json:"canary"`
}

func (opts CloudRunTrafficRoutingStageOptions) Percentages() (primary, canary int) {
switch opts.All {
case "primary":
primary = 100
return
case "canary":
canary = 100
return
}
return opts.Primary, opts.Canary
}
62 changes: 62 additions & 0 deletions pkg/config/deployment_lambda.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,65 @@
// limitations under the License.

package config

// LambdaDeploymentSpec represents a deployment configuration for Lambda application.
type LambdaDeploymentSpec struct {
Input LambdaDeploymentInput `json:"input"`
QuickSync LambdaSyncStageOptions `json:"quickSync"`
Pipeline *DeploymentPipeline `json:"pipeline"`
}

func (s *LambdaDeploymentSpec) GetStage(index int32) (PipelineStage, bool) {
if s.Pipeline == nil {
return PipelineStage{}, false
}
if int(index) >= len(s.Pipeline.Stages) {
return PipelineStage{}, false
}
return s.Pipeline.Stages[index], true
}

// Validate returns an error if any wrong configuration value was found.
func (s *LambdaDeploymentSpec) Validate() error {
return nil
}

type LambdaDeploymentInput struct {
Git string `json:"git"`
Path string `json:"path"`
Ref string `json:"ref"`
// Automatically reverts all changes from all stages when one of them failed.
// Default is true.
AutoRollback bool `json:"autoRollback"`
}

// LambdaSyncStageOptions contains all configurable values for a CLOUDRUN_SYNC stage.
type LambdaSyncStageOptions struct {
}

// LambdaCanaryRolloutStageOptions contains all configurable values for a CLOUDRUN_CANARY_ROLLOUT stage.
type LambdaCanaryRolloutStageOptions struct {
}

// LambdaTrafficRoutingStageOptions contains all configurable values for a CLOUDRUN_TRAFFIC_ROUTING stage.
type LambdaTrafficRoutingStageOptions struct {
// Which variant should receive all traffic.
// This can be either "primary" or "canary".
All string `json:"all"`
// The percentage of traffic should be routed to PRIMARY variant.
Primary int `json:"primary"`
// The percentage of traffic should be routed to CANARY variant.
Canary int `json:"canary"`
}

func (opts LambdaTrafficRoutingStageOptions) Percentages() (primary, canary int) {
switch opts.All {
case "primary":
primary = 100
return
case "canary":
canary = 100
return
}
return opts.Primary, opts.Canary
}
15 changes: 11 additions & 4 deletions pkg/config/deployment_terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ package config

// TerraformDeploymentSpec represents a deployment configuration for Terraform application.
type TerraformDeploymentSpec struct {
Input TerraformDeploymentInput `json:"input"`
Pipeline *DeploymentPipeline `json:"pipeline"`
Input TerraformDeploymentInput `json:"input"`
QuickSync TerraformApplyStageOptions `json:"quickSync"`
Pipeline *DeploymentPipeline `json:"pipeline"`
}

func (s *TerraformDeploymentSpec) GetStage(index int32) (PipelineStage, bool) {
Expand All @@ -44,11 +45,17 @@ type TerraformDeploymentInput struct {
Dependencies []string `json:"dependencies,omitempty"`
}

// TerraformPlanStageOptions contains all configurable values for a K8S_TERRAFORM_PLAN stage.
// TerraformSyncStageOptions contains all configurable values for a TERRAFORM_SYNC stage.
type TerraformSyncStageOptions struct {
// How many times to retry applying terraform changes.
Retries int `json:"retries"`
}

// TerraformPlanStageOptions contains all configurable values for a TERRAFORM_PLAN stage.
type TerraformPlanStageOptions struct {
}

// TerraformApplyStageOptions contains all configurable values for a K8S_TERRAFORM_APPLY stage.
// TerraformApplyStageOptions contains all configurable values for a TERRAFORM_APPLY stage.
type TerraformApplyStageOptions struct {
// How many times to retry applying terraform changes.
Retries int `json:"retries"`
Expand Down
4 changes: 2 additions & 2 deletions pkg/config/testdata/application/cloudrun-app-bluegreen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ spec:
stages:
# Deploy workloads of the new version.
# But this is still receiving no traffic.
- name: CLOUDRUN_NEW_VERSION_ROLLOUT
- name: CLOUDRUN_CANARY_ROLLOUT
# Change the traffic routing state where
# the new version will receive 100% of the traffic as soon as possible.
# This is known as blue-green strategy.
- name: CLOUDRUN_TRAFFIC_ROUTING
with:
newVersion: 100
canary: 100
# Optional: We can also add an ANALYSIS stage to verify the new version.
# If this stage finds any not good metrics of the new version,
# a rollback process to the previous version will be executed.
Expand Down
6 changes: 3 additions & 3 deletions pkg/config/testdata/application/cloudrun-app-canary.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ spec:
stages:
# Deploy workloads of the new version.
# But this is still receiving no traffic.
- name: CLOUDRUN_NEW_VERSION_ROLLOUT
- name: CLOUDRUN_CANARY_ROLLOUT
# Change the traffic routing state where
# the new version will receive the specified percentage of traffic.
# This is known as multi-phase canary strategy.
- name: CLOUDRUN_TRAFFIC_ROUTING
with:
newVersion: 10
canary: 10
# Optional: We can also add an ANALYSIS stage to verify the new version.
# If this stage finds any not good metrics of the new version,
# a rollback process to the previous version will be executed.
Expand All @@ -23,4 +23,4 @@ spec:
# thre new version will receive 100% of the traffic.
- name: CLOUDRUN_TRAFFIC_ROUTING
with:
newVersion: 100
canary: 100
4 changes: 2 additions & 2 deletions pkg/config/testdata/application/lambda-app-bluegreen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ spec:
stages:
# Deploy workloads of the new version.
# But this is still receiving no traffic.
- name: LAMBDA_NEW_VERSION_ROLLOUT
- name: LAMBDA_CANARY_ROLLOUT
# Change the traffic routing state where
# the new version will receive 100% of the traffic as soon as possible.
# This is known as blue-green strategy.
- name: LAMBDA_TRAFFIC_ROUTING
with:
newVersion: 100
canary: 100
# Optional: We can also add an ANALYSIS stage to verify the new version.
# If this stage finds any not good metrics of the new version,
# a rollback process to the previous version will be executed.
Expand Down
Loading