mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fn: fix broken flags (#336)
This commit is contained in:
committed by
Seif Lotfy سيف لطفي
parent
539d5a09c6
commit
b649d490d5
28
fn/init.go
28
fn/init.go
@@ -41,8 +41,8 @@ func init() {
|
|||||||
type initFnCmd struct {
|
type initFnCmd struct {
|
||||||
name string
|
name string
|
||||||
force bool
|
force bool
|
||||||
runtime *string
|
runtime string
|
||||||
entrypoint *string
|
entrypoint string
|
||||||
}
|
}
|
||||||
|
|
||||||
func initFn() cli.Command {
|
func initFn() cli.Command {
|
||||||
@@ -63,12 +63,12 @@ func initFn() cli.Command {
|
|||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "runtime",
|
Name: "runtime",
|
||||||
Usage: "choose an existing runtime - " + strings.Join(fnInitRuntimes, ", "),
|
Usage: "choose an existing runtime - " + strings.Join(fnInitRuntimes, ", "),
|
||||||
Destination: a.runtime,
|
Destination: &a.runtime,
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "entrypoint",
|
Name: "entrypoint",
|
||||||
Usage: "entrypoint is the command to run to start this function - equivalent to Dockerfile ENTRYPOINT.",
|
Usage: "entrypoint is the command to run to start this function - equivalent to Dockerfile ENTRYPOINT.",
|
||||||
Destination: a.entrypoint,
|
Destination: &a.entrypoint,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -92,9 +92,9 @@ func (a *initFnCmd) init(c *cli.Context) error {
|
|||||||
|
|
||||||
ff := &funcfile{
|
ff := &funcfile{
|
||||||
Name: a.name,
|
Name: a.name,
|
||||||
Runtime: a.runtime,
|
Runtime: &a.runtime,
|
||||||
Version: initialVersion,
|
Version: initialVersion,
|
||||||
Entrypoint: a.entrypoint,
|
Entrypoint: &a.entrypoint,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := encodeFuncfileYAML("func.yaml", ff); err != nil {
|
if err := encodeFuncfileYAML("func.yaml", ff); err != nil {
|
||||||
@@ -122,24 +122,24 @@ func (a *initFnCmd) buildFuncFile(c *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var rt string
|
var rt string
|
||||||
if a.runtime == nil || *a.runtime == "" {
|
if a.runtime == "" {
|
||||||
rt, err = detectRuntime(pwd)
|
rt, err = detectRuntime(pwd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
a.runtime = &rt
|
a.runtime = rt
|
||||||
fmt.Printf("assuming %v runtime\n", rt)
|
fmt.Printf("assuming %v runtime\n", rt)
|
||||||
}
|
}
|
||||||
if _, ok := acceptableFnRuntimes[*a.runtime]; !ok {
|
if _, ok := acceptableFnRuntimes[a.runtime]; !ok {
|
||||||
return fmt.Errorf("init does not support the %s runtime, you'll have to create your own Dockerfile for this function", *a.runtime)
|
return fmt.Errorf("init does not support the %s runtime, you'll have to create your own Dockerfile for this function", a.runtime)
|
||||||
}
|
}
|
||||||
|
|
||||||
if a.entrypoint == nil || *a.entrypoint == "" {
|
if a.entrypoint == "" {
|
||||||
ep, err := detectEntrypoint(*a.runtime)
|
ep, err := detectEntrypoint(a.runtime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not detect entrypoint for %v, use --entrypoint to add it explicitly. %v", *a.runtime, err)
|
return fmt.Errorf("could not detect entrypoint for %v, use --entrypoint to add it explicitly. %v", a.runtime, err)
|
||||||
}
|
}
|
||||||
a.entrypoint = &ep
|
a.entrypoint = ep
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user