-
Notifications
You must be signed in to change notification settings - Fork 8
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
Implement context usage #30
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like some of this code was copied from kcctl
, which has a different license from this project. In addition, I have a slightly different vision for the idea of persisting the remote server configuration.
Rather than require a context file to be present to perform any command, we can follow the structure of the 3scale-toolbox
tool: an optional file named ~/.3scalerc.yaml
which describes "destinations". When the 3scalerc file is not present, the remote can still be specified in the format https://<ACCESS_TOKEN>@<TENANT_HOST>/
.
In this way, it would be possible to share configuration between both 3scale-toolbox and 3scale-cms.
<java.version>17</java.version> | ||
<executable-suffix/> | ||
<maven.compiler.parameters>true</maven.compiler.parameters> | ||
<maven.compiler.release>${java.version}</maven.compiler.release> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to set these properties specific to the cli submodule, or should we apply in /parent/pom.xml so they apply across all the modules?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can make it to the parent pom.xml file. However, somehow I could not make my IDE recognize the java version from the parent, so I added it to the submodule.
@CommandLine.Command( | ||
header = {"3scale Content Management System CLI Tool"}, | ||
name = "3scale-cms", | ||
description = "Tool for interacting with 3scale's Content Management " + | ||
"System for managing content and templates that will be used to " + | ||
"render a tenant's Developer Portal", | ||
subcommands = { | ||
InfoCommand.class, | ||
DiffCommand.class, | ||
DownloadCommand.class, | ||
UploadCommand.class, | ||
DeleteCommand.class, | ||
}, | ||
synopsisSubcommandLabel = "[COMMAND] ", | ||
commandListHeading = "%n@|green,bold COMMANDS|@%n" | ||
) | ||
@CommandLine.Command(header = { | ||
"3scale Content Management System CLI Tool" }, name = "3scale-cms", description = "Tool for interacting with 3scale's Content Management " | ||
+ | ||
"System for managing content and templates that will be used to " + | ||
"render a tenant's Developer Portal", subcommands = { | ||
ConfigCommand.class, | ||
InfoCommand.class, | ||
DiffCommand.class, | ||
DownloadCommand.class, | ||
UploadCommand.class, | ||
DeleteCommand.class, | ||
}, synopsisSubcommandLabel = "[COMMAND] ", commandListHeading = "%n@|green,bold COMMANDS|@%n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard to see what, if anything, changed here... And the annotation properties are now combined at interesting places. Seems like a bad autoformat run?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you let me know if you're using a specific formatter? We could add a maven plugin to validate this before submitting.
factory.setBaseUrl(providerDomain); | ||
if (StringUtils.isNotBlank(accessToken)) { | ||
factory.setAccessToken(accessToken); | ||
} else { | ||
factory.setProviderKey(providerKey); | ||
} | ||
factory.setBaseUrl(context.getCurrentContext().getProviderDomain().toASCIIString()); | ||
factory.setAccessToken(context.getCurrentContext().getAccessToken()); | ||
factory.setUseInsecureConnections(useInsecureConnections); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this removes the option to use provider key. Is that intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's your experience with the provider key? Is that something that is still commonly used? Since a couple of versions, the standard is to use access tokens. For the sake of maintenance makes more sense to deprecate/remove that option.
@CommandLine.Option(names = { "-d", | ||
"--directory" }, paramLabel = "DIRECTORY", arity = "1", description = "Specify local directory path for determining files " | ||
+ | ||
"to upload, download, or compare between local filesystem and " + | ||
"3scale CMS content") | ||
private File rootDirectory; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The formatting of this annotation is strange. For annotations with many properties, let's start each new property on a new line for readability. Also, it seems that your IDE is not respecting the .editorconfig
directive of indenting by 4 spaces.
import picocli.CommandLine.Command; | ||
import picocli.CommandLine.Parameters; | ||
|
||
@Command(name = "use-context", description = "Configures 3scale-cmx to use the specified context") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a typo here in "3scale-cmx". It should be "3scale-cms"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, fixed
Good point. I didn't notice the difference with the license. Is there anything specific that requires MIT instead of Apache 2.0? |
implements #29
This implementation uses Java 17 and adds a dependency for ASCII tables.