Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for insecure docker registry #131

Merged
merged 2 commits into from
Apr 20, 2018
Merged
Show file tree
Hide file tree
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
18 changes: 10 additions & 8 deletions cmd/executor/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ import (
)

var (
dockerfilePath string
destination string
srcContext string
snapshotMode string
bucket string
logLevel string
force bool
dockerfilePath string
destination string
srcContext string
snapshotMode string
bucket string
dockerInsecureSkipTLSVerify bool
logLevel string
force bool
)

func init() {
Expand All @@ -47,6 +48,7 @@ func init() {
RootCmd.PersistentFlags().StringVarP(&bucket, "bucket", "b", "", "Name of the GCS bucket from which to access build context as tarball.")
RootCmd.PersistentFlags().StringVarP(&destination, "destination", "d", "", "Registry the final image should be pushed to (ex: gcr.io/test/example:latest)")
RootCmd.PersistentFlags().StringVarP(&snapshotMode, "snapshotMode", "", "full", "Set this flag to change the file attributes inspected during snapshotting")
RootCmd.PersistentFlags().BoolVarP(&dockerInsecureSkipTLSVerify, "insecure-skip-tls-verify", "", false, "Push to insecure registry ignoring TLS verify")
RootCmd.PersistentFlags().StringVarP(&logLevel, "verbosity", "v", constants.DefaultLogLevel, "Log level (debug, info, warn, error, fatal, panic")
RootCmd.PersistentFlags().BoolVarP(&force, "force", "", false, "Force building outside of a container")
}
Expand All @@ -70,7 +72,7 @@ var RootCmd = &cobra.Command{
}
logrus.Warn("kaniko is being run outside of a container. This can have dangerous effects on your system")
}
if err := executor.DoBuild(dockerfilePath, srcContext, destination, snapshotMode); err != nil {
if err := executor.DoBuild(dockerfilePath, srcContext, destination, snapshotMode, dockerInsecureSkipTLSVerify); err != nil {
logrus.Error(err)
os.Exit(1)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/sirupsen/logrus"
)

func DoBuild(dockerfilePath, srcContext, destination, snapshotMode string) error {
func DoBuild(dockerfilePath, srcContext, destination, snapshotMode string, dockerInsecureSkipTLSVerify bool) error {
// Parse dockerfile and unpack base image to root
d, err := ioutil.ReadFile(dockerfilePath)
if err != nil {
Expand Down Expand Up @@ -113,7 +113,7 @@ func DoBuild(dockerfilePath, srcContext, destination, snapshotMode string) error
if err := setDefaultEnv(); err != nil {
return err
}
return image.PushImage(sourceImage, destination)
return image.PushImage(sourceImage, destination, dockerInsecureSkipTLSVerify)
}

func getHasher(snapshotMode string) (func(string) (string, error), error) {
Expand Down
5 changes: 3 additions & 2 deletions pkg/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func NewSourceImage(srcImg string) (*img.MutableSource, error) {
}

// PushImage pushes the final image
func PushImage(ms *img.MutableSource, destImg string) error {
func PushImage(ms *img.MutableSource, destImg string, dockerInsecureSkipTLSVerify bool) error {
srcRef := &img.ProxyReference{
ImageReference: nil,
Src: ms,
Expand All @@ -65,7 +65,8 @@ func PushImage(ms *img.MutableSource, destImg string) error {

opts := &copy.Options{
DestinationCtx: &types.SystemContext{
DockerRegistryUserAgent: fmt.Sprintf("kaniko/executor-%s", version.Version()),
DockerRegistryUserAgent: fmt.Sprintf("kaniko/executor-%s", version.Version()),
DockerInsecureSkipTLSVerify: dockerInsecureSkipTLSVerify,
},
}
return copy.Image(policyContext, destRef, srcRef, opts)
Expand Down