(api *userconfig.API, compute userconfig.Compute, maxMemMap map[string]kresource.Quantity)
| 155 | } |
| 156 | |
| 157 | func nodeGroupResourcesTable(api *userconfig.API, compute userconfig.Compute, maxMemMap map[string]kresource.Quantity) string { |
| 158 | var skippedNodeGroups []string |
| 159 | var nodeGroupResourceRows [][]interface{} |
| 160 | |
| 161 | showGPU := false |
| 162 | showInf := false |
| 163 | if compute.GPU > 0 { |
| 164 | showGPU = true |
| 165 | } |
| 166 | if compute.Inf > 0 { |
| 167 | showInf = true |
| 168 | } |
| 169 | |
| 170 | for _, ng := range config.ClusterConfig.NodeGroups { |
| 171 | nodeCPU, nodeMem, nodeGPU, nodeInf := getNodeCapacity(ng.InstanceType, maxMemMap) |
| 172 | if nodeGPU > 0 { |
| 173 | showGPU = true |
| 174 | } |
| 175 | if nodeInf > 0 { |
| 176 | showInf = true |
| 177 | } |
| 178 | |
| 179 | if api.NodeGroups != nil && !slices.HasString(api.NodeGroups, ng.Name) { |
| 180 | skippedNodeGroups = append(skippedNodeGroups, ng.Name) |
| 181 | } else { |
| 182 | nodeGroupResourceRows = append(nodeGroupResourceRows, []interface{}{ng.Name, ng.InstanceType, nodeCPU, k8s.ToMiFloorStr(nodeMem), nodeGPU, nodeInf}) |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | nodeGroupResourceRowsTable := table.Table{ |
| 187 | Headers: []table.Header{ |
| 188 | {Title: "node group"}, |
| 189 | {Title: "instance type"}, |
| 190 | {Title: "CPU"}, |
| 191 | {Title: "memory"}, |
| 192 | {Title: "GPU", Hidden: !showGPU}, |
| 193 | {Title: "Inf", Hidden: !showInf}, |
| 194 | }, |
| 195 | Rows: nodeGroupResourceRows, |
| 196 | } |
| 197 | |
| 198 | out := nodeGroupResourceRowsTable.MustFormat() |
| 199 | if len(skippedNodeGroups) > 0 { |
| 200 | out += fmt.Sprintf("\nthe following %s skipped (based on the api configuration's %s field): %s", s.PluralCustom("node group was", "node groups were", len(skippedNodeGroups)), userconfig.NodeGroupsKey, strings.Join(skippedNodeGroups, ", ")) |
| 201 | } |
| 202 | |
| 203 | return out |
| 204 | } |
no test coverage detected