Skip to content

Commit

Permalink
Update to pack 0.15 and add debug support for CNB Platform API 0.4 (#…
Browse files Browse the repository at this point in the history
…5064)

* Update pack v0.15.0 and drop replace of Azure/go-autorest

* go mod vendor

* Update code to pack v0.15 (debug still requires adjusting)

* Add debug support for CNB Platform API 0.4

* missed tests

* Fix fallout from google/go-containerregistry#791

* Make the TestDebug/buildpacks integration tests pass

Tests were failing as I wasn't rewriting the entrypoint, so that
Platform 0.4-style process executables (/cnb/process/web) continued
through and the debug transformers wouldn't recognize the executable.

- fix adjustCommandLine() and add tests
- fix testutil.isNil to handle function pointers
- narrow isCNBImage() to only allow entrypoint to be 1-element array
  and add tests
- go style nits (rename isCnbImage -> isCNBImage, godoc style)

* Mark TestDevPortForwardDeletePod to be skipped due to flakiness
  • Loading branch information
briandealwis authored Nov 30, 2020

Verified

This commit was signed with the committer’s verified signature. The key has expired.
charlyx Charles-Henri GUERIN
1 parent 908ba43 commit e91c8e6
Showing 599 changed files with 42,459 additions and 9,419 deletions.
2 changes: 1 addition & 1 deletion deploy/buildpacks/publish.sh
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@

set -e

PACK_VERSION=v0.12.0
PACK_VERSION=v0.15.0

docker build . --build-arg PACK_VERSION=${PACK_VERSION} -t gcr.io/k8s-skaffold/pack:${PACK_VERSION} -t gcr.io/k8s-skaffold/pack:latest
docker push gcr.io/k8s-skaffold/pack:${PACK_VERSION}
40 changes: 20 additions & 20 deletions go.mod
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@ module github.com/GoogleContainerTools/skaffold
go 1.15

