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

Chore: filter out more redundant scopes from ConfigurationVariablesBy… #753

Merged
merged 5 commits into from
Dec 4, 2023

Conversation

TomerHeber
Copy link
Collaborator

…Scope

Issue & Steps to Reproduce / Feature Request

closes #751

Solution

  1. Updated the filter.
  2. Updated the unit tests.

Comment on lines 114 to 118
var filteredVariables []ConfigurationVariable
for _, variable := range result {
if scope == variable.Scope {
filteredVariables = append(filteredVariables, variable)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

that's not good enough 😅
as per the explanation in the issue #751

There'd be several variables from the same scope "type" from a different specific scope.
you'd get more variables from the API in the PROJECT scope, but which are NOT defined on the requested projectId.

Does that make sense?

Copy link
Contributor

Choose a reason for hiding this comment

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

Each variable has a scope and a scopeId.
The scope can be ENVIRONMENT, PROJECT, etc.
The scopeIds are uuids fir the specific environment, project, etc. respectfully.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

so.. should I filter instead based on scope ID? (instead of scope).

Copy link
Contributor

@Wassap124 Wassap124 Nov 22, 2023

Choose a reason for hiding this comment

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

Exactly

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated.

@Wassap124 Wassap124 self-requested a review November 22, 2023 08:05
@github-actions github-actions bot added ready to merge PR approved - can be merged once the PR owner is ready and removed pending final review labels Nov 22, 2023
Copy link
Contributor

@Wassap124 Wassap124 left a comment

Choose a reason for hiding this comment

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

Approved by mistake 🤦

@env0 env0 deleted a comment from weinguy-env0 Nov 22, 2023
@TomerHeber TomerHeber added pending final review reviewed - awaiting author and removed ready to merge PR approved - can be merged once the PR owner is ready pending final review labels Nov 22, 2023
// The API returns variables of upper scopes. Filter them out.
var filteredVariables []ConfigurationVariable
for _, variable := range result {
if scopeId == variable.ScopeId {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would also add scope == variable.Scope here for safety

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Wassap124 - do you concur?

Copy link
Contributor

@Wassap124 Wassap124 Nov 29, 2023

Choose a reason for hiding this comment

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

it's conceptually redundant but it won't harm + add explicitness to the code, so im not against it.
Also that way it'd be the exact same validation / predicate that's being made on env0 code post change so it'd be aligned with it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done!

@Wassap124
Copy link
Contributor

btw @TomerHeber we hadn't forgotten about this PR, we've started QAing this

Copy link
Contributor

@ronnyorot ronnyorot left a comment

Choose a reason for hiding this comment

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

I QAed it and it looks good 🙃

@github-actions github-actions bot added ready to merge PR approved - can be merged once the PR owner is ready and removed pending final review labels Dec 4, 2023
Copy link
Contributor

@Wassap124 Wassap124 left a comment

Choose a reason for hiding this comment

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

Great work 🫶🏻

@TomerHeber TomerHeber merged commit 5a55606 into main Dec 4, 2023
6 checks passed
@TomerHeber TomerHeber deleted the chore-filter-out-scopes-#751 branch December 4, 2023 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-client chore ready to merge PR approved - can be merged once the PR owner is ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Filter out more redundant scopes from ConfigurationVariablesByScope
4 participants