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

[v2] enable skaffold delete in kpt v2 deployer & backport ContainerHook #6388

Merged
merged 1 commit into from
Aug 10, 2021
Merged
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
23 changes: 23 additions & 0 deletions docs/content/en/schemas/v2beta19.json
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,29 @@
"description": "describes a dependency on another skaffold configuration.",
"x-intellij-html-description": "describes a dependency on another skaffold configuration."
},
"ContainerHook": {
"required": [
"command"
],
"properties": {
"command": {
"items": {
"type": "string"
},
"type": "array",
"description": "command to execute.",
"x-intellij-html-description": "command to execute.",
"default": "[]"
}
},
"preferredOrder": [
"command"
],
"additionalProperties": false,
"type": "object",
"description": "describes a lifecycle hook definition to execute on a container. The container name is inferred from the scope in which this hook is defined.",
"x-intellij-html-description": "describes a lifecycle hook definition to execute on a container. The container name is inferred from the scope in which this hook is defined."
},
"CustomArtifact": {
"properties": {
"buildCommand": {
Expand Down
23 changes: 23 additions & 0 deletions docs/content/en/schemas/v2beta20.json
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,29 @@
"description": "describes a dependency on another skaffold configuration.",
"x-intellij-html-description": "describes a dependency on another skaffold configuration."
},
"ContainerHook": {
"required": [
"command"
],
"properties": {
"command": {
"items": {
"type": "string"
},
"type": "array",
"description": "command to execute.",
"x-intellij-html-description": "command to execute.",
"default": "[]"
}
},
"preferredOrder": [
"command"
],
"additionalProperties": false,
"type": "object",
"description": "describes a lifecycle hook definition to execute on a container. The container name is inferred from the scope in which this hook is defined.",
"x-intellij-html-description": "describes a lifecycle hook definition to execute on a container. The container name is inferred from the scope in which this hook is defined."
},
"CustomArtifact": {
"properties": {
"buildCommand": {
Expand Down
31 changes: 30 additions & 1 deletion docs/content/en/schemas/v2beta21.json
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,29 @@
"description": "describes a dependency on another skaffold configuration.",
"x-intellij-html-description": "describes a dependency on another skaffold configuration."
},
"ContainerHook": {
"required": [
"command"
],
"properties": {
"command": {
"items": {
"type": "string"
},
"type": "array",
"description": "command to execute.",
"x-intellij-html-description": "command to execute.",
"default": "[]"
}
},
"preferredOrder": [
"command"
],
"additionalProperties": false,
"type": "object",
"description": "describes a lifecycle hook definition to execute on a container. The container name is inferred from the scope in which this hook is defined.",
"x-intellij-html-description": "describes a lifecycle hook definition to execute on a container. The container name is inferred from the scope in which this hook is defined."
},
"CustomArtifact": {
"properties": {
"buildCommand": {
Expand Down Expand Up @@ -2537,6 +2560,11 @@
"description": "additional flags passed to `kubectl`.",
"x-intellij-html-description": "additional flags passed to <code>kubectl</code>."
},
"hooks": {
"$ref": "#/definitions/DeployHooks",
"description": "describes a set of lifecycle hooks that are executed before and after every deploy.",
"x-intellij-html-description": "describes a set of lifecycle hooks that are executed before and after every deploy."
},
"manifests": {
"items": {
"type": "string"
Expand All @@ -2560,7 +2588,8 @@
"manifests",
"remoteManifests",
"flags",
"defaultNamespace"
"defaultNamespace",
"hooks"
],
"additionalProperties": false,
"type": "object",
Expand Down
4 changes: 3 additions & 1 deletion pkg/skaffold/deploy/v2/kpt/kpt.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@ func (k *Deployer) Cleanup(ctx context.Context, out io.Writer) error {
instrumentation.AddAttributesToCurrentSpanFromContext(ctx, map[string]string{
"DeployerType": deployerName,
})

if err := kptInitFunc(ctx, out, k); err != nil {
return err
}
cmd := exec.CommandContext(ctx, "kpt", k.kptArgs("live", "destroy", k.applyDir)...)
cmd.Stdout = out
cmd.Stderr = out
Expand Down
4 changes: 2 additions & 2 deletions pkg/skaffold/schema/latest/v1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ type KubectlDeploy struct {
DefaultNamespace *string `yaml:"defaultNamespace,omitempty"`

// LifecycleHooks describes a set of lifecycle hooks that are executed before and after every deploy.
LifecycleHooks DeployHooks `yaml:"-"`
LifecycleHooks DeployHooks `yaml:"hooks,omitempty"`
}

// KubectlFlags are additional flags passed on the command
Expand Down Expand Up @@ -1397,7 +1397,7 @@ type ContainerHook struct {
// NamedContainerHook describes a lifecycle hook definition to execute on a named container.
type NamedContainerHook struct {
// ContainerHook describes a lifecycle hook definition to execute on a container.
ContainerHook `yaml:",inline"`
ContainerHook `yaml:",inline" yamlTags:"skipTrim"`
// PodName is the name of the pod to execute the command in.
PodName string `yaml:"podName" yamltags:"required"`
// ContainerName is the name of the container to execute the command in.
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/schema/v2beta19/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,7 @@ type ContainerHook struct {
// NamedContainerHook describes a lifecycle hook definition to execute on a named container.
type NamedContainerHook struct {
// ContainerHook describes a lifecycle hook definition to execute on a container.
ContainerHook `yaml:",inline"`
ContainerHook `yaml:",inline" yamltags:"skipTrim"`
// PodName is the name of the pod to execute the command in.
PodName string `yaml:"podName" yamltags:"required"`
// ContainerName is the name of the container to execute the command in.
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/schema/v2beta20/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1397,7 +1397,7 @@ type ContainerHook struct {
// NamedContainerHook describes a lifecycle hook definition to execute on a named container.
type NamedContainerHook struct {
// ContainerHook describes a lifecycle hook definition to execute on a container.
ContainerHook `yaml:",inline"`
ContainerHook `yaml:",inline" yamltags:"skipTrim"`
// PodName is the name of the pod to execute the command in.
PodName string `yaml:"podName" yamltags:"required"`
// ContainerName is the name of the container to execute the command in.
Expand Down