Skip to content

Commit

Permalink
Add custom resource label for AppDeployment instead of directly in Bl…
Browse files Browse the repository at this point in the history
…ueGreen
  • Loading branch information
Shivam010 committed Apr 24, 2020
1 parent d59b0cd commit 87bf095
Show file tree
Hide file tree
Showing 51 changed files with 1,168 additions and 2,516 deletions.
16 changes: 12 additions & 4 deletions deploy/crds/mattermost.com_clusterinstallations_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,10 @@ spec:
name:
description: Name defines the name of the deployment
type: string
resourceLabels:
additionalProperties:
type: string
type: object
version:
description: Version defines the Docker image version that will
be used for the deployment. Required when BlueGreen or Canary
Expand All @@ -668,6 +672,10 @@ spec:
name:
description: Name defines the name of the deployment
type: string
resourceLabels:
additionalProperties:
type: string
type: object
version:
description: Version defines the Docker image version that will
be used for the deployment. Required when BlueGreen or Canary
Expand All @@ -678,10 +686,6 @@ spec:
description: ProductionDeployment defines if the current production
is blue or green.
type: string
resourceLabels:
additionalProperties:
type: string
type: object
type: object
canary:
description: Canary defines the configuration of Canary deployment for
Expand All @@ -703,6 +707,10 @@ spec:
name:
description: Name defines the name of the deployment
type: string
resourceLabels:
additionalProperties:
type: string
type: object
version:
description: Version defines the Docker image version that will
be used for the deployment. Required when BlueGreen or Canary
Expand Down
16 changes: 12 additions & 4 deletions docs/mattermost-operator/mattermost-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,10 @@ spec:
name:
description: Name defines the name of the deployment
type: string
resourceLabels:
additionalProperties:
type: string
type: object
version:
description: Version defines the Docker image version that will
be used for the deployment. Required when BlueGreen or Canary
Expand All @@ -673,6 +677,10 @@ spec:
name:
description: Name defines the name of the deployment
type: string
resourceLabels:
additionalProperties:
type: string
type: object
version:
description: Version defines the Docker image version that will
be used for the deployment. Required when BlueGreen or Canary
Expand All @@ -683,10 +691,6 @@ spec:
description: ProductionDeployment defines if the current production
is blue or green.
type: string
resourceLabels:
additionalProperties:
type: string
type: object
type: object
canary:
description: Canary defines the configuration of Canary deployment for
Expand All @@ -708,6 +712,10 @@ spec:
name:
description: Name defines the name of the deployment
type: string
resourceLabels:
additionalProperties:
type: string
type: object
version:
description: Version defines the Docker image version that will
be used for the deployment. Required when BlueGreen or Canary
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ require (
golang.org/x/crypto v0.0.0-20200117160349-530e935923ad // indirect
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82 // indirect
golang.org/x/tools v0.0.0-20200417140056-c07e33ef3290 // indirect
golang.org/x/tools v0.0.0-20200423205358-59e73619c742 // indirect
k8s.io/api v0.17.2
k8s.io/apimachinery v0.17.2
k8s.io/client-go v12.0.0+incompatible
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,8 @@ golang.org/x/tools v0.0.0-20200327172716-42235f63843a h1:nZPvz874FG8d8iARpJWCyVt
golang.org/x/tools v0.0.0-20200327172716-42235f63843a/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
golang.org/x/tools v0.0.0-20200417140056-c07e33ef3290 h1:NXNmtp0ToD36cui5IqWy95LC4Y6vT/4y3RnPxlQPinU=
golang.org/x/tools v0.0.0-20200417140056-c07e33ef3290/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200423205358-59e73619c742 h1:9OGWpORUXvk8AsaBJlpzzDx7Srv/rSK6rvjcsJq4rJo=
golang.org/x/tools v0.0.0-20200423205358-59e73619c742/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/mattermost/v1alpha1/clusterinstallation_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ type BlueGreen struct {
// Green defines the green deployment.
// +optional
Green AppDeployment `json:"green,omitempty"`

// +optional
ResourceLabels map[string]string `json:"resourceLabels,omitempty"`
}

// AppDeployment defines the configuration of deployment for a ClusterInstallation.
Expand All @@ -133,6 +130,9 @@ type AppDeployment struct {
// Required when BlueGreen or Canary is enabled.
// +optional
Version string `json:"version,omitempty"`

// +optional
ResourceLabels map[string]string `json:"resourceLabels,omitempty"`
}

// Minio defines the configuration of Minio for a ClusterInstallation.
Expand Down
17 changes: 12 additions & 5 deletions pkg/apis/mattermost/v1alpha1/clusterinstallation_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,13 +698,20 @@ func (mattermost *ClusterInstallation) ClusterInstallationLabels(name string) ma
l := ClusterInstallationResourceLabels(name)
l[ClusterLabel] = name
l["app"] = "mattermost"
if mattermost.Spec.BlueGreen.Enable && len(mattermost.Spec.BlueGreen.ResourceLabels) != 0 {
for k, v := range mattermost.Spec.BlueGreen.ResourceLabels {
l[k] = v

labels := map[string]string{}
if mattermost.Spec.BlueGreen.Enable {
if mattermost.Spec.BlueGreen.ProductionDeployment == BlueName {
labels = mattermost.Spec.BlueGreen.Blue.ResourceLabels
}
return l
if mattermost.Spec.BlueGreen.ProductionDeployment == GreenName {
labels = mattermost.Spec.BlueGreen.Green.ResourceLabels
}
} else {
labels = mattermost.Spec.ResourceLabels
}
for k, v := range mattermost.Spec.ResourceLabels {

for k, v := range labels {
l[k] = v
}
return l
Expand Down
22 changes: 11 additions & 11 deletions pkg/apis/mattermost/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 0 additions & 69 deletions pkg/client/clientset/versioned/fake/clientset_generated.go

This file was deleted.

7 changes: 0 additions & 7 deletions pkg/client/clientset/versioned/fake/doc.go

This file was deleted.

43 changes: 0 additions & 43 deletions pkg/client/clientset/versioned/fake/register.go

This file was deleted.

Loading

0 comments on commit 87bf095

Please sign in to comment.