-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow inline environments to be pruned (#511)
By adding the name field to the prune flags. This just works due to environment loading logic being shared across subcommands. Base NameLabel on both namespace and name. The namespace of inline environments includes the path on disk, and multiple environments with the same given name cannot be loaded from the same path on disk, so the tuple of these 2 fields is guaranteed to be unique within a Tanka project. Use a truncated hash of a combination of these 2 fields to form a label that is guaranteed to fit in Kubernetes' 63 character limit for label values. This fixes a bug in which 2 inline environments with identical metadata.Name, applied separately from 2 paths on disk to the same Kubernetes namespace would create resources with identical `tanka.dev/environment` labels, and so pruning one release would delete the resources of the other. When upgrading to this tanka version, environments with spec.injectLabels=true will show diffs on the `tanka.dev/environment` label, and prune-diffs will run clean, even if prune-able resources were previously visible. After applying the label change, the previously prune-able resources should be prune-able. Add test case for the "don't load multiple envs" assertion. Signed-off-by: Craig Furman <craig.furman89@gmail.com>
- Loading branch information
1 parent
1cfd6f9
commit 4d269e5
Showing
4 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
env1: { | ||
apiVersion: 'tanka.dev/v1alpha1', | ||
kind: 'Environment', | ||
metadata: { | ||
name: 'withenv', | ||
}, | ||
spec: { | ||
apiServer: 'https://localhost', | ||
namespace: 'withenv', | ||
}, | ||
data: { | ||
apiVersion: 'v1', | ||
kind: 'ConfigMap', | ||
metadata: { name: 'config' }, | ||
}, | ||
}, | ||
env2: { | ||
apiVersion: 'tanka.dev/v1alpha1', | ||
kind: 'Environment', | ||
metadata: { | ||
name: 'withenv', | ||
}, | ||
spec: { | ||
apiServer: 'https://localhost', | ||
namespace: 'withenv', | ||
}, | ||
data: { | ||
apiVersion: 'v1', | ||
kind: 'ConfigMap', | ||
metadata: { name: 'config' }, | ||
}, | ||
}, | ||
} |