diff --git a/pkg/skaffold/build/ko/builder.go b/pkg/skaffold/build/ko/builder.go index 8756c081d68..884c6f82f4c 100644 --- a/pkg/skaffold/build/ko/builder.go +++ b/pkg/skaffold/build/ko/builder.go @@ -27,6 +27,7 @@ import ( "github.com/google/ko/pkg/commands/options" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/config" + "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/constants" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/docker" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/platform" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/latest" @@ -40,9 +41,9 @@ func (b *Builder) newKoBuilder(ctx context.Context, a *latest.Artifact, platform return nil, fmt.Errorf("parsing image %v: %w", tag, err) } imageInfoEnv := map[string]string{ - "IMAGE_REPO": ref.Repo, - "IMAGE_NAME": ref.Name, - "IMAGE_TAG": ref.Tag, + constants.ImageRef.Repo: ref.Repo, + constants.ImageRef.Name: ref.Name, + constants.ImageRef.Tag: ref.Tag, } if err != nil { return nil, fmt.Errorf("could not resolve skaffold runtime env for ko builder: %v", err) diff --git a/pkg/skaffold/build/ko/builder_test.go b/pkg/skaffold/build/ko/builder_test.go index 5401ae0d2ff..783265b6e9a 100644 --- a/pkg/skaffold/build/ko/builder_test.go +++ b/pkg/skaffold/build/ko/builder_test.go @@ -152,7 +152,7 @@ func TestBuildOptions(t *testing.T) { }, }, { - description: "", + description: "test build option, inject envs for expanding templates", artifact: latest.Artifact{ ArtifactType: latest.ArtifactType{ KoArtifact: &latest.KoArtifact{ diff --git a/pkg/skaffold/constants/constants.go b/pkg/skaffold/constants/constants.go index f113a9bc8ee..1e5ef4c1dd5 100644 --- a/pkg/skaffold/constants/constants.go +++ b/pkg/skaffold/constants/constants.go @@ -140,10 +140,12 @@ var ImageRef = struct { Repo string Tag string Digest string + Name string }{ Repo: "IMAGE_REPO", Tag: "IMAGE_TAG", Digest: "IMAGE_DIGEST", + Name: "IMAGE_NAME", } var DefaultKubectlManifests = []string{"k8s/*.yaml"}