-
Notifications
You must be signed in to change notification settings - Fork 225
OCM-1520 | feat: Add --hide-empty-columns flag to rosa list commands #2983
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ package accessrequests | |
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net/http" | ||
"time" | ||
|
||
|
@@ -126,7 +125,6 @@ var _ = Describe("rosa attach policy", func() { | |
Expect(err).NotTo(HaveOccurred()) | ||
|
||
stdOut, _ := t.StdOutReader.Read() | ||
fmt.Println(stdOut) | ||
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. unnecessary change |
||
Expect(stdOut).To(Equal(accessRequestsOutput)) | ||
}) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,6 @@ limitations under the License. | |
package accountroles | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"text/tabwriter" | ||
"time" | ||
|
@@ -55,6 +54,7 @@ func init() { | |
"List only account-roles that are associated with the given version.", | ||
) | ||
output.AddFlag(Cmd) | ||
output.AddHideEmptyColumnsFlag(Cmd) | ||
} | ||
|
||
func run(_ *cobra.Command, _ []string) { | ||
|
@@ -108,23 +108,35 @@ func run(_ *cobra.Command, _ []string) { | |
os.Exit(0) | ||
} | ||
|
||
// Create the writer that will be used to print the tabulated results: | ||
writer := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) | ||
fmt.Fprintf(writer, "ROLE NAME\tROLE TYPE\tROLE ARN\tOPENSHIFT VERSION\tAWS Managed\n") | ||
headers := []string{"ROLE NAME", "ROLE TYPE", "ROLE ARN", "OPENSHIFT VERSION", "AWS Managed"} | ||
|
||
var tableData [][]string | ||
for _, accountRole := range accountRoles { | ||
awsManaged := "No" | ||
if accountRole.ManagedPolicy { | ||
awsManaged = "Yes" | ||
} | ||
fmt.Fprintf( | ||
writer, | ||
"%s\t%s\t%s\t%s\t%s\n", | ||
row := []string{ | ||
accountRole.RoleName, | ||
accountRole.RoleType, | ||
accountRole.RoleARN, | ||
accountRole.Version, | ||
awsManaged, | ||
) | ||
} | ||
tableData = append(tableData, row) | ||
Comment on lines
-120
to
+126
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. Can be simplified:
|
||
} | ||
|
||
if output.ShouldHideEmptyColumns() { | ||
tableData = output.RemoveEmptyColumns(headers, tableData) | ||
} else { | ||
tableData = append([][]string{headers}, tableData...) | ||
} | ||
writer.Flush() | ||
|
||
writer := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) | ||
output.BuildTable(writer, "\t", tableData) | ||
if err := writer.Flush(); err != nil { | ||
_ = r.Reporter.Errorf("Failed to flush output: %v", err) | ||
os.Exit(1) | ||
} | ||
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. This file looks great |
||
|
||
} |
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 command has been altered pretty heavily in terms of how it gathers data and im worried it will have different a different table for certain clusters after these changes. Could you provide some output from it to show that it works the same?