This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skipping container build if containerfile is not present (#5)
* Skipping container build if containerfile is not present * Support for task parts * Upgrade version of golangci-lint * Satisfy golangci-lint (makezero)
- Loading branch information
Showing
12 changed files
with
119 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,45 @@ | ||
package container | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/magefile/mage/mg" | ||
"github.com/magefile/mage/sh" | ||
"github.com/wavesoftware/go-ensure" | ||
"github.com/wavesoftware/go-magetasks" | ||
"github.com/wavesoftware/go-magetasks/config" | ||
"github.com/wavesoftware/go-magetasks/internal" | ||
"github.com/wavesoftware/go-magetasks/pkg/tasks" | ||
) | ||
|
||
// Images builds a OCI images of binaries. | ||
func Images() { | ||
mg.Deps(magetasks.Binary) | ||
|
||
ce, err := resolveContainerEngine() | ||
ensure.NoError(err) | ||
if len(config.Binaries) > 0 { | ||
t := tasks.StartMultiline("📦", "Packaging OCI images") | ||
errs := make([]error, 0) | ||
for _, binary := range config.Binaries { | ||
p := t.Part(binary.Name) | ||
cf := containerFile(binary) | ||
if internal.DontExists(cf) { | ||
p.Skip(fmt.Sprintf("containerfile %s don't exist", cf)) | ||
continue | ||
} | ||
st := p.Starting() | ||
args := []string{ | ||
"build", | ||
"-f", containerFile(binary), | ||
"-t", imageName(binary), | ||
".", | ||
"build", "-f", cf, "-t", imageName(binary), ".", | ||
} | ||
err := sh.RunV(ce, args...) | ||
err := sh.RunV(containerEngine(), args...) | ||
st.Done(err) | ||
errs = append(errs, err) | ||
} | ||
t.End(errs...) | ||
} | ||
} | ||
|
||
func containerEngine() string { | ||
ce, err := resolveContainerEngine() | ||
ensure.NoError(err) | ||
return ce | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CONTAINER_BASENAME=quay.io/cardil/magetasks-example- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/wavesoftware/go-magetasks/tests/example/internal" | ||
) | ||
|
||
func main() { | ||
fmt.Printf("Dummy code! Version: %s\n", internal.Version) | ||
} |