Skip to content

Command reconstruction - verb noun#291

Merged
JadeRedworth merged 9 commits intofnproject:masterfrom
JadeRedworth:command-structure
Jun 6, 2018
Merged

Command reconstruction - verb noun#291
JadeRedworth merged 9 commits intofnproject:masterfrom
JadeRedworth:command-structure

Conversation

@JadeRedworth
Copy link
Copy Markdown
Contributor

@JadeRedworth JadeRedworth commented May 24, 2018

Reconstruction of the command structure within the CLI. It has been changed from a noun verb to verb noun structure, as described in issue #216

Folders added:

  • Commands - all the top-level commands
  • Test - holds all the test files
  • Object
    • app
    • call
    • context
    • log
    • route
    • server
  • Common
  • Run - all run related files

Open for suggestions: I don’t like the way the structure no handles apps and routes config.
fn list config apps I think it would be nicer to have fn list apps config but urfave will be expecting that 4th command and therefore fn list apps will not be valid.

^^ We went with fn config [app | route] <key> <value> to set a configuration.

Following changes to documentation and commands:
Fn #1031
Tutorials #87
Flow Lib Go #5
Fdk-ruby #13
Fdk-java #138

@denismakogon
Copy link
Copy Markdown
Member

Would be nice to get #296 done as part of this change as well.

@denismakogon
Copy link
Copy Markdown
Member

At least one of the tests is broken:

2018/05/25 12:41:31 Expected sdterr message (Unable to parse annotation value 'value'. Annotations values must be valid JSON strings.) not found in result: COMMAND: /home/circleci/go/src/github.com/fnproject/cli/fn create routes xpldnjob myroute --image foo/duffimage:0.0.1 --annotation test=value
INPUT:
RESULT: true

maybe a regression?

@JadeRedworth JadeRedworth force-pushed the command-structure branch 3 times, most recently from 1a2a7cc to a8fb805 Compare May 29, 2018 08:40
@zootalures
Copy link
Copy Markdown
Member

zootalures commented Jun 1, 2018

Black box review:

  • can you accept both plural and singular of of apps and app , call/calls log/logs etc everywhere?
  • add ‘ls’ as an alias for list
  • Remove lambda command ? or put it at the bottom or hide it - it doesn't work anyway
  • fn push docs: “push function to Docker Hub” - > Push function to docker regsitry

Also fn set config app foo key value is a synonym for fn update app foo -c key=value
not sure it botheres me that much but just noticed.

The former seems a bit clunky - did you consider:

fn c[onfig[ure]] app foo key value ?

@JadeRedworth
Copy link
Copy Markdown
Contributor Author

In regard to single vs plural, we can one command name and then multiple aliases. It will just change the help text to have the 3 options apps, app, a etc.. If this is fine then it can be added?

Copy link
Copy Markdown
Member

@zootalures zootalures left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few nits here and there but good otherwise -

FWIW build server is a sort of esoteric command - and I don't think it should break the simplicity of fn build by making it fn build server and fn build function -

hence fn build-server or something

Comment thread main.go Outdated
// TODO: this doesn't seem to get called even when an error returns from a command, but maybe urfave is doing a non zero exit anyways? nope: https://github.com/urfave/cli/issues/610
fmt.Fprintf(os.Stderr, "ERROR: %v\n", err)
fmt.Fprintf(os.Stderr,"Client version: %s\n" , Version)
fmt.Fprintf(os.Stderr, "Client version: %s\n", commands.VersionCommand())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CopyPasta - here - this shoould be commands.Version

