- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.4k
 
🌱 Bump tablewriter package version #12320
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
          
     Closed
      
      
    
  
     Closed
                    Changes from all commits
      Commits
    
    
  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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 | 
|---|---|---|
| 
          
            
          
           | 
    @@ -28,6 +28,7 @@ | |
| "github.com/fatih/color" | ||
| "github.com/gobuffalo/flect" | ||
| "github.com/olekukonko/tablewriter" | ||
| "github.com/olekukonko/tablewriter/tw" | ||
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||
| 
          
            
          
           | 
    @@ -66,14 +67,14 @@ | |
| func PrintObjectTree(tree *tree.ObjectTree, w io.Writer) { | ||
| // Creates the output table | ||
| tbl := tablewriter.NewWriter(w) | ||
| tbl.SetHeader([]string{"NAME", "REPLICAS", "AVAILABLE", "READY", "UP TO DATE", "STATUS", "REASON", "SINCE", "MESSAGE"}) | ||
| tbl.Header([]string{"NAME", "REPLICAS", "AVAILABLE", "READY", "UP TO DATE", "STATUS", "REASON", "SINCE", "MESSAGE"}) | ||
| 
     | 
||
| formatTableTree(tbl) | ||
| // Add row for the root object, the cluster, and recursively for all the nodes representing the cluster status. | ||
| addObjectRow("", tbl, tree, tree.GetRoot()) | ||
| 
     | 
||
| // Prints the output table | ||
| tbl.Render() | ||
| } | ||
| 
     | 
||
| // PrintObjectTreeV1Beta1 prints the cluster status to stdout. | ||
| 
        
          
        
         | 
    @@ -81,44 +82,42 @@ | |
| func PrintObjectTreeV1Beta1(tree *tree.ObjectTree) { | ||
| // Creates the output table | ||
| tbl := tablewriter.NewWriter(os.Stdout) | ||
| tbl.SetHeader([]string{"NAME", "READY", "SEVERITY", "REASON", "SINCE", "MESSAGE"}) | ||
| tbl.Header([]string{"NAME", "READY", "SEVERITY", "REASON", "SINCE", "MESSAGE"}) | ||
| 
     | 
||
| formatTableTreeV1Beta1(tbl) | ||
| // Add row for the root object, the cluster, and recursively for all the nodes representing the cluster status. | ||
| addObjectRowV1Beta1("", tbl, tree, tree.GetRoot()) | ||
| 
     | 
||
| // Prints the output table | ||
| tbl.Render() | ||
| } | ||
| 
     | 
||
| // formats the table with required attributes. | ||
| func formatTableTree(tbl *tablewriter.Table) { | ||
| tbl.SetAutoWrapText(false) | ||
| tbl.SetHeaderAlignment(tablewriter.ALIGN_LEFT) | ||
| tbl.SetAlignment(tablewriter.ALIGN_LEFT) | ||
| 
     | 
||
| tbl.SetCenterSeparator("") | ||
| tbl.SetRowSeparator("") | ||
| 
     | 
||
| tbl.SetHeaderLine(false) | ||
| tbl.SetTablePadding(" ") | ||
| tbl.SetNoWhiteSpace(true) | ||
| tbl.Options( | ||
| tablewriter.WithRowAutoWrap(tw.WrapNone), | ||
| tablewriter.WithHeaderAlignment(tw.AlignLeft), | ||
| tablewriter.WithPadding(tw.Padding{Right: " "}), | ||
| tablewriter.WithRendition(tw.Rendition{ | ||
| Borders: tw.BorderNone, | ||
| Settings: tw.Settings{ | ||
| Separators: tw.SeparatorsNone, | ||
| }}), | ||
| ) | ||
| } | ||
| 
     | 
||
| // formats the table with required attributes. | ||
| func formatTableTreeV1Beta1(tbl *tablewriter.Table) { | ||
| tbl.SetAutoWrapText(false) | ||
| tbl.SetHeaderAlignment(tablewriter.ALIGN_LEFT) | ||
| tbl.SetAlignment(tablewriter.ALIGN_LEFT) | ||
| 
     | 
||
| tbl.SetCenterSeparator("") | ||
| tbl.SetColumnSeparator("") | ||
| tbl.SetRowSeparator("") | ||
| 
     | 
||
| tbl.SetHeaderLine(false) | ||
| tbl.SetBorder(false) | ||
| tbl.SetTablePadding(" ") | ||
| tbl.SetNoWhiteSpace(true) | ||
| tbl.Options( | ||
| tablewriter.WithRowAutoWrap(tw.WrapNone), | ||
| 
         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 can be moved into table constructor while initializing, Once everything works as it is now, I will take care of simplifying it.  | 
||
| tablewriter.WithHeaderAlignment(tw.AlignLeft), | ||
| tablewriter.WithPadding(tw.Padding{Right: " "}), | ||
| tablewriter.WithRendition(tw.Rendition{ | ||
| Borders: tw.BorderNone, | ||
| Settings: tw.Settings{ | ||
| Separators: tw.SeparatorsNone, | ||
| }}), | ||
| ) | ||
| } | ||
| 
     | 
||
| // addObjectRow add a row for a given object, and recursively for all the object's children. | ||
| 
          
            
          
           | 
    @@ -161,7 +160,7 @@ | |
| if len(msg) >= 1 { | ||
| msg0 = msg[0] | ||
| } | ||
| tbl.Append([]string{ | ||
| fmt.Sprintf("%s%s", gray.Sprint(prefix), name), | ||
| rowDescriptor.replicas, | ||
| rowDescriptor.availableCounters, | ||
| 
        
          
        
         | 
    @@ -174,7 +173,7 @@ | |
| 
     | 
||
| multilinePrefix := getRootMultiLineObjectPrefix(obj, objectTree) | ||
| for _, m := range msg[1:] { | ||
| tbl.Append([]string{ | ||
| gray.Sprint(multilinePrefix), | ||
| "", | ||
| "", | ||
| 
          
            
          
           | 
    @@ -241,7 +240,7 @@ | |
| // Add the row representing the object that includes | ||
| // - The row name with the tree view prefix. | ||
| // - The object's ready condition. | ||
| tbl.Append([]string{ | ||
| fmt.Sprintf("%s%s", gray.Sprint(prefix), name), | ||
| readyDescriptor.readyColor.Sprint(readyDescriptor.status), | ||
| readyDescriptor.readyColor.Sprint(readyDescriptor.severity), | ||
| 
          
            
          
           | 
    @@ -312,7 +311,7 @@ | |
| if len(msg) >= 1 { | ||
| msg0 = msg[0] | ||
| } | ||
| tbl.Append([]string{ | ||
| fmt.Sprintf("%s%s", gray.Sprint(childPrefix), cyan.Sprint(condition.Type)), | ||
| "", | ||
| "", | ||
| 
        
          
        
         | 
    @@ -324,7 +323,7 @@ | |
| msg0}) | ||
| 
     | 
||
| for _, m := range msg[1:] { | ||
| tbl.Append([]string{ | ||
| gray.Sprint(getMultilineConditionPrefix(childPrefix)), | ||
| "", | ||
| "", | ||
| 
          
            
          
           | 
    @@ -355,7 +354,7 @@ | |
| otherCondition := otherConditions[i] | ||
| otherDescriptor := newV1Beta1ConditionDescriptor(otherCondition) | ||
| otherConditionPrefix := getChildPrefix(prefix+childrenPipe+filler, i, len(otherConditions)) | ||
| tbl.Append([]string{ | ||
| fmt.Sprintf("%s%s", gray.Sprint(otherConditionPrefix), cyan.Sprint(otherCondition.Type)), | ||
| otherDescriptor.readyColor.Sprint(otherDescriptor.status), | ||
| otherDescriptor.readyColor.Sprint(otherDescriptor.severity), | ||
| 
          
            
          
           | 
    ||
  
    
      This file contains hidden or 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 hidden or 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
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  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.
Please handle error and solve lint error (everywhere)
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.
Sure thanks