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

FSOC - Table for config and patch flag implemented #146

Closed
wants to merge 11 commits into from

Conversation

GDW1
Copy link
Contributor

@GDW1 GDW1 commented Jul 10, 2023

Description

When executing a config set, it will check if the current authentication type allows writing to this field (can be overriden), additionally when changing the authentication type, it will clear all fields.

Type of Change

  • Bug Fix
  • New Feature
  • Breaking Change
  • Refactor
  • Documentation
  • Other (please describe)

Checklist

  • I have read the contributing guidelines
  • Existing issues have been referenced (where applicable)
  • I have verified this change is not present in other open pull requests
  • Functionality is documented
  • All code style checks pass
  • New code contribution is covered by automated tests
  • All new and existing tests pass

GDW1 and others added 10 commits June 29, 2023 16:03
* melt model support for isolation.

* fixing make pre-commit issue
- Enhance logging of profiler report processing
Attempt to fix FSOC-100, oauth login may show "request failed" in browser (even though the login was successful) instead of "login completed successfully". 

Co-authored-by: GDW1 <guwilks@cisco.com>
* Unhide --subscribe flag
 * Fix issue when --subscribe is used with --wait
 * Do not allow --subscribe with --solution-bundle
 * Remove double print of messages upon subscribe
 * Make subscription retries more resiliant (up to 4 retries with backoff)

Co-authored-by: Pavel Georgiev <p3l@appdynamics.com>
…heading level if the --h1 flag used (cisco-open#143)

* Filter and Print options for queries. example shown with fsoc solution list

* fix so that generating gendocs starts on the first level of heading

* hid gendocs header functionality behind header

---------

Co-authored-by: GDW1 <guwilks@cisco.com>
* FSOC-37 Added argument support to

* fixed deprecation messages, fixed documentation examples

---------

Co-authored-by: GDW1 <guwilks@cisco.com>
@GDW1 GDW1 requested a review from pnickolov as a code owner July 10, 2023 23:59
cmd/config/set.go Outdated Show resolved Hide resolved
if val != "" && !slices.Contains(GetAuthMethodsStringList(), val) {
log.Fatalf(`Invalid --auth method %q; must be one of {"%v"}`, val, strings.Join(GetAuthMethodsStringList(), `", "`))
}
//If this auth is different from the last auth then clear all fields
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
//If this auth is different from the last auth then clear all fields
//If this auth is different from the last auth then clear all subordinate auth settings

@@ -195,12 +209,21 @@ func configSetContext(cmd *cobra.Command, args []string) {
if err != nil {
log.Fatal(err.Error())
}
if !flags.Changed("patch") {
Copy link
Contributor

Choose a reason for hiding this comment

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

use the bool value of the flag, not whether it was set on the command line

@@ -187,6 +200,7 @@ func configSetContext(cmd *cobra.Command, args []string) {
log.Fatal(err.Error())
}
log.Warnf("The --server option is now deprecated. In the future, please use --url instead. We will set the url to %q for you now", cleanedUrl)
URLClearConditions(ctxPtr)
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be done only if not patching?

@@ -273,3 +326,13 @@ func expandHomePath(file string) string {
}
return file
}

func clearContext(ctxPtr *Context) {
Copy link
Contributor

Choose a reason for hiding this comment

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

consider renaming to clearAuthFields()
In the future, the context may contain non-auth-related values (e.g., devenv or uql.apiver). What we want to wipe are only the authentication fields that are likely no longer applicable.

}
//If this auth is different from the last auth then clear all fields
if val != ctxPtr.AuthMethod { // deal with conditions here
clearContext(ctxPtr)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
clearContext(ctxPtr)
clearContext(ctxPtr) // must be done before any of the other fields are set in the context

ctxPtr.URL = cleanedUrl
}
if flags.Changed("tenant") {
if ctxPtr.AuthMethod != "jwt" && !flags.Changed("patch") {
Copy link
Contributor

Choose a reason for hiding this comment

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

actually, the tenant is allowed for the JWT auth mode. Also the check above is for non-JWT mode... Can you please check/re-consider here?

ctxPtr.Tenant, _ = flags.GetString("tenant")
}
if flags.Changed("token") {
if ctxPtr.AuthMethod != "jwt" && !flags.Changed("patch") {
log.Fatalf("The tenant cannot be set for jwt. To override this, use the --patch flag")
Copy link
Contributor

Choose a reason for hiding this comment

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

see note above. Token can be explicitly set ONLY for the JWT mode, so the message seems incorrect


if ctxPtr.AuthMethod == AuthMethodLocal {
if flags.Changed(AppdPid) {
if ctxPtr.AuthMethod != "service-principal" && ctxPtr.AuthMethod != "agent-principal" && !flags.Changed("patch") {
Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary/confusing check. We already know we're in AuthMethodLocal auth mode (see line 250 above)

}
}

func TennantClearConditions(ctxPtr *Context) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func TennantClearConditions(ctxPtr *Context) {
func TenantClearConditions(ctxPtr *Context) {

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, this seems to be the same as the URLClearConditions.

@GDW1 GDW1 closed this Jul 15, 2023
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.

6 participants