Skip to content

Commit

Permalink
Merge pull request #43 from stefanprodan/app-validation
Browse files Browse the repository at this point in the history
 Add validation for label selectors
  • Loading branch information
stefanprodan authored Feb 11, 2019
2 parents 217ef06 + 434c614 commit 8a03ae1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LT_VERSION?=$(shell grep 'VERSION' cmd/loadtester/main.go | awk '{ print $$4 }'

run:
go run cmd/flagger/* -kubeconfig=$$HOME/.kube/config -log-level=info \
-metrics-server=https://prometheus.iowa.weavedx.com \
-metrics-server=https://prometheus.istio.weavedx.com \
-slack-url=https://hooks.slack.com/services/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 \
-slack-channel="devops-alerts"

Expand All @@ -31,7 +31,7 @@ test: test-fmt test-codegen
go test ./...

helm-package:
cd charts/ && helm package flagger/ && helm package grafana/ && helm package loadtester/
cd charts/ && helm package ./*
mv charts/*.tgz docs/
helm repo index docs --url https://stefanprodan.github.io/flagger --merge ./docs/index.yaml

Expand Down
5 changes: 5 additions & 0 deletions pkg/controller/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,11 @@ func (c *CanaryDeployer) createPrimaryDeployment(cd *flaggerv1.Canary) error {
return err
}

if appSel, ok := canaryDep.Spec.Selector.MatchLabels["app"]; !ok || appSel != canaryDep.Name {
return fmt.Errorf("invalid label selector! Deployment %s.%s spec.selector.matchLabels must contain selector 'app: %s'",
targetName, cd.Namespace, targetName)
}

primaryDep, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(primaryName, metav1.GetOptions{})
if errors.IsNotFound(err) {
// create primary secrets and config maps
Expand Down

0 comments on commit 8a03ae1

Please sign in to comment.