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

feat(config): Added json schema generator for providers #7

Open
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

bpowell
Copy link

@bpowell bpowell commented Jun 25, 2019

No description provided.

@armory-jenkins
Copy link
Member

The title of the Pull Request needs to be changed.
Please follow https://www.spinnaker.io/community/contributing/submitting/#commit-message-conventions

@dorisgjata dorisgjata changed the title Eng 4184 feat(cli): Added json schema generator for providers Jun 25, 2019
@dorisgjata
Copy link

I need to clean up some code from my previous commits

@dorisgjata dorisgjata changed the title feat(cli): Added json schema generator for providers feat(config): Added json schema generator for providers Jul 1, 2019
@ncknt
Copy link

ncknt commented Jul 1, 2019

I'd extract the logic out of NestableCommand because you're just using it as a static method call. I'd also not use stdout for that but gather the output in a buffer. You could have a json gradle task but I imagine this will be used dynamically in the web app.

}
}
}
public void addBakeryCommandFields(String providerName, Field[] fields) {
Copy link
Author

Choose a reason for hiding this comment

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

add new line above

}
}
}
public void addAccountCommandFields(String providerName, Field[] fields) {
Copy link
Author

Choose a reason for hiding this comment

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

add new line above

public JSONObject providersFields = Providers.providersMetadata();

public void addProviderCommandFields(String providerName, Field[] fields) {
JSONObject providerFields = (JSONObject) ((JSONObject) providersFields.get("providers")).get(providerName);
Copy link
Author

Choose a reason for hiding this comment

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

why the double cast? (JSONObject) ((JSONObject)....

public void addBakeryCommandFields(String providerName, Field[] fields) {
JSONObject bakeryDefaultsFields = (JSONObject) ((JSONObject) ((JSONObject) providersFields.get("providers"))
.get(providerName)).get("bakeryDefaultsFields");
if (providersFields != null && bakeryDefaultsFields != null) {
Copy link
Author

Choose a reason for hiding this comment

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

might want to use Objects.equals instead of !=, better null safety

.get(providerName)).get("bakeryDefaultsFields");
if (providersFields != null && bakeryDefaultsFields != null) {
for (Field f : fields) {
if (f.getAnnotation(Parameter.class) != null && bakeryDefaultsFields.get(f.getName()) != null) {
Copy link
Author

Choose a reason for hiding this comment

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

might want to use Objects.equals instead of !=, better null safety

for (Field field : fields) {
accountFields.put(field.getName(), fieldType(field));
}
if (providersFields != null && providersFields.get(providerName) != null) {
Copy link
Author

Choose a reason for hiding this comment

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

might want to use Objects.equals instead of !=, better null safety

for (Field field : fields) {
bakeryFields.put(field.getName(), fieldType(field));
}
if (providersFields != null && providersFields.get(providerName) != null) {
Copy link
Author

Choose a reason for hiding this comment

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

might want to use Objects.equals instead of !=, better null safety


public JSONObject fieldType(Field field) {
JSONObject typeWrapper = new JSONObject();
if (field.getAnnotation(LocalFile.class) != null) {
Copy link
Author

Choose a reason for hiding this comment

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

might want to use Objects.equals instead of !=, better null safety

JSONObject typeWrapper = new JSONObject();
if (field.getAnnotation(LocalFile.class) != null) {
typeWrapper.put("type", "upload");
} else if (field.getAnnotation(Secret.class) != null) {
Copy link
Author

Choose a reason for hiding this comment

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

might want to use Objects.equals instead of !=, better null safety

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