Skip to content

Commit daabddc

Browse files
committed
chore: fix ko test and lint issues
1 parent 643495c commit daabddc

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

cmd/skaffold/app/cmd/fix_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ import (
2222
"os"
2323
"testing"
2424

25+
"github.com/google/go-cmp/cmp"
26+
2527
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/latest"
2628
v1 "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/v1"
2729
"github.com/GoogleContainerTools/skaffold/v2/testutil"
28-
"github.com/google/go-cmp/cmp"
2930
)
3031

3132
func TestFix(t *testing.T) {

integration/ko_test.go

+14
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828

2929
"github.com/google/go-containerregistry/pkg/crane"
3030
"github.com/google/go-containerregistry/pkg/registry"
31+
"github.com/google/go-containerregistry/pkg/v1/mutate"
3132
"github.com/google/go-containerregistry/pkg/v1/random"
3233

3334
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/build/ko"
@@ -86,6 +87,19 @@ func registryServerWithImage(namespace string) (*httptest.Server, error) {
8687
if err != nil {
8788
return nil, fmt.Errorf("random.Image(): %+v", err)
8889
}
90+
// ko 0.12 starts to validate image platform, the random generated image doesn't that info, we need to manually to set
91+
// image platform back to the image. image.ConfigFile() is a deepCopy() method, we need to use mutate.ConfigFile() to inject
92+
// the platform info.
93+
configFile, _ := image.ConfigFile()
94+
configFile.OS = runtime.GOOS
95+
configFile.Architecture = runtime.GOARCH
96+
configFile.OSVersion = runtime.Version()
97+
98+
image, err = mutate.ConfigFile(image, configFile)
99+
if err != nil {
100+
return nil, fmt.Errorf("failed to mutate image: %+v", err)
101+
}
102+
89103
err = crane.Push(image, imageName)
90104
if err != nil {
91105
return nil, fmt.Errorf("crane.Push(): %+v", err)

pkg/skaffold/instrumentation/export.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import (
4242
"go.opentelemetry.io/otel/sdk/metric/metricdata"
4343
"go.opentelemetry.io/otel/sdk/resource"
4444
sdktrace "go.opentelemetry.io/otel/sdk/trace"
45-
"go.opentelemetry.io/otel/semconv/v1.17.0"
45+
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
4646
"go.opentelemetry.io/otel/trace"
4747
"google.golang.org/api/option"
4848

pkg/skaffold/render/renderer/kubectl/kubectl_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ package kubectl
1919
import (
2020
"bytes"
2121
"context"
22-
"github.com/google/go-cmp/cmp"
2322
"path/filepath"
2423
"testing"
2524

25+
"github.com/google/go-cmp/cmp"
26+
2627
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/graph"
2728
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/render"
2829
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/latest"

0 commit comments

Comments
 (0)