Skip to content
Merged
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
32 changes: 30 additions & 2 deletions pkg/app/pipedv1/plugin/kubernetes/deployment/traffic.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,35 @@
kubeconfig "github.com/pipe-cd/pipecd/pkg/app/pipedv1/plugin/kubernetes/config"
)

func (p *Plugin) executeK8sTrafficRoutingStage(_ context.Context, input *sdk.ExecuteStageInput[kubeconfig.KubernetesApplicationSpec], _ []*sdk.DeployTarget[kubeconfig.KubernetesDeployTargetConfig]) sdk.StageStatus {
input.Client.LogPersister().Error("Traffic routing is not yet implemented")
func (p *Plugin) executeK8sTrafficRoutingStage(ctx context.Context, input *sdk.ExecuteStageInput[kubeconfig.KubernetesApplicationSpec], dts []*sdk.DeployTarget[kubeconfig.KubernetesDeployTargetConfig]) sdk.StageStatus {
lp := input.Client.LogPersister()
lp.Info("Start routing the traffic")

cfg, err := input.Request.TargetDeploymentSource.AppConfig()
if err != nil {
lp.Errorf("Failed while loading application config (%v)", err)
return sdk.StageStatusFailure
}

Check warning on line 33 in pkg/app/pipedv1/plugin/kubernetes/deployment/traffic.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/pipedv1/plugin/kubernetes/deployment/traffic.go#L25-L33

Added lines #L25 - L33 were not covered by tests

switch kubeconfig.DetermineKubernetesTrafficRoutingMethod(cfg.Spec.TrafficRouting) {
case kubeconfig.KubernetesTrafficRoutingMethodPodSelector:
return p.executeK8sTrafficRoutingStagePodSelector(ctx, input, dts, cfg)
case kubeconfig.KubernetesTrafficRoutingMethodIstio:
return p.executeK8sTrafficRoutingStageIstio(ctx, input, dts, cfg)
default:
lp.Errorf("Unknown traffic routing method: %s", cfg.Spec.TrafficRouting.Method)
return sdk.StageStatusFailure

Check warning on line 42 in pkg/app/pipedv1/plugin/kubernetes/deployment/traffic.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/pipedv1/plugin/kubernetes/deployment/traffic.go#L35-L42

Added lines #L35 - L42 were not covered by tests
}
}

func (p *Plugin) executeK8sTrafficRoutingStagePodSelector(_ context.Context, input *sdk.ExecuteStageInput[kubeconfig.KubernetesApplicationSpec], _ []*sdk.DeployTarget[kubeconfig.KubernetesDeployTargetConfig], _ *sdk.ApplicationConfig[kubeconfig.KubernetesApplicationSpec]) sdk.StageStatus {
lp := input.Client.LogPersister()
lp.Error("Traffic routing by PodSelector is not yet implemented")
return sdk.StageStatusFailure

Check warning on line 49 in pkg/app/pipedv1/plugin/kubernetes/deployment/traffic.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/pipedv1/plugin/kubernetes/deployment/traffic.go#L46-L49

Added lines #L46 - L49 were not covered by tests
}

func (p *Plugin) executeK8sTrafficRoutingStageIstio(_ context.Context, input *sdk.ExecuteStageInput[kubeconfig.KubernetesApplicationSpec], _ []*sdk.DeployTarget[kubeconfig.KubernetesDeployTargetConfig], _ *sdk.ApplicationConfig[kubeconfig.KubernetesApplicationSpec]) sdk.StageStatus {
lp := input.Client.LogPersister()
lp.Error("Traffic routing by Istio is not yet implemented")

Check warning on line 54 in pkg/app/pipedv1/plugin/kubernetes/deployment/traffic.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/pipedv1/plugin/kubernetes/deployment/traffic.go#L52-L54

Added lines #L52 - L54 were not covered by tests
return sdk.StageStatusFailure
}