Skip to content

Commit

Permalink
chore: unnecessary use of fmt.Sprintf (#2717)
Browse files Browse the repository at this point in the history
Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
  • Loading branch information
testwill authored Sep 1, 2023
1 parent 5df0343 commit 382cf3a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/executor/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ COPY %s bar.txt
t.Errorf("couldn't create hash %v", err)
}

ch.AddKey(fmt.Sprintf("RUN foobar"))
ch.AddKey("RUN foobar")

// run hash
runHash, err := ch.Hash()
Expand Down
12 changes: 6 additions & 6 deletions pkg/executor/copy_multistage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ func TestCopyCommand_Multistage(t *testing.T) {
t.Run("copy a file across multistage", func(t *testing.T) {
testDir, fn := setupMultistageTests(t)
defer fn()
dockerFile := fmt.Sprintf(`
dockerFile := `
FROM scratch as first
COPY foo/bam.txt copied/
ENV test test
From scratch as second
COPY --from=first copied/bam.txt output/bam.txt`)
COPY --from=first copied/bam.txt output/bam.txt`
ioutil.WriteFile(filepath.Join(testDir, "workspace", "Dockerfile"), []byte(dockerFile), 0755)
opts := &config.KanikoOptions{
DockerfilePath: filepath.Join(testDir, "workspace", "Dockerfile"),
Expand All @@ -60,13 +60,13 @@ COPY --from=first copied/bam.txt output/bam.txt`)
t.Run("copy a file across multistage into a directory", func(t *testing.T) {
testDir, fn := setupMultistageTests(t)
defer fn()
dockerFile := fmt.Sprintf(`
dockerFile := `
FROM scratch as first
COPY foo/bam.txt copied/
ENV test test
From scratch as second
COPY --from=first copied/bam.txt output/`)
COPY --from=first copied/bam.txt output/`
ioutil.WriteFile(filepath.Join(testDir, "workspace", "Dockerfile"), []byte(dockerFile), 0755)
opts := &config.KanikoOptions{
DockerfilePath: filepath.Join(testDir, "workspace", "Dockerfile"),
Expand All @@ -85,13 +85,13 @@ COPY --from=first copied/bam.txt output/`)
t.Run("copy directory across multistage into a directory", func(t *testing.T) {
testDir, fn := setupMultistageTests(t)
defer fn()
dockerFile := fmt.Sprintf(`
dockerFile := `
FROM scratch as first
COPY foo copied
ENV test test
From scratch as second
COPY --from=first copied another`)
COPY --from=first copied another`
ioutil.WriteFile(filepath.Join(testDir, "workspace", "Dockerfile"), []byte(dockerFile), 0755)
opts := &config.KanikoOptions{
DockerfilePath: filepath.Join(testDir, "workspace", "Dockerfile"),
Expand Down

0 comments on commit 382cf3a

Please sign in to comment.