mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
committed by
Seif Lotfy سيف لطفي
parent
ba65220127
commit
32e9c45df5
@@ -128,7 +128,7 @@ functions. The files can be named as:
|
||||
An example of a function file:
|
||||
```yaml
|
||||
app: myapp
|
||||
image: iron/hello
|
||||
name: iron/hello
|
||||
route: "/custom/route"
|
||||
version: 0.0.1
|
||||
type: sync
|
||||
|
||||
@@ -50,14 +50,14 @@ func (b *bumpcmd) bump(path string) error {
|
||||
}
|
||||
|
||||
if funcfile.Version == "" {
|
||||
img, ver := imageversion(funcfile.Image)
|
||||
img, ver := imageversion(funcfile.Name)
|
||||
if ver == "" {
|
||||
return nil
|
||||
}
|
||||
funcfile.Image = img
|
||||
funcfile.Name = img
|
||||
funcfile.Version = ver
|
||||
} else if funcfile.Version != "" && strings.Contains(funcfile.Image, ":") {
|
||||
return fmt.Errorf("cannot do version bump: this function has tag in its image name and version at same time. image: %s. version: %s", funcfile.Image, funcfile.Version)
|
||||
} else if funcfile.Version != "" && strings.Contains(funcfile.Name, ":") {
|
||||
return fmt.Errorf("cannot do version bump: this function has tag in its image name and version at same time. name: %s. version: %s", funcfile.Name, funcfile.Version)
|
||||
}
|
||||
|
||||
s, err := storage.NewVersionStorage("local", funcfile.Version)
|
||||
|
||||
@@ -193,7 +193,7 @@ func (c commoncmd) dockerbuild(path string, ff *funcfile) error {
|
||||
}
|
||||
}
|
||||
|
||||
cmd := exec.Command("docker", "build", "-t", ff.FullImage(), ".")
|
||||
cmd := exec.Command("docker", "build", "-t", ff.FullName(), ".")
|
||||
cmd.Dir = dir
|
||||
cmd.Stderr = c.verbwriter
|
||||
cmd.Stdout = c.verbwriter
|
||||
|
||||
@@ -30,7 +30,7 @@ var (
|
||||
|
||||
type funcfile struct {
|
||||
App *string `yaml:"app,omitempty",json:"app,omitempty"`
|
||||
Image string `yaml:"image,omitempty",json:"image,omitempty"`
|
||||
Name string `yaml:"name,omitempty",json:"name,omitempty"`
|
||||
Version string `yaml:"version,omitempty",json:"version,omitempty"`
|
||||
Runtime *string `yaml:"runtime,omitempty",json:"runtime,omitempty"`
|
||||
Entrypoint *string `yaml:"entrypoint,omitempty",json:"entrypoint,omitempty"`
|
||||
@@ -41,12 +41,12 @@ type funcfile struct {
|
||||
Build []string `yaml:"build,omitempty",json:"build,omitempty"`
|
||||
}
|
||||
|
||||
func (ff *funcfile) FullImage() string {
|
||||
image := ff.Image
|
||||
func (ff *funcfile) FullName() string {
|
||||
fname := ff.Name
|
||||
if ff.Version != "" {
|
||||
image = fmt.Sprintf("%s:%s", image, ff.Version)
|
||||
fname = fmt.Sprintf("%s:%s", fname, ff.Version)
|
||||
}
|
||||
return image
|
||||
return fname
|
||||
}
|
||||
|
||||
func (ff *funcfile) RuntimeTag() (runtime, tag string) {
|
||||
|
||||
@@ -280,7 +280,7 @@ func createFunctionYaml(opts createImageOptions) error {
|
||||
route := fmt.Sprintf("/%s", strs[1])
|
||||
funcDesc := &funcfile{
|
||||
App: &strs[0],
|
||||
Image: opts.Name,
|
||||
Name: opts.Name,
|
||||
Route: &route,
|
||||
Config: opts.Config,
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ func (p *publishcmd) publish(path string) error {
|
||||
}
|
||||
|
||||
func (p publishcmd) dockerpush(ff *funcfile) error {
|
||||
cmd := exec.Command("docker", "push", ff.FullImage())
|
||||
cmd := exec.Command("docker", "push", ff.FullName())
|
||||
cmd.Stderr = p.verbwriter
|
||||
cmd.Stdout = p.verbwriter
|
||||
if err := cmd.Run(); err != nil {
|
||||
@@ -114,14 +114,14 @@ func (p *publishcmd) route(path string, ff *funcfile) error {
|
||||
body := functions.RouteWrapper{
|
||||
Route: functions.Route{
|
||||
Path: *ff.Route,
|
||||
Image: ff.FullImage(),
|
||||
Image: ff.FullName(),
|
||||
Memory: *ff.Memory,
|
||||
Type_: *ff.Type,
|
||||
Config: expandEnvConfig(ff.Config),
|
||||
},
|
||||
}
|
||||
|
||||
fmt.Fprintf(p.verbwriter, "updating API with appName: %s route: %s image: %s \n", *ff.App, *ff.Route, ff.Image)
|
||||
fmt.Fprintf(p.verbwriter, "updating API with app: %s route: %s name: %s \n", *ff.App, *ff.Route, ff.Name)
|
||||
|
||||
wrapper, resp, err := p.AppsAppRoutesPost(*ff.App, body)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user