Skip to content

Commit

Permalink
Add DockerfileContent to allow for an in-memory Dockerfile to be co…
Browse files Browse the repository at this point in the history
…nsumed
  • Loading branch information
kylecarbs committed Jun 30, 2023
1 parent 1c7cb91 commit c825422
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions pkg/config/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type KanikoOptions struct {
Git KanikoGitOptions
IgnorePaths multiArg
DockerfilePath string
DockerfileContent string
SrcContext string
SnapshotMode string
SnapshotModeDeprecated string
Expand Down
21 changes: 13 additions & 8 deletions pkg/dockerfile/dockerfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,21 @@ import (
func ParseStages(opts *config.KanikoOptions) ([]instructions.Stage, []instructions.ArgCommand, error) {
var err error
var d []uint8
match, _ := regexp.MatchString("^https?://", opts.DockerfilePath)
if match {
response, e := http.Get(opts.DockerfilePath) //nolint:noctx
if e != nil {
return nil, nil, e
}
d, err = ioutil.ReadAll(response.Body)
if opts.DockerfileContent != "" {
d = []uint8(opts.DockerfileContent)
} else {
d, err = ioutil.ReadFile(opts.DockerfilePath)
match, _ := regexp.MatchString("^https?://", opts.DockerfilePath)
if match {
response, e := http.Get(opts.DockerfilePath) //nolint:noctx
if e != nil {
return nil, nil, e
}
d, err = ioutil.ReadAll(response.Body)
} else {
d, err = ioutil.ReadFile(opts.DockerfilePath)
}
}


if err != nil {
return nil, nil, errors.Wrap(err, fmt.Sprintf("reading dockerfile at path %s", opts.DockerfilePath))
Expand Down

0 comments on commit c825422

Please sign in to comment.