-
Notifications
You must be signed in to change notification settings - Fork 32
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
Colors #349
Merged
Merged
Colors #349
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2aa39e7
Updating release after QA check
MattAWright 6555ebe
Fixing changelog merge conflict
MattAWright e78be7b
Update CHANGELOG.md
MattAWright 74ceaee
Fixed required org flag in policies view
MattAWright 045e8b6
Merge remote-tracking branch 'origin/colors' into colors
MattAWright 3cd0572
Fainted number in list, bolded org and proj
MattAWright File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,61 +59,14 @@ func listCmd(ctx *cli.Context) error { | |
|
||
tree := make(credentialTree) | ||
|
||
// Retrieve org and project flag values | ||
orgName := ctx.String("org") | ||
var org *envelope.Org | ||
if orgName == "" { | ||
// Retrieve list of available orgs | ||
orgs, err := client.Orgs.List(c) | ||
if err != nil { | ||
return errs.NewExitError("Failed to retrieve orgs list.") | ||
} | ||
|
||
// Prompt user to select from list of existing orgs | ||
idx, _, err := SelectExistingOrgPrompt(orgs) | ||
if err != nil { | ||
return errs.NewExitError("Failed to select org.") | ||
} | ||
|
||
org = &orgs[idx] | ||
orgName = org.Body.Name | ||
|
||
} else { | ||
// If org flag was used, identify the org supplied. | ||
org, err = client.Orgs.GetByName(c, orgName) | ||
if err != nil { | ||
return errs.NewErrorExitError("Failed to retrieve org " + orgName, err) | ||
} | ||
if org == nil { | ||
return errs.NewExitError("org " + orgName + " not found.") | ||
} | ||
org, err := getOrgWithPrompt(client, c, ctx.String("org")) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
projectName := ctx.String("project") | ||
var project *envelope.Project | ||
if projectName == "" { | ||
// Retrieve list of available projects | ||
projects, err := client.Projects.List(c, org.ID) | ||
if err != nil { | ||
return errs.NewErrorExitError("Failed to retrieve projects list.", err) | ||
} | ||
|
||
// Prompt user to select from list of existing orgs | ||
idx, _, err := SelectExistingProjectPrompt(projects) | ||
if err != nil { | ||
return errs.NewErrorExitError("Failed to select project.", err) | ||
} | ||
|
||
project = &projects[idx] | ||
projectName = project.Body.Name | ||
|
||
} else { | ||
// Get Project for project name, confirm project exists | ||
project, err = getProject(c, client, org.ID, projectName) | ||
if err != nil { | ||
return errs.NewErrorExitError("Failed to get project info for "+ | ||
orgName+"/"+projectName, err) | ||
} | ||
project, err := getProjectWithPrompt(client, c, org, ctx.String("project")) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// Retrieve environment flag values | ||
|
@@ -138,8 +91,8 @@ func listCmd(ctx *cli.Context) error { | |
// Create a PathExp based on flags. This is the search space that | ||
// will be used to retrieve credentials. | ||
filterPathExp, err := pathexp.New( | ||
orgName, | ||
projectName, | ||
org.Body.Name, | ||
project.Body.Name, | ||
envFilters, | ||
serviceFilters, | ||
instanceFilters, | ||
|
@@ -226,7 +179,8 @@ func listCmd(ctx *cli.Context) error { | |
// Check for each env and service in the filtered list, add | ||
// any credentials along that path to that env/service branch | ||
// of the credentialsTree | ||
projectPath := "/" + orgName + "/" + projectName + "/" | ||
credCount := 0 | ||
projectPath := "/" + org.Body.Name + "/" + project.Body.Name + "/" | ||
for _, e := range filteredEnvNames { | ||
for _, s := range filteredServiceNames { | ||
builtPathExp, err := pathexp.Parse(projectPath + e + "/" + s + "/*/*") | ||
|
@@ -262,8 +216,8 @@ func listCmd(ctx *cli.Context) error { | |
if(verbose){ | ||
fmt.Println("") | ||
projW := ansiterm.NewTabWriter(os.Stdout, 0, 0, 4, ' ', 0) | ||
fmt.Fprintf(projW, "Org:\t" + ui.Faint(orgName) + "\t\n") | ||
fmt.Fprintf(projW, "Project:\t" + ui.Faint(projectName) + "\t\n") | ||
fmt.Fprintf(projW, "Org:\t" + ui.Faint(org.Body.Name) + "\t\n") | ||
fmt.Fprintf(projW, "Project:\t" + ui.Faint(project.Body.Name) + "\t\n") | ||
projW.Flush() | ||
} | ||
|
||
|
@@ -280,6 +234,7 @@ func listCmd(ctx *cli.Context) error { | |
continue | ||
} | ||
for c, cred := range tree[e][s] { | ||
credCount += 1 | ||
if verbose { | ||
credPath := (*cred.Body).GetPathExp().String() + "/" | ||
fmt.Fprintf(w, "\t\t%s\t(%s)\t\n", c, ui.Faint(credPath+c)) | ||
|
@@ -290,7 +245,8 @@ func listCmd(ctx *cli.Context) error { | |
} | ||
} | ||
w.Flush() | ||
fmt.Println("") | ||
|
||
fmt.Printf("\n(%d) secrets found\n.", credCount) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could add some color to the number (light gray?) |
||
|
||
return nil | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 should probably bold org and project?