From afd99ec912f0725d69f3e133bcc828d33fb39f01 Mon Sep 17 00:00:00 2001 From: Abe Winter Date: Thu, 7 Nov 2024 13:31:52 -0500 Subject: [PATCH 1/2] show available platforms when 'module download' fails --- cli/module_registry.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cli/module_registry.go b/cli/module_registry.go index 8b05b765624..3862b8bb83d 100644 --- a/cli/module_registry.go +++ b/cli/module_registry.go @@ -977,17 +977,22 @@ func DownloadModuleAction(c *cli.Context) error { return fmt.Errorf("version %s not found in versions for module", requestedVersion) } } - infof(c.App.ErrWriter, "found version %s", ver.Version) + infof(c.App.ErrWriter, "Found version %s", ver.Version) if len(ver.Files) == 0 { return fmt.Errorf("version %s has 0 files uploaded", ver.Version) } platform := c.String(moduleFlagPlatform) if platform == "" { platform = fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH) - infof(c.App.ErrWriter, "using default platform %s", platform) + infof(c.App.ErrWriter, "Using current system platform %s", platform) } if !slices.ContainsFunc(ver.Files, func(file *apppb.Uploads) bool { return file.Platform == platform }) { - return fmt.Errorf("platform %s not present for version %s", platform, ver.Version) + availablePlatforms := make([]string, 0, len(ver.Files)) + for _, upload := range ver.Files { + availablePlatforms = append(availablePlatforms, upload.Platform) + } + return fmt.Errorf("Platform %s not present for version %s. Available platforms: %s", + platform, ver.Version, strings.Join(availablePlatforms, ", ")) } include := true packageType := packagespb.PackageType_PACKAGE_TYPE_MODULE From 4b15f06fbbaaecf3dc4cac4728ab1da7e9cfa616 Mon Sep 17 00:00:00 2001 From: Abe Winter Date: Thu, 7 Nov 2024 13:41:38 -0500 Subject: [PATCH 2/2] ugh linter --- cli/module_registry.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/module_registry.go b/cli/module_registry.go index 3862b8bb83d..41779ad1d90 100644 --- a/cli/module_registry.go +++ b/cli/module_registry.go @@ -991,7 +991,7 @@ func DownloadModuleAction(c *cli.Context) error { for _, upload := range ver.Files { availablePlatforms = append(availablePlatforms, upload.Platform) } - return fmt.Errorf("Platform %s not present for version %s. Available platforms: %s", + return fmt.Errorf("platform %s not present for version %s. available platforms: %s", platform, ver.Version, strings.Join(availablePlatforms, ", ")) } include := true