Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow optional leading slash in CLI commands #2424

Merged
merged 1 commit into from
Aug 11, 2017

Conversation

underwoodb-sd-ibm
Copy link
Contributor

@underwoodb-sd-ibm underwoodb-sd-ibm commented Jun 26, 2017

This update is intended to allow the user to input a 3 part fully qualified name (FQN) with or without a leading '/' whenever entering a command.

Closes #2328

@underwoodb-sd-ibm underwoodb-sd-ibm changed the title (WIP) Leading Slash issue #2328 (WIP) Leading Slash (issue #2328) Jun 27, 2017
@underwoodb-sd-ibm underwoodb-sd-ibm changed the title (WIP) Leading Slash (issue #2328) (WIP) Leading Slash (CLI issue #2328) Jun 27, 2017
@underwoodb-sd-ibm
Copy link
Contributor Author

underwoodb-sd-ibm commented Jun 29, 2017

PG2 1762
Failed

Copy link
Member

@dubee dubee left a comment

Choose a reason for hiding this comment

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

Might want to test for triggers, rules, etc. Need to update the docs as well.

@rabbah rabbah added cli enhancement review Review for this PR has been requested and yet needs to be done. labels Jun 29, 2017
@underwoodb-sd-ibm
Copy link
Contributor Author

underwoodb-sd-ibm commented Jun 30, 2017

PG4 477 - Passed

@underwoodb-sd-ibm underwoodb-sd-ibm changed the title (WIP) Leading Slash (CLI issue #2328) (Review) Leading Slash (CLI issue #2328) Jun 30, 2017
@underwoodb-sd-ibm
Copy link
Contributor Author

@mdeuser - in case you hadn't seen this, for when/if you have time for further review.

// replaceMissingLeadSlash(name) returns a (possibly fully qualified) resource name,
// inserting a leading '/' if it is of 3 parts (namespace/packageName/actionName)
// and lacking the leading '/'.
func replaceMissingLeadSlash(name string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be more clear if this were a method on the QualifedName struct? Perhaps rename it as well to a name that implies it only really works on a fully qualified entity name

Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose it might be time for the QualifiedName struct and associated methods, constructors, etc to reside in its own module.

if strings.HasPrefix(name, "/") {
parts := strings.Split(name, "/")
//parts = strings.Split(name, "/")
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove commented out code

@@ -112,7 +126,7 @@ func parseQualifiedName(name string) (QualifiedName, error) {
return qualifiedName, err
}

parts := strings.Split(name, "/")
//parts = strings.Split(name, "/")
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove commented out code

@@ -95,6 +97,41 @@ class WskBasicTests
stderr should include(errormsg)
}

it should "accept a 3 part Fully Qualified Name without a leading '/'" in {
val packageName = "packageName"
Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend using labels that can uniquely identify this particular test. If there's a need to traverse the backend logs, having unique labels is helpful

@underwoodb-sd-ibm underwoodb-sd-ibm force-pushed the leadSlash2328 branch 3 times, most recently from 0d6b9aa to 475de08 Compare July 11, 2017 18:10
@underwoodb-sd-ibm underwoodb-sd-ibm changed the title (Review) Leading Slash (CLI issue #2328) (Review) Leading Slash Closes https://github.com/apache/incubator-openwhisk/issues/2328 Jul 11, 2017
@underwoodb-sd-ibm underwoodb-sd-ibm changed the title (Review) Leading Slash Closes https://github.com/apache/incubator-openwhisk/issues/2328 (Review) Leading Slash Closes $https://github.com/apache/incubator-openwhisk/issues/2328 Jul 11, 2017
@underwoodb-sd-ibm underwoodb-sd-ibm changed the title (Review) Leading Slash Closes $https://github.com/apache/incubator-openwhisk/issues/2328 (Review) Leading Slash (CLI issue #2328) Jul 11, 2017
@underwoodb-sd-ibm
Copy link
Contributor Author

PG4 511 Passed

@@ -0,0 +1,207 @@
/*
Copy link
Member

Choose a reason for hiding this comment

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

I think the standard naming conventions for go files are to separate words using an underscore. Ie, quailifed_name.go.


// GetNamespaceFromQN() returns the name of the namespace in qualifiedName without
// a leading '/'
func (qualifiedName *QualifiedName) GetNamespaceFromQN() string {
Copy link
Member

Choose a reason for hiding this comment

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

I think you can drop FromQN since it isn't in the other function names. Since the type is a QualifiedName we can assume we can assume the from aspect.

try {
validArgs foreach {
cmd =>
val stderr = wsk.cli(cmd ++ wskprops.overrides ++ auth, expectedExitCode = SUCCESS_EXIT).stderr
Copy link
Member

Choose a reason for hiding this comment

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

cmd => wsk.cli(cmd ++ wskprops.overrides ++ auth, expectedExitCode = SUCCESS_EXIT)

Copy link
Member

Choose a reason for hiding this comment

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

Don't need to check standard error here since we are expecting a SUCCESS_EXIT code.

}
} finally {
cleanUp foreach {
cmd =>
Copy link
Member

Choose a reason for hiding this comment

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

Drop the new line after =>.

Copy link
Member

@dubee dubee left a comment

Choose a reason for hiding this comment

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

@underwoodb-sd-ibm, please put the link to the issue in your PR description and prepend with "Closes ".

"../wski18n"
)

type QualifiedName struct {
Copy link
Member

Choose a reason for hiding this comment

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

I like that all the qualified name functions are now part of the QualifiedName type. Having all the functionality for a type consolidated in one place make the code easier to follow. 👍

qualifiedName.namespace = parts[1]

if len(parts) < 2 || len(parts) > 4 {
whisk.Debug(whisk.DbgError, "A valid qualified name was not detected\n")
Copy link
Member

Choose a reason for hiding this comment

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

This code is duplicated below. Can move the body of the if block to a function and just call that where needed.

@@ -34,8 +34,8 @@ func entityNameError(entityName string) (error) {
return whisk.MakeWskError(errors.New(errMsg), whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.DISPLAY_USAGE)
}

func parseQualifiedNameError(entityName string, err error) (error) {
whisk.Debug(whisk.DbgError, "parseQualifiedName(%s) failed: %s\n", entityName, err)
func NewQualifiedNameError(entityName string, err error) (error) {
Copy link
Member

Choose a reason for hiding this comment

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

Can this be moved into qualified_name.go?

@rabbah
Copy link
Member

rabbah commented Aug 8, 2017

need to rebase.

@underwoodb-sd-ibm underwoodb-sd-ibm force-pushed the leadSlash2328 branch 2 times, most recently from a972611 to 31b3cd0 Compare August 8, 2017 19:11
@underwoodb-sd-ibm
Copy link
Contributor Author

PG2 1922

@underwoodb-sd-ibm
Copy link
Contributor Author

PG2 1922 - Passed

@underwoodb-sd-ibm underwoodb-sd-ibm force-pushed the leadSlash2328 branch 3 times, most recently from d2b8312 to 11fb9f0 Compare August 9, 2017 18:12
@rabbah
Copy link
Member

rabbah commented Aug 9, 2017

@underwoodb-sd-ibm can you move the tests out of the system package? sorry just noticed that.
don't need to re-pg.

Copy link
Member

@rabbah rabbah left a comment

Choose a reason for hiding this comment

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

see comment

…thout leading slash '/'

- Updated docs, fixed bug when creating Rule, improved and moved tests to WskBasicTests

- Created new module for QualifiedName struct and functions

* Built constructor and getter methods for QualifiedName, modified code to recognize QualifiedName pointers

* Changed qualifiedname.go to qualified_name.go

* Updated code to use getter functions for QualifiedName
@underwoodb-sd-ibm
Copy link
Contributor Author

@rabbah, tests have been moved to WskBasicUsageTests. Please confirm where I put it in the test is satisfactory, and if so, I'll tag Carlos for merging. Thanks!

@dubee
Copy link
Member

dubee commented Aug 10, 2017

@underwoodb-sd-ibm, test is in the correct suite.

@underwoodb-sd-ibm
Copy link
Contributor Author

@csantanapr - I'm assuming we need to wait for @rabbah to give the ok, but is it possible to merge this guy when/if you have time? Thanks!

@csantanapr
Copy link
Member

@rabbah if you are OK with the recent changes then adjust your review and merge away.

Copy link
Member

@rabbah rabbah left a comment

Choose a reason for hiding this comment

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

thanks for moving the tests.

@rabbah rabbah merged commit c2c44c3 into apache:master Aug 11, 2017
houshengbo pushed a commit to houshengbo/openwhisk that referenced this pull request Aug 17, 2017
houshengbo pushed a commit to houshengbo/openwhisk that referenced this pull request Aug 17, 2017
houshengbo pushed a commit to houshengbo/openwhisk that referenced this pull request Sep 18, 2017
houshengbo pushed a commit to houshengbo/openwhisk that referenced this pull request Sep 18, 2017
houshengbo pushed a commit to houshengbo/openwhisk that referenced this pull request Nov 13, 2017
houshengbo pushed a commit to houshengbo/openwhisk that referenced this pull request Nov 13, 2017
houshengbo pushed a commit to houshengbo/openwhisk that referenced this pull request Nov 13, 2017
houshengbo pushed a commit to houshengbo/openwhisk that referenced this pull request Nov 13, 2017
houshengbo pushed a commit to houshengbo/openwhisk that referenced this pull request Nov 14, 2017
houshengbo pushed a commit to houshengbo/openwhisk that referenced this pull request Nov 14, 2017
BillZong pushed a commit to BillZong/openwhisk that referenced this pull request Nov 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli enhancement review Review for this PR has been requested and yet needs to be done.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants