Skip to content

Commit

Permalink
GH-969: Support templateAnnotations per each component
Browse files Browse the repository at this point in the history
Co-authored-by: Joan Miquel Luque Oliver <joan.luque@dynatrace.com>
Co-authored-by: Carlos Vega <carlos.vega@dynatrace.com>

Signed-off-by: Joan Miquel Luque Oliver <joan.luque@dynatrace.com>
  • Loading branch information
xoanmi authored and bitsf committed Nov 22, 2022
1 parent 96bd0ef commit 544d2dc
Show file tree
Hide file tree
Showing 17 changed files with 934 additions and 7 deletions.
4 changes: 4 additions & 0 deletions apis/meta/v1alpha1/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ type ImageSpec struct {
}

type ComponentSpec struct {
// +kubebuilder:validation:Optional
// Custom annotations to be added into the pods
TemplateAnnotations map[string]string `json:"templateAnnotations,omitempty"`

ImageSpec `json:",inline"`

// +kubebuilder:validation:Optional
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.

300 changes: 300 additions & 0 deletions charts/harbor-operator/templates/crds.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions controllers/goharbor/chartmuseum/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ func (r *Reconciler) GetDeployment(ctx context.Context, chartMuseum *goharborv1.
Replicas: chartMuseum.Spec.Replicas,
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Annotations: chartMuseum.Spec.ComponentSpec.TemplateAnnotations,
Labels: map[string]string{
r.Label("name"): name,
r.Label("namespace"): namespace,
Expand Down
1 change: 1 addition & 0 deletions controllers/goharbor/core/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ func (r *Reconciler) GetDeployment(ctx context.Context, core *goharborv1.Core) (
Replicas: core.Spec.Replicas,
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Annotations: core.Spec.ComponentSpec.TemplateAnnotations,
Labels: map[string]string{
r.Label("name"): name,
r.Label("namespace"): namespace,
Expand Down
1 change: 1 addition & 0 deletions controllers/goharbor/exporter/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ func (r *Reconciler) GetDeployment(ctx context.Context, exporter *goharborv1.Exp
Replicas: exporter.Spec.Replicas,
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Annotations: exporter.Spec.ComponentSpec.TemplateAnnotations,
Labels: map[string]string{
r.Label("name"): name,
r.Label("namespace"): namespace,
Expand Down
1 change: 1 addition & 0 deletions controllers/goharbor/jobservice/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ func (r *Reconciler) GetDeployment(ctx context.Context, jobservice *goharborv1.J
Replicas: jobservice.Spec.Replicas,
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Annotations: jobservice.Spec.ComponentSpec.TemplateAnnotations,
Labels: map[string]string{
r.Label("name"): name,
r.Label("namespace"): namespace,
Expand Down
1 change: 1 addition & 0 deletions controllers/goharbor/notaryserver/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ func (r *Reconciler) GetDeployment(ctx context.Context, notary *goharborv1.Notar
Replicas: notary.Spec.Replicas,
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Annotations: notary.Spec.ComponentSpec.TemplateAnnotations,
Labels: map[string]string{
r.Label("name"): name,
r.Label("namespace"): namespace,
Expand Down
1 change: 1 addition & 0 deletions controllers/goharbor/notarysigner/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ func (r *Reconciler) GetDeployment(ctx context.Context, notary *goharborv1.Notar
Replicas: notary.Spec.Replicas,
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Annotations: notary.Spec.ComponentSpec.TemplateAnnotations,
Labels: map[string]string{
r.Label("name"): name,
r.Label("namespace"): namespace,
Expand Down
1 change: 1 addition & 0 deletions controllers/goharbor/portal/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func (r *Reconciler) GetDeployment(ctx context.Context, portal *goharborv1.Porta
Replicas: portal.Spec.Replicas,
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Annotations: portal.Spec.ComponentSpec.TemplateAnnotations,
Labels: map[string]string{
r.Label("name"): name,
r.Label("namespace"): namespace,
Expand Down
1 change: 1 addition & 0 deletions controllers/goharbor/registry/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ func (r *Reconciler) GetDeployment(ctx context.Context, registry *goharborv1.Reg
Replicas: registry.Spec.Replicas,
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Annotations: registry.Spec.ComponentSpec.TemplateAnnotations,
Labels: map[string]string{
r.Label("name"): name,
r.Label("namespace"): namespace,
Expand Down
1 change: 1 addition & 0 deletions controllers/goharbor/trivy/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ func (r *Reconciler) GetDeployment(ctx context.Context, trivy *goharborv1.Trivy)
Replicas: trivy.Spec.Replicas,
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Annotations: trivy.Spec.ComponentSpec.TemplateAnnotations,
Labels: map[string]string{
r.Label("name"): name,
r.Label("namespace"): namespace,
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ require (
github.com/zalando/postgres-operator v1.6.1
go.uber.org/zap v1.19.1
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
golang.org/x/exp v0.0.0-20221012211006-4de253d81b95
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.23.0
Expand Down Expand Up @@ -80,7 +81,7 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
Expand Down Expand Up @@ -135,7 +136,7 @@ require (
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/net v0.0.0-20211013171255-e13a2654a71e // indirect
golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1 // indirect
golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8 // indirect
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,9 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-intervals v0.0.2/go.mod h1:MkaR3LNRfeKLPmqgJYs4E66z5InYjmCjbbr4TQlcT6Y=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=
Expand Down Expand Up @@ -1505,6 +1506,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20221012211006-4de253d81b95 h1:sBdrWpxhGDdTAYNqbgBLAR+ULAPPhfgncLr1X0lyWtg=
golang.org/x/exp v0.0.0-20221012211006-4de253d81b95/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand Down Expand Up @@ -1741,8 +1744,8 @@ golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8 h1:M69LAlWZCshgp0QSzyDcSsSIejIEeuaCVpmwcKwyLMk=
golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
Expand Down Expand Up @@ -1855,7 +1858,6 @@ golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8T
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=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gomodules.xyz/jsonpatch/v2 v2.0.1/go.mod h1:IhYNNY4jnS53ZnfE4PAmpKtDpTCj1JFXc+3mwe7XcUU=
gomodules.xyz/jsonpatch/v2 v2.2.0 h1:4pT439QV83L+G9FkcCriY6EkpcK6r6bK+A5FBUMI7qY=
Expand Down
Loading

0 comments on commit 544d2dc

Please sign in to comment.