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

Implement context usage #30

Closed
wants to merge 4 commits into from
Closed

Implement context usage #30

wants to merge 4 commits into from

Conversation

hguerrero
Copy link

implements #29

This implementation uses Java 17 and adds a dependency for ASCII tables.

@hguerrero hguerrero changed the title implement context usage Implement context usage Feb 10, 2023
Copy link
Contributor

@rmgrimm rmgrimm left a 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.

Comment on lines +25 to +28
<java.version>17</java.version>
<executable-suffix/>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.release>${java.version}</maven.compiler.release>
Copy link
Contributor

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?

Copy link
Author

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.

Comment on lines -16 to +30
@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")
Copy link
Contributor

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?

Copy link
Author

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.

Comment on lines -87 to 65
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);
Copy link
Contributor

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?

Copy link
Author

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.

Comment on lines +50 to 55
@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;
Copy link
Contributor

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")
Copy link
Contributor

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"

Copy link
Author

@hguerrero hguerrero Feb 11, 2023

Choose a reason for hiding this comment

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

good catch, fixed

@hguerrero
Copy link
Author

... different license from this project.

Good point. I didn't notice the difference with the license. Is there anything specific that requires MIT instead of Apache 2.0?

@rmgrimm rmgrimm closed this Oct 8, 2023
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.

2 participants