Apply suggestions from code review
fix formatting based on review Co-Authored-By: Tejal Desai <tejal29@gmail.com>
This commit is contained in:
parent
78e9974694
commit
a86ffc8c57
|
|
@ -37,18 +37,18 @@ type AzureBlob struct {
|
|||
// Download context file from given azure blob storage url and unpack it to BuildContextDir
|
||||
func (b *AzureBlob) UnpackTarFromBuildContext() (string, error) {
|
||||
|
||||
//Get Azure_STORAGE_ACCESS_KEY from environment variables
|
||||
// Get Azure_STORAGE_ACCESS_KEY from environment variables
|
||||
accountKey := os.Getenv("AZURE_STORAGE_ACCESS_KEY")
|
||||
if len(accountKey) == 0 {
|
||||
return "", errors.New("AZURE_STORAGE_ACCESS_KEY environment variable is not set")
|
||||
}
|
||||
|
||||
//Get storage accoutname for Azure Blob Storage
|
||||
// Get storage accoutname for Azure Blob Storage
|
||||
u, _ := url.Parse(b.context)
|
||||
parts := azblob.NewBlobURLParts(*u)
|
||||
accountName := strings.Split(parts.Host, ".")[0]
|
||||
|
||||
//Generate credentail with accountname and accountkey
|
||||
// Generate credentail with accountname and accountkey
|
||||
credential, err := azblob.NewSharedKeyCredential(accountName, accountKey)
|
||||
if err != nil {
|
||||
return parts.Host, err
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ const (
|
|||
// ScratchEnvVars are the default environment variables needed for a scratch image.
|
||||
var ScratchEnvVars = []string{"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"}
|
||||
|
||||
//AzureBlobStorageHostRegEx is ReqEX for Valid azure blob storage host suffix in url for AzureCloud, AzureChinaCloud, AzureGermanCloud and AzureUSGovernment
|
||||
// AzureBlobStorageHostRegEx is ReqEX for Valid azure blob storage host suffix in url for AzureCloud, AzureChinaCloud, AzureGermanCloud and AzureUSGovernment
|
||||
var AzureBlobStorageHostRegEx = []string{"https://(.+?).blob.core.windows.net/(.+)",
|
||||
"https://(.+?).blob.core.chinacloudapi.cn/(.+)",
|
||||
"https://(.+?).blob.core.cloudapi.de/(.+)",
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ import (
|
|||
"github.com/GoogleContainerTools/kaniko/pkg/constants"
|
||||
)
|
||||
|
||||
//Validate if the host url provided is with correct suffix for AzureCloud, AzureChinaCloud, AzureGermanCloud and AzureUSGovernment
|
||||
//RegEX for supported suffix defined in constants.AzureBlobStorageHostRegEx
|
||||
// Validate if the host url provided is with correct suffix for AzureCloud, AzureChinaCloud, AzureGermanCloud and AzureUSGovernment
|
||||
// RegEX for supported suffix defined in constants.AzureBlobStorageHostRegEx
|
||||
func ValidAzureBlobStorageHost(context string) bool {
|
||||
for _, re := range constants.AzureBlobStorageHostRegEx {
|
||||
validBlobURL := regexp.MustCompile(re)
|
||||
|
|
|
|||
Loading…
Reference in New Issue