This change includes a bunch of refactorings I made in prep for doing refresh (first, the command, see pulumi/pulumi#1081): * The primary change is to change the way the engine's core update functionality works with respect to deploy.Source. This is the way we can plug in new sources of resource information during planning (and, soon, diffing). The way I intend to model refresh is by having a new kind of source, deploy.RefreshSource, which will let us do virtually everything about an update/diff the same way with refreshes, which avoid otherwise duplicative effort. This includes changing the planOptions (nee deployOptions) to take a new SourceFunc callback, which is responsible for creating a source specific to the kind of plan being requested. Preview, Update, and Destroy now are primarily differentiated by the kind of deploy.Source that they return, rather than sprinkling things like `if Destroying` throughout. This tidies up some logic and, more importantly, gives us precisely the refresh hook we need. * Originally, we used the deploy.NullSource for Destroy operations. This simply returns nothing, which is how Destroy works. For some reason, we were no longer doing this, and instead had some `if Destroying` cases sprinkled throughout the deploy.EvalSource. I think this is a vestige of some old way we did configuration, at least judging by a comment, which is apparently no longer relevant. * Move diff and diff-printing logic within the engine into its own pkg/engine/diff.go file, to prepare for upcoming work. * I keep noticing benign diffs anytime I regenerate protobufs. I suspect this is because we're also on different versions. I changed generate.sh to also dump the version into grpc_version.txt. At least we can understand where the diffs are coming from, decide whether to take them (i.e., a newer version), and ensure that as a team we are monotonically increasing, and not going backwards. * I also tidied up some tiny things I noticed while in there, like comments, incorrect types, lint suppressions, and so on.
45 lines
2.1 KiB
Bash
Executable file
45 lines
2.1 KiB
Bash
Executable file
#!/bin/bash
|
|
# This script regenerates all Protobuf/gRPC client files.
|
|
#
|
|
# For now, it must be run manually, and the results are checked into source control. Eventually we might choose to
|
|
# automate this process as part of the overall build so that it's less manual and hence error prone.
|
|
#
|
|
# To run this script, the following pre-requisites are necessary:
|
|
#
|
|
# 1) Install the latest Protobuf compiler from https://github.com/google/protobuf/releases.
|
|
# 2) Add the `protoc` binary to your PATH (so that it can be found below).
|
|
# 3) Install the Golang Protobuf compiler by running this command from your Go workspace (also on your PATH):
|
|
# go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
|
|
# 4) Install the Node.js gRPC SDK, which includes the gRPC Node.js compiler plugin
|
|
# npm install -g grpc-tools
|
|
# and add the `grpc_tools_node_protoc_plugin` binary to your PATH.a
|
|
# 5) Install the Python gRPC SDK, which includes the gRPC Python compiler plugin
|
|
# python -m pip install grpcio grpcio-tools
|
|
#
|
|
# The results are checked into bin/; at this moment, they need to be copied to their final destinations manually.
|
|
set -e
|
|
|
|
PROTOC=$(which protoc || { >&2 echo "error: Protobuf compiler (protoc) not found on PATH"; exit 1; })
|
|
|
|
echo Generating Protobuf/gRPC SDK files:
|
|
echo -e "\tVERSION: $(protoc --version)"
|
|
echo -e "Generated by version $(protoc --version) of protoc" > ./grpc_version.txt
|
|
|
|
GO_PULUMIRPC=./go
|
|
GO_PROTOFLAGS="plugins=grpc"
|
|
echo -e "\tGo: $GO_PULUMIRPC [$GO_PROTOFLAGS]"
|
|
mkdir -p $GO_PULUMIRPC
|
|
$PROTOC --go_out=$GO_PROTOFLAGS:$GO_PULUMIRPC *.proto
|
|
|
|
JS_PULUMIRPC=../nodejs/proto/
|
|
JS_PROTOFLAGS="import_style=commonjs,binary"
|
|
echo -e "\tJS: $JS_PULUMIRPC [$JS_PROTOFLAGS]"
|
|
mkdir -p $JS_PULUMIRPC
|
|
$PROTOC --js_out=$JS_PROTOFLAGS:$JS_PULUMIRPC --grpc_out=$JS_PULUMIRPC --plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` *.proto
|
|
|
|
PY_PULUMIRPC=../python/lib/pulumi/runtime/proto/
|
|
echo -e "\tPython: $PY_PULUMIRPC"
|
|
mkdir -p $PY_PULUMIRPC
|
|
python -m grpc_tools.protoc -I./ --python_out=$PY_PULUMIRPC --grpc_python_out=$PY_PULUMIRPC *.proto
|
|
|
|
echo Done.
|