Skip to content

Commit b64db94

Browse files
authored
replace usages of SmithyGoTypes (#637)
1 parent 3e78a2b commit b64db94

31 files changed

Lines changed: 186 additions & 369 deletions

codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/ClientOptions.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import software.amazon.smithy.go.codegen.integration.ConfigField;
2929
import software.amazon.smithy.go.codegen.integration.ProtocolGenerator;
3030
import software.amazon.smithy.go.codegen.integration.auth.AnonymousDefinition;
31+
import software.amazon.smithy.go.codegen.SmithyGoDependency;
3132
import software.amazon.smithy.model.knowledge.ServiceIndex;
3233
import software.amazon.smithy.model.shapes.ShapeId;
3334
import software.amazon.smithy.model.traits.synthetic.NoAuthTrait;
@@ -94,7 +95,7 @@ private Writable generate() {
9495
"protocolTypes", generateProtocolTypes(),
9596
"apiOptionsDocs", apiOptionsDocs,
9697
"options", NAME,
97-
"stack", SmithyGoTypes.Middleware.Stack,
98+
"stack", SmithyGoDependency.SMITHY_MIDDLEWARE.struct("Stack"),
9899
"fields", ChainWritable.of(fields.stream().map(this::writeField).toList()).compose(),
99100
"protocolFields", generateProtocolFields(),
100101
"copy", generateCopy(),
@@ -151,7 +152,7 @@ private Writable generateProtocolFields() {
151152
goDocTemplate("The auth scheme resolver which determines how to authenticate for each operation."),
152153
goDocTemplate("The list of auth schemes supported by the client."),
153154
AuthSchemeResolverGenerator.INTERFACE_NAME,
154-
SmithyGoTypes.Transport.Http.AuthScheme,
155+
SmithyGoDependency.SMITHY_HTTP_TRANSPORT.func("AuthScheme"),
155156
goDocTemplate("Client registry of operation interceptors."),
156157
SmithyGoDependency.SMITHY_HTTP_TRANSPORT.struct("InterceptorRegistry"),
157158
goDocTemplate("Priority list of preferred auth scheme names (e.g. sigv4a)."));
@@ -168,7 +169,7 @@ private Writable generateCopy() {
168169
169170
return to
170171
}
171-
""", NAME, SmithyGoTypes.Middleware.Stack);
172+
""", NAME, SmithyGoDependency.SMITHY_MIDDLEWARE.struct("Stack"));
172173
}
173174

174175
private Writable generateGetIdentityResolver() {
@@ -180,7 +181,7 @@ private Writable generateGetIdentityResolver() {
180181
}
181182
""",
182183
NAME,
183-
SmithyGoTypes.Auth.IdentityResolver,
184+
SmithyGoDependency.SMITHY_AUTH.interfaceSymbol("IdentityResolver"),
184185
ChainWritable.of(
185186
ServiceIndex.of(context.getModel())
186187
.getEffectiveAuthSchemes(context.getService()).keySet().stream()
@@ -211,7 +212,7 @@ func WithAPIOptions(optFns ...func($P) error) func(*Options) {
211212
goDocTemplate(
212213
"WithAPIOptions returns a functional option for setting the Client's APIOptions option."
213214
),
214-
SmithyGoTypes.Middleware.Stack);
215+
SmithyGoDependency.SMITHY_MIDDLEWARE.struct("Stack"));
215216

216217
fields.stream().filter(ConfigField::getWithHelper).filter(ConfigField::isDeprecated)
217218
.forEach(configField -> {

codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/GoStackStepMiddlewareGenerator.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package software.amazon.smithy.go.codegen;
1717

1818
import static software.amazon.smithy.go.codegen.GoWriter.goTemplate;
19+
import software.amazon.smithy.go.codegen.SmithyGoDependency;
1920

2021
import java.util.function.BiConsumer;
2122
import software.amazon.smithy.codegen.core.Symbol;
@@ -82,10 +83,10 @@ public static Writable generateInitializeMiddlewareFunc(Writable body) {
8283
}
8384
""",
8485
GoStdlibTypes.Context.Context,
85-
SmithyGoTypes.Middleware.InitializeInput,
86-
SmithyGoTypes.Middleware.InitializeHandler,
87-
SmithyGoTypes.Middleware.InitializeOutput,
88-
SmithyGoTypes.Middleware.Metadata,
86+
SmithyGoDependency.SMITHY_MIDDLEWARE.struct("InitializeInput"),
87+
SmithyGoDependency.SMITHY_MIDDLEWARE.struct("InitializeHandler"),
88+
SmithyGoDependency.SMITHY_MIDDLEWARE.struct("InitializeOutput"),
89+
SmithyGoDependency.SMITHY_MIDDLEWARE.struct("Metadata"),
8990
body);
9091
}
9192

