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

PoC: Add cross-compilation support #139

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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 @@ -14,13 +14,14 @@ import (
)

var fromImageFilename string
var imageArch string

var imageCmd = &cobra.Command{
Use: "image OUTPUT-FILENAME CONFIG.JSON LAYERS-1.JSON LAYERS-2.JSON ...",
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:])
err := image(args[0], args[1], fromImageFilename, imageArch, args[2:])
if err != nil {
fmt.Fprintf(os.Stderr, "%s", err)
os.Exit(1)
Expand Down Expand Up @@ -88,7 +89,7 @@ func imageFromManifest(outputFilename, manifestFilename string, blobsFilename st
return nil
}

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

Expand All @@ -114,7 +115,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
for _, path := range layerPaths {
Expand Down Expand Up @@ -145,6 +146,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")
rootCmd.AddCommand(imageFromDirCmd)
rootCmd.AddCommand(imageFromManifestCmd)
}
Loading