Skip to content

Commit

Permalink
chore: remove getCredentialProviderConfig from AddAwsRuntimeConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Nov 25, 2020
1 parent 03dbab8 commit e4635bf
Showing 1 changed file with 13 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public Map<String, Consumer<TypeScriptWriter>> getRuntimeConfigWriters(
+ "trait was found on " + service.getId());
}
}
runtimeConfigs.putAll(getCredentialProviderConfig(service, target));
runtimeConfigs.putAll(getDefaultConfig(target));
return runtimeConfigs;
}
Expand All @@ -146,6 +145,13 @@ private Map<String, Consumer<TypeScriptWriter>> getDefaultConfig(LanguageTarget
TypeScriptDependency.INVALID_DEPENDENCY.packageName);
writer.write("region: invalidFunction(\"Region is missing\") as any,");
},
"credentialDefaultProvider", writer -> {
writer.addDependency(TypeScriptDependency.INVALID_DEPENDENCY);
writer.addImport("invalidFunction", "invalidFunction",
TypeScriptDependency.INVALID_DEPENDENCY.packageName);
writer.write(
"credentialDefaultProvider: invalidFunction(\"Credential is missing\") as any,");
},
"maxAttempts", writer -> {
writer.addDependency(TypeScriptDependency.MIDDLEWARE_RETRY);
writer.addImport("DEFAULT_MAX_ATTEMPTS", "DEFAULT_MAX_ATTEMPTS",
Expand All @@ -167,6 +173,12 @@ private Map<String, Consumer<TypeScriptWriter>> getDefaultConfig(LanguageTarget
writer.write(
"region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS),");
},
"credentialDefaultProvider", writer -> {
writer.addDependency(AwsDependency.CREDENTIAL_PROVIDER_NODE);
writer.addImport("defaultProvider", "credentialDefaultProvider",
AwsDependency.CREDENTIAL_PROVIDER_NODE.packageName);
writer.write("credentialDefaultProvider,");
},
"maxAttempts", writer -> {
writer.addImport("NODE_MAX_ATTEMPT_CONFIG_OPTIONS", "NODE_MAX_ATTEMPT_CONFIG_OPTIONS",
TypeScriptDependency.MIDDLEWARE_RETRY.packageName);
Expand All @@ -177,34 +189,4 @@ private Map<String, Consumer<TypeScriptWriter>> getDefaultConfig(LanguageTarget
return Collections.emptyMap();
}
}

private Map<String, Consumer<TypeScriptWriter>> getCredentialProviderConfig(
ServiceShape service,
LanguageTarget target
) {
String serviceId = service.getTrait(ServiceTrait.class).map(ServiceTrait::getSdkId).orElse("");
switch (target) {
case BROWSER:
return MapUtils.of(
"credentialDefaultProvider", writer -> {
writer.addDependency(TypeScriptDependency.INVALID_DEPENDENCY);
writer.addImport("invalidFunction", "invalidFunction",
TypeScriptDependency.INVALID_DEPENDENCY.packageName);
writer.write(
"credentialDefaultProvider: invalidFunction(\"Credential is missing\") as any,");
}
);
case NODE:
return MapUtils.of(
"credentialDefaultProvider", writer -> {
writer.addDependency(AwsDependency.CREDENTIAL_PROVIDER_NODE);
writer.addImport("defaultProvider", "credentialDefaultProvider",
AwsDependency.CREDENTIAL_PROVIDER_NODE.packageName);
writer.write("credentialDefaultProvider,");
}
);
default:
return Collections.emptyMap();
}
}
}

0 comments on commit e4635bf

Please sign in to comment.