Skip to content

Commit

Permalink
fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Priya Wadhwa committed Dec 9, 2020
2 parents 8ea2577 + 53a81ad commit d61ca86
Show file tree
Hide file tree
Showing 65 changed files with 1,994 additions and 790 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# v1.17.2 Release - 12/08/2020
**Linux**
`curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/v1.17.2/skaffold-linux-amd64 && chmod +x skaffold && sudo mv skaffold /usr/local/bin`

**macOS**
`curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/v1.17.2/skaffold-darwin-amd64 && chmod +x skaffold && sudo mv skaffold /usr/local/bin`

**Windows**
https://storage.googleapis.com/skaffold/releases/v1.17.2/skaffold-windows-amd64.exe

**Docker image**
`gcr.io/k8s-skaffold/skaffold:v1.17.2`

This is a minor release with a fix for sync issue for docker artifacts in `skaffold dev`. See [#5110](https://github.com/GoogleContainerTools/skaffold/issues/5110) & [#5115](https://github.com/GoogleContainerTools/skaffold/issues/5115)

Fixes:
* Recompute docker dependencies across dev loops. [#5121](https://github.com/GoogleContainerTools/skaffold/pull/5121)


# v1.17.1 Release - 12/01/2020
**Linux**
`curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/v1.17.1/skaffold-linux-amd64 && chmod +x skaffold && sudo mv skaffold /usr/local/bin`
Expand Down
68 changes: 5 additions & 63 deletions cmd/skaffold/app/cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package cmd

import (
"context"
"fmt"
"io"

"github.com/spf13/cobra"
Expand All @@ -27,14 +26,12 @@ import (
"github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/flags"
"github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/tips"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/build"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/build/tag"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
)

var (
deployFromBuildOutputFile flags.BuildOutputFileFlag
preBuiltImages flags.Images
preBuiltImages flags.Images
)

// NewCmdDeploy describes the CLI command to deploy artifacts.
Expand All @@ -48,7 +45,6 @@ func NewCmdDeploy() *cobra.Command {
WithCommonFlags().
WithFlags(func(f *pflag.FlagSet) {
f.VarP(&preBuiltImages, "images", "i", "A list of pre-built images to deploy")
f.VarP(&deployFromBuildOutputFile, "build-artifacts", "a", "File containing build result from a previous 'skaffold build --file-output'")
f.BoolVar(&opts.SkipRender, "skip-render", false, "Don't render the manifests, just deploy them")
}).
WithHouseKeepingMessages().
Expand All @@ -60,67 +56,13 @@ func doDeploy(ctx context.Context, out io.Writer) error {
if opts.SkipRender {
return r.DeployAndLog(ctx, out, []build.Artifact{})
}
deployed, err := getArtifactsToDeploy(out, deployFromBuildOutputFile.BuildArtifacts(), preBuiltImages.Artifacts(), config.Build.Artifacts)

buildArtifacts, err := getBuildArtifactsAndSetTags(r, config)
if err != nil {
tips.PrintUseRunVsDeploy(out)
return err
}

for i := range deployed {
tag, err := r.ApplyDefaultRepo(deployed[i].Tag)
if err != nil {
return err
}
deployed[i].Tag = tag
}

return r.DeployAndLog(ctx, out, deployed)
return r.DeployAndLog(ctx, out, buildArtifacts)
})
}

func getArtifactsToDeploy(out io.Writer, fromFile, fromCLI []build.Artifact, artifacts []*latest.Artifact) ([]build.Artifact, error) {
var deployed []build.Artifact
for _, artifact := range artifacts {
deployed = append(deployed, build.Artifact{
ImageName: artifact.ImageName,
})
}

// Tags provided by file take precedence over those provided on the command line
deployed = build.MergeWithPreviousBuilds(fromCLI, deployed)
deployed = build.MergeWithPreviousBuilds(fromFile, deployed)

deployed, err := applyCustomTag(deployed)
if err != nil {
return nil, err
}

// Check that every image has a non empty tag
for _, d := range deployed {
if d.Tag == "" {
tips.PrintUseRunVsDeploy(out)
return nil, fmt.Errorf("no tag provided for image [%s]", d.ImageName)
}
}

return deployed, nil
}

func applyCustomTag(artifacts []build.Artifact) ([]build.Artifact, error) {
if opts.CustomTag != "" {
var result []build.Artifact
for _, artifact := range artifacts {
if artifact.Tag == "" {
artifact.Tag = artifact.ImageName + ":" + opts.CustomTag
} else {
newTag, err := tag.SetImageTag(artifact.Tag, opts.CustomTag)
if err != nil {
return nil, err
}
artifact.Tag = newTag
}
result = append(result, artifact)
}
return result, nil
}
return artifacts, nil
}
14 changes: 14 additions & 0 deletions cmd/skaffold/app/cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/flags"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/constants"
)

var (
fromBuildOutputFile flags.BuildOutputFileFlag
)

// Flag defines a Skaffold CLI flag which contains a list of
// subcommands the flag belongs to in `DefinedOn` field.
type Flag struct {
Expand Down Expand Up @@ -423,6 +428,15 @@ var flagRegistry = []Flag{
FlagAddMethod: "BoolVar",
DefinedOn: []string{"build", "debug", "delete", "deploy", "dev", "run"},
},
{
Name: "build-artifacts",
Shorthand: "a",
Usage: "File containing build result from a previous 'skaffold build --file-output'",
Value: &fromBuildOutputFile,
DefValue: "",
FlagAddMethod: "Var",
DefinedOn: []string{"deploy"},
},
}

func (fl *Flag) flag() *pflag.Flag {
Expand Down
4 changes: 4 additions & 0 deletions cmd/skaffold/app/cmd/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ func runContext(opts config.SkaffoldOptions) (*runcontext.RunContext, *latest.Sk
return nil, nil, fmt.Errorf("getting run context: %w", err)
}

if err := validation.ProcessWithRunContext(config, runCtx); err != nil {
return nil, nil, fmt.Errorf("invalid skaffold config: %w", err)
}

return runCtx, config, nil
}

Expand Down
5 changes: 4 additions & 1 deletion cmd/skaffold/app/cmd/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ func TestCreateNewRunner(t *testing.T) {
for _, test := range tests {
testutil.Run(t, test.description, func(t *testutil.T) {
t.Override(&docker.NewAPIClient, func(docker.Config) (docker.LocalDaemon, error) {
return nil, nil
return docker.NewLocalDaemon(&testutil.FakeAPIClient{
ErrVersion: true,
}, nil, false, nil), nil
})

t.Override(&update.GetLatestAndCurrentVersion, func() (semver.Version, semver.Version, error) {
return semver.Version{}, semver.Version{}, nil
})
Expand Down
98 changes: 98 additions & 0 deletions cmd/skaffold/app/cmd/util.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
Copyright 2020 The Skaffold Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package cmd

import (
"fmt"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/build"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/build/tag"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
)

func getBuildArtifactsAndSetTags(r runner.Runner, config *latest.SkaffoldConfig) ([]build.Artifact, error) {
buildArtifacts, err := getArtifacts(fromBuildOutputFile.BuildArtifacts(), preBuiltImages.Artifacts(), config.Build.Artifacts)
if err != nil {
return nil, err
}

for i := range buildArtifacts {
tag, err := r.ApplyDefaultRepo(buildArtifacts[i].Tag)
if err != nil {
return nil, err
}
buildArtifacts[i].Tag = tag
}

return buildArtifacts, nil
}

func getArtifacts(fromFile, fromCLI []build.Artifact, artifacts []*latest.Artifact) ([]build.Artifact, error) {
var buildArtifacts []build.Artifact
for _, artifact := range artifacts {
buildArtifacts = append(buildArtifacts, build.Artifact{
ImageName: artifact.ImageName,
})
}

// Tags provided by file take precedence over those provided on the command line
buildArtifacts = build.MergeWithPreviousBuilds(fromCLI, buildArtifacts)
buildArtifacts = build.MergeWithPreviousBuilds(fromFile, buildArtifacts)

buildArtifacts, err := applyCustomTag(buildArtifacts)
if err != nil {
return nil, err
}

// Check that every image has a non empty tag
_, err = TestValidateArtifacts(buildArtifacts)
if err != nil {
return nil, err
}

return buildArtifacts, nil
}

func applyCustomTag(artifacts []build.Artifact) ([]build.Artifact, error) {
if opts.CustomTag != "" {
var result []build.Artifact
for _, artifact := range artifacts {
if artifact.Tag == "" {
artifact.Tag = artifact.ImageName + ":" + opts.CustomTag
} else {
newTag, err := tag.SetImageTag(artifact.Tag, opts.CustomTag)
if err != nil {
return nil, err
}
artifact.Tag = newTag
}
result = append(result, artifact)
}
return result, nil
}
return artifacts, nil
}

func TestValidateArtifacts(artifacts []build.Artifact) (bool, error) {
for _, artifact := range artifacts {
if artifact.Tag == "" {
return false, fmt.Errorf("no tag provided for image [%s]", artifact.ImageName)
}
}
return true, nil
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019 The Skaffold Authors
Copyright 2020 The Skaffold Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -17,15 +17,14 @@ limitations under the License.
package cmd

import (
"io/ioutil"
"testing"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/build"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/testutil"
)

func TestGetDeployedArtifacts(t *testing.T) {
func TestGetArtifacts(t *testing.T) {
tests := []struct {
description string
artifacts []*latest.Artifact
Expand Down Expand Up @@ -99,16 +98,24 @@ func TestGetDeployedArtifacts(t *testing.T) {
expected: []build.Artifact{{ImageName: "image1", Tag: "image1:test"}, {ImageName: "image2", Tag: "image2:test"}},
customTag: "test",
},
{
description: "apply tags to no artifacts",
artifacts: []*latest.Artifact{},
fromFile: nil,
fromCLI: nil,
expected: []build.Artifact(nil),
customTag: "test",
},
}
for _, test := range tests {
testutil.Run(t, test.description, func(t *testutil.T) {
if test.customTag != "" {
t.Override(&opts.CustomTag, test.customTag)
}

deployed, err := getArtifactsToDeploy(ioutil.Discard, test.fromFile, test.fromCLI, test.artifacts)
artifacts, err := getArtifacts(test.fromFile, test.fromCLI, test.artifacts)

t.CheckErrorAndDeepEqual(test.shouldErr, err, test.expected, deployed)
t.CheckErrorAndDeepEqual(test.shouldErr, err, test.expected, artifacts)
})
}
}
69 changes: 55 additions & 14 deletions docs/content/en/api/skaffold.swagger.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions docs/content/en/docs/references/api/grpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,9 @@ For Cancelled Error code, use range 800 to 850.
| BUILD_UNKNOWN_JIB_PLUGIN_TYPE | 119 | Build error indicating unknown Jib plugin type. Should be one of [maven, gradle] |
| BUILD_JIB_GRADLE_DEP_ERR | 120 | Build error determining dependency for jib gradle project. |
| BUILD_JIB_MAVEN_DEP_ERR | 121 | Build error determining dependency for jib gradle project. |
| INIT_DOCKER_NETWORK_LISTING_CONTAINERS | 122 | Docker build error when listing containers. |
| INIT_DOCKER_NETWORK_INVALID_CONTAINER_NAME | 123 | Docker build error indicating an invalid container name (or id). |
| INIT_DOCKER_NETWORK_CONTAINER_DOES_NOT_EXIST | 124 | Docker build error indicating the container referenced does not exists in the docker context used. |
| STATUSCHECK_IMAGE_PULL_ERR | 300 | Container image pull error |
| STATUSCHECK_CONTAINER_CREATING | 301 | Container creating error |
| STATUSCHECK_RUN_CONTAINER_ERR | 302 | Container run error |
Expand Down Expand Up @@ -910,6 +913,8 @@ Enum for Suggestion codes
| FIX_CACHE_FROM_ARTIFACT_CONFIG | 109 | Fix `cacheFrom` config for given artifact and try again |
| FIX_SKAFFOLD_CONFIG_DOCKERFILE | 110 | Fix `dockerfile` config for a given artifact and try again. |
| FIX_JIB_PLUGIN_CONFIGURATION | 111 | Use a supported Jib plugin type |
| FIX_DOCKER_NETWORK_CONTAINER_NAME | 112 | Docker build network invalid docker container name (or id). |
| CHECK_DOCKER_NETWORK_CONTAINER_RUNNING | 113 | Docker build network container not existing in the current context. |
| CHECK_CLUSTER_CONNECTION | 201 | Check cluster connection |
| CHECK_MINIKUBE_STATUS | 202 | Check minikube status |
| INSTALL_HELM | 203 | Install helm tool |
Expand Down
5 changes: 3 additions & 2 deletions docs/content/en/schemas/v2beta11.json
Original file line number Diff line number Diff line change
Expand Up @@ -992,11 +992,12 @@
},
"network": {
"type": "string",
"description": "passed through to docker and overrides the network configuration of docker builder. If unset, use whatever is configured in the underlying docker daemon. Valid modes are `host`: use the host's networking stack. `bridge`: use the bridged network configuration. `none`: no networking in the container.",
"x-intellij-html-description": "passed through to docker and overrides the network configuration of docker builder. If unset, use whatever is configured in the underlying docker daemon. Valid modes are <code>host</code>: use the host's networking stack. <code>bridge</code>: use the bridged network configuration. <code>none</code>: no networking in the container.",
"description": "passed through to docker and overrides the network configuration of docker builder. If unset, use whatever is configured in the underlying docker daemon. Valid modes are `host`: use the host's networking stack. `bridge`: use the bridged network configuration. `container:<name|id>`: reuse another container's network stack. `none`: no networking in the container.",
"x-intellij-html-description": "passed through to docker and overrides the network configuration of docker builder. If unset, use whatever is configured in the underlying docker daemon. Valid modes are <code>host</code>: use the host's networking stack. <code>bridge</code>: use the bridged network configuration. <code>container:&lt;name|id&gt;</code>: reuse another container's network stack. <code>none</code>: no networking in the container.",
"enum": [
"host",
"bridge",
"container:<name|id>",
"none"
]
},
Expand Down
5 changes: 5 additions & 0 deletions examples/getting-started/skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ kind: Config
build:
artifacts:
- image: skaffold-example
context: .
docker:
network: "container:alpine"
local:
push: false
deploy:
kubectl:
manifests:
Expand Down
2 changes: 1 addition & 1 deletion examples/jib-gradle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id 'groovy'
id 'io.spring.dependency-management' version '1.0.6.RELEASE'
id 'net.ltgt.apt-idea' version '0.18'
id 'com.google.cloud.tools.jib' version '2.6.0'
id 'com.google.cloud.tools.jib' version '2.7.0'
}

version '0.1'
Expand Down
2 changes: 1 addition & 1 deletion examples/jib-multimodule/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<properties>
<java.version>1.8</java.version>
<jib.maven-plugin-version>2.6.0</jib.maven-plugin-version>
<jib.maven-plugin-version>2.7.0</jib.maven-plugin-version>
</properties>

<dependencies>
Expand Down
Loading

0 comments on commit d61ca86

Please sign in to comment.