Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ linters:
- makezero
- misspell
- nakedret
- nestif
# - nestif
- nilerr
- nilnil
- nlreturn
Expand Down
4 changes: 4 additions & 0 deletions api/v1alpha1/provider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ type DeploymentSpec struct {
// List of containers specified in the Deployment
// +optional
Containers []ContainerSpec `json:"containers"`

// List of image pull secrets specified in the Deployment
// +optional
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
}

// ContainerSpec defines the properties available to override for each
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

13 changes: 13 additions & 0 deletions config/crd/bases/operator.cluster.x-k8s.io_bootstrapproviders.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,19 @@ spec:
- name
type: object
type: array
imagePullSecrets:
description: List of image pull secrets specified in the Deployment
items:
description: LocalObjectReference contains enough information
to let you locate the referenced object inside the same namespace.
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
type: object
x-kubernetes-map-type: atomic
type: array
nodeSelector:
additionalProperties:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,19 @@ spec:
- name
type: object
type: array
imagePullSecrets:
description: List of image pull secrets specified in the Deployment
items:
description: LocalObjectReference contains enough information
to let you locate the referenced object inside the same namespace.
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
type: object
x-kubernetes-map-type: atomic
type: array
nodeSelector:
additionalProperties:
type: string
Expand Down
13 changes: 13 additions & 0 deletions config/crd/bases/operator.cluster.x-k8s.io_coreproviders.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,19 @@ spec:
- name
type: object
type: array
imagePullSecrets:
description: List of image pull secrets specified in the Deployment
items:
description: LocalObjectReference contains enough information
to let you locate the referenced object inside the same namespace.
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
type: object
x-kubernetes-map-type: atomic
type: array
nodeSelector:
additionalProperties:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,19 @@ spec:
- name
type: object
type: array
imagePullSecrets:
description: List of image pull secrets specified in the Deployment
items:
description: LocalObjectReference contains enough information
to let you locate the referenced object inside the same namespace.
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
type: object
x-kubernetes-map-type: atomic
type: array
nodeSelector:
additionalProperties:
type: string
Expand Down
4 changes: 4 additions & 0 deletions internal/controller/component_customizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ func customizeDeployment(pSpec operatorv1.ProviderSpec, d *appsv1.Deployment) {
d.Spec.Template.Spec.Tolerations = dSpec.Tolerations
}

if dSpec.ImagePullSecrets != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably the best way to deal with the lint issue is to add //nolint:nestif before the if block on line 94

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Fedosin for the suggestion. Even with that statement golangci-lint was still complaining with:

internal/controller/component_customizer.go:94:2: `if pSpec.Deployment != nil` has complex nested blocks (complexity: 5) (nestif)
	if pSpec.Deployment != nil {
	^
internal/controller/component_customizer.go:113:3: directive `//nolint:nestif` is unused for linter "nestif" (nolintlint)
		//nolint:nestif
		^

So I went ahead and commented out the nestif, similar with what you've done in #176

d.Spec.Template.Spec.ImagePullSecrets = dSpec.ImagePullSecrets
}

for _, pc := range dSpec.Containers {
customizeContainer(pc, d)
}
Expand Down
35 changes: 35 additions & 0 deletions internal/controller/component_customizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,31 @@ func TestCustomizeDeployment(t *testing.T) {
return expectedDS, reflect.DeepEqual(inputDS.Template.Spec.Affinity, expectedDS.Template.Spec.Affinity)
},
},
{
name: "only image pull secrets modified",
inputDeploymentSpec: &operatorv1.DeploymentSpec{
ImagePullSecrets: []corev1.LocalObjectReference{
{
Name: "test",
},
},
},
expectedDeploymentSpec: func(inputDS *appsv1.DeploymentSpec) (*appsv1.DeploymentSpec, bool) {
expectedDS := &appsv1.DeploymentSpec{
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
ImagePullSecrets: []corev1.LocalObjectReference{
{
Name: "test",
},
},
},
},
}

return expectedDS, reflect.DeepEqual(inputDS.Template.Spec.ImagePullSecrets, expectedDS.Template.Spec.ImagePullSecrets)
},
},
{
name: "only containers modified",
inputDeploymentSpec: &operatorv1.DeploymentSpec{
Expand Down Expand Up @@ -304,6 +329,11 @@ func TestCustomizeDeployment(t *testing.T) {
},
},
},
ImagePullSecrets: []corev1.LocalObjectReference{
{
Name: "test",
},
},
Containers: []operatorv1.ContainerSpec{
{
Name: "manager",
Expand Down Expand Up @@ -356,6 +386,11 @@ func TestCustomizeDeployment(t *testing.T) {
},
},
},
ImagePullSecrets: []corev1.LocalObjectReference{
{
Name: "test",
},
},
Containers: []corev1.Container{
{
Name: "manager",
Expand Down