-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add region validation from ocm-shards and list regions command
- Loading branch information
Showing
5 changed files
with
71 additions
and
5 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,39 @@ | ||
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, | ||
} | ||
|
||
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