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

fix(patch): switch yaml to json pattern #36

Merged
merged 3 commits into from
Feb 25, 2020
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
2 changes: 2 additions & 0 deletions .vela/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# - .cluster: (default: "")
# - .context: (default: "")
# - .namespace: (default: "")
# - .path: (default: "")
# - .dry_run: (default: false)
# - .files: (default: "[]")
# - .containers: (default: "{}")
Expand All @@ -29,6 +30,7 @@ steps:
cluster: {{ default "" .cluster }}
context: {{ default "" .context }}
namespace: {{ default "" .namespace }}
path: {{ default "" .path }}
dry_run: {{ default "false" .dry_run }}
files: {{ default "[]" .files }}
containers: {{ default "{}" .containers }}
Expand Down
17 changes: 9 additions & 8 deletions DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,15 @@ steps:

The following parameters are used to configure the image:

| Name | Description | Required | Default |
| ----------- | ---------------------------------------------------- | -------- | ------- |
| `action` | action to perform against Kubernetes | `true` | `N/A` |
| `cluster` | Kubernetes cluster from the configuration file | `false` | `N/A` |
| `context` | Kubernetes context from the configuration file | `false` | `N/A` |
| `file` | configuration file for communication with Kubernetes | `true` | `N/A` |
| `log_level` | set the log level for the plugin | `true` | `info` |
| `namespace` | Kubernetes namespace from the configuration file | `false` | `N/A` |
| Name | Description | Required | Default |
| ----------- | ---------------------------------------------------- | -------- | ----------------- |
| `action` | action to perform against Kubernetes | `true` | `N/A` |
| `cluster` | Kubernetes cluster from the configuration file | `false` | `N/A` |
| `context` | Kubernetes context from the configuration file | `false` | `N/A` |
| `file` | configuration file for communication with Kubernetes | `true` | `N/A` |
| `log_level` | set the log level for the plugin | `true` | `info` |
| `namespace` | Kubernetes namespace from the configuration file | `false` | `N/A` |
| `path` | path to Kubernetes configuration file | `false` | **set by Vela** |

#### Apply

Expand Down
6 changes: 3 additions & 3 deletions cmd/vela-kubernetes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ func run(c *cli.Context) error {
}

logrus.WithFields(logrus.Fields{
"code": "https://github.com/go-vela/vela-kubernetes",
"docs": "https://go-vela.github.io/docs/plugins/registry/kubernetes",
"time": time.Now(),
"code": "https://github.com/go-vela/vela-kubernetes",
"docs": "https://go-vela.github.io/docs/plugins/registry/kubernetes",
"registry": "https://hub.docker.com/r/target/vela-kubernetes",
}).Info("Vela Kubernetes Plugin")

// create the plugin
Expand Down
28 changes: 20 additions & 8 deletions cmd/vela-kubernetes/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,27 @@ const patchAction = "patch"
// patchPattern represents the pattern needed to
// patch a Kubernetes container with a new image.
//
// spec: (pod)
// containers:
// - name:
// image
// spec: (replica set)
// template:
// spec: (pod)
// containers:
// - name:
// image:
const patchPattern = `
spec:
containers:
- name: %s
image: %s
{
"spec": {
"template": {
"spec": {
"containers": [
{
"name": "%s",
"image": "%s"
}
]
}
}
}
}
`

// Patch represents the plugin configuration for Patch config information.
Expand Down