Documentation ¶
Index ¶
- Constants
- Variables
- func ExecuteCreateDeployment(cmd *cobra.Command, args []string) error
- func GetAzureCmd() *cobra.Command
- func GetAzureCreateDeploymentCmd() *cobra.Command
- func GetAzureCreateVMCmd() *cobra.Command
- func GetAzureDestroyCmd() *cobra.Command
- func GetAzureListResourcesCmd() *cobra.Command
- func GetAzureListSKUsCmd() *cobra.Command
- func GetAzureListSubscriptionsCmd() *cobra.Command
- func InitializeCommands()
- func ListSubscriptions(configFilePath string, setSubscription bool) error
- type ConfigDeployment
- type Subscription
- type SubscriptionTable
Constants ¶
View Source
const ( RetryTimeout = 2 * time.Second DefaultSSHPort = 22 )
Variables ¶
View Source
var AzureCmd = &cobra.Command{
Use: "azure",
Short: "Azure-related commands",
Long: `Commands for interacting with Azure resources.`,
}
View Source
var AzureListResourcesCmd = &cobra.Command{ Use: "list-resources", Short: "List Azure resources", Long: `List all resources in a subscription or specific resource group.`, Run: func(cmd *cobra.Command, args []string) { verbose, _ := cmd.Flags().GetBool("verbose") log := logger.Get() log.SetVerbose(verbose) projectPrefix := viper.GetString("general.project_prefix") uniqueID := viper.GetString("general.unique_id") tags := azure_provider.GenerateTags(projectPrefix, uniqueID) log.Info("Listing Azure resources...") azureProvider, err := azure_provider.NewAzureProviderFunc( cmd.Context(), viper.GetString("azure.subscription_id"), ) if err != nil { log.Fatal("failed to assert provider to common.AzureProviderer") } allFlag, _ := cmd.Flags().GetBool("all") resourceGroup, _ := cmd.Flags().GetString("resource-group") if !allFlag && resourceGroup == "" { log.Fatal("Either --all or --resource-group must be specified") } if allFlag && resourceGroup != "" { log.Fatal("Cannot use both --all and --resource-group flags simultaneously") } log.Info("Contacting Azure API...") startTime := time.Now() var resources []interface{} if err != nil { log.Fatalf("Failed to get subscription ID: %v", err) } if allFlag { resources, err = azureProvider. ListAllResourcesInSubscription(cmd.Context(), tags) } else { resources, err = azureProvider.GetResources(cmd.Context(), resourceGroup, tags) } _ = resources if err != nil { switch { case isNetworkError(err): log.Fatal("Network is down. Please check your internet connection and try again.") case isAzureServiceError(err): log.Fatalf("Azure service error: %v", err) default: log.Fatalf("Failed to query resources: %v", err) } } log.Infof("Azure API contacted (took %s)", time.Since(startTime).Round(time.Millisecond)) }, }
View Source
var AzureListSubscriptionsCmd = &cobra.Command{
Use: "list-subscriptions",
Short: "List Azure subscriptions",
Long: `List all subscriptions and optionally select one to use.`,
Run: runListSubscriptions,
}
AzureListSubscriptionsCmd represents the command to list Azure subscriptions
Functions ¶
func ExecuteCreateDeployment ¶
func GetAzureCmd ¶
func GetAzureCreateVMCmd ¶
func GetAzureDestroyCmd ¶
func GetAzureListSKUsCmd ¶
func InitializeCommands ¶
func InitializeCommands()
func ListSubscriptions ¶
Types ¶
type ConfigDeployment ¶
type Subscription ¶
type Subscription struct { DisplayName string ID string State string SubscriptionID string TenantID string }
Subscription represents an Azure subscription
type SubscriptionTable ¶
type SubscriptionTable struct { Title string Columns []display.DisplayColumn LogFile string DataType interface{} }
SubscriptionTable defines the structure for displaying subscription data
Click to show internal directories.
Click to hide internal directories.