(or just Version once you've moved the version var up to /version.go)

Comment thread commands/version.go Outdated
@@ -15,16 +15,17 @@ import (
// Version of Fn CLI
var Version = "0.4.106"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is auto-set by in releases by the version bump tool - that expects a Version var in a version.goin the top level directory

Suggest creating version.go in ../ and just putting var Version = ".... in it as a global .

Comment thread common/common.go Outdated

func getWd() string {
type FnClient struct {
Client *fnclient.Fn
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't see this being used anywhere - can it be deleted?

Comment thread common/bump.go
@@ -138,7 +140,7 @@ func bumpVersion(funcfile *funcfile, t VType) (*funcfile, error) {
// cleanImageName is intended to remove any trailing tag from the image name
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caps on doc

Comment thread test.sh Outdated

# start fn
CONTAINER_ID=$($fn start -d)
CONTAINER_ID=$($fn start server -d)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still just fn start right?

Comment thread test/bump_test.go Outdated
@@ -1,7 +1,9 @@
package main
package test
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a unit test on common - should be under common/bump_test.go

Comment thread test/cli_docker_runtime_test.go Outdated
tctx.WithFile("func.go", goFuncDotGo, 0644)

tctx.Fn("--verbose", "build").AssertFailed().AssertStderrContains("Dockerfile does not exist")
tctx.Fn("--verbose", "build", "function").AssertFailed().AssertStderrContains("Dockerfile does not exist")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be fn build shouldn't it?

Comment thread test/routes_test.go Outdated
@@ -0,0 +1,27 @@
package test
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No unit tests in /test (sorry should have called it "e2e_test" or something - I think this test already exists in client/call_fn_test.go (my bad)

Comment thread common/funcfile.go
)

type inputMap struct {
type InputMap struct {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dox on all the structs in this file now their public.

Comment thread objects/server/server.go Outdated
// • ‎then generate a main.go with extensions
// • ‎compile, throw in another container like main dockerfile
func (b *buildServerCmd) buildServer(c *cli.Context) error {
func (b *buildServerCmd) Build(c *cli.Context) error {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't see this referenced anywhere

Suggest you put this as its own top-level command rather than under the build verb

fn build-server ?

@zootalures
Copy link
Copy Markdown
Member

zootalures commented Jun 1, 2018

I did a quick scan and I think you pick up most uses of the ‘fn’ command that need changing in docs with the following grep:

 fgrep -rE "fn +(apps|routes|calls|logs|context|update) "  *  | grep -v \.git

client works

filter through get sub commands

dumping this here

re order folder structure

add oracle specific context file struct and move around more files

refactor apps and calls

add a test folder to hold test files

fix cli_config_test.go file

switch around commands in crud_test.go

enable bash or zsh auto completion

remove bash completion for this structure change

Add bash completion for commands, add aliases for lambda command
and fix tests.

remove old app command

add nicer start command message

add <image> command to creating route

add both singular and plural object commands

rebase with master and fix client issue

add singular and plural options

rebase

Move version to main package to allow for auto-bump by releases.

Change build-server to its own command so it does affect fn build
and clutter the command.

Remove some unused code.

Fix tests.

update context readme
remove set command and replace with configure to set the
configuration on an app/route
@JadeRedworth JadeRedworth requested a review from rikgibson June 5, 2018 11:18
Comment thread commands/build_server.go Outdated
Action: cmd.buildServer,
Name: "build-server",
Usage: "build custom fn server",
Category: "DEVELOPMENT COMMANDS",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this belongs more closely to SERVER COMMANDS

Copy link
Copy Markdown
Contributor

@rikgibson rikgibson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get "help" and "version" in an "Other Commands" group?

@rikgibson
Copy link
Copy Markdown
Contributor

I think the help text is quite sparse at this point but that can be worked on in conjunction with @michael-w-williams and shouldn't be a blocker in any way.

@JadeRedworth
Copy link
Copy Markdown
Contributor Author

@rikgibson the help command comes with urfave so there is no way to add a category.
version can be moved to other commands but then it would be on its own?

@JadeRedworth JadeRedworth merged commit f83f292 into fnproject:master Jun 6, 2018
JadeRedworth added a commit to fnproject/fdk-ruby that referenced this pull request Jun 7, 2018
Update CLI commands to reflect new CLI verb/noun structure to follow: fnproject/cli#291
JadeRedworth added a commit to fnproject/flow-lib-go that referenced this pull request Jun 7, 2018
Update CLI commands to reflect new CLI verb/noun structure to follow: fnproject/cli#291
JadeRedworth added a commit to fnproject/tutorials that referenced this pull request Jun 7, 2018
Update CLI docs to reflect new CLI verb/noun structure to follow: fnproject/cli#291
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants