├── LICENSE ├── Makefile ├── README.md ├── cmd ├── view-node-resource │ ├── BUILD │ ├── app │ │ ├── server.go │ │ └── utils.go │ └── main.go └── view-node-taints │ ├── BUILD │ ├── app │ ├── server.go │ └── utils.go │ └── main.go ├── go.mod ├── go.sum └── pkg ├── kubeclient ├── client.go └── interface.go ├── printers └── table.go ├── types ├── resource.go └── taints.go └── utils └── resource.go /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build kubectl plugin 2 | 3 | GOENV := GO15VENDOREXPERIMENT="1" GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 4 | GO := $(GOENV) go 5 | 6 | default: build 7 | 8 | build: view-node-resource view-node-taints 9 | 10 | plugin: 11 | GO111MODULE=on CGO_ENABLED=0 go build -o kubectl-debug cmd/plugin/main.go 12 | 13 | view-node-resource: 14 | $(GO) build -o kubectl-view-node-resource cmd/view-node-resource/main.go 15 | 16 | view-node-taints: 17 | $(GO) build -o kubectl-view-node-taints cmd/view-node-taints/main.go 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # kubectl-plugin 2 | 3 | build : 4 | ``` 5 | $ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/kubectl-view-node-resource cmd/view-node-resource/main.go 6 | 7 | $ GO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/kubectl-view-node-taints cmd/view-node-taints/main.go 8 | ``` 9 | 10 | start : 11 | ``` 12 | $ mv bin/kubectl-view-node-resource /usr/bin/ 13 | 14 | $ mv bin/kubectl-view-node-taints /usr/bin/ 15 | ``` 16 | 17 | demo: 18 | ``` 19 | $ kubectl view node resource 20 | Name PodCount CPURequests MemoryRequests CPULimits MemoryLimits 21 | 192.168.1.110 4 0 (0.00%) 6.4 (41.26%) 8 (100.00%) 16.0 (103.14%) 22 | 23 | 24 | $ kubectl view node taints 25 | Name Status Age Version Taints 26 | 192.168.1.110 Ready,SchedulingDisabled 49d v1.8.1-35+9406f9d9909c61-dirty enabledDiskSchedule=true:NoSchedule 27 | ``` 28 | 29 | 30 | -------------------------------------------------------------------------------- /cmd/view-node-resource/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gosoon/kubectl-plugin/da748238aa4e5d953ee03548705bcfba4d558e68/cmd/view-node-resource/BUILD -------------------------------------------------------------------------------- /cmd/view-node-resource/app/server.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2019 NAME HERE 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package app 16 | 17 | import ( 18 | "fmt" 19 | "os" 20 | 21 | "github.com/gosoon/kubectl-plugin/pkg/kubeclient" 22 | "github.com/gosoon/kubectl-plugin/pkg/printers" 23 | "github.com/gosoon/kubectl-plugin/pkg/types" 24 | "github.com/gosoon/kubectl-plugin/pkg/utils" 25 | 26 | homedir "github.com/mitchellh/go-homedir" 27 | "github.com/spf13/cobra" 28 | "github.com/spf13/viper" 29 | "k8s.io/api/core/v1" 30 | ) 31 | 32 | var cfgFile string 33 | 34 | // RootCmd represents the base command when called without any subcommands 35 | var RootCmd = &cobra.Command{ 36 | Use: "view-node-resource", 37 | Short: "A brief description of your application", 38 | Long: `A longer description that spans multiple lines and likely contains 39 | examples and usage of using your application. For example: 40 | 41 | Cobra is a CLI library for Go that empowers applications. 42 | This application is a tool to generate the needed files 43 | to quickly create a Cobra application.`, 44 | // Uncomment the following line if your bare application 45 | // has an action associated with it: 46 | Run: func(cmd *cobra.Command, args []string) { 47 | client, err := kubeclient.NewClient() 48 | if err != nil { 49 | panic(err) 50 | } 51 | run(client) 52 | }, 53 | } 54 | 55 | // Execute adds all child commands to the root command and sets flags appropriately. 56 | // This is called by main.main(). It only needs to happen once to the rootCmd. 57 | func Execute() { 58 | if err := RootCmd.Execute(); err != nil { 59 | fmt.Println(err) 60 | os.Exit(1) 61 | } 62 | } 63 | 64 | func init() { 65 | cobra.OnInitialize(initConfig) 66 | 67 | // Here you will define your flags and configuration settings. 68 | // Cobra supports persistent flags, which, if defined here, 69 | // will be global for your application. 70 | RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.view-node-resource.yaml)") 71 | 72 | // Cobra also supports local flags, which will only run 73 | // when this action is called directly. 74 | RootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") 75 | } 76 | 77 | // initConfig reads in config file and ENV variables if set. 78 | func initConfig() { 79 | if cfgFile != "" { 80 | // Use config file from the flag. 81 | viper.SetConfigFile(cfgFile) 82 | } else { 83 | // Find home directory. 84 | home, err := homedir.Dir() 85 | if err != nil { 86 | fmt.Println(err) 87 | os.Exit(1) 88 | } 89 | 90 | // Search config in home directory with name ".view-node-resource" (without extension). 91 | viper.AddConfigPath(home) 92 | viper.SetConfigName(".view-node-resource") 93 | } 94 | 95 | viper.AutomaticEnv() // read in environment variables that match 96 | 97 | // If a config file is found, read it in. 98 | if err := viper.ReadInConfig(); err == nil { 99 | fmt.Println("Using config file:", viper.ConfigFileUsed()) 100 | } 101 | } 102 | 103 | func run(client *kubeclient.Client) { 104 | nodeList, err := client.ListNode() 105 | if err != nil { 106 | panic(err) 107 | } 108 | 109 | podList, err := client.ListPod() 110 | if err != nil { 111 | panic(err) 112 | } 113 | nodeResourceList := NodeResouceHandler(nodeList, podList) 114 | 115 | printNodeResourceColumnDefinitions(nodeResourceList) 116 | } 117 | 118 | func printNodeResourceColumnDefinitions(nodeResourceList map[string]*types.NodeResourceList) { 119 | var nodeResourceColumnDefinitions []types.NodeResourceColumnDefinitions 120 | for _, node := range nodeResourceList { 121 | nodeResourceColumnDefinitions = append(nodeResourceColumnDefinitions, 122 | types.NodeResourceColumnDefinitions{ 123 | Name: node.Name, 124 | PodCount: node.PodCount, 125 | CPURequests: pickNodeCPURequests(node), 126 | MemoryRequests: pickNodeMemoryRequests(node), 127 | CPULimits: pickNodeCPULimits(node), 128 | MemoryLimits: pickNodeMemoryLimits(node), 129 | }) 130 | } 131 | 132 | printers.Output(nodeResourceColumnDefinitions) 133 | } 134 | 135 | func NodeResouceHandler(nodeList *v1.NodeList, podList *v1.PodList) map[string]*types.NodeResourceList { 136 | nodeResourceList := make(map[string]*types.NodeResourceList) 137 | 138 | for _, node := range nodeList.Items { 139 | if _, existed := nodeResourceList[node.Name]; !existed { 140 | nodeCPU, nodeMemory := getNodeAllocatable(node.Status.Allocatable) 141 | nodeResourceList[node.Name] = &types.NodeResourceList{ 142 | Name: node.Name, 143 | CPU: nodeCPU, 144 | Memory: nodeMemory, 145 | } 146 | } 147 | } 148 | 149 | for _, pod := range podList.Items { 150 | nodeName := pod.Spec.NodeName 151 | if _, existed := nodeResourceList[nodeName]; existed { 152 | for _, container := range pod.Spec.Containers { 153 | for name, value := range container.Resources.Requests { 154 | if string(name) == "cpu" { 155 | cr, _ := utils.ConvertCPUUnit(value.String()) 156 | nodeResourceList[nodeName].CPURequests += cr 157 | } 158 | if string(name) == "memory" { 159 | mr, _ := utils.ConvertMemoryUnit(value.String()) 160 | nodeResourceList[pod.Spec.NodeName].MemoryRequests += mr 161 | } 162 | } 163 | for name, value := range container.Resources.Limits { 164 | if string(name) == "cpu" { 165 | cl, _ := utils.ConvertCPUUnit(value.String()) 166 | nodeResourceList[nodeName].CPULimits += cl 167 | } 168 | if string(name) == "memory" { 169 | ml, _ := utils.ConvertMemoryUnit(value.String()) 170 | nodeResourceList[nodeName].MemoryLimits += ml 171 | } 172 | } 173 | nodeResourceList[nodeName].PodCount++ 174 | } 175 | } 176 | } 177 | 178 | for _, node := range nodeList.Items { 179 | nodeName := node.Name 180 | 181 | nodeResourceList[nodeName].CPURequestsUsage = fmt.Sprintf("%.2f%%", 182 | nodeResourceList[nodeName].CPURequests/nodeResourceList[nodeName].CPU*100) 183 | 184 | nodeResourceList[nodeName].MemoryRequestsUsage = fmt.Sprintf("%.2f%%", 185 | nodeResourceList[nodeName].MemoryRequests/nodeResourceList[nodeName].Memory*100) 186 | 187 | nodeResourceList[nodeName].CPULimitsUsage = fmt.Sprintf("%.2f%%", 188 | nodeResourceList[nodeName].CPULimits/nodeResourceList[nodeName].CPU*100) 189 | 190 | nodeResourceList[nodeName].MemoryLimitsUsage = fmt.Sprintf("%.2f%%", 191 | nodeResourceList[nodeName].MemoryLimits/nodeResourceList[nodeName].Memory*100) 192 | } 193 | return nodeResourceList 194 | } 195 | -------------------------------------------------------------------------------- /cmd/view-node-resource/app/utils.go: -------------------------------------------------------------------------------- 1 | package app 2 | 3 | import ( 4 | "fmt" 5 | "github.com/gosoon/kubectl-plugin/pkg/types" 6 | "github.com/gosoon/kubectl-plugin/pkg/utils" 7 | 8 | v1 "k8s.io/api/core/v1" 9 | ) 10 | 11 | func getNodeAllocatable(allocatable v1.ResourceList) (float64, float64) { 12 | nodeCPU := float64(0) 13 | nodeMemory := float64(0) 14 | for name, value := range allocatable { 15 | if string(name) == "cpu" { 16 | //cpu, _ := strconv.ParseFloat(value.String(), 64) 17 | // MilliValue returns the value of ceil(q * 1000); this could overflow an int64; 18 | // if that's a concern, call Value() first to verify the number is small enough. 19 | cpu := float64(value.MilliValue()/1000) 20 | nodeCPU = cpu 21 | } else if string(name) == "memory" { 22 | memory, _ := utils.ConvertMemoryUnit(value.String()) 23 | nodeMemory += memory 24 | } 25 | } 26 | return nodeCPU, nodeMemory 27 | } 28 | 29 | func pickNodeCPURequests(node *types.NodeResourceList) string { 30 | return fmt.Sprintf("%.2f (%v)", node.CPURequests, node.CPURequestsUsage) 31 | } 32 | 33 | func pickNodeMemoryRequests(node *types.NodeResourceList) string { 34 | return fmt.Sprintf("%.1f (%v)", node.MemoryRequests, node.MemoryRequestsUsage) 35 | } 36 | 37 | func pickNodeCPULimits(node *types.NodeResourceList) string { 38 | return fmt.Sprintf("%.2f (%v)", node.CPULimits, node.CPULimitsUsage) 39 | } 40 | 41 | func pickNodeMemoryLimits(node *types.NodeResourceList) string { 42 | return fmt.Sprintf("%.1f (%v)", node.MemoryLimits, node.MemoryLimitsUsage) 43 | } 44 | -------------------------------------------------------------------------------- /cmd/view-node-resource/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2019 NAME HERE 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import "github.com/gosoon/kubectl-plugin/cmd/view-node-resource/app" 18 | 19 | func main() { 20 | app.Execute() 21 | } 22 | -------------------------------------------------------------------------------- /cmd/view-node-taints/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gosoon/kubectl-plugin/da748238aa4e5d953ee03548705bcfba4d558e68/cmd/view-node-taints/BUILD -------------------------------------------------------------------------------- /cmd/view-node-taints/app/server.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2019 NAME HERE 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | package app 15 | 16 | import ( 17 | "fmt" 18 | "os" 19 | "time" 20 | 21 | "github.com/gosoon/kubectl-plugin/pkg/kubeclient" 22 | "github.com/gosoon/kubectl-plugin/pkg/printers" 23 | "github.com/gosoon/kubectl-plugin/pkg/types" 24 | 25 | homedir "github.com/mitchellh/go-homedir" 26 | "github.com/spf13/cobra" 27 | "github.com/spf13/viper" 28 | "k8s.io/api/core/v1" 29 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 30 | ) 31 | 32 | var cfgFile string 33 | 34 | // RootCmd represents the base command when called without any subcommands 35 | var RootCmd = &cobra.Command{ 36 | Use: "view-node-taints", 37 | Short: "A brief description of your application", 38 | Long: `A longer description that spans multiple lines and likely contains 39 | examples and usage of using your application. For example: 40 | Cobra is a CLI library for Go that empowers applications. 41 | This application is a tool to generate the needed files 42 | to quickly create a Cobra application.`, 43 | // Uncomment the following line if your bare application 44 | // has an action associated with it: 45 | Run: func(cmd *cobra.Command, args []string) { 46 | client, err := kubeclient.NewClient() 47 | if err != nil { 48 | panic(err) 49 | } 50 | run(client) 51 | }, 52 | } 53 | 54 | // Execute adds all child commands to the root command and sets flags appropriately. 55 | // This is called by main.main(). It only needs to happen once to the rootCmd. 56 | func Execute() { 57 | if err := RootCmd.Execute(); err != nil { 58 | fmt.Println(err) 59 | os.Exit(1) 60 | } 61 | } 62 | func init() { 63 | cobra.OnInitialize(initConfig) 64 | // Here you will define your flags and configuration settings. 65 | // Cobra supports persistent flags, which, if defined here, 66 | // will be global for your application. 67 | RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.view-node-taints.yaml)") 68 | // Cobra also supports local flags, which will only run 69 | // when this action is called directly. 70 | RootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") 71 | } 72 | 73 | // initConfig reads in config file and ENV variables if set. 74 | func initConfig() { 75 | if cfgFile != "" { 76 | // Use config file from the flag. 77 | viper.SetConfigFile(cfgFile) 78 | } else { 79 | // Find home directory. 80 | home, err := homedir.Dir() 81 | if err != nil { 82 | fmt.Println(err) 83 | os.Exit(1) 84 | } 85 | // Search config in home directory with name ".view-node-taints" (without extension). 86 | viper.AddConfigPath(home) 87 | viper.SetConfigName(".view-node-taints") 88 | } 89 | viper.AutomaticEnv() // read in environment variables that match 90 | // If a config file is found, read it in. 91 | if err := viper.ReadInConfig(); err == nil { 92 | fmt.Println("Using config file:", viper.ConfigFileUsed()) 93 | } 94 | } 95 | 96 | func run(client *kubeclient.Client) { 97 | nodeList, err := client.ListNode() 98 | if err != nil { 99 | panic(err) 100 | } 101 | taintsColumnDefinitions := getTaintsColumnDefinitions(nodeList) 102 | printTaintsColumnDefinitions(taintsColumnDefinitions) 103 | } 104 | 105 | func getTaintsColumnDefinitions(nodeList *v1.NodeList) []types.TaintsColumnDefinitions { 106 | var taintsColumnDefinitions []types.TaintsColumnDefinitions 107 | for _, node := range nodeList.Items { 108 | status := NodeNotReady 109 | for _, condition := range node.Status.Conditions { 110 | if condition.Type == NodeReady && condition.Status == "True" { 111 | status = NodeReady 112 | } 113 | } 114 | taintsList := "" 115 | if len(node.Spec.Taints) != 0 { 116 | taintsList = visitTaints(node.Spec.Taints) 117 | } 118 | 119 | if node.Spec.Unschedulable { 120 | status += "," + NodeSchedulingDisabled 121 | } 122 | 123 | nodeAge := convertToAge(node.CreationTimestamp) 124 | taintsColumnDefinitions = append(taintsColumnDefinitions, types.TaintsColumnDefinitions{ 125 | Name: node.Name, 126 | Status: status, 127 | Age: nodeAge, 128 | Version: node.Status.NodeInfo.KubeletVersion, 129 | Taints: taintsList, 130 | }) 131 | } 132 | return taintsColumnDefinitions 133 | } 134 | 135 | func printTaintsColumnDefinitions(taintsColumnDefinitions []types.TaintsColumnDefinitions) { 136 | printers.Output(taintsColumnDefinitions) 137 | } 138 | 139 | func visitTaints(taints []v1.Taint) string { 140 | var taintsStr string 141 | var ct int 142 | taintsLen := len(taints) 143 | for _, taint := range taints { 144 | taintsStr += fmt.Sprintf("%v=%v:%v", taint.Key, taint.Value, taint.Effect) 145 | ct += 1 146 | if ct < taintsLen { 147 | taintsStr += "," 148 | } 149 | } 150 | return taintsStr 151 | } 152 | 153 | func convertToAge(creationTimestamp metav1.Time) string { 154 | s := creationTimestamp.Time.Format("2006-01-02T15:04:05Z") 155 | t, _ := time.Parse("2006-01-02T15:04:05Z", s) 156 | 157 | now := time.Now() 158 | sub := now.Sub(t) 159 | subHours := sub.Hours() 160 | 161 | if subHours < float64(24) { 162 | return fmt.Sprintf("%vh", subHours) 163 | } 164 | 165 | hours := int(subHours) 166 | days := hours / 24 167 | if (hours % 24) > 0 { 168 | days += 1 169 | } 170 | return fmt.Sprintf("%vd", days) 171 | } 172 | -------------------------------------------------------------------------------- /cmd/view-node-taints/app/utils.go: -------------------------------------------------------------------------------- 1 | package app 2 | 3 | const ( 4 | NodeReady = "Ready" 5 | NodeNotReady = "NotReady" 6 | 7 | NodeSchedulingDisabled = "SchedulingDisabled" 8 | ) 9 | -------------------------------------------------------------------------------- /cmd/view-node-taints/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2019 NAME HERE 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import "github.com/gosoon/kubectl-plugin/cmd/view-node-taints/app" 18 | 19 | func main() { 20 | app.Execute() 21 | } 22 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/gosoon/kubectl-plugin 2 | 3 | go 1.12 4 | 5 | require ( 6 | github.com/imdario/mergo v0.3.7 // indirect 7 | github.com/mitchellh/go-homedir v1.1.0 8 | github.com/spf13/cobra v0.0.5 9 | github.com/spf13/viper v1.4.0 10 | k8s.io/api v0.0.0-20190927115716-5d581ce610b0 11 | k8s.io/apimachinery v0.0.0-20190927035529-0104e33c351d 12 | k8s.io/client-go v11.0.0+incompatible 13 | k8s.io/utils v0.0.0-20190923111123-69764acb6e8e // indirect 14 | ) 15 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 2 | github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= 3 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 4 | github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= 5 | github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= 6 | github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= 7 | github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= 8 | github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= 9 | github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= 10 | github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= 11 | github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= 12 | github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= 13 | github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= 14 | github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= 15 | github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= 16 | github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= 17 | github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= 18 | github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= 19 | github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= 20 | github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= 21 | github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= 22 | github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 23 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 24 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 25 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 26 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= 27 | github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= 28 | github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= 29 | github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= 30 | github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= 31 | github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= 32 | github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= 33 | github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= 34 | github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= 35 | github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= 36 | github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= 37 | github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= 38 | github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= 39 | github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= 40 | github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= 41 | github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= 42 | github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= 43 | github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= 44 | github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= 45 | github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 46 | github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= 47 | github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d h1:3PaI8p3seN09VjbTYC/QWlUZdZ1qS1zGjy7LH2Wt07I= 48 | github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= 49 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 50 | github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 51 | github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 52 | github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 53 | github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 54 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 55 | github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= 56 | github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 57 | github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 58 | github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= 59 | github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= 60 | github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 61 | github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= 62 | github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= 63 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 64 | github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 65 | github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d h1:7XGaL1e6bYS1yIonGp9761ExpPPV1ui0SAC59Yube9k= 66 | github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= 67 | github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= 68 | github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= 69 | github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= 70 | github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= 71 | github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 72 | github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= 73 | github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= 74 | github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= 75 | github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI= 76 | github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= 77 | github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= 78 | github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= 79 | github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= 80 | github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= 81 | github.com/json-iterator/go v1.1.7 h1:KfgG9LzI+pYjr4xvmz/5H4FXjokeP+rlHLhv3iH62Fo= 82 | github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= 83 | github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= 84 | github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= 85 | github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= 86 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= 87 | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 88 | github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= 89 | github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= 90 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 91 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 92 | github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= 93 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 94 | github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= 95 | github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= 96 | github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= 97 | github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= 98 | github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= 99 | github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= 100 | github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= 101 | github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 102 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 103 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= 104 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 105 | github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 106 | github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 107 | github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= 108 | github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 109 | github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= 110 | github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= 111 | github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= 112 | github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= 113 | github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 114 | github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 115 | github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 116 | github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= 117 | github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= 118 | github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= 119 | github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= 120 | github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 121 | github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 122 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 123 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 124 | github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= 125 | github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= 126 | github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= 127 | github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 128 | github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= 129 | github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= 130 | github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= 131 | github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= 132 | github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= 133 | github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= 134 | github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= 135 | github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= 136 | github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= 137 | github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= 138 | github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= 139 | github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= 140 | github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= 141 | github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= 142 | github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= 143 | github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= 144 | github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s= 145 | github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= 146 | github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= 147 | github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= 148 | github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 149 | github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= 150 | github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 151 | github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= 152 | github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU= 153 | github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= 154 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 155 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 156 | github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 157 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 158 | github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= 159 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 160 | github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= 161 | github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= 162 | github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= 163 | github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= 164 | github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= 165 | go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= 166 | go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= 167 | go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= 168 | go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= 169 | golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 170 | golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 171 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= 172 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 173 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 174 | golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 175 | golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 176 | golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 177 | golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 178 | golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 179 | golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 180 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 181 | golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= 182 | golang.org/x/net v0.0.0-20190812203447-cdfb69ac37fc h1:gkKoSkUmnU6bpS/VhkuO27bzQeSA51uaEfbOW5dNb68= 183 | golang.org/x/net v0.0.0-20190812203447-cdfb69ac37fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 184 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs= 185 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 186 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 187 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 188 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 189 | golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 190 | golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 191 | golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 192 | golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 193 | golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 194 | golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 195 | golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 196 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 197 | golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f h1:25KHgbfyiSm6vwQLbM3zZIe1v9p/3ea4Rz+nnM5K/i4= 198 | golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 199 | golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 200 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 201 | golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= 202 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 203 | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ= 204 | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 205 | golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 206 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 207 | golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 208 | golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 209 | golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 210 | golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 211 | google.golang.org/appengine v1.1.0 h1:igQkv0AAhEIvTEpD5LIpAfav2eeVO9HBTjvKHVJPRSs= 212 | google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 213 | google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 214 | google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= 215 | google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= 216 | gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= 217 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 218 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= 219 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 220 | gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= 221 | gopkg.in/inf.v0 v0.9.0 h1:3zYtXIO92bvsdS3ggAdA8Gb4Azj0YU+TVY1uGYNFA8o= 222 | gopkg.in/inf.v0 v0.9.0/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= 223 | gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= 224 | gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= 225 | gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= 226 | gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 227 | gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= 228 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 229 | honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 230 | k8s.io/api v0.0.0-20190927115716-5d581ce610b0 h1:fwx2jAKNlXBQ8uiB3RNN5hVU/nEJTEBg/CfxoXEYri4= 231 | k8s.io/api v0.0.0-20190927115716-5d581ce610b0/go.mod h1:l2ZHS8QbgqodGx7yrYsOSwIxOR76BpGiW1OywXo9PFI= 232 | k8s.io/apimachinery v0.0.0-20190927035529-0104e33c351d h1:oYLB5Nk2IOm17BHdatnaWAgzNGzq/5dlWy7Bzo5Htdc= 233 | k8s.io/apimachinery v0.0.0-20190927035529-0104e33c351d/go.mod h1:grJJH0hgilA2pYoUiJcPu2EDUal95NTq1vpxxvMLSu8= 234 | k8s.io/client-go v11.0.0+incompatible h1:LBbX2+lOwY9flffWlJM7f1Ct8V2SRNiMRDFeiwnJo9o= 235 | k8s.io/client-go v11.0.0+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s= 236 | k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= 237 | k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= 238 | k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= 239 | k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= 240 | k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= 241 | k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= 242 | k8s.io/utils v0.0.0-20190923111123-69764acb6e8e h1:BXSmdH6S3YGLlhC89DZp+sNdYSmwNeDU6Xu5ZpzGOlM= 243 | k8s.io/utils v0.0.0-20190923111123-69764acb6e8e/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= 244 | sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= 245 | sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= 246 | sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= 247 | -------------------------------------------------------------------------------- /pkg/kubeclient/client.go: -------------------------------------------------------------------------------- 1 | package kubeclient 2 | 3 | import ( 4 | v1 "k8s.io/api/core/v1" 5 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 6 | "k8s.io/client-go/kubernetes" 7 | "k8s.io/client-go/tools/clientcmd" 8 | ) 9 | 10 | const kubeconfig = "/root/.kube/config" 11 | 12 | type Client struct { 13 | Clientset *kubernetes.Clientset 14 | } 15 | 16 | func NewClient() (*Client, error) { 17 | cfg, err := clientcmd.BuildConfigFromFlags("", kubeconfig) 18 | clientset, err := kubernetes.NewForConfig(cfg) 19 | if err != nil { 20 | panic(err.Error()) 21 | } 22 | 23 | client := &Client{ 24 | Clientset: clientset, 25 | } 26 | return client, nil 27 | } 28 | 29 | func (client *Client) ListNode() (*v1.NodeList, error) { 30 | nodeList, err := client.Clientset.CoreV1().Nodes().List(metav1.ListOptions{}) 31 | if err != nil { 32 | return nil, err 33 | } 34 | return nodeList, nil 35 | } 36 | 37 | func (client *Client) ListPod() (*v1.PodList, error) { 38 | podList, err := client.Clientset.CoreV1().Pods("").List(metav1.ListOptions{}) 39 | if err != nil { 40 | return nil, err 41 | } 42 | return podList, nil 43 | } 44 | -------------------------------------------------------------------------------- /pkg/kubeclient/interface.go: -------------------------------------------------------------------------------- 1 | package kubeclient 2 | 3 | import v1 "k8s.io/api/core/v1" 4 | 5 | type Interface interface { 6 | ListNode() (*v1.NodeList, error) 7 | 8 | ListPod() (*v1.PodList, error) 9 | } 10 | -------------------------------------------------------------------------------- /pkg/printers/table.go: -------------------------------------------------------------------------------- 1 | package printers 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "reflect" 7 | ) 8 | 9 | type bd struct { 10 | H rune // BOX DRAWINGS HORIZONTAL 11 | V rune // BOX DRAWINGS VERTICAL 12 | VH rune // BOX DRAWINGS VERTICAL AND HORIZONTAL 13 | HU rune // BOX DRAWINGS HORIZONTAL AND UP 14 | HD rune // BOX DRAWINGS HORIZONTAL AND DOWN 15 | VL rune // BOX DRAWINGS VERTICAL AND LEFT 16 | VR rune // BOX DRAWINGS VERTICAL AND RIGHT 17 | DL rune // BOX DRAWINGS DOWN AND LEFT 18 | DR rune // BOX DRAWINGS DOWN AND RIGHT 19 | UL rune // BOX DRAWINGS UP AND LEFT 20 | UR rune // BOX DRAWINGS UP AND RIGHT 21 | } 22 | 23 | var m = map[string]bd{ 24 | "ascii": bd{'-', '|', '+', '+', '+', '+', '+', '+', '+', '+', '+'}, 25 | "box-drawing": bd{'─', '│', '┼', '┴', '┬', '┤', '├', '┐', '┌', '┘', '└'}, 26 | "nothing": bd{}, 27 | } 28 | 29 | // Output formats slice of structs data and writes to standard output.(Using box drawing characters) 30 | func Output(slice interface{}) { 31 | fmt.Println(Table(slice)) 32 | } 33 | 34 | // Table formats slice of structs data and returns the resulting string.(Using box drawing characters) 35 | func Table(slice interface{}) string { 36 | coln, colw, rows, err := parse(slice) 37 | if err != nil { 38 | return err.Error() 39 | } 40 | table := table(coln, colw, rows, m["nothing"]) 41 | return table 42 | } 43 | 44 | func table(coln []string, colw []int, rows [][]string, b bd) (table string) { 45 | //head := [][]rune{[]rune{b.DR}, []rune{b.V}, []rune{b.VR}} 46 | head := [][]rune{[]rune{}, []rune{b.V}} 47 | bttm := []rune{b.UR} 48 | for i, v := range colw { 49 | //head[0] = append(head[0], []rune(repeat(v+2, b.H)+string(b.HD))...) 50 | //head[1] = append(head[1], []rune(" "+coln[i]+repeat(v-len(coln[i])+1, ' ')+string(b.V))...) 51 | //head[2] = append(head[2], []rune(repeat(v+2, b.H)+string(b.VH))...) 52 | //bttm = append(bttm, []rune(repeat(v+2, b.H)+string(b.HU))...) 53 | 54 | //head[0] = append(head[0], []rune(repeat(v+2, b.H)+string(b.HD))...) 55 | head[1] = append(head[1], []rune(" "+coln[i]+repeat(v-len(coln[i])+1, ' '))...) 56 | //head[2] = append(head[2], []rune(repeat(v+2, b.H)+string(b.VH))...) 57 | //bttm = append(bttm, []rune(repeat(v+2, b.H)+string(b.HU))...) 58 | } 59 | //head[0][len(head[0])-1] = b.DL 60 | //head[2][len(head[2])-1] = b.VL 61 | //bttm[len(bttm)-1] = b.UL 62 | 63 | var body [][]rune 64 | for _, r := range rows { 65 | row := []rune{b.V} 66 | for i, v := range colw { 67 | // handle non-ascii character 68 | l := length([]rune(r[i])) 69 | 70 | row = append(row, []rune(" "+r[i]+repeat(v-l+1, ' ')+string(b.V))...) 71 | } 72 | body = append(body, row) 73 | } 74 | 75 | for _, v := range head { 76 | table += string(v) + "\n" 77 | } 78 | for i, v := range body { 79 | table += string(v) 80 | if i+1 != len(body) { 81 | table += "\n" 82 | } 83 | //table += string(v) + "\n" 84 | } 85 | table += string(bttm) 86 | return table 87 | } 88 | 89 | func parse(slice interface{}) ( 90 | coln []string, // name of columns 91 | colw []int, // width of columns 92 | rows [][]string, // rows of content 93 | err error, 94 | ) { 95 | 96 | s, err := sliceconv(slice) 97 | if err != nil { 98 | return 99 | } 100 | for i, u := range s { 101 | v := reflect.ValueOf(u) 102 | t := reflect.TypeOf(u) 103 | if v.Kind() == reflect.Ptr { 104 | v = v.Elem() 105 | t = t.Elem() 106 | } 107 | if v.Kind() != reflect.Struct { 108 | err = errors.New("warning: table: items of slice should be on struct value") 109 | return 110 | } 111 | var row []string 112 | 113 | m := 0 // count of unexported field 114 | for n := 0; n < v.NumField(); n++ { 115 | if t.Field(n).PkgPath != "" { 116 | m++ 117 | continue 118 | } 119 | cn := t.Field(n).Name 120 | cv := fmt.Sprintf("%+v", v.FieldByName(cn).Interface()) 121 | if i == 0 { 122 | coln = append(coln, cn) 123 | colw = append(colw, len(cn)) 124 | } 125 | if colw[n-m] < len(cv) { 126 | colw[n-m] = len(cv) 127 | } 128 | 129 | row = append(row, cv) 130 | } 131 | rows = append(rows, row) 132 | } 133 | return coln, colw, rows, nil 134 | } 135 | 136 | func sliceconv(slice interface{}) ([]interface{}, error) { 137 | v := reflect.ValueOf(slice) 138 | if v.Kind() != reflect.Slice { 139 | return nil, errors.New("warning: sliceconv: param \"slice\" should be on slice value") 140 | } 141 | 142 | l := v.Len() 143 | r := make([]interface{}, l) 144 | for i := 0; i < l; i++ { 145 | r[i] = v.Index(i).Interface() 146 | } 147 | return r, nil 148 | } 149 | 150 | func repeat(time int, char rune) string { 151 | var s = make([]rune, time) 152 | for i := range s { 153 | s[i] = char 154 | } 155 | return string(s) 156 | } 157 | 158 | func length(r []rune) int { 159 | // CJK(Chinese, Japanese, Korean) 160 | type cjk struct { 161 | from rune 162 | to rune 163 | } 164 | 165 | // References: 166 | // - [Unicode Table](http://www.tamasoft.co.jp/en/general-info/unicode.html) 167 | // - [汉字 Unicode 编码范围](http://www.qqxiuzi.cn/zh/hanzi-unicode-bianma.php) 168 | 169 | var a = []cjk{ 170 | {0x2E80, 0x9FD0}, // Chinese, Hiragana, Katakana, ... 171 | {0xAC00, 0xD7A3}, // Hangul 172 | {0xF900, 0xFACE}, // Kanji 173 | {0xFE00, 0xFE6C}, // Fullwidth 174 | {0xFF00, 0xFF60}, // Fullwidth again 175 | {0x20000, 0x2FA1D}, // Extension 176 | // More? PRs are aways welcome here. 177 | } 178 | length := len(r) 179 | l: 180 | for _, v := range r { 181 | for _, c := range a { 182 | if v >= c.from && v <= c.to { 183 | length++ 184 | continue l 185 | } 186 | } 187 | } 188 | return length 189 | } 190 | -------------------------------------------------------------------------------- /pkg/types/resource.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // NodeResourceList xxx 4 | type NodeResourceList struct { 5 | Name string 6 | PodCount int 7 | 8 | CPU float64 9 | Memory float64 10 | 11 | // request resource 12 | CPURequests float64 13 | MemoryRequests float64 14 | 15 | // request resource usage 16 | CPURequestsUsage string 17 | MemoryRequestsUsage string 18 | 19 | // limit resource 20 | CPULimits float64 21 | MemoryLimits float64 22 | 23 | // limit resource usage 24 | CPULimitsUsage string 25 | MemoryLimitsUsage string 26 | } 27 | 28 | // NodeResourceColumnDefinitions xxx 29 | type NodeResourceColumnDefinitions struct { 30 | Name string 31 | PodCount int 32 | 33 | // requests resource 34 | CPURequests string 35 | MemoryRequests string 36 | 37 | // limits resource 38 | CPULimits string 39 | MemoryLimits string 40 | } 41 | -------------------------------------------------------------------------------- /pkg/types/taints.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // TaintsColumnDefinitions xxx 4 | type TaintsColumnDefinitions struct { 5 | Name string 6 | Status string 7 | Age string 8 | Version string 9 | Taints string 10 | } 11 | -------------------------------------------------------------------------------- /pkg/utils/resource.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "strconv" 5 | "strings" 6 | ) 7 | 8 | // ConvertCPUUnit is convert cpu unit to C. 9 | func ConvertCPUUnit(cpu string) (float64, error) { 10 | cpufloat := float64(0) 11 | if strings.Contains(cpu, "m") { 12 | rcpu, err := strconv.ParseFloat(strings.Split(cpu, "m")[0], 64) 13 | if err != nil { 14 | return float64(0), err 15 | } 16 | cpufloat = rcpu / 1000 17 | } else { 18 | rcpu, err := strconv.ParseFloat(cpu, 64) 19 | if err != nil { 20 | return float64(0), err 21 | } 22 | cpufloat = rcpu 23 | } 24 | return cpufloat, nil 25 | } 26 | 27 | // ConvertMemoryUnit is convert memory unit to Gi. 28 | func ConvertMemoryUnit(mem string) (float64, error) { 29 | memfloat := float64(0) 30 | if strings.Contains(mem, "Gi") { 31 | rmem, err := strconv.ParseFloat(strings.Split(mem, "Gi")[0], 64) 32 | if err != nil { 33 | return float64(0), err 34 | } 35 | memfloat = rmem 36 | } else if strings.Contains(mem, "Mi") { 37 | rmem, err := strconv.ParseFloat(strings.Split(mem, "Mi")[0], 64) 38 | if err != nil { 39 | return float64(0), err 40 | } 41 | memfloat = rmem / 1024 42 | } else if strings.Contains(mem, "Ki") { 43 | rmem, err := strconv.ParseFloat(strings.Split(mem, "Ki")[0], 64) 44 | if err != nil { 45 | return float64(0), err 46 | } 47 | memfloat = rmem / (1024 * 1024) 48 | } else if strings.Contains(mem, "m") { 49 | rmem, err := strconv.ParseFloat(strings.Split(mem, "m")[0], 64) 50 | if err != nil { 51 | return float64(0), err 52 | } 53 | memfloat = rmem / (1024 * 1024 * 1024 * 1000) 54 | } else { 55 | rmem, err := strconv.ParseFloat(mem, 64) 56 | if err != nil { 57 | return float64(0), err 58 | } 59 | memfloat = rmem / (1024 * 1024 * 1024) 60 | } 61 | return memfloat, nil 62 | } 63 | --------------------------------------------------------------------------------