chore: unnecessary use of fmt.Sprintf (#2717)

Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
This commit is contained in:
guangwu 2023-09-02 00:44:31 +08:00 committed by GitHub
parent 5df0343d5b
commit 382cf3a9c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -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()

View File

@ -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"),