Skip to content

Commit

Permalink
feat: customLabels in ComponentSpec (goharbor#1061)
Browse files Browse the repository at this point in the history
feat: templateLabels in ComponentSpec

This change allow user to inject
customized label to deployment.

Signed-off-by: Shou-En Hsiao <shouenhsiao@google.com>
  • Loading branch information
ShouEnHsiao committed Aug 3, 2023
1 parent 8c7a4a6 commit f06cd9e
Show file tree
Hide file tree
Showing 4 changed files with 615 additions and 0 deletions.
8 changes: 8 additions & 0 deletions apis/meta/v1alpha1/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ type ComponentSpec struct {
// Custom annotations to be added into the pods
TemplateAnnotations map[string]string `json:"templateAnnotations,omitempty"`

// +kubebuilder:validation:Optional
// Custom Labels to be added into the pods
TemplateLabels map[string]string `json:"templateLabels,omitempty"`

ImageSpec `json:",inline"`

// +kubebuilder:validation:Optional
Expand Down Expand Up @@ -116,6 +120,10 @@ func (c *ComponentSpec) ApplyToDeployment(deploy *appsv1.Deployment) {
deploy.Spec.Template.Spec.Containers[i].Resources = c.Resources
}

for k, v := range c.TemplateLabels {
deploy.Spec.Template.Labels[k] = v
}

deploy.Spec.Template.Spec.ImagePullSecrets = c.ImagePullSecrets
deploy.Spec.Template.Spec.NodeSelector = c.NodeSelector
deploy.Spec.Template.Spec.Tolerations = c.Tolerations
Expand Down
7 changes: 7 additions & 0 deletions apis/meta/v1alpha1/zz_generated.deepcopy.go

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

Loading

0 comments on commit f06cd9e

Please sign in to comment.