forked from linuxkit/linuxkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpush_azure.go
More file actions
46 lines (36 loc) · 1.15 KB
/
Copy pathpush_azure.go
File metadata and controls
46 lines (36 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"github.com/spf13/cobra"
)
func pushAzureCmd() *cobra.Command {
var (
resourceGroup string
accountName string
)
cmd := &cobra.Command{
Use: "azure",
Short: "push image to Azure",
Long: `Push image to Azure.
First argument specifies the path to a VHD. It will be uploaded to an Azure Storage Account.
Relies on the following environment variables:
AZURE_SUBSCRIPTION_ID
AZURE_TENANT_ID
AZURE_CLIENT_ID
AZURE_CLIENT_SECRET
`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
path := args[0]
subscriptionID := getEnvVarOrExit("AZURE_SUBSCRIPTION_ID")
tenantID := getEnvVarOrExit("AZURE_TENANT_ID")
clientID := getEnvVarOrExit("AZURE_CLIENT_ID")
clientSecret := getEnvVarOrExit("AZURE_CLIENT_SECRET")
initializeAzureClients(subscriptionID, tenantID, clientID, clientSecret)
uploadVMImage(resourceGroup, accountName, path)
return nil
},
}
cmd.Flags().StringVar(&resourceGroup, "resource-group", "", "Name of resource group to be used for VM")
cmd.Flags().StringVar(&accountName, "storage-account", "", "Name of the storage account")
return cmd
}