Skip to content

Commit

Permalink
pull secret for console (#1373)
Browse files Browse the repository at this point in the history
* Propagate pull-secret for operator console too when using the `kubectl minio init --image-pull-secret` command
  • Loading branch information
pjuarezd committed Dec 17, 2022
1 parent 687fcf1 commit 6977fbd
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions kubectl-minio/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ func (o *operatorInitCmd) run(writer io.Writer) error {
}

var operatorDepPatches []interface{}

var consoleDepPatches []interface{}

// create patches for the supplied arguments
if o.operatorOpts.Image != "" {
operatorDepPatches = append(operatorDepPatches, opStr{
Expand Down Expand Up @@ -205,6 +208,11 @@ func (o *operatorInitCmd) run(writer io.Writer) error {
Path: "/spec/template/spec/imagePullSecrets",
Value: []corev1.LocalObjectReference{{Name: o.operatorOpts.ImagePullSecret}},
})
consoleDepPatches = append(consoleDepPatches, opInterface{
Op: "add",
Path: "/spec/template/spec/imagePullSecrets",
Value: []corev1.LocalObjectReference{{Name: o.operatorOpts.ImagePullSecret}},
})
}
if o.operatorOpts.PrometheusNamespace != "" {
operatorDepPatches = append(operatorDepPatches, opInterface{
Expand All @@ -226,6 +234,13 @@ func (o *operatorInitCmd) run(writer io.Writer) error {
},
})
}
if o.operatorOpts.ConsoleImage != "" {
consoleDepPatches = append(consoleDepPatches, opStr{
Op: "replace",
Path: "/spec/template/spec/containers/0/image",
Value: o.operatorOpts.ConsoleImage,
})
}
// attach the patches to the kustomization file
if len(operatorDepPatches) > 0 {
kustomizationYaml.PatchesJson6902 = append(kustomizationYaml.PatchesJson6902, types.Patch{
Expand All @@ -243,15 +258,9 @@ func (o *operatorInitCmd) run(writer io.Writer) error {
})
}

if o.operatorOpts.ConsoleImage != "" {
if len(consoleDepPatches) > 0 {
kustomizationYaml.PatchesJson6902 = append(kustomizationYaml.PatchesJson6902, types.Patch{
Patch: o.serializeJSONPatchOps([]interface{}{
opStr{
Op: "replace",
Path: "/spec/template/spec/containers/0/image",
Value: o.operatorOpts.ConsoleImage,
},
}),
Patch: o.serializeJSONPatchOps(consoleDepPatches),
Target: &types.Selector{
ResId: resid.ResId{
Gvk: resid.Gvk{
Expand Down

0 comments on commit 6977fbd

Please sign in to comment.