-
Notifications
You must be signed in to change notification settings - Fork 97
feat(manifest): loader.Load(...)
includes unselected environments as skipped with Skip: true
#1876
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
base: main
Are you sure you want to change the base?
Conversation
3af64be
to
a7dc9ee
Compare
28bf0d7
to
a8add41
Compare
a8add41
to
788ac03
Compare
manifest.Load(...)
includes unselected environments as not enabled environments with Enabled: false
loader.Load(...)
includes unselected environments as not enabled environments with Enabled: false
788ac03
to
469fd7b
Compare
I'm pretty satisfied that E2E tests are working with this change, although I've been unable to get them all green in one run here. |
8018745
to
98d9536
Compare
At the moment, we have a small behavior change here Here is also a behavior change, right?
Previously, it was marked as an undefined environment Not sure about this though
Anyway, it would be nice if @Laubi or @tomazpu could also have a look, as this touches a lot of places :) |
if shouldSkipEnv(context, group, env) { | ||
log.WithFields(field.F("manifestPath", context.ManifestPath)).Debug("skipping loading of environment %q", env.Name) | ||
environments[env.Name] = manifest.EnvironmentDefinition{Enabled: false, Name: env.Name, Group: group.Name} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit]: When looking at this, Skip
would fit a bit better. We're using Skip
for configs, and the condition and logs for excluding this environment are also "skip".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So Skip: true
would mean "don't use this environment"? I like that idea 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
98d9536
to
26ef6c4
Compare
@Kirdock, you're correct: we need to clarify what the expected behavior is. The code: dynatrace-configuration-as-code/cmd/monaco/deploy/deploy.go Lines 157 to 161 in 485b408
doesn't really work as configs are only created for environments in the loaded manifest, which means no configs will violate this. There is even a test for this: dynatrace-configuration-as-code/cmd/monaco/deploy/deploy_test.go Lines 166 to 181 in 485b408
|
In response to |
…s not enabled environments with `Enabled: false` In order to be able to check environment and group overrides in `project.LoadProject(...)` they need not to be removed in `loader.Load(...)`. Instead, this function marks them as not enabled, with `Enabled: false`.
…d rather than enabled
…t no configs are loaded for environments with `Skip: true`
8505894
to
b19958e
Compare
|
loader.Load(...)
includes unselected environments as not enabled environments with Enabled: false
loader.Load(...)
includes unselected environments as skipped with Skip: true
@@ -38,6 +38,9 @@ import ( | |||
func Delete(ctx context.Context, environments manifest.Environments, entriesToDelete delete.DeleteEntries) error { | |||
var envsWithDeleteErrs []string | |||
for _, env := range environments { | |||
if env.Skip { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now have a lot of these env.Skip
checks (7), and I am thinking if it would be possible to not even pass them into the consuming functions, aka filter them beforehand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering the same. Would it be possible to add to the Manifest
struct something like a getter method where only active Environments are returned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a fair point - let's do this!
I just tried with an iterator, but it doesn't really solve the problem: defining it on the Manifest
would require changing many function signatures (including this one), definition it on manifest.Environments
doesn't improve the problem, as you could still forget to use it. So I think I'll go for an actual getter on the Manifest
that does the filtering when called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't like how this looked, so have tried something different: #1897
Based on feedback, I've gone ahead and tried this in a different way: #1897 |
Why this PR?
In order to be able to check environment and group overrides in
project.LoadProjects(...)
, something that will be done in a follow up PR, the loaded manifest needs to contain at least the names of all environment and groups, and not just those selected to be deployed or deleted.What has changed?
An additional field,
Skip
is added tomanifest.EnvironmentDefinition
:Skip
set tofalse
, the environment should be used as previously; it is not skipped and therefore is selected for deployment or deletion.Skip
set totrue
, the environment is loaded within its group, but is not selected for deployment or deletion. Such an environment won't have its URL or credentials resolved.How does it do it?
loader.Load(...)
now loads all environments defined in the manifest, setting theSkip
field appropriately.dynatrace.VerifyEnvironmentGeneration(...)
,dynatrace.CreateEnvironmentClients(...)
,project.toEnvironmentSlice(...)
to make them skip non-Enabled environments.How is it tested?
Skip: true
for environments that should be skipped.TestLoadConfigFile_ConfigsGeneratedForNonSkippedEnvironments
andTestLoadConfigFile_NoConfigsGeneratedForSkippedEnvironments
How does it affect users?
It has no effect on users.