replace (
github.com/Azure/go-autorest => github.com/Azure/go-autorest v13.0.1+incompatible
github.com/containerd/containerd => github.com/containerd/containerd v1.3.4
github.com/docker/docker => github.com/docker/docker v1.4.2-0.20200221181110-62bd5a33f707
github.com/tektoncd/pipeline => github.com/tektoncd/pipeline v0.5.1-0.20190731183258-9d7e37e85bf8
@@ -27,9 +26,9 @@ require (
contrib.go.opencensus.io/exporter/stackdriver v0.13.1 // indirect
github.com/blang/semver v3.5.1+incompatible
github.com/bmatcuk/doublestar v1.2.4
github.com/buildpacks/imgutil v0.0.0-20200520132953-ba4f77a60397
github.com/buildpacks/lifecycle v0.7.2
github.com/buildpacks/pack v0.12.0
github.com/buildpacks/imgutil v0.0.0-20201022190551-6525b8cdcdd0
github.com/buildpacks/lifecycle v0.9.3
github.com/buildpacks/pack v0.15.0
github.com/cenkalti/backoff/v4 v4.0.2
github.com/docker/cli v0.0.0-20200312141509-ef2f64abbd37
github.com/docker/distribution v2.7.1+incompatible
@@ -40,51 +39,52 @@ require (
github.com/go-git/go-git/v5 v5.0.0
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e
github.com/golang/protobuf v1.4.2
github.com/google/go-cmp v0.4.1
github.com/google/go-containerregistry v0.1.1
github.com/golang/protobuf v1.4.3
github.com/google/go-cmp v0.5.2
github.com/google/go-containerregistry v0.1.4
github.com/google/go-github v17.0.0+incompatible
github.com/google/uuid v1.1.1
github.com/google/martian v2.1.1-0.20190517191504-25dcb96d9e51+incompatible // indirect
github.com/google/uuid v1.1.2
github.com/grpc-ecosystem/grpc-gateway v1.14.3
github.com/heroku/color v0.0.6
github.com/imdario/mergo v0.3.9
github.com/karrick/godirwalk v1.15.6
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/krishicks/yaml-patch v0.0.10
github.com/mattn/go-colorable v0.1.6
github.com/mattn/go-colorable v0.1.8
github.com/mitchellh/go-homedir v1.1.0
github.com/moby/buildkit v0.7.1
github.com/opencontainers/go-digest v1.0.0-rc1.0.20190228220655-ac19fd6e7483
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.0.1
github.com/openzipkin/zipkin-go v0.2.2 // indirect
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4
github.com/rakyll/statik v0.1.7
github.com/rjeczalik/notify v0.9.2
github.com/russross/blackfriday/v2 v2.0.1
github.com/segmentio/textio v1.2.0
github.com/sirupsen/logrus v1.6.0
github.com/spf13/cobra v1.0.0
github.com/sirupsen/logrus v1.7.0
github.com/spf13/cobra v1.1.1
github.com/spf13/pflag v1.0.5
github.com/tektoncd/pipeline v0.5.1-0.20190731183258-9d7e37e85bf8
github.com/xeipuuv/gojsonschema v1.2.0
go.uber.org/multierr v1.4.0 // indirect
go.uber.org/zap v1.12.0 // indirect
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897
golang.org/x/mod v0.3.0
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
golang.org/x/sys v0.0.0-20200523222454-059865788121
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6
gomodules.xyz/jsonpatch/v2 v2.1.0 // indirect
google.golang.org/api v0.25.0
google.golang.org/genproto v0.0.0-20200527145253-8367513e4ece
google.golang.org/grpc v1.29.1
google.golang.org/genproto v0.0.0-20201022181438-0ff5f38871d5
google.golang.org/grpc v1.33.1
gopkg.in/AlecAivazis/survey.v1 v1.8.8
gopkg.in/yaml.v2 v2.3.0
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c
k8s.io/api v0.18.1
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
k8s.io/api v0.18.8
k8s.io/apiextensions-apiserver v0.18.1 // indirect
k8s.io/apimachinery v0.19.2
k8s.io/client-go v0.18.1
k8s.io/client-go v0.18.8
k8s.io/kubectl v0.0.0-20190831163037-3b58a944563f
k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89
knative.dev/pkg v0.0.0-20200416021448-f68639f04b39 // indirect
406 changes: 110 additions & 296 deletions go.sum

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions integration/port_forward_test.go
Original file line number Diff line number Diff line change
@@ -99,6 +99,7 @@ func TestRunPortForwardByPortName(t *testing.T) {
// and tests that the pod eventually comes up at the same port again.
func TestDevPortForwardDeletePod(t *testing.T) {
MarkIntegrationTest(t, CanRunWithoutGcp)
t.Skip("Flakey on Travis with k3d and kind")

ns, _ := SetupNamespace(t)

87 changes: 44 additions & 43 deletions pkg/skaffold/build/buildpacks/build_test.go
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ import (
"testing"

"github.com/buildpacks/pack"
packcfg "github.com/buildpacks/pack/config"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/config"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/docker"
@@ -76,12 +77,12 @@ func TestBuild(t *testing.T) {
api: &testutil.FakeAPIClient{},
resolver: mockArtifactResolver{},
expectedOptions: &pack.BuildOptions{
AppPath: ".",
Builder: "my/builder",
RunImage: "my/run",
NoPull: true,
Env: nonDebugModeArgs,
Image: "img:latest",
AppPath: ".",
Builder: "my/builder",
RunImage: "my/run",
PullPolicy: packcfg.PullNever,
Env: nonDebugModeArgs,
Image: "img:latest",
},
},

@@ -115,7 +116,7 @@ func TestBuild(t *testing.T) {
RunImage: "my/otherRun",
Buildpacks: []string{"my/buildpack", "my/otherBuildpack"},
TrustBuilder: true,
NoPull: true,
PullPolicy: packcfg.PullNever,
Env: nonDebugModeArgs,
Image: "img:latest",
},
@@ -309,12 +310,12 @@ func TestBuildWithArtifactDependencies(t *testing.T) {
api: &testutil.FakeAPIClient{},
resolver: mockArtifactResolver{m: map[string]string{"builder-image": "my/custom-builder"}},
expectedOptions: &pack.BuildOptions{
AppPath: ".",
Builder: "my/custom-builder",
RunImage: "my/run",
NoPull: true,
Env: nonDebugModeArgs,
Image: "img:latest",
AppPath: ".",
Builder: "my/custom-builder",
RunImage: "my/run",
PullPolicy: packcfg.PullIfNotPresent,
Env: nonDebugModeArgs,
Image: "img:latest",
},
},
{
@@ -326,12 +327,12 @@ func TestBuildWithArtifactDependencies(t *testing.T) {
api: &testutil.FakeAPIClient{},
resolver: mockArtifactResolver{m: map[string]string{"run-image": "my/custom-run"}},
expectedOptions: &pack.BuildOptions{
AppPath: ".",
Builder: "my/builder",
RunImage: "my/custom-run",
NoPull: true,
Env: nonDebugModeArgs,
Image: "img:latest",
AppPath: ".",
Builder: "my/builder",
RunImage: "my/custom-run",
PullPolicy: packcfg.PullIfNotPresent,
Env: nonDebugModeArgs,
Image: "img:latest",
},
},
{
@@ -343,12 +344,12 @@ func TestBuildWithArtifactDependencies(t *testing.T) {
api: &testutil.FakeAPIClient{},
resolver: mockArtifactResolver{m: map[string]string{"builder-image": "my/custom-builder"}},
expectedOptions: &pack.BuildOptions{
AppPath: ".",
Builder: "my/custom-builder",
RunImage: "my/run",
NoPull: false,
Env: nonDebugModeArgs,
Image: "img:latest",
AppPath: ".",
Builder: "my/custom-builder",
RunImage: "my/run",
PullPolicy: packcfg.PullIfNotPresent,
Env: nonDebugModeArgs,
Image: "img:latest",
},
},
{
@@ -360,12 +361,12 @@ func TestBuildWithArtifactDependencies(t *testing.T) {
api: &testutil.FakeAPIClient{},
resolver: mockArtifactResolver{m: map[string]string{"run-image": "my/custom-run"}},
expectedOptions: &pack.BuildOptions{
AppPath: ".",
Builder: "my/builder",
RunImage: "my/custom-run",
NoPull: false,
Env: nonDebugModeArgs,
Image: "img:latest",
AppPath: ".",
Builder: "my/builder",
RunImage: "my/custom-run",
PullPolicy: packcfg.PullIfNotPresent,
Env: nonDebugModeArgs,
Image: "img:latest",
},
},
{
@@ -377,12 +378,12 @@ func TestBuildWithArtifactDependencies(t *testing.T) {
api: &testutil.FakeAPIClient{},
resolver: mockArtifactResolver{m: map[string]string{"builder-image": "my/custom-builder", "run-image": "my/custom-run"}},
expectedOptions: &pack.BuildOptions{
AppPath: ".",
Builder: "my/custom-builder",
RunImage: "my/custom-run",
NoPull: true,
Env: nonDebugModeArgs,
Image: "img:latest",
AppPath: ".",
Builder: "my/custom-builder",
RunImage: "my/custom-run",
PullPolicy: packcfg.PullNever,
Env: nonDebugModeArgs,
Image: "img:latest",
},
},
{
@@ -394,12 +395,12 @@ func TestBuildWithArtifactDependencies(t *testing.T) {
api: &testutil.FakeAPIClient{},
resolver: mockArtifactResolver{m: map[string]string{"builder-image": "my/custom-builder", "run-image": "my/custom-run"}},
expectedOptions: &pack.BuildOptions{
AppPath: ".",
Builder: "my/custom-builder",
RunImage: "my/custom-run",
NoPull: true,
Env: nonDebugModeArgs,
Image: "img:latest",
AppPath: ".",
Builder: "my/custom-builder",
RunImage: "my/custom-run",
PullPolicy: packcfg.PullNever,
Env: nonDebugModeArgs,
Image: "img:latest",
},
},
}
8 changes: 6 additions & 2 deletions pkg/skaffold/build/buildpacks/fetcher.go
Original file line number Diff line number Diff line change
@@ -23,10 +23,14 @@ import (

"github.com/buildpacks/imgutil"
"github.com/buildpacks/imgutil/local"
"github.com/buildpacks/pack"
packcfg "github.com/buildpacks/pack/config"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/docker"
)

var _ pack.ImageFetcher = (*fetcher)(nil)

type fetcher struct {
out io.Writer
docker docker.LocalDaemon
@@ -39,8 +43,8 @@ func newFetcher(out io.Writer, docker docker.LocalDaemon) *fetcher {
}
}

func (f *fetcher) Fetch(ctx context.Context, name string, _, pull bool) (imgutil.Image, error) {
if pull {
func (f *fetcher) Fetch(ctx context.Context, name string, _ bool, pullPolicy packcfg.PullPolicy) (imgutil.Image, error) {
if pullPolicy == packcfg.PullAlways || (pullPolicy == packcfg.PullIfNotPresent && !f.docker.ImageExists(ctx, name)) {
if err := f.docker.Pull(ctx, f.out, name); err != nil {
return nil, err
}
22 changes: 19 additions & 3 deletions pkg/skaffold/build/buildpacks/fetcher_test.go
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ import (
"context"
"testing"

packcfg "github.com/buildpacks/pack/config"
"github.com/docker/docker/client"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/docker"
@@ -30,23 +31,38 @@ import (
func TestFetcher(t *testing.T) {
tests := []struct {
description string
pull bool
imageExists bool
pull packcfg.PullPolicy
expectedPulled []string
}{
{
description: "pull",
pull: true,
pull: packcfg.PullAlways,
expectedPulled: []string{"image"},
},
{
description: "pull-if-not-present but image present",
pull: packcfg.PullIfNotPresent,
imageExists: true,
expectedPulled: nil,
},
{
description: "pull-if-not-present",
pull: packcfg.PullIfNotPresent,
expectedPulled: []string{"image"},
},
{
description: "don't pull",
pull: false,
pull: packcfg.PullNever,
expectedPulled: nil,
},
}
for _, test := range tests {
testutil.Run(t, test.description, func(t *testutil.T) {
api := &testutil.FakeAPIClient{}
if test.imageExists {
api.Add("image", "sha256:deadbeef")
}
docker := fakeLocalDaemon(api)

var out bytes.Buffer
Loading

0 comments on commit e91c8e6

Please sign in to comment.