Skip to content

Commit

Permalink
Allow --platforms for faas-cli publish
Browse files Browse the repository at this point in the history
--publish is for multi-arch builds, therefore the --platforms
flag needed to be present and available.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Jun 8, 2024
1 parent 6bb351b commit 7eaa545
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions commands/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func init() {

upFlagset := pflag.NewFlagSet("up", pflag.ExitOnError)
upFlagset.BoolVar(&usePublish, "publish", false, "Use faas-cli publish instead of faas-cli build followed by faas-cli push")
upFlagset.StringVar(&platforms, "platforms", "linux/amd64", "Publish for these platforms, when used with --publish")

upFlagset.BoolVar(&skipPush, "skip-push", false, "Skip pushing function to remote registry")
upFlagset.BoolVar(&skipDeploy, "skip-deploy", false, "Skip function deployment")
Expand Down Expand Up @@ -90,25 +91,27 @@ func preRunUp(cmd *cobra.Command, args []string) error {
func upHandler(cmd *cobra.Command, args []string) error {
if watch {
return watchLoop(cmd, args, func(cmd *cobra.Command, args []string, ctx context.Context) error {

if err := upRunner(cmd, args, ctx); err != nil {
if err := upRunner(cmd, args); err != nil {
return err
}
fmt.Println("[Watch] Change a file to trigger a rebuild...")
return nil
})
}

ctx := context.Background()
return upRunner(cmd, args, ctx)
return upRunner(cmd, args)
}

func upRunner(cmd *cobra.Command, args []string, ctx context.Context) error {
func upRunner(cmd *cobra.Command, args []string) error {
if usePublish {
if err := runPublish(cmd, args); err != nil {
return err
}
} else {
if len(platforms) > 0 && cmd.Flags().Changed("platforms") {
return fmt.Errorf("--platforms can only be used with the --publish flag")
}

if err := runBuild(cmd, args); err != nil {
return err
}
Expand Down

0 comments on commit 7eaa545

Please sign in to comment.