(chartRef string, _ string)
| 251 | } |
| 252 | |
| 253 | func compVersionFlag(chartRef string, _ string) ([]string, cobra.ShellCompDirective) { |
| 254 | chartInfo := strings.Split(chartRef, "/") |
| 255 | if len(chartInfo) != 2 { |
| 256 | return nil, cobra.ShellCompDirectiveNoFileComp |
| 257 | } |
| 258 | |
| 259 | repoName := chartInfo[0] |
| 260 | chartName := chartInfo[1] |
| 261 | |
| 262 | path := filepath.Join(settings.RepositoryCache, helmpath.CacheIndexFile(repoName)) |
| 263 | |
| 264 | var versions []string |
| 265 | if indexFile, err := repo.LoadIndexFile(path); err == nil { |
| 266 | for _, details := range indexFile.Entries[chartName] { |
| 267 | appVersion := details.AppVersion |
| 268 | appVersionDesc := "" |
| 269 | if appVersion != "" { |
| 270 | appVersionDesc = fmt.Sprintf("App: %s, ", appVersion) |
| 271 | } |
| 272 | created := details.Created.Format("January 2, 2006") |
| 273 | createdDesc := "" |
| 274 | if created != "" { |
| 275 | createdDesc = fmt.Sprintf("Created: %s ", created) |
| 276 | } |
| 277 | deprecated := "" |
| 278 | if details.Deprecated { |
| 279 | deprecated = "(deprecated)" |
| 280 | } |
| 281 | versions = append(versions, fmt.Sprintf("%s\t%s%s%s", details.Version, appVersionDesc, createdDesc, deprecated)) |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | return versions, cobra.ShellCompDirectiveNoFileComp |
| 286 | } |
| 287 | |
| 288 | // addKlogFlags adds flags from k8s.io/klog |
| 289 | // marks the flags as hidden to avoid polluting the help text |
no test coverage detected
searching dependent graphs…