Merge pull request #698 from takmatsu/s3-endpoint
Add support for S3 custom endpoint
This commit is contained in:
commit
8acab90dec
|
|
@ -19,6 +19,7 @@ package buildcontext
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/GoogleContainerTools/kaniko/pkg/constants"
|
"github.com/GoogleContainerTools/kaniko/pkg/constants"
|
||||||
"github.com/GoogleContainerTools/kaniko/pkg/util"
|
"github.com/GoogleContainerTools/kaniko/pkg/util"
|
||||||
|
|
@ -36,9 +37,21 @@ type S3 struct {
|
||||||
// UnpackTarFromBuildContext download and untar a file from s3
|
// UnpackTarFromBuildContext download and untar a file from s3
|
||||||
func (s *S3) UnpackTarFromBuildContext() (string, error) {
|
func (s *S3) UnpackTarFromBuildContext() (string, error) {
|
||||||
bucket, item := util.GetBucketAndItem(s.context)
|
bucket, item := util.GetBucketAndItem(s.context)
|
||||||
sess, err := session.NewSessionWithOptions(session.Options{
|
option := session.Options{
|
||||||
SharedConfigState: session.SharedConfigEnable,
|
SharedConfigState: session.SharedConfigEnable,
|
||||||
})
|
}
|
||||||
|
endpoint := os.Getenv(constants.S3EndpointEnv)
|
||||||
|
forcePath := false
|
||||||
|
if strings.ToLower(os.Getenv(constants.S3ForcePathStyle)) == "true" {
|
||||||
|
forcePath = true
|
||||||
|
}
|
||||||
|
if endpoint != "" {
|
||||||
|
option.Config = aws.Config{
|
||||||
|
Endpoint: aws.String(endpoint),
|
||||||
|
S3ForcePathStyle: aws.Bool(forcePath),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sess, err := session.NewSessionWithOptions(option)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bucket, err
|
return bucket, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,10 @@ const (
|
||||||
|
|
||||||
// Name of the .dockerignore file
|
// Name of the .dockerignore file
|
||||||
Dockerignore = ".dockerignore"
|
Dockerignore = ".dockerignore"
|
||||||
|
|
||||||
|
// S3 Custom endpoint ENV name
|
||||||
|
S3EndpointEnv = "S3_ENDPOINT"
|
||||||
|
S3ForcePathStyle = "S3_FORCE_PATH_STYLE"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ScratchEnvVars are the default environment variables needed for a scratch image.
|
// ScratchEnvVars are the default environment variables needed for a scratch image.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue