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

avoid duplicate display of resources bug #417

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/kubernetes/kubernetes_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ If you wish to use a custom format, the available fields are:
os.Exit(1)
}

ow := utility.NewOutputWriter()
for _, cluster := range kubernetesClusters.Items {
ow := utility.NewOutputWriter() // Create a new OutputWriter instance for each cluster
ow.StartLine()

ow.AppendDataWithLabel("id", cluster.ID, "ID")
Expand Down Expand Up @@ -74,8 +74,8 @@ If you wish to use a custom format, the available fields are:
if common.OutputFormat == "json" || common.OutputFormat == "custom" {
ow.AppendDataWithLabel("status", cluster.Status, "Status")
}
}

ow.FinishAndPrintOutput()
ow.FinishAndPrintOutput() // Ensure output is finished and printed at the end of each loop iteration
}
},
}
4 changes: 2 additions & 2 deletions utility/output_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func (ow *OutputWriter) StartLine() {
func (ow *OutputWriter) finishExistingLine() {
if len(ow.TempValues) > 0 {
ow.Values = append(ow.Values, ow.TempValues)
ow.TempValues = nil
}
}

Expand Down Expand Up @@ -197,9 +198,8 @@ func (ow *OutputWriter) WriteKeyValues() {
// WriteTable prints multiple objects stored in the OutputWriter
// in tabular format
func (ow *OutputWriter) WriteTable() {
ow.finishExistingLine()

table := tablewriter.NewWriter(os.Stdout)
ow.finishExistingLine()
if len(ow.Keys) > 0 {
table.SetHeader(ow.Labels)
table.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
Expand Down
Loading