Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Add option --baseurl to override default endpoint #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions vhdUploadCmdHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ import (
"github.com/Microsoft/azure-vhd-utils/vhdcore/common"
"github.com/Microsoft/azure-vhd-utils/vhdcore/diskstream"
"github.com/Microsoft/azure-vhd-utils/vhdcore/validator"
"gopkg.in/urfave/cli.v1"
cli "gopkg.in/urfave/cli.v1"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change? It should be usable under just v1.

)

func vhdUploadCmdHandler() cli.Command {
return cli.Command{
Name: "upload",
Usage: "Upload a local VHD to Azure storage as page blob",
Flags: []cli.Flag{
cli.StringFlag{
Name: "baseurl",
Usage: "Base URL for storage endpoint",
},
cli.StringFlag{
Name: "localvhdpath",
Usage: "Path to source VHD in the local machine.",
Expand Down Expand Up @@ -55,6 +59,11 @@ func vhdUploadCmdHandler() cli.Command {
Action: func(c *cli.Context) error {
const PageBlobPageSize int64 = 2 * 1024 * 1024

baseURL := c.String("baseurl")
if baseURL == "" {
baseURL = storage.DefaultBaseURL
}

localVHDPath := c.String("localvhdpath")
if localVHDPath == "" {
return errors.New("Missing required argument --localvhdpath")
Expand Down Expand Up @@ -106,7 +115,7 @@ func vhdUploadCmdHandler() cli.Command {
}
defer diskStream.Close()

storageClient, err := storage.NewBasicClient(stgAccountName, stgAccountKey)
storageClient, err := storage.NewClient(stgAccountName, stgAccountKey, baseURL, storage.DefaultAPIVersion, true)
if err != nil {
return err
}
Expand Down