-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OCM-5281 | Feat | Add region validation from ocm-shards and list regi…
…ons command (#586) * Add region validation from ocm-shards and list regions command * Fixed mior debug changes * Marked rh region list flag hidden in cmd * Formatting change in example section in cmd file
- Loading branch information
Showing
5 changed files
with
70 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package rhRegion | ||
|
||
import ( | ||
"fmt" | ||
sdk "github.com/openshift-online/ocm-sdk-go" | ||
|
||
"github.com/openshift-online/ocm-cli/pkg/config" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var Cmd = &cobra.Command{ | ||
Use: "rh-regions", | ||
Short: "List available OCM regions", | ||
Long: "List available OCM regions", | ||
Example: ` # List all supported OCM regions | ||
ocm list rh-regions`, | ||
RunE: run, | ||
Hidden: true, | ||
} | ||
|
||
func run(cmd *cobra.Command, argv []string) error { | ||
// Load the configuration file: | ||
cfg, err := config.Load() | ||
if err != nil { | ||
return fmt.Errorf("Can't load config file: %v", err) | ||
} | ||
if cfg == nil { | ||
return fmt.Errorf("Not logged in, run the 'login' command") | ||
} | ||
|
||
regions, err := sdk.GetRhRegions(cfg.URL) | ||
if err != nil { | ||
return fmt.Errorf("Failed to get OCM regions: %w", err) | ||
} | ||
|
||
for regionName := range regions { | ||
fmt.Println(regionName) | ||
} | ||
return nil | ||
|
||
} |
This file contains 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 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 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