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

Make NSTemplateTier generator generic #381

Conversation

MatousJobanek
Copy link
Contributor

@MatousJobanek MatousJobanek commented Apr 3, 2024

This PR moves the logic of nstemplatetier_generator.go from host-operator to toolchain-common and make it generic so it can be used by a ksctl command for generating NSTemplateTier & TierTemplate manifests locally in a GitOps repository.
There is almost no change in the logic of the generator, it should work in the same way as it was before, just with the difference that it doesn't load templates from the assets, but takes them from the map passed as a parameter.

KUBESAW-59

related PR in host-operator repo codeready-toolchain/host-operator#1006

Comment on lines +35 to +36
//go:embed testdata/nstemplatetiers*
var testTemplateFiles embed.FS
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

codecov bot commented Apr 3, 2024

Codecov Report

Merging #381 (4dcad48) into master (fd379c9) will increase coverage by 1.91%.
The diff coverage is 92.41%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #381      +/-   ##
==========================================
+ Coverage   75.75%   77.66%   +1.91%     
==========================================
  Files          45       46       +1     
  Lines        1728     1952     +224     
==========================================
+ Hits         1309     1516     +207     
- Misses        367      376       +9     
- Partials       52       60       +8     
Files Coverage Δ
...mplate/nstemplatetiers/nstemplatetier_generator.go 92.41% <92.41%> (ø)

Copy link
Contributor

@mfrancisc mfrancisc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice Job 👍

I like that we switched to embed.FS and the new ensureObject function.

for _, tierTmpl := range tierTmpls.tierTemplates {
log.Info("creating TierTemplate", "namespace", tierTmpl.Namespace, "name", tierTmpl.Name)
// using the "standard" client since we don't need to support updates on such resources, they should be immutable
if _, err := t.ensureObject(tierTmpl, false); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the second parameter wasn't immediately clear to me, but I like the new ensureObject function.

Copy link

sonarcloud bot commented Apr 12, 2024

Quality Gate Passed Quality Gate passed

Issues
9 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
5.3% Duplication on New Code

See analysis details on SonarCloud

@MatousJobanek MatousJobanek merged commit 32311a6 into codeready-toolchain:master Apr 17, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants