Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Improve addons list table design #21288

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

Open
pavansaikrishna78 wants to merge 7 commits into kubernetes:master
base: master
Choose a base branch
Loading
from pavansaikrishna78:addon-list

Conversation

Copy link

@pavansaikrishna78 pavansaikrishna78 commented Aug 11, 2025

If status is enabled then the whole row green

command: addons list
image

command: addons list -d
image

command: profile list
image

command: profile list -d
image

ADDON.LIST.MINIKUBE.docx

Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pavansaikrishna78
Once this PR has been reviewed and has the lgtm label, please assign spowelljr for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 11, 2025
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 11, 2025
Copy link
Contributor

Hi @pavansaikrishna78. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 11, 2025
Copy link
Collaborator

Can one of the admins verify this patch?

// Mirror CN
AliyunMirror = "registry.cn-hangzhou.aliyuncs.com/google_containers"

//TABLE WRITER COLORS
Copy link
Member

@medyagh medyagh Aug 11, 2025
edited
Loading

Choose a reason for hiding this comment

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

is there a way to show how it looks like maybe a link or copy to the comment ?
is a library to use?

Copy link
Author

@pavansaikrishna78 pavansaikrishna78 Aug 12, 2025

Choose a reason for hiding this comment

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

enabled := addonBundle.IsEnabled(cc)
temp = []string{addonName, cc.Name, fmt.Sprintf("%s %s", stringFromStatus(enabled), iconFromStatus(enabled)), maintainer}
if enabled{
status := fmt.Sprintf("%s%s%s", constants.Enabled, iconFromStatus(enabled), constants.Default)
Copy link
Member

@medyagh medyagh Aug 11, 2025
edited
Loading

Choose a reason for hiding this comment

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

add a helper func to Format the text

we have a style package
style.Enable(.....)

cpIP, strconv.Itoa(cpPort), k8sVersion, p.Status, strconv.Itoa(len(p.Config.Nodes)), c, k})
if p.Status == "OK" {
data = append(data, []string{
fmt.Sprintf("%s%s%s", constants.Enabled, p.Name, constants.Default),
Copy link
Member

Choose a reason for hiding this comment

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

we should have a style func that does
style.Normal( white color)
style.Enabled(
Style.Trouble(

if isDetailed {
data = append(data, []string{p.Name, p.Config.Driver, p.Config.KubernetesConfig.ContainerRuntime,
cpIP, strconv.Itoa(cpPort), k8sVersion, p.Status, strconv.Itoa(len(p.Config.Nodes)), c, k})
if p.Status == "OK" {
Copy link
Member

Choose a reason for hiding this comment

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

this should be an iteration loop that calls the and based on the status it will call the Style Function in the package.

Copy link
Contributor

@nirs nirs left a comment

Choose a reason for hiding this comment

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

Please split the logical changes to separate commits instead of posing a new commit on every change.

If tests fail fix the failing commit. Don't post another commit fixing the first commit. This makes reviewing the changes much harder. Adding fix commit locally is fine, but before you post a new version you should squash the fix commit into the commit that introduced the problem.

Please remove all the unrelated and unnecessary changes. Focus on only on the design change to keep the change small, easy to review and be able to complete it quickly.

AliyunMirror = "registry.cn-hangzhou.aliyuncs.com/google_containers"

//TABLE WRITER COLORS
Enabled = "033円[32m"
Copy link
Contributor

Choose a reason for hiding this comment

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

This is green forground color. I will help to add a comment like:

Enabled = "033円[32m" // green forground


//TABLE WRITER COLORS
Enabled = "033円[32m"
Default = "033円[0m"
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not a color but a reset command, removing all attributes (foreground color, background color, effects). We don't need a constant for default since it does not change the text.

//TABLE WRITER COLORS
Enabled = "033円[32m"
Default = "033円[0m"
Disabled = "033円[0m"
Copy link
Contributor

Choose a reason for hiding this comment

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

Same, since this is using the same value as default.

Enabled = "033円[32m"
Default = "033円[0m"
Disabled = "033円[0m"
Error = "033円[31m"
Copy link
Contributor

Choose a reason for hiding this comment

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

This is red foreground, a comment will help.

But I don't think this is the way to go. What we need is a new package for color that can be reused by code writing output for tables or other output.

This package can use constants to the define the color of enabled, disabled, or errors, and provide functions using this signature:

Enabled(s string) string

Code rendering UI should use the functions to decorate fragments of text.

To implement this we can use a library like this:
https://github.com/fatih/color?tab=readme-ov-file#insert-into-noncolor-strings-sprintfunc

The advantage of using a library is using a well tested code that works on all platforms.

@@ -1,5 +1,5 @@
/*
Copyright 2019 The Kubernetes Authors All rights reserved.
Copyright 2025 The Kubernetes Authors All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need to update the dates, that's pointless effort. The best way is to remove the date form the copyright headers, but this is not in the scope of this PR, so just remove this change.

applyColor = true
default:
applyColor = false
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is too complicated for no reason.

row[i] = fmt.Sprintf("%s%d%s", colorCode, v, constants.Default)
default:
row[i] = fmt.Sprintf("%s%v%s", colorCode, v, constants.Default)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Converting the values to string like we did before was better. If we colorize all value in a raw, we can keep the old code as is and apply the right color function to the entire slice.

updateProfilesStatus(validProfiles)

var body = map[string]interface{}{}
body := map[string]interface{}{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you change this?

tHeader = []string{"Addon Name", "Maintainer"}
} else {
tHeader = []string{"Addon Name", "Profile", "Status", "Maintainer"}
tHeader = []string{"Addon Name", "Enabled", "Maintainer"}
Copy link
Contributor

Choose a reason for hiding this comment

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

We have 3 logic changes:

  • Removing the profile column
  • Replacing Status with Enabled
  • Coloring the output

Each change should be done in a separate commit. This will make it easier to write the code without errors, test it, and review.

temp[i] = fmt.Sprintf("%s%s%s", valueColorCode, valueStr, constants.Default)
} else {
temp[i] = valueStr
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Too complicated.

We need 2 steps:

  • Create list of strings for the table writer
  • Color the strings

For creating list of strings we can modify the previous code a little bit:

enabled := addonBundle.IsEnabled(cc)
row = []string{addonName, cc.Name, iconFromStatus(enabled), maintainer}

iconForStatus() should return empty string if enabled is false. If it does not do this create a function that does this.

Since the list is so simple, we don't really need a loop to color it:

if enabled {
 row[0] = color.Enabled(row[0])
 row[2] = color.Enabled(row[2])
}

But since wan to color longer lists (like profile list), we can add a function to color rows:

type colorFunc func(string) string
func ColorRow(row []string, colored colorFunc) {
 for i := range row {
 text := row[i]
 if text == "" || isEmoji(text) {
 continue
 }
 row[i] = colored(text)
 }
}

With this we can do:

switch status {
case Broken:
 color.ColorRow(row, color.Broken)
case Error:
 color.ColorRow(row, color.Error)
case Enabled:
 color.ColorRow(row, color.Enabled)
}

@k8s-ci-robot k8s-ci-robot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 18, 2025
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 18, 2025
addons list and profile list and making pass the test
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 18, 2025
Copy link
Member

@medyagh medyagh left a comment

Choose a reason for hiding this comment

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

lets plz not do changes not related to this PR
and also check nir's suggetsions how to make the code more simple

Copy link
Contributor

@Wilson-Duncan Wilson-Duncan left a comment

Choose a reason for hiding this comment

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

Reviewed and left a comment. In addition, for the run instructions it would be cleaner to update the screenshots to just be the table output. Or update listing the full command in plain text to make it easier to copy and paste.

i.e.

command: ./out/minikube addons list
...
command: ./out/minikube profile list -d

}

var printAddonsList=func(cc *config.ClusterConfig, printDocs bool) {
func printAddonsList(cc *config.ClusterConfig, printDocs bool) {
Copy link
Contributor

@Wilson-Duncan Wilson-Duncan Sep 9, 2025

Choose a reason for hiding this comment

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

I don't think this change is needed or relevant to the PR. Other files follow the same convention. So this should be taken care of in a different PR for refactoring once its determined why its being done this way. I think this is done to make the function easier to test but I'm not sure.

Copy link
Author

@pavansaikrishna78 pavansaikrishna78 Sep 9, 2025

Choose a reason for hiding this comment

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

hi @Wilson-Duncan here is the output of the and correcting your above comment
image
image
image

Copy link
Contributor

@Wilson-Duncan Wilson-Duncan Sep 22, 2025

Choose a reason for hiding this comment

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

I'm saying the commands should not be in the screenshots. ./out/minikube profile list, make, ./out/minikube addons list, and ./out/minikube profile list -d should be plain text and not a part of the screenshot.

@k8s-ci-robot k8s-ci-robot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 9, 2025
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 9, 2025
Copy link
Contributor

@nirs nirs left a comment

Choose a reason for hiding this comment

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

Lets remove all unrelated changes and keep only the code needed to add colors.

We can add additional changes later, for now we need to focus on the color changes.


table.Options(
tablewriter.WithHeaderAutoFormat(tw.On),
)
Copy link
Contributor

Choose a reason for hiding this comment

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

table.Options(tablewriter.WithHeaderAutoFormat(tw.On)) replaces this code?

Is this related to the color change? If not please don't include this in this PR. I'm trying to review the color changes and I don't have time to review other changes now.

header = append(header, "Docs")
}
table.Header(tHeader)
table.Header(header)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you change these names? Is this related to the color changes?

if maintainer == "" {
maintainer = "3rd party (unknown)"
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Why to you keep adding unrelated whitespace changes? I already commented about it in previous reviews several times.

row[i] = colored("%s", row[i])
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Lets move the helpers to another file since they are used both in adding_list.go and profile_list.go. We can add a color.go file for these helpers. If we use colors only in the config package this is good enough for now, but I think the best place for it is a new color package in pkg/minikube/color/color.go.

type colorFunc func(string, ...interface{}) string

func isEmoji(s string) bool {
return strings.Contains(s, "✅")
Copy link
Contributor

Choose a reason for hiding this comment

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

This will not color test with emoji like "enabled ✅". Currently we don't have this but it will be more correct to use:

s == "✅"

Ideally we can use the unicode package to detect if the string contains only emoji characters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@prezha prezha Awaiting requested review from prezha

@Wilson-Duncan Wilson-Duncan Awaiting requested review from Wilson-Duncan

@medyagh medyagh Awaiting requested review from medyagh

@nirs nirs Awaiting requested review from nirs

Assignees

No one assigned

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /