Skip to content

Commit

Permalink
Skip Secrets, add some text to README.md about diff
Browse files Browse the repository at this point in the history
  • Loading branch information
vadim.reyder authored and rvadim committed Dec 16, 2020
1 parent 4232335 commit b930105
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ k8s-handle is a helm alternative, but without package manager
* [Sync mode](#sync-mode)
* [Strict mode](#strict-mode)
* [Destroy](#destroy)
* [Diff](#diff)
* [Operating without config.yaml](#operating-without-configyaml)
* [Render](#render)
* [Apply](#apply)
Expand Down Expand Up @@ -535,7 +536,7 @@ You can specify number of tries before k8s-handle exit with non zero exit code a
In some cases k8s-handle warn you about ambiguous situations and keep working. With `--strict` mode k8s-handle warn and exit
with non zero code. For example when some used environment variables is empty.
```bash
$ k8s-handle-os deploy -s staging --use-kubeconfig --strict
$ k8s-handle deploy -s staging --use-kubeconfig --strict
ERROR:__main__:RuntimeError: Environment variable "IMAGE_VERSION" is not set
$ echo $?
1
Expand All @@ -546,6 +547,13 @@ support `destroy` subcommand for you. Just use `destroy` instead of `deploy`. k8
call delete kubernetes api calls instead of create or replace.
> Sync mode is available for destroy as well.
### Diff
You can get diff between objects in Kubernetes API and local working copy of configuration.
```bash
$ k8s-handle diff -s <section> --use-kubeconfig
```
> Secrets are ignored by security reasons
## Operating without config.yaml
The most common way for the most of use cases is to operate with k8s-handle via `config.yaml`, specifying
connection parameters, targets (sections and tags) and variables in one file. The deploy command that runs after that,
Expand Down
3 changes: 3 additions & 0 deletions k8s_handle/k8s/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class Diff:
@staticmethod
def run(file_path):
for template_body in get_template_contexts(file_path):
if template_body.get('kind') == 'Secret':
log.info(f'Skipping secret {template_body.get("metadata", {}).get("name")}')
continue
kube_client = Adapter.get_instance(template_body)
new = yaml.safe_dump(template_body)
k8s_object = kube_client.get()
Expand Down

0 comments on commit b930105

Please sign in to comment.