Skip to content

Commit

Permalink
Revert "[elastic-agent] Fix docker tar.gz generation for complete ima…
Browse files Browse the repository at this point in the history
…ge (#27621)"

This reverts commit 89e415d.
  • Loading branch information
mdelapenya committed Oct 19, 2021
1 parent 0971fe7 commit 08c6c20
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
7 changes: 3 additions & 4 deletions dev-tools/mage/dockerbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (b *dockerBuilder) Build() error {
return errors.Wrap(err, "failed to build docker")
}

if err := b.dockerSave(tag, variant); err != nil {
if err := b.dockerSave(tag); err != nil {
return errors.Wrap(err, "failed to save docker as artifact")
}
}
Expand Down Expand Up @@ -209,7 +209,7 @@ func (b *dockerBuilder) dockerBuild(variant string) (string, error) {
return taggedImageName, sh.Run("docker", "build", "-t", taggedImageName, b.buildDir)
}

func (b *dockerBuilder) dockerSave(tag string, variant string) error {
func (b *dockerBuilder) dockerSave(tag string) error {
if _, err := os.Stat(distributionsDir); os.IsNotExist(err) {
err := os.MkdirAll(distributionsDir, 0750)
if err != nil {
Expand All @@ -220,8 +220,7 @@ func (b *dockerBuilder) dockerSave(tag string, variant string) error {
outputFile := b.OutputFile
if outputFile == "" {
outputTar, err := b.Expand(defaultBinaryName+".docker.tar.gz", map[string]interface{}{
"Name": b.imageName,
"Variant": variant,
"Name": b.imageName,
})
if err != nil {
return err
Expand Down
6 changes: 2 additions & 4 deletions dev-tools/mage/pkgtypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const (
packageStagingDir = "build/package"

// defaultBinaryName specifies the output file for zip and tar.gz.
defaultBinaryName = "{{.Name}}-{{if .Variant}}{{.Variant}}-{{end}}{{.Version}}{{if .Snapshot}}-SNAPSHOT{{end}}{{if .OS}}-{{.OS}}{{end}}{{if .Arch}}-{{.Arch}}{{end}}"
defaultBinaryName = "{{.Name}}-{{.Version}}{{if .Snapshot}}-SNAPSHOT{{end}}{{if .OS}}-{{.OS}}{{end}}{{if .Arch}}-{{.Arch}}{{end}}"
)

// PackageType defines the file format of the package (e.g. zip, rpm, etc).
Expand Down Expand Up @@ -329,10 +329,8 @@ func (s *PackageSpec) ExtraVar(key, value string) {

// Expand expands a templated string using data from the spec.
func (s PackageSpec) Expand(in string, args ...map[string]interface{}) (string, error) {
// Assign a default value for variant since it's not always passed in
return expandTemplate("inline", in, FuncMap,

EnvMap(append([]map[string]interface{}{s.evalContext, {"Variant": ""}, s.toMap()}, args...)...))
EnvMap(append([]map[string]interface{}{s.evalContext, s.toMap()}, args...)...))
}

// MustExpand expands a templated string using data from the spec. It panics if
Expand Down

0 comments on commit 08c6c20

Please sign in to comment.