-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor fn to seperate common and commands (#657) [skip ci]
* refactor fn to seperate common and commands * remove refactored code * reorganize imports * move image commands in images folder
- Loading branch information
Showing
28 changed files
with
322 additions
and
310 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package commands | ||
|
||
import ( | ||
image_commands "github.com/iron-io/functions/fn/commands/images" | ||
"github.com/iron-io/functions_go" | ||
"github.com/urfave/cli" | ||
) | ||
|
||
type imagesCmd struct { | ||
*functions.AppsApi | ||
} | ||
|
||
func Images() cli.Command { | ||
return cli.Command{ | ||
Name: "images", | ||
Usage: "manage function images", | ||
Subcommands: []cli.Command{ | ||
image_commands.Build(), | ||
image_commands.Deploy(), | ||
image_commands.Bump(), | ||
Call(), | ||
image_commands.Push(), | ||
image_commands.Run(), | ||
testfn(), | ||
}, | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package commands | ||
|
||
import ( | ||
"fmt" | ||
"github.com/iron-io/functions/fn/common" | ||
"github.com/urfave/cli" | ||
"os" | ||
) | ||
|
||
var ( | ||
initialVersion = common.INITIAL_VERSION | ||
) | ||
|
||
func Bump() cli.Command { | ||
cmd := bumpcmd{} | ||
flags := append([]cli.Flag{}, cmd.flags()...) | ||
return cli.Command{ | ||
Name: "bump", | ||
Usage: "bump function version", | ||
Flags: flags, | ||
Action: cmd.bump, | ||
} | ||
} | ||
|
||
type bumpcmd struct { | ||
verbose bool | ||
} | ||
|
||
func (b *bumpcmd) flags() []cli.Flag { | ||
return []cli.Flag{ | ||
cli.BoolFlag{ | ||
Name: "v", | ||
Usage: "verbose mode", | ||
Destination: &b.verbose, | ||
}, | ||
} | ||
} | ||
|
||
// bump will take the found valid function and bump its version | ||
func (b *bumpcmd) bump(c *cli.Context) error { | ||
verbwriter := common.Verbwriter(b.verbose) | ||
|
||
path, err := os.Getwd() | ||
if err != nil { | ||
return err | ||
} | ||
fn, err := common.FindFuncfile(path) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
fmt.Fprintln(verbwriter, "bumping version for", fn) | ||
|
||
funcfile, err := common.ParseFuncfile(fn) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = funcfile.Bumpversion() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if err := common.StoreFuncfile(fn, funcfile); err != nil { | ||
return err | ||
} | ||
|
||
fmt.Println("Bumped to version", funcfile.Version) | ||
return nil | ||
} |
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
Oops, something went wrong.