Skip to content

Commit 16c9b13

Browse files
authored
rename the embedded-cluster binary before running 'materialize' (#497)
1 parent a4c603f commit 16c9b13

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

cmd/local-artifact-mirror/pull.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,18 @@ var binariesCommand = &cli.Command{
171171
logrus.Infof("removing temporary directory %s", location)
172172
os.RemoveAll(location)
173173
}()
174-
175174
bin := filepath.Join(location, EmbeddedClusterBinaryArtifactName)
176-
if err := os.Chmod(bin, 0755); err != nil {
175+
namedBin := filepath.Join(location, in.Spec.BinaryName)
176+
if err := os.Rename(bin, namedBin); err != nil {
177+
return fmt.Errorf("unable to rename binary: %w", err)
178+
}
179+
180+
if err := os.Chmod(namedBin, 0755); err != nil {
177181
return fmt.Errorf("unable to change permissions on %s: %w", bin, err)
178182
}
179183

180184
out := bytes.NewBuffer(nil)
181-
cmd := exec.Command(bin, "materialize")
185+
cmd := exec.Command(namedBin, "materialize")
182186
cmd.Stdout = out
183187
cmd.Stderr = out
184188

@@ -190,14 +194,6 @@ var binariesCommand = &cli.Command{
190194

191195
logrus.Infof("embedded cluster binaries materialized")
192196

193-
targetBinaryName := filepath.Join(defaults.EmbeddedClusterBinsSubDir(), EmbeddedClusterBinaryArtifactName)
194-
if in.Spec.BinaryName != "" {
195-
targetBinaryName = filepath.Join(defaults.EmbeddedClusterBinsSubDir(), in.Spec.BinaryName)
196-
}
197-
198-
if err := helpers.MoveFile(bin, targetBinaryName); err != nil {
199-
return fmt.Errorf("unable to move embedded-cluster binary: %w", err)
200-
}
201197
return nil
202198
},
203199
}

0 commit comments

Comments
 (0)