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

Merges branch 'master' into jib_skaffold. #1088

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
cc9fa1e
[watch] watch returns list of added, modified, deleted files
r2d4 Sep 26, 2018
361e95c
Revert "Rename kustomize.KustomizePath to kustomize.Path" (#1061)
dgageot Sep 28, 2018
59d184f
[watch] add tests, update runner
r2d4 Sep 28, 2018
2bc69a8
Introduce v1alpha4 config version
dgageot Sep 28, 2018
3ec4835
Merge pull request #1062 from dgageot/v1alpha4
dgageot Sep 29, 2018
84f3953
Version check for skaffold config files
r2d4 Sep 30, 2018
b2ee55e
move debug statement out of getter
r2d4 Sep 30, 2018
1a601a7
Update go-containerregistry dep and remove unnecessary Options (#1072)
imjasonh Oct 1, 2018
600f25b
transform values files in profiles to v1alpha3 (#1070)
GeertJohan Oct 1, 2018
1fa94f4
Cleanup docker file parsing
dgageot Sep 27, 2018
2454fa1
Stage names in Dockerfiles are case insensitive
dgageot Sep 27, 2018
a90613d
Support cascaded stage names in Dockerfiles
dgageot Sep 27, 2018
d19f720
Fix sample yaml names
dgageot Sep 27, 2018
f3dffd6
Fix cases where build args are defined at the top
dgageot Sep 27, 2018
8570e92
Simplify code
dgageot Sep 28, 2018
7cf7a35
Handle error
dgageot Sep 29, 2018
ff305af
Artifacts syntax look more alike docker-compose syntax
dgageot Sep 29, 2018
0be3f96
Rename kustomize.KustomizePath to kustomize.Path
dgageot Sep 29, 2018
c27bcd4
Merge pull request #1053 from dgageot/dockerfile-parsing
dgageot Oct 2, 2018
296d8ab
Merge pull request #1026 from r2d4/version-parsing-v2
dgageot Oct 2, 2018
a6a874e
Merge pull request #1065 from dgageot/rename-config
dgageot Oct 2, 2018
7ce2b37
Simplify schema versioning
dgageot Sep 29, 2018
998e6a6
review feedback
r2d4 Oct 2, 2018
98c01af
Merge pull request #1064 from r2d4/watch-returns-filemap
dgageot Oct 2, 2018
83da27e
added changelog notes for v0.15.1 (#1075)
balopat Oct 2, 2018
bd3fc88
Merge pull request #1067 from dgageot/versionning
dgageot Oct 2, 2018
3674813
Add test runner
nkubala Sep 18, 2018
d888488
cleanup and organization
nkubala Sep 21, 2018
b0a83d6
add tests
nkubala Sep 21, 2018
a96cbfb
lint
nkubala Sep 21, 2018
9c59029
check runner.Tester in unit tests. pin cst binary to version in Docke…
nkubala Sep 24, 2018
f703c8d
move config changes to v1alpha4 and examples to integration/examples
nkubala Oct 2, 2018
50e565a
Fix tests
nkubala Oct 2, 2018
7907f24
fix rebase
nkubala Oct 2, 2018
a7b9412
add support for wildcards when specifying test files
nkubala Oct 2, 2018
95df153
Merge pull request #1013 from nkubala/test-runner
dgageot Oct 3, 2018
874e729
Merge branch 'master' into jib_skaffold
coollog Oct 3, 2018
4e5435f
Uses latest instead of v1alpha3 for JibMavenArtifact and JibGradleArt…
coollog Oct 3, 2018
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v0.15.1 Release - 10/02/2018

This is a minor release to address an inconsistency in the `skaffold fix` upgrade:

* Transform values files in profiles to v1alpha3 [#1070](https://github.com/GoogleContainerTools/skaffold/pull/1070)


# v0.15.0 Release - 9/27/2018

New Features:
Expand Down
5 changes: 3 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions cmd/skaffold/app/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"os"
"strings"

cmdutil "github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/cmd/util"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/config"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/constants"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/update"
Expand Down Expand Up @@ -164,15 +163,3 @@ func SetUpLogs(out io.Writer, level string) error {
logrus.SetLevel(lvl)
return nil
}

func readConfiguration(opts *config.SkaffoldOptions) (*config.SkaffoldConfig, error) {
config, err := cmdutil.ParseConfig(opts.ConfigurationFile)
if err != nil {
return nil, errors.Wrap(err, "parsing skaffold config")
}
err = config.ApplyProfiles(opts.Profiles)
if err != nil {
return nil, errors.Wrap(err, "applying profiles")
}
return config, nil
}
18 changes: 9 additions & 9 deletions cmd/skaffold/app/cmd/fix.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,31 @@ import (
"io/ioutil"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/color"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/config"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema"
schemautil "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/util"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/util"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
yaml "gopkg.in/yaml.v2"
"k8s.io/client-go/tools/clientcmd/api/latest"
)

func NewCmdFix(out io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "fix",
Short: "Converts old skaffold.yaml to newest schema version",
Run: func(cmd *cobra.Command, args []string) {
contents, err := util.ReadConfiguration(opts.ConfigurationFile)
if err != nil {
logrus.Errorf("fix: %s", err)
}
cfg, err := config.GetConfig(contents, false)
cfg, err := schema.ParseConfig(opts.ConfigurationFile, false)
if err != nil {
logrus.Error(err)
return
}
if cfg.GetVersion() == config.LatestVersion {

if cfg.GetVersion() == latest.Version {
color.Default.Fprintln(out, "config is already latest version")
return
}

if err := runFix(out, cfg); err != nil {
logrus.Errorf("fix: %s", err)
}
Expand All @@ -60,14 +57,16 @@ func NewCmdFix(out io.Writer) *cobra.Command {
}

func runFix(out io.Writer, cfg schemautil.VersionedConfig) error {
cfg, err := schema.RunTransform(cfg)
cfg, err := schema.UpgradeToLatest(cfg)
if err != nil {
return err
}

newCfg, err := yaml.Marshal(cfg)
if err != nil {
return errors.Wrap(err, "marshaling new config")
}

if overwrite {
if err := ioutil.WriteFile(opts.ConfigurationFile, newCfg, 0644); err != nil {
return errors.Wrap(err, "writing config file")
Expand All @@ -76,5 +75,6 @@ func runFix(out io.Writer, cfg schemautil.VersionedConfig) error {
} else {
out.Write(newCfg)
}

return nil
}
45 changes: 22 additions & 23 deletions cmd/skaffold/app/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,17 @@ import (
"path/filepath"
"strings"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/constants"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/docker"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/util"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"gopkg.in/AlecAivazis/survey.v1"
yaml "gopkg.in/yaml.v2"

cmdutil "github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/cmd/util"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/config"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/constants"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/docker"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/v1alpha3"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/util"

"k8s.io/apimachinery/pkg/runtime"

k8syaml "k8s.io/apimachinery/pkg/util/yaml"
"k8s.io/client-go/kubernetes/scheme"
)
Expand Down Expand Up @@ -95,11 +91,12 @@ func doInit(out io.Writer) error {
return err
}
for _, file := range potentialConfigs {
config, err := cmdutil.ParseConfig(file)
config, err := schema.ParseConfig(file, true)
if err == nil && config != nil {
out.Write([]byte(fmt.Sprintf("pre-existing skaffold yaml %s found: exiting\n", file)))
return nil
}

logrus.Debugf("%s is not a valid skaffold configuration: continuing", file)
imgs, err := parseKubernetesYaml(file)
if err == nil {
Expand Down Expand Up @@ -206,23 +203,23 @@ func promptUserForDockerfile(image string, dockerfiles []string) dockerfilePair
}
}

func processBuildArtifacts(pairs []dockerfilePair) v1alpha3.BuildConfig {
var config v1alpha3.BuildConfig
func processBuildArtifacts(pairs []dockerfilePair) latest.BuildConfig {
var config latest.BuildConfig

if len(pairs) > 0 {
var artifacts []*v1alpha3.Artifact
var artifacts []*latest.Artifact
for _, pair := range pairs {
workspace := filepath.Dir(pair.Dockerfile)
dockerfilePath := filepath.Base(pair.Dockerfile)
a := &v1alpha3.Artifact{
a := &latest.Artifact{
ImageName: pair.ImageName,
}
if workspace != "." {
a.Workspace = workspace
}
if dockerfilePath != constants.DefaultDockerfilePath {
a.ArtifactType = v1alpha3.ArtifactType{
DockerArtifact: &v1alpha3.DockerArtifact{
a.ArtifactType = latest.ArtifactType{
DockerArtifact: &latest.DockerArtifact{
DockerfilePath: dockerfilePath,
},
}
Expand All @@ -239,16 +236,18 @@ func generateSkaffoldConfig(k8sConfigs []string, dockerfilePairs []dockerfilePai
// if the user doesn't have any k8s yamls, generate one for each dockerfile
logrus.Info("generating skaffold config")

var err error
config, err := config.NewConfig()
if err != nil {
config := &latest.SkaffoldConfig{
APIVersion: latest.Version,
Kind: "Config",
}
if err := config.SetDefaultValues(); err != nil {
return nil, errors.Wrap(err, "generating default config")
}
config.Build = processBuildArtifacts(dockerfilePairs)

config.Deploy = v1alpha3.DeployConfig{
DeployType: v1alpha3.DeployType{
KubectlDeploy: &v1alpha3.KubectlDeploy{
config.Build = processBuildArtifacts(dockerfilePairs)
config.Deploy = latest.DeployConfig{
DeployType: latest.DeployType{
KubectlDeploy: &latest.KubectlDeploy{
Manifests: k8sConfigs,
},
},
Expand Down
18 changes: 15 additions & 3 deletions cmd/skaffold/app/cmd/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,26 @@ package cmd
import (
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/config"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/pkg/errors"
)

// newRunner creates a SkaffoldRunner and returns the SkaffoldConfig associated with it.
func newRunner(opts *config.SkaffoldOptions) (*runner.SkaffoldRunner, *config.SkaffoldConfig, error) {
config, err := readConfiguration(opts)
func newRunner(opts *config.SkaffoldOptions) (*runner.SkaffoldRunner, *latest.SkaffoldConfig, error) {
parsed, err := schema.ParseConfig(opts.ConfigurationFile, true)
if err != nil {
return nil, nil, errors.Wrap(err, "reading configuration")
return nil, nil, errors.Wrap(err, "parsing skaffold config")
}

if err := schema.CheckVersionIsLatest(parsed.GetVersion()); err != nil {
return nil, nil, errors.Wrap(err, "invalid config")
}

config := parsed.(*latest.SkaffoldConfig)
err = schema.ApplyProfiles(config, opts.Profiles)
if err != nil {
return nil, nil, errors.Wrap(err, "applying profiles")
}

runner, err := runner.NewForConfig(opts, config)
Expand Down
50 changes: 0 additions & 50 deletions cmd/skaffold/app/cmd/util/util.go

This file was deleted.

6 changes: 5 additions & 1 deletion deploy/skaffold/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ RUN echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8
RUN apt-get update \
&& apt-get install -y bazel

ENV CONTAINER_STRUCTURE_TEST_VERSION=1.5.0
RUN curl -LO https://storage.googleapis.com/container-structure-test/v${CONTAINER_STRUCTURE_TEST_VERSION}/container-structure-test-linux-amd64 \
&& chmod +x container-structure-test-linux-amd64 \
&& mv container-structure-test-linux-amd64 /usr/local/bin/container-structure-test

ENV PATH /usr/local/go/bin:/go/bin:/google-cloud-sdk/bin:$PATH

FROM runtime_deps as builder
Expand Down Expand Up @@ -94,4 +99,3 @@ CMD ["make", "integration"]
FROM runtime_deps as distribution

COPY --from=integration /usr/bin/skaffold /usr/bin/skaffold

2 changes: 1 addition & 1 deletion examples/annotated-skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ deploy:
# - namespace:deployment/web-app2

# kustomize:
# path: .
# kustomizePath: .
# kustomize deploys manifests with kubectl.
# kubectl can be passed additional option flags either on every command (Global),
# on creations (Apply) or deletions (Delete).
Expand Down
8 changes: 4 additions & 4 deletions integration/examples/annotated-skaffold.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: skaffold/v1alpha3
apiVersion: skaffold/v1alpha4
kind: Config
build:
# tagPolicy determines how skaffold is going to tag your images.
Expand Down Expand Up @@ -36,15 +36,15 @@ build:
# you can include as many as you want here.
artifacts:
# The name of the image to be built.
- imageName: gcr.io/k8s-skaffold/skaffold-example
- image: gcr.io/k8s-skaffold/skaffold-example
# The path to your dockerfile context. Defaults to ".".
workspace: ../examples/getting-started
context: ../examples/getting-started

# Each artifact is of a given type among: `docker` and `bazel`.
# If not specified, it defaults to `docker: {}`.
docker:
# Dockerfile's location relative to workspace. Defaults to "Dockerfile"
dockerfilePath: Dockerfile
dockerfile: Dockerfile
# Key/value arguements passed to the docker build.
buildArgs:
key1: "value1"
Expand Down
4 changes: 2 additions & 2 deletions integration/examples/bazel/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ The way you configure it in `skaffold.yaml` is the following build stanza:
----
build:
artifacts:
- imageName: gcr.io/k8s-skaffold/skaffold-example
workspace: . <1>
- image: gcr.io/k8s-skaffold/skaffold-example
context: . <1>
bazel: # <2>
target: //:skaffold_example.tar # <3>
----
Expand Down
10 changes: 3 additions & 7 deletions integration/examples/bazel/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
apiVersion: skaffold/v1alpha3
apiVersion: skaffold/v1alpha4
kind: Config
build:
artifacts:
- imageName: gcr.io/k8s-skaffold/skaffold-bazel
workspace: .
- image: gcr.io/k8s-skaffold/skaffold-bazel
context: .
bazel:
target: //:skaffold_example.tar
local: {}
deploy:
kubectl:
manifests:
Loading