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

Trigger parameter issue #479

Merged
merged 15 commits into from
Feb 25, 2020
Merged

Conversation

steven0711dong
Copy link
Contributor

close #290, #293

rabbah
rabbah previously requested changes Jan 28, 2020
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.

There's at least one regression so requesting changes accordingly.

commands/commands.go Outdated Show resolved Hide resolved
tests/src/test/scala/system/basic/WskCliBasicTests.scala Outdated Show resolved Hide resolved
commands/trigger.go Outdated Show resolved Hide resolved
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.

WSK operations test framework needs to be updated for CLI and REST. All the doc and tests in the provider repos need updating, for Kafka, Cloudant, Alarms.

commands/commands.go Outdated Show resolved Hide resolved
commands/trigger.go Outdated Show resolved Hide resolved
commands/trigger.go Outdated Show resolved Hide resolved
//then we use the old way to create the trigger.
if len(Flags.common.param) > 0 || simplestTrigger {
if len(Flags.trigger.feedParam) > 0 || len(Flags.trigger.triggerParam) > 0 {
whisk.Debug(whisk.DbgError, "User tries to mix use of --param with --feed-param and --trigger-param")
Copy link
Member

Choose a reason for hiding this comment

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

Is there a use case for the user trying to use trigger parameters and feed parameters together?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, if users want to create a trigger using the new way. They will create trigger parameters using --trigger-param flag and create feed parameters using --feed-param flag. They just cannot combine --param with --feed-param or --trigger-param. The meaning is ambiguous. So we issue an error here.

}
annotations := getParameters(annotationArray, true, true)

//simplestTrigger indicates user are creating a trigger without any feed or parameters
Copy link
Member

Choose a reason for hiding this comment

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

Does duplicate code exist in create and update? If so it'd be better to create functions out of the duplicate code to reduce complexity.

Copy link
Contributor Author

@steven0711dong steven0711dong Feb 7, 2020

Choose a reason for hiding this comment

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

I created two functions so that both create and update could use. Some other variables such as params, feed params do exist in both functions but are created differently and the creation depends on users' intention on how to issue trigger command(old way and new way). So it might make things more complicated to create functions out of duplicate code.

I have to admit that after adding the new flags, both functions become bigger but I think it might be a good idea to separate execution path for the old way of creating trigger from the new way so they do not get lumped together. I'll update the PR this afternoon.

commands/commands.go Outdated Show resolved Hide resolved
commands/commands.go Outdated Show resolved Hide resolved
commands/trigger.go Outdated Show resolved Hide resolved
commands/trigger.go Outdated Show resolved Hide resolved
}
annotations := getParameters(annotationArray, true, true)

//Within this if statement, we process users' trigger command using the old way.
Copy link
Member

Choose a reason for hiding this comment

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

This is quite a large method with over 100 lines of code. Generally large functions are hard to follow and should be broken out into several functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can try to separate the 'old way' and 'new way' into two different functions.

// Get full feed name from trigger get request as it is needed to get the feed
if retTrigger != nil && retTrigger.Annotations != nil {
fullFeedName = getValueString(retTrigger.Annotations, "feed")
// Get full feed name from trigger get request as it is needed to get the feed
Copy link
Member

Choose a reason for hiding this comment

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

This this update method has 200 lines of code making it extremely hard to understand quickly.

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.

Is it possible to add unit tests for these changes since there are no integration tests?

@steven0711dong
Copy link
Contributor Author

steven0711dong commented Feb 12, 2020

I've already changed the error message thing, I'll look at how to break them into small functions tomorrow

commands/trigger.go Outdated Show resolved Hide resolved
wski18n/resources/en_US.all.json Outdated Show resolved Hide resolved
annotations := getParameters(annotationArray, true, true)

//if trigger contains no feed but user tries to update feed parameter, then we issue error.
if feedQualifiedName == nil && len(Flags.trigger.feedParam) > 0 {
whisk.Debug(whisk.DbgError, "Incorrect usage. trigger without a feed cannot have feed parameters")
Copy link
Member

Choose a reason for hiding this comment

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

This error string does not match what is in en_US.all.json.

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.

Unable to update Trigger parameters from CLI
3 participants