From 382cf3a9c2405cdf056fc5d66e0f84ed9abbabd2 Mon Sep 17 00:00:00 2001 From: guangwu Date: Sat, 2 Sep 2023 00:44:31 +0800 Subject: [PATCH] chore: unnecessary use of fmt.Sprintf (#2717) Signed-off-by: guoguangwu --- pkg/executor/build_test.go | 2 +- pkg/executor/copy_multistage_test.go | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/executor/build_test.go b/pkg/executor/build_test.go index 870118277..af3865d14 100644 --- a/pkg/executor/build_test.go +++ b/pkg/executor/build_test.go @@ -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() diff --git a/pkg/executor/copy_multistage_test.go b/pkg/executor/copy_multistage_test.go index 89cd044ec..450b3056f 100644 --- a/pkg/executor/copy_multistage_test.go +++ b/pkg/executor/copy_multistage_test.go @@ -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"), @@ -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"), @@ -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"),