Skip to content

Commit 4a688f4

Browse files
committed
Support ~ in secret path for Kaniko
Signed-off-by: David Gageot <[email protected]>
1 parent 2ed4b03 commit 4a688f4

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

examples/kaniko/skaffold.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build:
55
- imageName: gcr.io/k8s-skaffold/skaffold-example
66
kaniko:
77
gcsBucket: k8s-skaffold
8-
pullSecret: /a/secret/path/kaniko.json
8+
pullSecret: ~/secrets/kaniko/kaniko.json
99
deploy:
1010
kubectl:
1111
manifests:

pkg/skaffold/schema/v1alpha2/config.go

+15
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121

2222
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/constants"
23+
homedir "github.com/mitchellh/go-homedir"
2324

2425
"github.com/pkg/errors"
2526
"github.com/sirupsen/logrus"
@@ -206,6 +207,19 @@ func setDefaultWorkspaces(cfg *SkaffoldConfig) {
206207
}
207208
}
208209

210+
func expandKanikoSecretPath(cfg *SkaffoldConfig) {
211+
if cfg.Build.KanikoBuild == nil || cfg.Build.KanikoBuild.PullSecret == "" {
212+
return
213+
}
214+
215+
absPath, err := homedir.Expand(cfg.Build.KanikoBuild.PullSecret)
216+
if err != nil {
217+
logrus.Errorln("unable to expand pullSecret", cfg.Build.KanikoBuild.PullSecret)
218+
} else {
219+
cfg.Build.KanikoBuild.PullSecret = absPath
220+
}
221+
}
222+
209223
// ApplyProfiles returns configuration modified by the application
210224
// of a list of profiles.
211225
func (c *SkaffoldConfig) ApplyProfiles(profiles []string) error {
@@ -258,6 +272,7 @@ func (config *SkaffoldConfig) Parse(contents []byte, useDefaults bool, mode bool
258272
setDefaultTagger(config, mode)
259273
setDefaultDockerfiles(config)
260274
setDefaultWorkspaces(config)
275+
expandKanikoSecretPath(config)
261276
}
262277
return nil
263278
}

0 commit comments

Comments
 (0)