Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make IMAGE_TAG available in buildArgs when used in docker FROM #9664

Merged
merged 46 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
1657f18
provide a docker.ImageReference in dependency resolution step
abe-winter Jun 19, 2024
147d21b
pass nils
abe-winter Jun 19, 2024
35a37c1
other plumbing
abe-winter Jun 19, 2024
f6411bf
fix: add back out io.Writer field
alphanota Jan 14, 2025
354b03c
Merge branch 'GoogleContainerTools:main' into abe-winter-changes
alphanota Jan 14, 2025
a61996c
fix bugs
alphanota Jan 14, 2025
13849cf
Merge branch 'GoogleContainerTools:main' into abe-winter-changes
alphanota Jan 15, 2025
d506f62
fix lookup and hash tests
alphanota Jan 15, 2025
c3bcf4d
fix tag test
alphanota Jan 15, 2025
67014b3
fix skaffold/runner
alphanota Jan 15, 2025
5076965
fix skaffold/graph
alphanota Jan 15, 2025
5324000
remove the tags field where its not needed
alphanota Jan 15, 2025
2784556
make fixes to test
alphanota Jan 16, 2025
630979a
fix tests
alphanota Jan 16, 2025
65af3c9
fix another typo
alphanota Jan 16, 2025
7e67078
add license boilerplate
alphanota Jan 16, 2025
ae699c0
add 2025 as a valid year
alphanota Jan 16, 2025
0b19012
chore:add integration test
alphanota Jan 16, 2025
da11b02
format go file
alphanota Jan 16, 2025
0787e5a
fix: lint and test
alphanota Jan 16, 2025
10ed9ec
fix test
alphanota Jan 16, 2025
104f908
fix:lint
alphanota Jan 16, 2025
0469ddd
add debug output
alphanota Jan 17, 2025
20c9e2a
add test action for debugging
alphanota Jan 17, 2025
6090a40
add test
alphanota Jan 17, 2025
a212113
add test
alphanota Jan 17, 2025
d52f744
add test
alphanota Jan 17, 2025
8f7960a
add test
alphanota Jan 17, 2025
a0569f3
add test
alphanota Jan 17, 2025
09b820a
use the default context when building the image
alphanota Jan 17, 2025
19cc68e
fix imports
alphanota Jan 17, 2025
6ea296a
fix: flaky helm deploy unit test by making the order of helm command …
alphanota Jan 17, 2025
fd7d94d
fix lint
alphanota Jan 18, 2025
954da5c
add unit tests and fix existing tests
alphanota Jan 22, 2025
d3556f7
remove xtra file
alphanota Jan 22, 2025
b042e30
fix lint
alphanota Jan 22, 2025
c052c83
test that the build arg used as part of a filename is also replaced
alphanota Jan 22, 2025
004c943
use stub instead of mock for test objects
alphanota Jan 22, 2025
8c4e2e4
use empty string in place of tag because hash_test unit tests mock Si…
alphanota Jan 22, 2025
4a345a2
add integration test to ensure that the build int BUILD args can be u…
alphanota Jan 22, 2025
6ff04ca
fix imports, remove github action workflow used for debugging
alphanota Jan 22, 2025
c4f74ff
fix lint
alphanota Jan 22, 2025
0ddf270
use one function everywhere in the codebase to generate the image inf…
alphanota Jan 22, 2025
7ca8dbc
Replace use of EvalBuildArgs with EvalBuildArgsWithEnv since they inv…
alphanota Jan 22, 2025
9fd1b34
add unit test for hash package
alphanota Jan 22, 2025
c6298fe
add test for TestCheckArtifacts
alphanota Jan 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix lookup and hash tests
  • Loading branch information
alphanota committed Jan 15, 2025
commit d506f62449e2e33ce669f532c4995c46da6c6437
22 changes: 11 additions & 11 deletions pkg/skaffold/build/cache/hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
)

func stubDependencyLister(dependencies []string) DependencyLister {
return func(context.Context, *latest.Artifact) ([]string, error) {
return func(context.Context, *latest.Artifact, map[string]string) ([]string, error) {
return dependencies, nil
}
}
Expand Down Expand Up @@ -162,7 +162,7 @@ func TestGetHashForArtifact(t *testing.T) {
}

depLister := stubDependencyLister(test.dependencies)
actual, err := newArtifactHasher(nil, depLister, test.mode).hash(context.Background(), io.Discard, test.artifact, test.platforms)
actual, err := newArtifactHasher(nil, depLister, test.mode).hash(context.Background(), io.Discard, test.artifact, test.platforms, nil)

t.CheckNoError(err)
t.CheckDeepEqual(test.expected, actual)
Expand Down Expand Up @@ -242,11 +242,11 @@ func TestGetHashForArtifactWithDependencies(t *testing.T) {
}
}

