-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: sarthak <[email protected]>
enable target support for extension
- Loading branch information
1 parent
86ff68a
commit caa7edc
Showing
4 changed files
with
143 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,15 @@ import ( | |
"fmt" | ||
"os" | ||
"path/filepath" | ||
"runtime" | ||
"strings" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/buildpacks/pack/internal/style" | ||
"github.com/buildpacks/pack/internal/target" | ||
"github.com/buildpacks/pack/pkg/client" | ||
"github.com/buildpacks/pack/pkg/dist" | ||
"github.com/buildpacks/pack/pkg/logging" | ||
) | ||
|
||
|
@@ -19,6 +22,7 @@ type ExtensionNewFlags struct { | |
API string | ||
Path string | ||
Stacks []string | ||
Targets []string | ||
Version string | ||
} | ||
|
||
|
@@ -56,10 +60,23 @@ func ExtensionNew(logger logging.Logger, creator ExtensionCreator) *cobra.Comman | |
return fmt.Errorf("directory %s exists", style.Symbol(path)) | ||
} | ||
|
||
var targets []dist.Target | ||
if len(flags.Targets) == 0 && len(flags.Stacks) == 0 { | ||
targets = []dist.Target{{ | ||
OS: runtime.GOOS, | ||
Arch: runtime.GOARCH, | ||
}} | ||
} else { | ||
if targets, err = target.ParseTargets(flags.Targets, logger); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
if err := creator.NewExtension(cmd.Context(), client.NewExtensionOptions{ | ||
API: flags.API, | ||
ID: id, | ||
Path: path, | ||
Targets: targets, | ||
Version: flags.Version, | ||
}); err != nil { | ||
return err | ||
|
@@ -72,6 +89,13 @@ func ExtensionNew(logger logging.Logger, creator ExtensionCreator) *cobra.Comman | |
cmd.Flags().StringVarP(&flags.API, "api", "a", "0.9", "Buildpack API compatibility of the generated extension") | ||
cmd.Flags().StringVarP(&flags.Path, "path", "p", "", "Path to generate the extension") | ||
cmd.Flags().StringVarP(&flags.Version, "version", "V", "1.0.0", "Version of the generated extension") | ||
cmd.Flags().MarkDeprecated("stacks", "prefer `--targets` instead: https://github.com/buildpacks/rfcs/blob/main/text/0096-remove-stacks-mixins.md") | ||
cmd.Flags().StringSliceVarP(&flags.Targets, "targets", "t", nil, | ||
`Targets are the list platforms that one targeting, these are generated as part of scaffolding inside buildpack.toml file. one can provide target platforms in format [os][/arch][/variant]:[distroname@osversion@anotherversion];[distroname@osversion] | ||
- Base case for two different architectures : '--targets "linux/amd64" --targets "linux/arm64"' | ||
- case for distribution version: '--targets "windows/amd64:[email protected]"' | ||
- case for different architecture with distributed versions : '--targets "linux/arm/v6:[email protected]" --targets "linux/arm/v6:[email protected]"' | ||
`) | ||
|
||
AddHelpFlag(cmd, "new") | ||
return cmd | ||
|
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