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

test commit #2

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# 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.

GOOS ?= $(shell go env GOOS)
GOARCH = amd64
BUILD_DIR ?= ./out
Expand Down
12 changes: 11 additions & 1 deletion docs/content/en/schemas/v1beta15.json
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,15 @@
},
"KustomizeDeploy": {
"properties": {
"buildArgs": {
"items": {
"type": "string"
},
"type": "array",
"description": "additional args passed to `kustomize build`.",
"x-intellij-html-description": "additional args passed to <code>kustomize build</code>.",
"default": "[]"
},
"flags": {
"$ref": "#/definitions/KubectlFlags",
"description": "additional flags passed to `kubectl`.",
Expand All @@ -1431,7 +1440,8 @@
},
"preferredOrder": [
"path",
"flags"
"flags",
"buildArgs"
],
"additionalProperties": false,
"description": "*beta* uses the `kustomize` CLI to \"patch\" a deployment for a target environment.",
Expand Down
14 changes: 14 additions & 0 deletions integration/examples/kustomize/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,17 @@ include::deployment.yaml[]
----

endif::[]

=== Example: passing arguments to kustomize
:icons: font

This is an example demonstrating how additional arguments can be passed to the `kustomize build` command.

ifndef::env-github[]

[source,yaml, indent=3, title=skaffold-kustomize-args.yaml]
----
include::skaffold-kustomize-args.yaml[]
----

endif::[]
6 changes: 6 additions & 0 deletions integration/examples/kustomize/skaffold-kustomize-args.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: skaffold/v1beta14
kind: Config
deploy:
kustomize:
buildArgs:
- "--load_restrictor none"
1 change: 1 addition & 0 deletions pkg/skaffold/deploy/kustomize.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func NewKustomizeDeployer(runCtx *runcontext.RunContext) *KustomizeDeployer {
},
defaultRepo: runCtx.DefaultRepo,
insecureRegistries: runCtx.InsecureRegistries,
BuildArgs: runCtx.Cfg.Deploy.KustomizeDeploy.BuildArgs,
}
}

Expand Down
6 changes: 0 additions & 6 deletions pkg/skaffold/deploy/resource/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,3 @@ func NewDeployment(name string, ns string, deadline time.Duration) *Deployment {
status: newStatus("", nil),
}
}

// For testing
func (d *Deployment) WithStatus(details string, err error) *Deployment {
d.UpdateStatus(details, err)
return d
}
4 changes: 2 additions & 2 deletions pkg/skaffold/deploy/status_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func StatusCheck(ctx context.Context, defaultLabeller *DefaultLabeller, runCtx *
defer wg.Done()
pollDeploymentRolloutStatus(ctx, kubectl.NewFromRunContext(runCtx), d)
pending := c.markProcessed()
printStatusCheckSummary(d, pending, c.total, out)
printStatusCheckSummary(out, d, pending, c.total)
}(d)
}

Expand Down Expand Up @@ -166,7 +166,7 @@ func getDeadline(d int) time.Duration {
return defaultStatusCheckDeadline
}