depLister := func(_ context.Context, a *latest.Artifact) ([]string, error) {
depLister := func(_ context.Context, a *latest.Artifact, _ map[string]string) ([]string, error) {
return test.fileDeps[a.ImageName], nil
}

actual, err := newArtifactHasher(g, depLister, test.mode).hash(context.Background(), io.Discard, test.artifacts[0], platform.Resolver{})
actual, err := newArtifactHasher(g, depLister, test.mode).hash(context.Background(), io.Discard, test.artifacts[0], platform.Resolver{}, nil)

t.CheckNoError(err)
t.CheckDeepEqual(test.expected, actual)
Expand Down Expand Up @@ -309,21 +309,21 @@ func TestBuildArgs(t *testing.T) {
}
t.Override(&fileHasherFunc, mockCacheHasher)
t.Override(&artifactConfigFunc, fakeArtifactConfig)
actual, err := newArtifactHasher(nil, stubDependencyLister(nil), test.mode).hash(context.Background(), io.Discard, artifact, platform.Resolver{})
actual, err := newArtifactHasher(nil, stubDependencyLister(nil), test.mode).hash(context.Background(), io.Discard, artifact, platform.Resolver{}, nil)

t.CheckNoError(err)
t.CheckDeepEqual(test.expected, actual)

// Change order of buildargs
artifact.ArtifactType.DockerArtifact.BuildArgs = map[string]*string{"two": util.Ptr("2"), "one": util.Ptr("1")}
actual, err = newArtifactHasher(nil, stubDependencyLister(nil), test.mode).hash(context.Background(), io.Discard, artifact, platform.Resolver{})
actual, err = newArtifactHasher(nil, stubDependencyLister(nil), test.mode).hash(context.Background(), io.Discard, artifact, platform.Resolver{}, nil)

t.CheckNoError(err)
t.CheckDeepEqual(test.expected, actual)

// Change build args, get different hash
artifact.ArtifactType.DockerArtifact.BuildArgs = map[string]*string{"one": util.Ptr("1")}
actual, err = newArtifactHasher(nil, stubDependencyLister(nil), test.mode).hash(context.Background(), io.Discard, artifact, platform.Resolver{})
actual, err = newArtifactHasher(nil, stubDependencyLister(nil), test.mode).hash(context.Background(), io.Discard, artifact, platform.Resolver{}, nil)

t.CheckNoError(err)
if actual == test.expected {
Expand Down Expand Up @@ -356,7 +356,7 @@ func TestBuildArgsEnvSubstitution(t *testing.T) {
t.Override(&artifactConfigFunc, fakeArtifactConfig)

depLister := stubDependencyLister([]string{"graph"})
hash1, err := newArtifactHasher(nil, depLister, config.RunModes.Build).hash(context.Background(), io.Discard, artifact, platform.Resolver{})
hash1, err := newArtifactHasher(nil, depLister, config.RunModes.Build).hash(context.Background(), io.Discard, artifact, platform.Resolver{}, nil)

t.CheckNoError(err)

Expand All @@ -366,7 +366,7 @@ func TestBuildArgsEnvSubstitution(t *testing.T) {
return []string{"FOO=baz"}
}

hash2, err := newArtifactHasher(nil, depLister, config.RunModes.Build).hash(context.Background(), io.Discard, artifact, platform.Resolver{})
hash2, err := newArtifactHasher(nil, depLister, config.RunModes.Build).hash(context.Background(), io.Discard, artifact, platform.Resolver{}, nil)

t.CheckNoError(err)
if hash1 == hash2 {
Expand Down Expand Up @@ -423,7 +423,7 @@ func TestCacheHasher(t *testing.T) {
path := originalFile
depLister := stubDependencyLister([]string{tmpDir.Path(originalFile)})

oldHash, err := newArtifactHasher(nil, depLister, config.RunModes.Build).hash(context.Background(), io.Discard, &latest.Artifact{}, platform.Resolver{})
oldHash, err := newArtifactHasher(nil, depLister, config.RunModes.Build).hash(context.Background(), io.Discard, &latest.Artifact{}, platform.Resolver{}, nil)
t.CheckNoError(err)

test.update(originalFile, tmpDir)
Expand All @@ -432,7 +432,7 @@ func TestCacheHasher(t *testing.T) {
}

depLister = stubDependencyLister([]string{tmpDir.Path(path)})
newHash, err := newArtifactHasher(nil, depLister, config.RunModes.Build).hash(context.Background(), io.Discard, &latest.Artifact{}, platform.Resolver{})
newHash, err := newArtifactHasher(nil, depLister, config.RunModes.Build).hash(context.Background(), io.Discard, &latest.Artifact{}, platform.Resolver{}, nil)

t.CheckNoError(err)
t.CheckFalse(test.differentHash && oldHash == newHash)
Expand Down
4 changes: 2 additions & 2 deletions pkg/skaffold/build/cache/lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,15 @@ type mockHasher struct {
val string
}

func (m mockHasher) hash(context.Context, io.Writer, *latest.Artifact, platform.Resolver) (string, error) {
func (m mockHasher) hash(context.Context, io.Writer, *latest.Artifact, platform.Resolver, map[string]string) (string, error) {
return m.val, nil
}

type failingHasher struct {
err error
}

func (f failingHasher) hash(context.Context, io.Writer, *latest.Artifact, platform.Resolver) (string, error) {
func (f failingHasher) hash(context.Context, io.Writer, *latest.Artifact, platform.Resolver, map[string]string) (string, error) {
return "", f.err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/build/cache/retrieve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
)

func depLister(files map[string][]string) DependencyLister {
return func(_ context.Context, artifact *latest.Artifact) ([]string, error) {
return func(_ context.Context, artifact *latest.Artifact, _ map[string]string) ([]string, error) {
list, found := files[artifact.ImageName]
if !found {
return nil, errors.New("unknown artifact")
Expand Down