Apply suggestions from code review

fix formatting based on review

Co-Authored-By: Tejal Desai <tejal29@gmail.com>
This commit is contained in:
Tao Yang 2019-10-21 10:19:32 +08:00 committed by GitHub
parent 78e9974694
commit a86ffc8c57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View File

@ -37,18 +37,18 @@ type AzureBlob struct {
// Download context file from given azure blob storage url and unpack it to BuildContextDir // Download context file from given azure blob storage url and unpack it to BuildContextDir
func (b *AzureBlob) UnpackTarFromBuildContext() (string, error) { 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") accountKey := os.Getenv("AZURE_STORAGE_ACCESS_KEY")
if len(accountKey) == 0 { if len(accountKey) == 0 {
return "", errors.New("AZURE_STORAGE_ACCESS_KEY environment variable is not set") 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) u, _ := url.Parse(b.context)
parts := azblob.NewBlobURLParts(*u) parts := azblob.NewBlobURLParts(*u)
accountName := strings.Split(parts.Host, ".")[0] accountName := strings.Split(parts.Host, ".")[0]
//Generate credentail with accountname and accountkey // Generate credentail with accountname and accountkey
credential, err := azblob.NewSharedKeyCredential(accountName, accountKey) credential, err := azblob.NewSharedKeyCredential(accountName, accountKey)
if err != nil { if err != nil {
return parts.Host, err return parts.Host, err

View File

@ -80,7 +80,7 @@ const (
// ScratchEnvVars are the default environment variables needed for a scratch image. // 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"} 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/(.+)", var AzureBlobStorageHostRegEx = []string{"https://(.+?).blob.core.windows.net/(.+)",
"https://(.+?).blob.core.chinacloudapi.cn/(.+)", "https://(.+?).blob.core.chinacloudapi.cn/(.+)",
"https://(.+?).blob.core.cloudapi.de/(.+)", "https://(.+?).blob.core.cloudapi.de/(.+)",

View File

@ -22,8 +22,8 @@ import (
"github.com/GoogleContainerTools/kaniko/pkg/constants" "github.com/GoogleContainerTools/kaniko/pkg/constants"
) )
//Validate if the host url provided is with correct suffix for AzureCloud, AzureChinaCloud, AzureGermanCloud and AzureUSGovernment // Validate if the host url provided is with correct suffix for AzureCloud, AzureChinaCloud, AzureGermanCloud and AzureUSGovernment
//RegEX for supported suffix defined in constants.AzureBlobStorageHostRegEx // RegEX for supported suffix defined in constants.AzureBlobStorageHostRegEx
func ValidAzureBlobStorageHost(context string) bool { func ValidAzureBlobStorageHost(context string) bool {
for _, re := range constants.AzureBlobStorageHostRegEx { for _, re := range constants.AzureBlobStorageHostRegEx {
validBlobURL := regexp.MustCompile(re) validBlobURL := regexp.MustCompile(re)