Skip to content

Commit

Permalink
[v2] enable skafffold delete in kpt v2 deployer
Browse files Browse the repository at this point in the history
Also update v2beta20.
  • Loading branch information
yuwenma committed Aug 10, 2021
1 parent 8544d9a commit af9f858
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 5 deletions.
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/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

0 comments on commit af9f858

Please sign in to comment.