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 cross-compilation support #153

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 5 additions & 3 deletions cmd/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

var fromImageFilename string

var imageArch string
var created timeValue

type timeValue time.Time
Expand All @@ -39,7 +40,7 @@ var imageCmd = &cobra.Command{
Short: "Generate an image.json file from a image configuration and layers",
Args: cobra.MinimumNArgs(3),
Run: func(cmd *cobra.Command, args []string) {
err := image(args[0], args[1], fromImageFilename, args[2:], (time.Time)(created))
err := image(args[0], args[1], fromImageFilename, args[2:], imageArch, (time.Time)(created))
if err != nil {
fmt.Fprintf(os.Stderr, "%s", err)
os.Exit(1)
Expand Down Expand Up @@ -107,7 +108,7 @@ func imageFromManifest(outputFilename, manifestFilename string, blobsFilename st
return nil
}

func image(outputFilename, imageConfigPath string, fromImageFilename string, layerPaths []string, created time.Time) error {
func image(outputFilename, imageConfigPath string, fromImageFilename string, layerPaths []string, arch string, created time.Time) error {
var imageConfig v1.ImageConfig
var image types.Image

Expand All @@ -133,7 +134,7 @@ func image(outputFilename, imageConfigPath string, fromImageFilename string, lay
logrus.Infof("Using base image %s containing %d layers", fromImageFilename, len(fromImage.Layers))
}

image.Arch = runtime.GOARCH
image.Arch = arch

image.ImageConfig = imageConfig

Expand Down Expand Up @@ -167,6 +168,7 @@ func image(outputFilename, imageConfigPath string, fromImageFilename string, lay
func init() {
rootCmd.AddCommand(imageCmd)
imageCmd.Flags().StringVarP(&fromImageFilename, "from-image", "", "", "A JSON file describing the base image")
imageCmd.Flags().StringVarP(&imageArch, "arch", "", runtime.GOARCH, "Target CPU architecture of the image")
imageCmd.Flags().Var(&created, "created", "Timestamp at which the image was created")
rootCmd.AddCommand(imageFromDirCmd)
rootCmd.AddCommand(imageFromManifestCmd)
Expand Down
Loading