Skip to content

Commit

Permalink
feat: func run build options and host runs
Browse files Browse the repository at this point in the history
- Refactors the run command to include all options from build, in the same
  manner as deploy.
- Adds the --container flag (currently defaults to true) which will, when
  disabled, invoke the localhost-based runner which, in this commit, is not
  yet active.
- Updates help text to match the other command format, and lays the verbal
  groundwork for the difference between containerized (currently default)
  and non-containerized runs.
  • Loading branch information
lkingland committed Apr 25, 2023
1 parent 506cb71 commit 4a3e9a8
Show file tree
Hide file tree
Showing 6 changed files with 240 additions and 149 deletions.
5 changes: 0 additions & 5 deletions cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ func NewTestClient(options ...fn.Option) ClientFactory {
// 'Namespace' is optional. If not provided (see DefaultNamespace commentary),
// the currently configured is used.
// 'Verbose' indicates the system should write out a higher amount of logging.
// Example:
//
// client, done := NewClient("",false)
// defer done()
func NewClient(cfg ClientConfig, options ...fn.Option) (*fn.Client, func()) {
var (
p = progress.New(cfg.Verbose) // updates the CLI
Expand All @@ -79,7 +75,6 @@ func NewClient(cfg ClientConfig, options ...fn.Option) (*fn.Client, func()) {
fn.WithRemover(knative.NewRemover(cfg.Namespace, cfg.Verbose)),
fn.WithDescriber(knative.NewDescriber(cfg.Namespace, cfg.Verbose)),
fn.WithLister(knative.NewLister(cfg.Namespace, cfg.Verbose)),
fn.WithRunner(docker.NewRunner(cfg.Verbose, os.Stdout, os.Stderr)),
fn.WithDeployer(d),
fn.WithPipelinesProvider(pp),
fn.WithPusher(docker.NewPusher(
Expand Down
14 changes: 7 additions & 7 deletions cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
"knative.dev/client-pkg/pkg/util"
"knative.dev/func/pkg/builders"
"knative.dev/func/pkg/builders/buildpacks"
pack "knative.dev/func/pkg/builders/buildpacks"
"knative.dev/func/pkg/builders/s2i"
"knative.dev/func/pkg/config"
fn "knative.dev/func/pkg/functions"
Expand All @@ -30,7 +30,7 @@ NAME
SYNOPSIS
{{rootCmdUse}} deploy [-R|--remote] [-r|--registry] [-i|--image] [-n|--namespace]
[-e|env] [-g|--git-url] [-t|git-branch] [-d|--git-dir]
[-e|--env] [-g|--git-url] [-t|git-branch] [-d|--git-dir]
[-b|--build] [--builder] [--builder-image] [-p|--push]
[--platform] [-c|--confirm] [-v|--verbose]
Expand Down Expand Up @@ -217,7 +217,7 @@ func runDeploy(cmd *cobra.Command, newClient ClientFactory) (err error) {
return
}

// TODO: this is duplicate logic with runBuild.
// TODO: this is duplicate logic with runBuild and runRun.
// Refactor both to have this logic part of creating the buildConfig and thus
// shared because newDeployConfig uses newBuildConfig for its embedded struct.
if f.Registry != "" && !cmd.Flags().Changed("image") && strings.Index(f.Image, "/") > 0 && !strings.HasPrefix(f.Image, f.Registry) {
Expand All @@ -238,9 +238,9 @@ func runDeploy(cmd *cobra.Command, newClient ClientFactory) (err error) {
// Concrete implementations (ex builder) vary based on final effective cfg.
var builder fn.Builder
if f.Build.Builder == builders.Pack {
builder = buildpacks.NewBuilder(
buildpacks.WithName(builders.Pack),
buildpacks.WithVerbose(cfg.Verbose))
builder = pack.NewBuilder(
pack.WithName(builders.Pack),
pack.WithVerbose(cfg.Verbose))
} else if f.Build.Builder == builders.S2I {
builder = s2i.NewBuilder(
s2i.WithName(builders.S2I),
Expand Down Expand Up @@ -540,7 +540,7 @@ func (c deployConfig) Validate(cmd *cobra.Command) (err error) {
// --build can be "auto"|true|false
if c.Build != "auto" {
if _, err := strconv.ParseBool(c.Build); err != nil {
return fmt.Errorf("unrecognized value for --build '%v'. accepts 'auto', 'true' or 'false' (or similarly truthy value)", c.Build)
return fmt.Errorf("unrecognized value for --build '%v'. Accepts 'auto', 'true' or 'false' (or similarly truthy value)", c.Build)
}
}

Expand Down
Loading

0 comments on commit 4a3e9a8

Please sign in to comment.