-
Notifications
You must be signed in to change notification settings - Fork 89
CLOUDP-332913: [AtlasCLI] Decouple profile from viper #4050
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
Conversation
internal/validate/validate_test.go
Outdated
@@ -141,6 +141,7 @@ func TestObjectID(t *testing.T) { | |||
} | |||
} | |||
|
|||
/* |
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.
instead of commenting the test you can add t.Skip("Will reenable on ticket CLOUDP-XXX")
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, thanks for the suggestion!
internal/validate/validate_test.go
Outdated
t.Fatalf("NoAPIKeys() expected error\n") | ||
} | ||
}) | ||
/* |
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.
same as above t.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.
Done
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.
LGTM. All my comments are not blocking. Great improvement! 💯
// Configuration needs to be deleted from toml, as viper doesn't support this yet. | ||
// FIXME :: change when https://github.com/spf13/viper/pull/519 is merged. |
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] can we add a cloudp ticket in backlog so we don't forget about this?
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 comment was there since 2018, I didn't want to change the code to make the PR easier to review.
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.
ah wow, I am wondering if it is still valid 😅
// Configuration needs to be deleted from toml, as viper doesn't support this yet. | ||
// FIXME :: change when https://github.com/spf13/viper/pull/519 is merged. |
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.
👀
} | ||
|
||
func (*InMemoryStore) RenameProfile(_, _ string) error { | ||
panic("not implemented") |
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 am wondering what is the benefit here of using panic instead of returning the error as the function signature suggests to do 🤔
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.
InMemoryStore
is not meant to be used, it's just there to keep tests working. The ultimate goal is to get rid of it. So if someone creates a new test they will realize they shouldn't use the method.
if !exists { | ||
if err := s.fs.MkdirAll(s.configDir, defaultPermissions); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return s.viper.WriteConfigAs(s.Filename()) |
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 think is more readable but feel free to ignore
if !exists { | |
if err := s.fs.MkdirAll(s.configDir, defaultPermissions); err != nil { | |
return err | |
} | |
} | |
return s.viper.WriteConfigAs(s.Filename()) | |
if exists { | |
return s.viper.WriteConfigAs(s.Filename()) | |
} | |
return s.fs.MkdirAll(s.configDir, defaultPermissions) |
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.
Will create a ticket to address the actual logic, right now it's just a copy pasted
Co-authored-by: Melanija Cvetic <[email protected]>
e0ba606
to
d0d1323
Compare
Coverage Report 📉
|
Co-authored-by: Melanija Cvetic <[email protected]>
Proposed changes
config.Store
(originally calledConfigStore
, but the linter didn't like it)ViperConfigStore
, I tried to not touch the logic, mainly copy paste where possibleWithProfile
/ProfileFromContext
and attached the profile to the context, so in commands you can get theProfile
from thecontext
instead of using static variables.profile.go
intoprofile.go
/identifiers.go
(code was unrelated to profile)internal/validate/validate_test.go
because they directly invoke viper 👎 , will fix them in a followup PRJira ticket: CLOUDP-332913