Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding AdditionalLabels #236

Merged
merged 13 commits into from
Dec 3, 2021
6 changes: 6 additions & 0 deletions apis/cassandra/v1beta1/cassandradatacenter_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ type CassandraDatacenterSpec struct {

// Tolerations applied to the Cassandra pod. Note that these cannot be overridden with PodTemplateSpec.
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`

// Additional Labels allows to define additional labels that will be included in all object created by the operator. Not, user can override values set by default from the cass-operator and doing so could break cass-operator functionality.
AdditionalLabels map[string]string `json:"additionalLabels,omitempty"`

// Additional annotations allows to define additional annotations that will be included in all object created by the operator. Not, user can override values set by default from the cass-operator and doing so could break cass-operator functionality.
piclemx marked this conversation as resolved.
Show resolved Hide resolved
AdditionalAnnotations map[string]string `json:"additionalAnnotations,omitempty"`
}

type NetworkingConfig struct {
Expand Down
14 changes: 14 additions & 0 deletions apis/cassandra/v1beta1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ spec:
spec:
description: CassandraDatacenterSpec defines the desired state of a CassandraDatacenter
properties:
additionalAnnotations:
additionalProperties:
type: string
description: Additional annotations allows to define additional annotations
that will be included in all object created by the operator. Not,
user can override values set by default from the cass-operator and
doing so could break cass-operator functionality.
type: object
additionalLabels:
additionalProperties:
type: string
description: Additional Labels allows to define additional labels
that will be included in all object created by the operator. Not,
user can override values set by default from the cass-operator and
doing so could break cass-operator functionality.
type: object
additionalSeeds:
items:
type: string
Expand Down
6 changes: 6 additions & 0 deletions pkg/oplabels/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ func AddKubernetesLabels(m map[string]string, dc *api.CassandraDatacenter) {

instanceName := fmt.Sprintf("cassandra-%s", dc.Spec.ClusterName)
m[InstanceLabel] = instanceName

if len(dc.Spec.AdditionalLabels) != 0 {
piclemx marked this conversation as resolved.
Show resolved Hide resolved
for key, value := range dc.Spec.AdditionalLabels {
m[key] = value
}
}
}

func AddDefunctManagedByLabel(m map[string]string) {
Expand Down