Skip to content

Commit

Permalink
Merge pull request #92 from Norsk-Tipping/annotations_dep_sfs
Browse files Browse the repository at this point in the history
  • Loading branch information
eriweb authored Jun 27, 2024
2 parents 62c6cc6 + d2b8320 commit 4d7ed46
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
2 changes: 2 additions & 0 deletions mg/cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ func init() {
createCmd.PersistentFlags().StringVar(&Version, "version", "", "Override version in metaGraf specification.")
createCmd.PersistentFlags().BoolVar(&Dryrun, "dryrun", false, "do not create objects, only output")
createCmd.PersistentFlags().StringSliceVar(&params.Labels, "labels", []string{}, "Provide extra labels as key=value pairs, seperated by ,")
createCmd.PersistentFlags().StringSliceVar(&params.Annotations, "annotations", []string{}, "Provide extra annotations as key=value pairs, seperated by ,")

createCmd.AddCommand(createConfigMapCmd)
createCmd.AddCommand(createDotCmd)
createCmd.AddCommand(createSecretCmd)
Expand Down
18 changes: 11 additions & 7 deletions pkg/modules/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func GenDeployment(mg *metagraf.MetaGraf, namespace string) {
// Add labels from params
l = MergeLabels(l, LabelsFromParams(params.Labels))

// Resource annotations
a := Labels(objname, mg.Metadata.Annotations)
a = MergeLabels(a, AnnotationsFromParams(params.Annotations))

// Selector
sm := make(map[string]string)
sm["app"] = objname
Expand Down Expand Up @@ -162,10 +166,10 @@ func GenDeployment(mg *metagraf.MetaGraf, namespace string) {
APIVersion: "apps/v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: objname,
Labels: l,
Annotations: mg.Metadata.Annotations,
Namespace: namespace,
Name: objname,
Labels: l,
Annotations: a,
Namespace: namespace,
},
Spec: appsv1.DeploymentSpec{
Replicas: &params.Replicas,
Expand All @@ -177,9 +181,9 @@ func GenDeployment(mg *metagraf.MetaGraf, namespace string) {
},
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Name: objname,
Labels: l,
Namespace: namespace,
Name: objname,
Labels: l,
Namespace: namespace,
Annotations: mg.Metadata.Annotations,
},
Spec: corev1.PodSpec{
Expand Down
18 changes: 11 additions & 7 deletions pkg/modules/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func GenStatefulSet(mg *metagraf.MetaGraf, namespace string) {
// Add labels from params
l = MergeLabels(l, LabelsFromParams(params.Labels))

// Resource annotations
a := Labels(objname, mg.Metadata.Annotations)
a = MergeLabels(a, AnnotationsFromParams(params.Annotations))

// Selector
sm := make(map[string]string)
sm["app"] = objname
Expand Down Expand Up @@ -168,10 +172,10 @@ func GenStatefulSet(mg *metagraf.MetaGraf, namespace string) {
APIVersion: "apps/v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: objname,
Labels: l,
Namespace: namespace,
Annotations: mg.Metadata.Annotations,
Name: objname,
Labels: l,
Namespace: namespace,
Annotations: a,
},
Spec: appsv1.StatefulSetSpec{
Replicas: &params.Replicas,
Expand All @@ -183,9 +187,9 @@ func GenStatefulSet(mg *metagraf.MetaGraf, namespace string) {
},
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Name: objname,
Labels: l,
Namespace: namespace,
Name: objname,
Labels: l,
Namespace: namespace,
Annotations: mg.Metadata.Annotations,
},
Spec: corev1.PodSpec{
Expand Down

0 comments on commit 4d7ed46

Please sign in to comment.