construct method
Future<ConstructResponse>
construct(
- ServiceCall call,
- ConstructRequest request
)
Implementation
@override
Future<providerpb.ConstructResponse> construct(
ServiceCall call,
providerpb.ConstructRequest request,
) async {
return _withSerializedRuntime(() async {
await _configureRuntime(
project: request.project,
stack: request.stack,
parallel: request.parallel,
monitorEndpoint: request.monitorEndpoint,
dryRun: request.dryRun,
organization: request.organization,
config: request.config,
configSecretKeys: request.configSecretKeys,
);
final inputs = await deserializeInputs(
request.inputs,
(key) => request.inputDependencies[key]?.urns ?? const <String>[],
);
final options = _buildConstructOptions(request);
try {
late final ConstructResult result;
try {
result = await provider.construct(
request.name,
request.type,
inputs,
options,
);
} on UnsupportedProviderOperationError catch (error) {
throw GrpcError.unimplemented(error.toString());
}
await DeploymentImpl.current?.registerOutputs();
final response = providerpb.ConstructResponse();
response.urn = await result.urn.toOutput().getValue();
final serialized = await _serializeInputMap(
'construct(${request.type}, ${request.name})',
result.state,
);
response.state = serialized.struct;
for (final entry in serialized.dependencies.entries) {
response.stateDependencies[entry.key] =
providerpb.ConstructResponse_PropertyDependencies()
..urns.addAll(entry.value);
}
return response;
} on InputPropertiesError catch (error) {
throw _buildInvalidPropertiesError(error.message, error.errors);
} on InputPropertyError catch (error) {
throw _buildInvalidPropertiesError('', <InputPropertyErrorDetails>[
InputPropertyErrorDetails(
propertyPath: error.propertyPath,
reason: error.reason,
),
]);
} on ComponentInitError catch (error) {
throw GrpcError.unknown(error.toString());
}
});
}