mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-09-30 19:04:02 +02:00
Created Git buildcontext
This commit is contained in:
@@ -18,8 +18,9 @@ package buildcontext
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/constants"
|
||||
"strings"
|
||||
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/constants"
|
||||
)
|
||||
|
||||
// BuildContext unifies calls to download and unpack the build context.
|
||||
@@ -41,6 +42,8 @@ func GetBuildContext(srcContext string) (BuildContext, error) {
|
||||
return &S3{context: context}, nil
|
||||
case constants.LocalDirBuildContextPrefix:
|
||||
return &Dir{context: context}, nil
|
||||
case constants.GitBuildContextPrefix:
|
||||
return &Git{context: context}, nil
|
||||
}
|
||||
return nil, errors.New("unknown build context prefix provided, please use one of the following: gs://, dir://, s3://")
|
||||
return nil, errors.New("unknown build context prefix provided, please use one of the following: gs://, dir://, s3://, git://")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
Copyright 2018 Google LLC
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package buildcontext
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/GoogleContainerTools/kaniko/pkg/constants"
|
||||
git "gopkg.in/src-d/go-git.v4"
|
||||
)
|
||||
|
||||
// Git unifies calls to download and unpack the build context.
|
||||
type Git struct {
|
||||
context string
|
||||
}
|
||||
|
||||
// UnpackTarFromBuildContext will provide the directory where Git Repository is Cloned
|
||||
func (g *Git) UnpackTarFromBuildContext() (string, error) {
|
||||
directory := constants.BuildContextDir
|
||||
_, err := git.PlainClone(directory, false, &git.CloneOptions{
|
||||
URL: "https://" + g.context,
|
||||
Progress: os.Stdout,
|
||||
})
|
||||
return directory, err
|
||||
}
|
||||
@@ -54,6 +54,7 @@ const (
|
||||
GCSBuildContextPrefix = "gs://"
|
||||
S3BuildContextPrefix = "s3://"
|
||||
LocalDirBuildContextPrefix = "dir://"
|
||||
GitBuildContextPrefix = "git://"
|
||||
|
||||
// DefaultHOMEValue is the default value Docker sets for $HOME
|
||||
HOME = "HOME"
|
||||
|
||||
Reference in New Issue
Block a user