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

Strip kustomize-style name hash suffix #517

Open
wants to merge 53 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
0e66161
Podman build
criztovyl May 19, 2022
1289a91
Refactor podman script to run tests and other scripts
criztovyl May 19, 2022
7768d60
Add script shortcuts to podman scripts
criztovyl May 20, 2022
5eadc82
Demonstrate nameHashSuffix strip
criztovyl May 29, 2022
3376aff
Podman interactive
criztovyl May 29, 2022
12c3862
Move suffix-strip flag to change set type
criztovyl May 29, 2022
0099750
Add note about SYS_PTRACE
criztovyl May 29, 2022
9b32450
Add test against suffix-stripping unsupported resources
criztovyl May 29, 2022
eed12ec
Add note about disabled check
criztovyl May 29, 2022
5b4255c
Fix ChangeSetWithVersionedRs tests
criztovyl May 29, 2022
a396c46
Add StripNameHashSuffix to config
criztovyl May 29, 2022
795bee4
podman histfile
criztovyl Jun 11, 2022
a728a67
adjust test to match (new) expectations
criztovyl Jun 11, 2022
8d94e34
Move version checks and version updates
criztovyl Jun 11, 2022
44c51d9
Implement ignoring name-hash-suffix in diff
criztovyl Jun 11, 2022
1f8d0bc
Fix striping suffix from unrelated resources
criztovyl Jun 11, 2022
da8749a
podman e2e
criztovyl Jun 11, 2022
f3d8e74
gofmt changes
criztovyl Jun 11, 2022
4815452
golint changes
criztovyl Jun 12, 2022
25e6c49
Add files for e2e
criztovyl Jun 27, 2022
8730f13
more e2e resources
criztovyl Jul 10, 2022
faf26d7
Delete old name-hash-suffixed resources
criztovyl Jul 17, 2022
cd782ec
Mark method private
criztovyl Jul 17, 2022
9391cef
Delete name-hash-suffix CMs based on change
criztovyl Jul 17, 2022
66cc9ea
Add E2E test for name-hash-suffix stripping
criztovyl Aug 16, 2022
9e6a6f1
Kustomize resources README
criztovyl Aug 16, 2022
6b435dc
Fix persisting podman interactive history
criztovyl Aug 29, 2022
8e1c533
Add copyright header
criztovyl Aug 29, 2022
a8fd0eb
Test only operation and diff count
criztovyl Aug 29, 2022
9807418
Make name-hash-suffix-strip resource check configurable
criztovyl Aug 29, 2022
72253b1
Lint fixes
criztovyl Aug 29, 2022
0a9194e
Merge remote-tracking branch 'upstream/develop' into criztovyl/strip-…
criztovyl Aug 29, 2022
dfd2ccb
Fixes after module rename
criztovyl Aug 29, 2022
3081bd5
Fix test resources after config changed
criztovyl Sep 4, 2022
d837a40
Allow to call gen.sh from any directory
criztovyl Sep 4, 2022
9cb989a
Fix comparing diff test
criztovyl Sep 4, 2022
be2c3f2
gofmt
criztovyl Sep 4, 2022
c8b1e26
Drop old suffix strip implementation
criztovyl Sep 11, 2022
cb5da9e
Skip testing unimplemented functionality for now
criztovyl Sep 11, 2022
2bf6a39
instantiate VersionedResource as such
criztovyl Sep 11, 2022
f485fcb
Turn VersionedResource into an interface
criztovyl Sep 11, 2022
5c555a0
Reimplement suffix strip
criztovyl Sep 11, 2022
121cb03
Reimplement deleting old has-suffixed resources
criztovyl Sep 11, 2022
e22da5b
Make dedicated method for converting []VersionedResource
criztovyl Sep 11, 2022
f5333ab
Remove naked return
criztovyl Sep 22, 2022
e5cfb41
Keep logic within one method
criztovyl Sep 22, 2022
be8bf30
Remove disabled assert
criztovyl Sep 27, 2022
ba249a7
enabling suffix strip by matcher presence
criztovyl Sep 29, 2022
4f51583
Drop suffix-strip enable flag
criztovyl Sep 29, 2022
aaca097
Fix test
criztovyl Sep 29, 2022
76991f6
replace left-over naked return
criztovyl Oct 16, 2022
8f7848a
Streamline suffix strip config
criztovyl Oct 16, 2022
40fa319
Convert to tests to table tests
criztovyl Oct 16, 2022
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 hack/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.bash_history
.dlv
5 changes: 5 additions & 0 deletions hack/build-podman.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

cd $(dirname ${BASH_SOURCE[0]})

./podman.sh build
32 changes: 32 additions & 0 deletions hack/podman.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

cd $(dirname ${BASH_SOURCE[0]})

action=$1

if [ "$action" ]; then
[ -x "$action.sh" ] && action=hack/$action.sh
else
histfile=.bash_history
[ -f $histfile ] || >$histfile

interactive="-it -v $PWD/$histfile:/root/$histfile"

dlv_conf=.dlv
[ -d $dlv_conf ] || mkdir $dlv_conf

interactive="$interactive -v $PWD/$dlv_conf:/root/.config/dlv"
fi

# SYS_PTRACE for dlv
# host network for minikube
podman run --rm \
-v gopath:/go \
-v gobuild:/root/.cache/go-build \
-v $HOME/.kube:/root/.kube \
-v $HOME/.minikube:$HOME/.minikube \
-v $(realpath $PWD/..):/mnt -w /mnt \
$interactive \
--cap-add SYS_PTRACE \
--network host \
docker.io/golang $action
5 changes: 5 additions & 0 deletions hack/test-podman.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

cd $(dirname ${BASH_SOURCE[0]})

./podman.sh test
2 changes: 1 addition & 1 deletion pkg/kapp/cmd/app/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ func (o *DeployOptions) calculateAndPresentChanges(existingResources,

changes, err := ctldiff.NewChangeSetWithVersionedRs(
existingResources, newResources, conf.TemplateRules(),
o.DiffFlags.ChangeSetOpts, changeFactory).Calculate()
o.DiffFlags.ChangeSetOpts, changeFactory, conf.StripNameHashSuffixConfigs()).Calculate()
if err != nil {
return clusterChangeSet, nil, false, "", err
}
Expand Down
18 changes: 18 additions & 0 deletions pkg/kapp/config/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,21 @@ func (c Conf) ChangeRuleBindings() []ChangeRuleBinding {
}
return result
}

type StripNameHashSuffixConfigs []StripNameHashSuffixConfig

func (c StripNameHashSuffixConfigs) AggregateToCtlRes() [][]ctlres.ResourceMatcher {
criztovyl marked this conversation as resolved.
Show resolved Hide resolved
var resourceMatchers [][]ctlres.ResourceMatcher
for _, conf := range c {
resourceMatchers = append(resourceMatchers, ResourceMatchers(conf.ResourceMatchers).AsResourceMatchers())
}
return resourceMatchers
}

func (c Conf) StripNameHashSuffixConfigs() StripNameHashSuffixConfigs {
criztovyl marked this conversation as resolved.
Show resolved Hide resolved
var configs []StripNameHashSuffixConfig
for _, config := range c.configs {
configs = append(configs, config.StripNameHashSuffixConfig)
}
return StripNameHashSuffixConfigs(configs)
}
6 changes: 6 additions & 0 deletions pkg/kapp/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ type Config struct {
// TODO validations
ChangeGroupBindings []ChangeGroupBinding
ChangeRuleBindings []ChangeRuleBinding

StripNameHashSuffixConfig StripNameHashSuffixConfig
criztovyl marked this conversation as resolved.
Show resolved Hide resolved
}

type WaitRule struct {
Expand Down Expand Up @@ -139,6 +141,10 @@ type ChangeRuleBinding struct {
ResourceMatchers []ResourceMatcher
}

type StripNameHashSuffixConfig struct {
ResourceMatchers []ResourceMatcher
}

func NewConfigFromResource(res ctlres.Resource) (Config, error) {
if res.APIVersion() != configAPIVersion {
return Config{}, fmt.Errorf(
Expand Down
2 changes: 2 additions & 0 deletions pkg/kapp/config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,8 @@ changeRuleBindings:
- anyMatcher: {matchers: *rbacMatchers}
- anyMatcher: {matchers: *podRelatedMatchers}
- hasNamespaceMatcher: {}

StripNameHashSuffix: {}
criztovyl marked this conversation as resolved.
Show resolved Hide resolved
`

var defaultConfigRes = ctlres.MustNewResourceFromBytes([]byte(defaultConfigYAML))
Expand Down
Loading