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

Update settings api to use ResourceContext over ModificationInfo #1633

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

tomazpu
Copy link
Contributor

@tomazpu tomazpu commented Nov 21, 2024

What this PR does / Why we need it:

Update settings API to use ResourceContext over ModificationInfo, ModificationInfo is deprecated by the API and only used as a fallback

Special notes for your reviewer:

Does this PR introduce a user-facing change?

@tomazpu tomazpu requested a review from a team as a code owner November 21, 2024 10:06
@tomazpu tomazpu self-assigned this Nov 21, 2024
Copy link

sonarcloud bot commented Nov 21, 2024

Copy link

Unit Test Results

1 894 tests  +3   1 893 ✅ +3   54s ⏱️ ±0s
  133 suites ±0       1 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 7442a1e. ± Comparison against base commit 21c774b.

@tomazpu tomazpu added the run-e2e-test Manually trigger the E2E tests for reviewed PRs label Nov 21, 2024
@@ -60,6 +117,13 @@ type SettingsModificationInfo struct {
NonModifiablePaths []interface{} `json:"nonModifiablePaths"`
}

type SettingsResourceContext struct {
Operations []string `json:"operations"`
Movable *bool `json:"modifications:movable"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To the reviewer. I chose a pointer over its own struct type, the problem here is that the param Movable is optional, and logic code in method isMovable() depends on it.

If preferred, I could change it to a NullBool type and implement the unmarshaling myself. Since is not done anywhere else in the code i chose *bool over NullBool.

Copy link
Contributor

Choose a reason for hiding this comment

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

By now, I wasn't aware of the NullBool type in GO. But as I see it, it is part of the SQL library and for that reason wouldn't it even consider. For me pointer is just enough

Copy link

E2E Test Results

    4 files   -   1    268 suites   - 133   21m 55s ⏱️ - 52m 36s
2 012 tests +  1  2 010 ✅ +  1  2 💤 ±0  0 ❌ ±0 
2 127 runs   - 114  2 125 ✅  - 114  2 💤 ±0  0 ❌ ±0 

Results for commit 7442a1e. ± Comparison against base commit 21c774b.

This pull request removes 2 and adds 3 tests. Note that renamed tests count towards both.
github.com/dynatrace/dynatrace-configuration-as-code/v2/cmd/monaco/integrationtest/v2 ‑ TestPaginationClassic
github.com/dynatrace/dynatrace-configuration-as-code/v2/cmd/monaco/integrationtest/v2 ‑ TestPaginationPlatform
github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/client/dtclient ‑ TestResourceContextWorksAsModificationInfo
github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/client/dtclient ‑ TestResourceContextWorksAsModificationInfo/deletable,_modifiable,_movable_item_-_no_movable_param_provided_in_resource_context
github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/client/dtclient ‑ TestResourceContextWorksAsModificationInfo/only_read_item

logger.Info("Deleting %d objects of type %q...", len(settingsObjects), s)
for _, settingsObject := range settingsObjects {
if !settingsObject.IsDeletable() {
//@Reviewer should here also be a log as it is in the Delete() method
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency, it can be added. But if you doesn't see the purpose, I wouldn't

// skip discarded settings objects
if shouldDiscard, reason := filters.Get(o.SchemaId).ShouldDiscard(contentUnmarshalled); shouldFilterSettings() && shouldDiscard {
log.WithFields(field.Type(o.SchemaId), field.F("object", o)).Debug("Discarded setting object %q (%s). Reason: %s", o.ObjectId, o.SchemaId, reason)
// skip discarded settings settingsObjects
Copy link
Contributor

Choose a reason for hiding this comment

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

to much of renaming :)

WriteOperation = "write"
//ReadOperation = "read"
)

// DownloadSettingsObject is the response type for the ListSettings operation
type DownloadSettingsObject struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not move to a separate file

@@ -60,6 +117,13 @@ type SettingsModificationInfo struct {
NonModifiablePaths []interface{} `json:"nonModifiablePaths"`
}

type SettingsResourceContext struct {
Operations []string `json:"operations"`
Movable *bool `json:"modifications:movable"`
Copy link
Contributor

Choose a reason for hiding this comment

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

By now, I wasn't aware of the NullBool type in GO. But as I see it, it is part of the SQL library and for that reason wouldn't it even consider. For me pointer is just enough

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-e2e-test Manually trigger the E2E tests for reviewed PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants