Skip to content

Commit

Permalink
Merge pull request kubernetes#1843 from saschagrunert/extra-files
Browse files Browse the repository at this point in the history
Make staging of extra files optional
  • Loading branch information
k8s-ci-robot authored Jan 13, 2021
2 parents 6b7d184 + 04ef7d4 commit 5d2c1e2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 4 additions & 0 deletions pkg/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ type Options struct {
// Validate that the remove image digests exists, needs `skopeo` in
// `$PATH`.
ValidateRemoteImageDigests bool

// Stage additional files defined by `ExtraGcpStageFiles` and
// `ExtraWindowsStageFiles`, otherwise they will be skipped.
StageExtraFiles bool
}

// TODO: Refactor so that version is not required as a parameter
Expand Down
17 changes: 9 additions & 8 deletions pkg/build/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ type stageFile struct {

const extraDir = "extra"

var gcpStageFiles = []stageFile{
// ExtraGcpStageFiles defines extra GCP files to be staged if `StageExtraFiles`
// in `Options` is set to `true`.
var ExtraGcpStageFiles = []stageFile{
{
srcPath: filepath.Join(release.GCEPath, "configure-vm.sh"),
dstPath: extraDir + "/gce/configure-vm.sh",
Expand Down Expand Up @@ -69,7 +71,9 @@ var gcpStageFiles = []stageFile{
},
}

var windowsStageFiles = []stageFile{
// ExtraWindowsStageFiles defines extra Windows files to be staged if
// `StageExtraFiles` in `Options` is set to `true`.
var ExtraWindowsStageFiles = []stageFile{
{
srcPath: filepath.Join(release.WindowsLocalPath, "configure.ps1"),
dstPath: extraDir + "/gce/windows/configure.ps1",
Expand Down Expand Up @@ -294,21 +298,18 @@ func (bi *Instance) StageLocalArtifacts() error {
return errors.Wrap(err, "copy source directory into destination")
}

extraPath := filepath.Join(stageDir, extraDir)
if util.Exists(extraPath) {
if bi.opts.StageExtraFiles {
// Copy helpful GCP scripts to local GCS staging directory for push
logrus.Info("Copying extra GCP stage files")
if err := bi.copyStageFiles(stageDir, gcpStageFiles); err != nil {
if err := bi.copyStageFiles(stageDir, ExtraGcpStageFiles); err != nil {
return errors.Wrapf(err, "copy GCP stage files")
}

// Copy helpful Windows scripts to local GCS staging directory for push
logrus.Info("Copying extra Windows stage files")
if err := bi.copyStageFiles(stageDir, windowsStageFiles); err != nil {
if err := bi.copyStageFiles(stageDir, ExtraWindowsStageFiles); err != nil {
return errors.Wrapf(err, "copy Windows stage files")
}
} else {
logrus.Infof("Skipping not existing extra dir %s", extraPath)
}

// Copy the plain binaries to GCS. This is useful for install scripts that
Expand Down

0 comments on commit 5d2c1e2

Please sign in to comment.