func printStatusCheckSummary(d *resource.Deployment, pending int, total int, out io.Writer) {
func printStatusCheckSummary(out io.Writer, d *resource.Deployment, pending int, total int) {
status := fmt.Sprintf("%s %s", tabHeader, d)
if err := d.Status().Error(); err != nil {
status = fmt.Sprintf("%s failed.%s Error: %s.",
Expand Down
72 changes: 52 additions & 20 deletions pkg/skaffold/deploy/status_check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,32 +258,52 @@ func TestGetDeployStatus(t *testing.T) {
{
description: "one error",
deps: []*resource.Deployment{
resource.NewDeployment("dep1", "test", time.Second).
WithStatus("success", nil),
resource.NewDeployment("dep2", "test", time.Second).
WithStatus("error", errors.New("could not return within default timeout")),
withStatus(
resource.NewDeployment("dep1", "test", time.Second),
"success",
nil,
),
withStatus(
resource.NewDeployment("dep2", "test", time.Second),
"error",
errors.New("could not return within default timeout"),
),
},
expectedErrMsg: []string{"dep2 failed due to could not return within default timeout"},
shouldErr: true,
},
{
description: "no error",
deps: []*resource.Deployment{
resource.NewDeployment("dep1", "test", time.Second).
WithStatus("success", nil),
resource.NewDeployment("dep2", "test", time.Second).
WithStatus("running", nil),
withStatus(
resource.NewDeployment("dep1", "test", time.Second),
"success",
nil,
),
withStatus(resource.NewDeployment("dep2", "test", time.Second),
"running",
nil,
),
},
},
{
description: "multiple errors",
deps: []*resource.Deployment{
resource.NewDeployment("dep1", "test", time.Second).
WithStatus("success", nil),
resource.NewDeployment("dep2", "test", time.Second).
WithStatus("error", errors.New("could not return within default timeout")),
resource.NewDeployment("dep3", "test", time.Second).
WithStatus("error", errors.New("ERROR")),
withStatus(
resource.NewDeployment("dep1", "test", time.Second),
"success",
nil,
),
withStatus(
resource.NewDeployment("dep2", "test", time.Second),
"error",
errors.New("could not return within default timeout"),
),
withStatus(
resource.NewDeployment("dep3", "test", time.Second),
"error",
errors.New("ERROR"),
),
},
expectedErrMsg: []string{"dep2 failed due to could not return within default timeout",
"dep3 failed due to ERROR"},
Expand Down Expand Up @@ -385,10 +405,11 @@ func TestPrintSummaryStatus(t *testing.T) {
testutil.Run(t, test.description, func(t *testutil.T) {
out := new(bytes.Buffer)
printStatusCheckSummary(
resource.NewDeployment("dep", "test", 0).WithStatus("", test.err),
out,
withStatus(resource.NewDeployment("dep", "test", 0), "", test.err),
int(test.pending),
10,
out)
)
t.CheckDeepEqual(test.expected, out.String())
})
}
Expand Down Expand Up @@ -431,8 +452,11 @@ func TestPrintStatus(t *testing.T) {
"succes",
nil,
),
resource.NewDeployment("r2", "test", 1).
WithStatus("pending", nil),
withStatus(
resource.NewDeployment("r2", "test", 1),
"pending",
nil,
),
},
expectedOut: " - test:deployment/r2 pending\n",
},
Expand All @@ -444,8 +468,11 @@ func TestPrintStatus(t *testing.T) {
"succes",
nil,
),
resource.NewDeployment("r2", "test", 1).
WithStatus("", fmt.Errorf("context deadline expired")),
withStatus(
resource.NewDeployment("r2", "test", 1),
"",
fmt.Errorf("context deadline expired"),
),
},
expectedOut: " - test:deployment/r2 context deadline expired\n",
},
Expand All @@ -466,3 +493,8 @@ func withDone(d *resource.Deployment, details string, err error) *resource.Deplo
d.MarkDone()
return d
}

func withStatus(d *resource.Deployment, details string, err error) *resource.Deployment {
d.UpdateStatus(details, err)
return d
}
3 changes: 3 additions & 0 deletions pkg/skaffold/schema/latest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,9 @@ type KustomizeDeploy struct {

// Flags are additional flags passed to `kubectl`.
Flags KubectlFlags `yaml:"flags,omitempty"`

// BuildArgs are additional args passed to `kustomize build`.
BuildArgs []string `yaml:"buildArgs,omitempty"`
}

// HelmRelease describes a helm release to be deployed.
Expand Down
1 change: 1 addition & 0 deletions pkg/skaffold/schema/v1beta14/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
// Upgrade upgrades a configuration to the next version.
// Config changes from v1beta14 to v1beta15
// 1. Additions:
// buildArgs for Kustomize deployer
// 2. Removals:
// 3. No updates
func (config *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
Expand Down