Skip to content

Commit

Permalink
Merge pull request #59 from nais/rollout_status_annotation
Browse files Browse the repository at this point in the history
Pass rollout reason annotation to deployment
  • Loading branch information
sechmann authored Jun 13, 2019
2 parents 0c5adbd + fcb015d commit bc12573
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 4 additions & 2 deletions pkg/apis/naiserator/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,13 @@ func (in Application) Hash() (string, error) {
// struct including the relevant fields for
// creating a hash of an Application object
relevantValues := struct {
AppSpec ApplicationSpec
Labels map[string]string
AppSpec ApplicationSpec
Labels map[string]string
ChangeCause string
}{
in.Spec,
in.Labels,
in.Annotations["kubernetes.io/change-cause"],
}

h, err := hash.Hash(relevantValues, nil)
Expand Down
12 changes: 11 additions & 1 deletion pkg/resourcecreator/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,22 @@ func Deployment(app *nais.Application, resourceOptions ResourceOptions) (*appsv1
if err != nil {
return nil, err
}

objectMeta := app.CreateObjectMeta()
if val, ok := app.Annotations["kubernetes.io/change-cause"]; ok {
if objectMeta.Annotations == nil {
objectMeta.Annotations = make(map[string]string)
}

objectMeta.Annotations["kubernetes.io/change-cause"] = val
}

return &appsv1.Deployment{
TypeMeta: metav1.TypeMeta{
Kind: "Deployment",
APIVersion: "apps/v1",
},
ObjectMeta: app.CreateObjectMeta(),
ObjectMeta: objectMeta,
Spec: *spec,
}, nil
}
Expand Down

0 comments on commit bc12573

Please sign in to comment.