@@ -132,9 +133,9 @@ public static GoStackStepMiddlewareGenerator createFinalizeStepMiddleware(String
132133
return createMiddleware(name,
133134
id,
134135
"HandleFinalize",
135-
SmithyGoTypes.Middleware.FinalizeInput,
136-
SmithyGoTypes.Middleware.FinalizeOutput,
137-
SmithyGoTypes.Middleware.FinalizeHandler);
136+
SmithyGoDependency.SMITHY_MIDDLEWARE.struct("FinalizeInput"),
137+
SmithyGoDependency.SMITHY_MIDDLEWARE.struct("FinalizeOutput"),
138+
SmithyGoDependency.SMITHY_MIDDLEWARE.struct("FinalizeHandler"));
138139
}
139140

140141
/**
@@ -152,10 +153,10 @@ public static Writable generateFinalizeMiddlewareFunc(Writable body) {
152153
}
153154
""",
154155
GoStdlibTypes.Context.Context,
155-
SmithyGoTypes.Middleware.FinalizeInput,
156-
SmithyGoTypes.Middleware.FinalizeHandler,
157-
SmithyGoTypes.Middleware.FinalizeOutput,
158-
SmithyGoTypes.Middleware.Metadata,
156+
SmithyGoDependency.SMITHY_MIDDLEWARE.struct("FinalizeInput"),
157+
SmithyGoDependency.SMITHY_MIDDLEWARE.struct("FinalizeHandler"),
158+
SmithyGoDependency.SMITHY_MIDDLEWARE.struct("FinalizeOutput"),
159+
SmithyGoDependency.SMITHY_MIDDLEWARE.struct("Metadata"),
159160
body);
160161
}
161162

codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/ServiceGenerator.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import software.amazon.smithy.go.codegen.integration.GoIntegration;
4040
import software.amazon.smithy.go.codegen.integration.OperationMetricsStruct;
4141
import software.amazon.smithy.go.codegen.integration.RuntimeClientPlugin;
42+
import software.amazon.smithy.go.codegen.SmithyGoDependency;
4243
import software.amazon.smithy.model.Model;
4344
import software.amazon.smithy.model.knowledge.ServiceIndex;
4445
import software.amazon.smithy.model.knowledge.TopDownIndex;
@@ -338,7 +339,7 @@ func resolveAuthSchemes(options *Options) {
338339
}
339340
""",
340341
AuthSchemeResolverGenerator.DEFAULT_NAME,
341-
SmithyGoTypes.Transport.Http.AuthScheme,
342+
SmithyGoDependency.SMITHY_HTTP_TRANSPORT.func("AuthScheme"),
342343
schemeMappings);
343344
}
344345

@@ -433,7 +434,7 @@ defer endTimer()
433434
"middleware", SmithyGoDependency.SMITHY_MIDDLEWARE,
434435
"tracing", SmithyGoDependency.SMITHY_TRACING,
435436
"newStack", generateNewStack(),
436-
"operationError", SmithyGoTypes.Smithy.OperationError,
437+
"operationError", SmithyGoDependency.SMITHY.struct("OperationError"),
437438
"resolvers", ChainWritable.of(
438439
getConfigResolvers(
439440
ConfigFieldResolver.Location.OPERATION,
@@ -549,7 +550,7 @@ go func() {
549550
"middleware", SmithyGoDependency.SMITHY_MIDDLEWARE,
550551
"tracing", SmithyGoDependency.SMITHY_TRACING,
551552
"newStack", generateNewStack(),
552-
"operationError", SmithyGoTypes.Smithy.OperationError,
553+
"operationError", SmithyGoDependency.SMITHY.struct("OperationError"),
553554
"resolvers", ChainWritable.of(
554555
getConfigResolvers(
555556
ConfigFieldResolver.Location.OPERATION,
@@ -629,7 +630,7 @@ go func() {
629630
private Writable generateNewStack() {
630631
ensureSupportedProtocol();
631632
return goTemplate("stack := $T(opID, $T)",
632-
SmithyGoTypes.Middleware.NewStack, SmithyGoTypes.Transport.Http.NewStackRequest);
633+
SmithyGoDependency.SMITHY_MIDDLEWARE.func("NewStack"), SmithyGoDependency.SMITHY_HTTP_TRANSPORT.func("NewStackRequest"));
633634
}
634635

635636
private void ensureSupportedProtocol() {
@@ -663,8 +664,8 @@ func getOperationInput(ctx $1T) interface{} {
663664
$4W
664665
""",
665666
GoStdlibTypes.Context.Context,
666-
SmithyGoTypes.Middleware.WithStackValue,
667-
SmithyGoTypes.Middleware.GetStackValue,
667+
SmithyGoDependency.SMITHY_MIDDLEWARE.func("WithStackValue"),
668+
SmithyGoDependency.SMITHY_MIDDLEWARE.func("GetStackValue"),
668669
new SetOperationInputContextMiddleware().generate());
669670
}
670671

@@ -676,7 +677,7 @@ func addProtocolFinalizerMiddlewares(stack $P, options $L, operation string) err
676677
return nil
677678
}
678679
""",
679-
SmithyGoTypes.Middleware.Stack,
680+
SmithyGoDependency.SMITHY_MIDDLEWARE.struct("Stack"),
680681
CONFIG_NAME,
681682
ChainWritable.of(
682683
ResolveAuthSchemeMiddlewareGenerator.generateAddToProtocolFinalizers(),

0 commit comments

Comments
 (0)