Skip to content

Commit 7c2aae6

Browse files
committed
fix bad merge
1 parent 1864199 commit 7c2aae6

File tree

22 files changed

+123
-122
lines changed

22 files changed

+123
-122
lines changed

integration/ko_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535

3636
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/build/ko"
3737
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/config"
38-
latestV1 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v1"
38+
latestV2 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v2"
3939
)
4040

4141
func TestBuildAndPushKoImageProgrammatically(t *testing.T) {
@@ -61,9 +61,9 @@ func TestBuildAndPushKoImageProgrammatically(t *testing.T) {
6161
// Build the artifact
6262
b := ko.NewArtifactBuilder(nil, true, config.RunModes.Build, nil)
6363
var imageFullNameBuffer bytes.Buffer
64-
artifact := &latestV1.Artifact{
65-
ArtifactType: latestV1.ArtifactType{
66-
KoArtifact: &latestV1.KoArtifact{
64+
artifact := &latestV2.Artifact{
65+
ArtifactType: latestV2.ArtifactType{
66+
KoArtifact: &latestV2.KoArtifact{
6767
BaseImage: baseImage,
6868
},
6969
},

pkg/skaffold/build/gcb/kaniko_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ func TestKanikoBuildSpec(t *testing.T) {
8080
},
8181
{
8282
description: "with Cache Copy Layers",
83-
artifact: &latestV1.KanikoArtifact{
83+
artifact: &latestV2.KanikoArtifact{
8484
DockerfilePath: "Dockerfile",
85-
Cache: &latestV1.KanikoCache{CacheCopyLayers: true},
85+
Cache: &latestV2.KanikoCache{CacheCopyLayers: true},
8686
},
8787
expectedArgs: []string{
8888
kaniko.CacheFlag,

pkg/skaffold/build/ko/build.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ import (
2828
"github.com/google/ko/pkg/publish"
2929
"golang.org/x/tools/go/packages"
3030

31-
latestV1 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v1"
31+
latestV2 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v2"
3232
)
3333

3434
// Build an artifact using ko, and either push it to an image registry, or
3535
// sideload it to the local docker daemon.
3636
// Build prints the image name to the out io.Writer and returns the image
3737
// identifier. The image identifier is the tag or digest for pushed images, or
3838
// the docker image ID for sideloaded images.
39-
func (b *Builder) Build(ctx context.Context, out io.Writer, a *latestV1.Artifact, ref string) (string, error) {
39+
func (b *Builder) Build(ctx context.Context, out io.Writer, a *latestV2.Artifact, ref string) (string, error) {
4040
koBuilder, err := b.newKoBuilder(ctx, a)
4141
if err != nil {
4242
return "", fmt.Errorf("error creating ko builder: %w", err)
@@ -58,7 +58,7 @@ func (b *Builder) Build(ctx context.Context, out io.Writer, a *latestV1.Artifact
5858
}
5959

6060
// buildAndPublish the image using the ko builder and publisher.
61-
func (b *Builder) buildAndPublish(ctx context.Context, a *latestV1.Artifact, koBuilder build.Interface, koPublisher publish.Interface) (name.Reference, error) {
61+
func (b *Builder) buildAndPublish(ctx context.Context, a *latestV2.Artifact, koBuilder build.Interface, koPublisher publish.Interface) (name.Reference, error) {
6262
importpath, err := getImportPath(a)
6363
if err != nil {
6464
return nil, fmt.Errorf("could not determine Go import path for ko image %q: %w", a.ImageName, err)
@@ -85,7 +85,7 @@ func (b *Builder) buildAndPublish(ctx context.Context, a *latestV1.Artifact, koB
8585
//
8686
// If the image name does _not_ start with `ko://`, determine the Go import
8787
// path of the image workspace directory.
88-
func getImportPath(a *latestV1.Artifact) (string, error) {
88+
func getImportPath(a *latestV2.Artifact) (string, error) {
8989
if strings.HasPrefix(a.ImageName, build.StrictScheme) {
9090
return a.ImageName, nil
9191
}

pkg/skaffold/build/ko/build_test.go

+20-20
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929

3030
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/config"
3131
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/docker"
32-
latestV1 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v1"
32+
latestV2 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v2"
3333
"github.com/GoogleContainerTools/skaffold/testutil"
3434
)
3535

@@ -61,9 +61,9 @@ func TestBuild(t *testing.T) {
6161
importPath := "ko://github.com/GoogleContainerTools/skaffold/pkg/skaffold/build/ko" // this package
6262
b := stubKoArtifactBuilder(test.expectedRef, test.expectedImageIdentifier, test.pushImages, importPath)
6363

64-
artifact := &latestV1.Artifact{
65-
ArtifactType: latestV1.ArtifactType{
66-
KoArtifact: &latestV1.KoArtifact{},
64+
artifact := &latestV2.Artifact{
65+
ArtifactType: latestV2.ArtifactType{
66+
KoArtifact: &latestV2.KoArtifact{},
6767
},
6868
ImageName: importPath,
6969
}
@@ -81,14 +81,14 @@ func TestBuild(t *testing.T) {
8181
func Test_getImportPath(t *testing.T) {
8282
tests := []struct {
8383
description string
84-
artifact *latestV1.Artifact
84+
artifact *latestV2.Artifact
8585
expectedImportPath string
8686
}{
8787
{
8888
description: "main is ignored when image name is ko-prefixed full Go import path",
89-
artifact: &latestV1.Artifact{
90-
ArtifactType: latestV1.ArtifactType{
91-
KoArtifact: &latestV1.KoArtifact{
89+
artifact: &latestV2.Artifact{
90+
ArtifactType: latestV2.ArtifactType{
91+
KoArtifact: &latestV2.KoArtifact{
9292
Main: "./main-should-be-ignored",
9393
},
9494
},
@@ -98,19 +98,19 @@ func Test_getImportPath(t *testing.T) {
9898
},
9999
{
100100
description: "plain image name",
101-
artifact: &latestV1.Artifact{
102-
ArtifactType: latestV1.ArtifactType{
103-
KoArtifact: &latestV1.KoArtifact{},
101+
artifact: &latestV2.Artifact{
102+
ArtifactType: latestV2.ArtifactType{
103+
KoArtifact: &latestV2.KoArtifact{},
104104
},
105105
ImageName: "any-image-name-1",
106106
},
107107
expectedImportPath: "ko://github.com/GoogleContainerTools/skaffold/pkg/skaffold/build/ko", // this package
108108
},
109109
{
110110
description: "plain image name with workspace directory",
111-
artifact: &latestV1.Artifact{
112-
ArtifactType: latestV1.ArtifactType{
113-
KoArtifact: &latestV1.KoArtifact{},
111+
artifact: &latestV2.Artifact{
112+
ArtifactType: latestV2.ArtifactType{
113+
KoArtifact: &latestV2.KoArtifact{},
114114
},
115115
ImageName: "any-image-name-2",
116116
Workspace: "./testdata/package-main-in-root",
@@ -119,9 +119,9 @@ func Test_getImportPath(t *testing.T) {
119119
},
120120
{
121121
description: "plain image name with workspace directory and main",
122-
artifact: &latestV1.Artifact{
123-
ArtifactType: latestV1.ArtifactType{
124-
KoArtifact: &latestV1.KoArtifact{
122+
artifact: &latestV2.Artifact{
123+
ArtifactType: latestV2.ArtifactType{
124+
KoArtifact: &latestV2.KoArtifact{
125125
Main: "./baz",
126126
},
127127
},
@@ -132,9 +132,9 @@ func Test_getImportPath(t *testing.T) {
132132
},
133133
{
134134
description: "plain image name with workspace directory and main and source directory",
135-
artifact: &latestV1.Artifact{
136-
ArtifactType: latestV1.ArtifactType{
137-
KoArtifact: &latestV1.KoArtifact{
135+
artifact: &latestV2.Artifact{
136+
ArtifactType: latestV2.ArtifactType{
137+
KoArtifact: &latestV2.KoArtifact{
138138
Dir: "package-main-not-in-root",
139139
Main: "./baz",
140140
},

pkg/skaffold/build/ko/builder.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ import (
2727
"github.com/google/ko/pkg/commands/options"
2828

2929
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/config"
30-
latestV1 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v1"
30+
latestV2 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v2"
3131
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/version"
3232
)
3333

34-
func (b *Builder) newKoBuilder(ctx context.Context, a *latestV1.Artifact) (build.Interface, error) {
34+
func (b *Builder) newKoBuilder(ctx context.Context, a *latestV2.Artifact) (build.Interface, error) {
3535
bo, err := buildOptions(a, b.runMode)
3636
if err != nil {
3737
return nil, fmt.Errorf("could not construct ko build options: %v", err)
3838
}
3939
return commands.NewBuilder(ctx, bo)
4040
}
4141

42-
func buildOptions(a *latestV1.Artifact, runMode config.RunMode) (*options.BuildOptions, error) {
42+
func buildOptions(a *latestV2.Artifact, runMode config.RunMode) (*options.BuildOptions, error) {
4343
buildconfig, err := buildConfig(a)
4444
if err != nil {
4545
return nil, fmt.Errorf("could not create ko build config: %v", err)
@@ -60,7 +60,7 @@ func buildOptions(a *latestV1.Artifact, runMode config.RunMode) (*options.BuildO
6060
// A map entry is only required if the artifact config specifies fields that need to be part of ko build configs.
6161
// If none of these are specified, we can provide an empty `BuildConfigs` map.
6262
// In this case, ko falls back to build configs provided in `.ko.yaml`, or to the default zero config.
63-
func buildConfig(a *latestV1.Artifact) (map[string]build.Config, error) {
63+
func buildConfig(a *latestV2.Artifact) (map[string]build.Config, error) {
6464
buildconfigs := map[string]build.Config{}
6565
if koArtifactSpecifiesBuildConfig(*a.KoArtifact) {
6666
koImportpath, err := getImportPath(a)
@@ -80,7 +80,7 @@ func buildConfig(a *latestV1.Artifact) (map[string]build.Config, error) {
8080
return buildconfigs, nil
8181
}
8282

83-
func koArtifactSpecifiesBuildConfig(k latestV1.KoArtifact) bool {
83+
func koArtifactSpecifiesBuildConfig(k latestV2.KoArtifact) bool {
8484
if k.Dir != "" && k.Dir != "." {
8585
return true
8686
}
@@ -99,7 +99,7 @@ func koArtifactSpecifiesBuildConfig(k latestV1.KoArtifact) bool {
9999
return false
100100
}
101101

102-
func labels(a *latestV1.Artifact) []string {
102+
func labels(a *latestV2.Artifact) []string {
103103
var labels []string
104104
for k, v := range a.KoArtifact.Labels {
105105
labels = append(labels, fmt.Sprintf("%s=%s", k, v))

pkg/skaffold/build/ko/builder_test.go

+29-29
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ import (
2323
"github.com/google/go-cmp/cmp/cmpopts"
2424

2525
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/config"
26-
latestV1 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v1"
26+
latestV2 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v2"
2727
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/version"
2828
"github.com/GoogleContainerTools/skaffold/testutil"
2929
)
3030

3131
func TestBuildOptions(t *testing.T) {
3232
tests := []struct {
3333
description string
34-
artifact latestV1.Artifact
34+
artifact latestV2.Artifact
3535
runMode config.RunMode
3636
wantDisableOptimizations bool
3737
wantLabels []string
@@ -41,17 +41,17 @@ func TestBuildOptions(t *testing.T) {
4141
}{
4242
{
4343
description: "all zero value",
44-
artifact: latestV1.Artifact{
45-
ArtifactType: latestV1.ArtifactType{
46-
KoArtifact: &latestV1.KoArtifact{},
44+
artifact: latestV2.Artifact{
45+
ArtifactType: latestV2.ArtifactType{
46+
KoArtifact: &latestV2.KoArtifact{},
4747
},
4848
},
4949
},
5050
{
5151
description: "base image",
52-
artifact: latestV1.Artifact{
53-
ArtifactType: latestV1.ArtifactType{
54-
KoArtifact: &latestV1.KoArtifact{
52+
artifact: latestV2.Artifact{
53+
ArtifactType: latestV2.ArtifactType{
54+
KoArtifact: &latestV2.KoArtifact{
5555
BaseImage: "gcr.io/distroless/base:nonroot",
5656
},
5757
},
@@ -60,9 +60,9 @@ func TestBuildOptions(t *testing.T) {
6060
},
6161
{
6262
description: "empty platforms",
63-
artifact: latestV1.Artifact{
64-
ArtifactType: latestV1.ArtifactType{
65-
KoArtifact: &latestV1.KoArtifact{
63+
artifact: latestV2.Artifact{
64+
ArtifactType: latestV2.ArtifactType{
65+
KoArtifact: &latestV2.KoArtifact{
6666
Platforms: []string{},
6767
},
6868
},
@@ -71,9 +71,9 @@ func TestBuildOptions(t *testing.T) {
7171
},
7272
{
7373
description: "multiple platforms",
74-
artifact: latestV1.Artifact{
75-
ArtifactType: latestV1.ArtifactType{
76-
KoArtifact: &latestV1.KoArtifact{
74+
artifact: latestV2.Artifact{
75+
ArtifactType: latestV2.ArtifactType{
76+
KoArtifact: &latestV2.KoArtifact{
7777
Platforms: []string{"linux/amd64", "linux/arm64"},
7878
},
7979
},
@@ -83,9 +83,9 @@ func TestBuildOptions(t *testing.T) {
8383
},
8484
{
8585
description: "workspace",
86-
artifact: latestV1.Artifact{
87-
ArtifactType: latestV1.ArtifactType{
88-
KoArtifact: &latestV1.KoArtifact{},
86+
artifact: latestV2.Artifact{
87+
ArtifactType: latestV2.ArtifactType{
88+
KoArtifact: &latestV2.KoArtifact{},
8989
},
9090
ImageName: "ko://example.com/foo",
9191
Workspace: "my-app-subdirectory",
@@ -94,9 +94,9 @@ func TestBuildOptions(t *testing.T) {
9494
},
9595
{
9696
description: "source dir",
97-
artifact: latestV1.Artifact{
98-
ArtifactType: latestV1.ArtifactType{
99-
KoArtifact: &latestV1.KoArtifact{
97+
artifact: latestV2.Artifact{
98+
ArtifactType: latestV2.ArtifactType{
99+
KoArtifact: &latestV2.KoArtifact{
100100
Dir: "my-go-mod-is-here",
101101
},
102102
},
@@ -107,9 +107,9 @@ func TestBuildOptions(t *testing.T) {
107107
},
108108
{
109109
description: "workspace and source dir",
110-
artifact: latestV1.Artifact{
111-
ArtifactType: latestV1.ArtifactType{
112-
KoArtifact: &latestV1.KoArtifact{
110+
artifact: latestV2.Artifact{
111+
ArtifactType: latestV2.ArtifactType{
112+
KoArtifact: &latestV2.KoArtifact{
113113
Dir: "my-go-mod-is-here",
114114
},
115115
},
@@ -121,9 +121,9 @@ func TestBuildOptions(t *testing.T) {
121121
},
122122
{
123123
description: "disable compiler optimizations for debug",
124-
artifact: latestV1.Artifact{
125-
ArtifactType: latestV1.ArtifactType{
126-
KoArtifact: &latestV1.KoArtifact{},
124+
artifact: latestV2.Artifact{
125+
ArtifactType: latestV2.ArtifactType{
126+
KoArtifact: &latestV2.KoArtifact{},
127127
},
128128
ImageName: "ko://example.com/foo",
129129
},
@@ -132,9 +132,9 @@ func TestBuildOptions(t *testing.T) {
132132
},
133133
{
134134
description: "labels",
135-
artifact: latestV1.Artifact{
136-
ArtifactType: latestV1.ArtifactType{
137-
KoArtifact: &latestV1.KoArtifact{
135+
artifact: latestV2.Artifact{
136+
ArtifactType: latestV2.ArtifactType{
137+
KoArtifact: &latestV2.KoArtifact{
138138
Labels: map[string]string{
139139
"foo": "bar",
140140
"frob": "baz",

pkg/skaffold/build/ko/dependencies.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ import (
2020
"context"
2121

2222
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/build/list"
23-
latestV1 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v1"
23+
latestV2 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v2"
2424
)
2525

2626
// GetDependencies returns a list of files to watch for changes to rebuild.
27-
func GetDependencies(_ context.Context, workspace string, a *latestV1.KoArtifact) ([]string, error) {
27+
func GetDependencies(_ context.Context, workspace string, a *latestV2.KoArtifact) ([]string, error) {
2828
if a.Dependencies == nil || (a.Dependencies.Paths == nil && a.Dependencies.Ignore == nil) {
2929
a.Dependencies = defaultKoDependencies()
3030
}
3131
return list.Files(workspace, a.Dependencies.Paths, a.Dependencies.Ignore)
3232
}
3333

3434
// defaultKoDependencies behavior is to watch all Go files in the context directory and its subdirectories.
35-
func defaultKoDependencies() *latestV1.KoDependencies {
36-
return &latestV1.KoDependencies{
35+
func defaultKoDependencies() *latestV2.KoDependencies {
36+
return &latestV2.KoDependencies{
3737
Paths: []string{"**/*.go"},
3838
Ignore: []string{},
3939
}

pkg/skaffold/build/ko/dependencies_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323

2424
"github.com/google/go-cmp/cmp/cmpopts"
2525

26-
latestV1 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v1"
26+
latestV2 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v2"
2727
"github.com/GoogleContainerTools/skaffold/testutil"
2828
)
2929

@@ -97,8 +97,8 @@ func TestGetDependencies(t *testing.T) {
9797
}
9898
for _, test := range tests {
9999
testutil.Run(t, test.description, func(t *testutil.T) {
100-
deps, err := GetDependencies(context.Background(), tmpDir.Root(), &latestV1.KoArtifact{
101-
Dependencies: &latestV1.KoDependencies{
100+
deps, err := GetDependencies(context.Background(), tmpDir.Root(), &latestV2.KoArtifact{
101+
Dependencies: &latestV2.KoDependencies{
102102
Paths: test.paths,
103103
Ignore: test.ignore,
104104
},

0 commit comments

Comments
 (0)