Skip to content

Commit

Permalink
Merge pull request #1088 from coollog/jib_skaffold_merge_master
Browse files Browse the repository at this point in the history
Merges branch 'master' into jib_skaffold.
  • Loading branch information
balopat authored Oct 3, 2018
2 parents 412101b + 4e5435f commit 352217a
Show file tree
Hide file tree
Showing 105 changed files with 2,245 additions and 1,278 deletions.
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

0 comments on commit 352217a

Please sign in to comment.