diff --git a/.circleci/config.yml b/.circleci/config.yml index 64950d91d..d77ae4f2c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -53,9 +53,8 @@ jobs: name: Install golang - run: command: | - sudo rm -rf /usr/bin/protoc - sudo ./scripts/vagrant-linux-priv-protoc.sh - name: install protoc + sudo ./scripts/vagrant-linux-priv-buf.sh + name: install buf - run: command: | curl -SL --fail -o /tmp/consul.zip https://releases.hashicorp.com/consul/1.8.3/consul_1.8.3_linux_amd64.zip @@ -171,9 +170,8 @@ jobs: name: Install golang - run: command: | - sudo rm -rf /usr/bin/protoc - sudo ./scripts/vagrant-linux-priv-protoc.sh - name: install protoc + sudo ./scripts/vagrant-linux-priv-buf.sh + name: install buf - run: command: | curl -SL --fail -o /tmp/consul.zip https://releases.hashicorp.com/consul/1.8.3/consul_1.8.3_linux_amd64.zip @@ -289,9 +287,8 @@ jobs: name: Install golang - run: command: | - sudo rm -rf /usr/bin/protoc - sudo ./scripts/vagrant-linux-priv-protoc.sh - name: install protoc + sudo ./scripts/vagrant-linux-priv-buf.sh + name: install buf - run: command: | curl -SL --fail -o /tmp/consul.zip https://releases.hashicorp.com/consul/1.8.3/consul_1.8.3_linux_amd64.zip @@ -407,9 +404,8 @@ jobs: name: Install golang - run: command: | - sudo rm -rf /usr/bin/protoc - sudo ./scripts/vagrant-linux-priv-protoc.sh - name: install protoc + sudo ./scripts/vagrant-linux-priv-buf.sh + name: install buf - run: command: | curl -SL --fail -o /tmp/consul.zip https://releases.hashicorp.com/consul/1.8.3/consul_1.8.3_linux_amd64.zip @@ -630,9 +626,8 @@ jobs: name: Install golang - run: command: | - sudo rm -rf /usr/bin/protoc - sudo ./scripts/vagrant-linux-priv-protoc.sh - name: install protoc + sudo ./scripts/vagrant-linux-priv-buf.sh + name: install buf - run: command: | curl -SL --fail -o /tmp/consul.zip https://releases.hashicorp.com/consul/1.8.3/consul_1.8.3_linux_amd64.zip @@ -740,9 +735,8 @@ jobs: command: apt-get update; apt-get install -y shellcheck sudo unzip - run: command: | - sudo rm -rf /usr/bin/protoc - sudo ./scripts/vagrant-linux-priv-protoc.sh - name: install protoc + sudo ./scripts/vagrant-linux-priv-buf.sh + name: install buf - run: command: "CCI_VERSION=\"0.1.5879\"\nCCI_SHA256=\"f178ea62c781aec06267017404f87983c87f171fd0e66ef3737916246ae66dd6\"\n\nURL=\"https://github.com/CircleCI-Public/circleci-cli/releases/download/v${CCI_VERSION}/circleci-cli_${CCI_VERSION}_linux_amd64.tar.gz\"\n\nmkdir -p /tmp/circleci-cli/\ncurl --fail --show-error --location \\\n -o /tmp/circleci-cli/cli.tar.gz \"${URL}\"\n\necho \"$CCI_SHA256 /tmp/circleci-cli/cli.tar.gz\" | sha256sum -c\n\ntar -xz --strip-components=1 \\\n -C /tmp/circleci-cli \\\n -f /tmp/circleci-cli/cli.tar.gz \\\n \"circleci-cli_${CCI_VERSION}_linux_amd64/circleci\" \n\nsudo cp /tmp/circleci-cli/circleci /usr/bin/circleci-local-cli\n\ncircleci-local-cli version\n" name: Install CircleCI CLI 0.1.5879 @@ -841,9 +835,8 @@ jobs: name: Install golang - run: command: | - sudo rm -rf /usr/bin/protoc - sudo ./scripts/vagrant-linux-priv-protoc.sh - name: install protoc + sudo ./scripts/vagrant-linux-priv-buf.sh + name: install buf - run: command: | curl -SL --fail -o /tmp/consul.zip https://releases.hashicorp.com/consul/1.8.3/consul_1.8.3_linux_amd64.zip @@ -933,9 +926,8 @@ jobs: command: make deps - run: command: | - sudo rm -rf /usr/bin/protoc - sudo ./scripts/vagrant-linux-priv-protoc.sh - name: install protoc + sudo ./scripts/vagrant-linux-priv-buf.sh + name: install buf - run: command: | curl -SL --fail -o /tmp/consul.zip https://releases.hashicorp.com/consul/1.8.3/consul_1.8.3_linux_amd64.zip @@ -1113,9 +1105,8 @@ jobs: name: Install golang - run: command: | - sudo rm -rf /usr/bin/protoc - sudo ./scripts/vagrant-linux-priv-protoc.sh - name: install protoc + sudo ./scripts/vagrant-linux-priv-buf.sh + name: install buf - run: command: | curl -SL --fail -o /tmp/consul.zip https://releases.hashicorp.com/consul/1.8.3/consul_1.8.3_linux_amd64.zip @@ -1203,9 +1194,8 @@ jobs: command: make deps - run: command: | - sudo rm -rf /usr/bin/protoc - sudo ./scripts/vagrant-linux-priv-protoc.sh - name: install protoc + sudo ./scripts/vagrant-linux-priv-buf.sh + name: install buf - run: command: sudo -E PATH="$GOPATH/bin:/usr/local/go/bin:$PATH" make generate-structs - run: @@ -1295,9 +1285,8 @@ jobs: name: Install golang - run: command: | - sudo rm -rf /usr/bin/protoc - sudo ./scripts/vagrant-linux-priv-protoc.sh - name: install protoc + sudo ./scripts/vagrant-linux-priv-buf.sh + name: install buf - run: command: | curl -SL --fail -o /tmp/consul.zip https://releases.hashicorp.com/consul/1.8.3/consul_1.8.3_linux_amd64.zip diff --git a/.circleci/config/commands/install-buf.yml b/.circleci/config/commands/install-buf.yml new file mode 100644 index 000000000..794c3a319 --- /dev/null +++ b/.circleci/config/commands/install-buf.yml @@ -0,0 +1,5 @@ +steps: + - run: + name: install buf + command: | + sudo ./scripts/vagrant-linux-priv-buf.sh diff --git a/.circleci/config/commands/install-protoc.yml b/.circleci/config/commands/install-protoc.yml deleted file mode 100644 index db0d0dad7..000000000 --- a/.circleci/config/commands/install-protoc.yml +++ /dev/null @@ -1,6 +0,0 @@ -steps: - - run: - name: install protoc - command: | - sudo rm -rf /usr/bin/protoc - sudo ./scripts/vagrant-linux-priv-protoc.sh diff --git a/.circleci/config/jobs/build-binaries.yml b/.circleci/config/jobs/build-binaries.yml index 21a0079c5..d6d603343 100644 --- a/.circleci/config/jobs/build-binaries.yml +++ b/.circleci/config/jobs/build-binaries.yml @@ -6,7 +6,7 @@ steps: - checkout - run: apt-get update; apt-get install -y sudo unzip zip - run: make deps - - install-protoc + - install-buf - run: sudo -E PATH="$GOPATH/bin:/usr/local/go/bin:$PATH" make generate-structs - run: make pkg/windows_amd64.zip pkg/linux_amd64.zip - store_artifacts: diff --git a/.circleci/config/jobs/lint-go.yml b/.circleci/config/jobs/lint-go.yml index fb04c011f..7a52d8690 100644 --- a/.circleci/config/jobs/lint-go.yml +++ b/.circleci/config/jobs/lint-go.yml @@ -2,7 +2,7 @@ executor: go steps: - checkout - run: apt-get update; apt-get install -y shellcheck sudo unzip - - install-protoc + - install-buf - install-circleci-local-cli - run: make deps lint-deps - run: make check diff --git a/.circleci/config/jobs/test-container.yml b/.circleci/config/jobs/test-container.yml index 744f931d0..933e2afb9 100644 --- a/.circleci/config/jobs/test-container.yml +++ b/.circleci/config/jobs/test-container.yml @@ -17,7 +17,7 @@ steps: - checkout - run: apt-get update; apt-get install -y shellcheck sudo unzip - run: make deps - - install-protoc + - install-buf - install-consul - install-vault - run-tests diff --git a/.circleci/config/jobs/test-machine.yml b/.circleci/config/jobs/test-machine.yml index 0cf1e5ae1..179b85a17 100644 --- a/.circleci/config/jobs/test-machine.yml +++ b/.circleci/config/jobs/test-machine.yml @@ -23,7 +23,7 @@ environment: steps: - checkout - install-golang - - install-protoc + - install-buf - install-consul - install-vault - run: diff --git a/GNUmakefile b/GNUmakefile index 226c9f876..04efa4fd5 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -203,6 +203,9 @@ check: ## Lint the source code @echo "==> Spell checking website..." @misspell -error -source=text website/pages/ + @echo "==> Checking for breaking changes in protos..." + @buf check breaking --config tools/buf/buf.yaml --against-config tools/buf/buf.yaml --against .git#tag=v1.0.0-beta3 + @echo "==> Check proto files are in-sync..." @$(MAKE) proto @if (git status -s | grep -q .pb.go); then echo the following proto files are out of sync; git status -s | grep .pb.go; exit 1; fi @@ -240,22 +243,10 @@ generate-structs: ## Update generated code @echo "--> Running go generate..." @go generate $(LOCAL_PACKAGES) -## The ",M=" below is required to tell -## protoc-gen-go what the import path for a given proto file should be. This is -## necessary when a proto file foo/a.proto imports a proto file from another -## directory, e.g. bar/b.proto .PHONY: proto proto: @echo "--> Generating proto bindings..." - @for file in $$(git ls-files "*.proto" | grep -E -v -- "vendor\/.*.proto|demo\/.*.proto"); do \ - protoc -I . --go_out=plugins=grpc\ - ,Mplugins/shared/hclspec/hcl_spec.proto=github.com/hashicorp/nomad/plugins/shared/hclspec\ - ,Mplugins/shared/structs/proto/stats.proto=github.com/hashicorp/nomad/plugins/shared/structs/proto\ - ,Mplugins/shared/structs/proto/attribute.proto=github.com/hashicorp/nomad/plugins/shared/structs/proto\ - ,Mplugins/shared/structs/proto/recoverable_error.proto=github.com/hashicorp/nomad/plugins/shared/structs/proto\ - ,Mplugins/drivers/proto/driver.proto=github.com/hashicorp/nomad/plugins/drivers/proto\ - :. $$file; \ - done + @buf --config tools/buf/buf.yaml --template tools/buf/buf.gen.yaml generate .PHONY: generate-examples generate-examples: command/job_init.bindata_assetfs.go diff --git a/README.md b/README.md index 69aadeb3a..1fade3c01 100644 --- a/README.md +++ b/README.md @@ -195,8 +195,8 @@ $ make dev-ui $ bin/nomad ... -To compile protobuf files, installing protoc is required: See -https://github.com/google/protobuf for more information. +To compile protobuf files, installing [buf](https://docs.buf.build/installation) is required. + ``` **Note:** Building the Nomad UI from source requires Node, Yarn, and Ember CLI. These tools are already in the Vagrant VM. Read the [UI README](https://github.com/hashicorp/nomad/blob/master/ui/README.md) for more info. diff --git a/Vagrantfile b/Vagrantfile index 6f744f684..f55b623b7 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -158,7 +158,7 @@ def configureLinuxProvisioners(vmCfg) vmCfg.vm.provision "shell", privileged: true, - path: './scripts/vagrant-linux-priv-protoc.sh' + path: './scripts/vagrant-linux-priv-buf.sh' return vmCfg end diff --git a/plugins/shared/hclspec/hcl_spec.pb.go b/plugins/shared/hclspec/hcl_spec.pb.go index 46d4a1736..0bf62c49a 100644 --- a/plugins/shared/hclspec/hcl_spec.pb.go +++ b/plugins/shared/hclspec/hcl_spec.pb.go @@ -36,7 +36,7 @@ //The following type names and type constructors are supported: // // `any` is a wildcard that accepts a value of any type. (In HCL terms, this -//is the _dynamic pseudo-type_.) +// is the _dynamic pseudo-type_.) // `string` is a Unicode string. // `number` is an arbitrary-precision floating point number. // `bool` is a boolean value (`true` or `false`) @@ -44,11 +44,11 @@ // `set(element_type)` constructs a set type with the given element type // `map(element_type)` constructs a map type with the given element type // `object({name1 = element_type, name2 = element_type, ...})` constructs -//an object type with the given attribute types. +// an object type with the given attribute types. // `tuple([element_type, element_type, ...])` constructs a tuple type with -//the given element types. This can be used, for example, to require an -//array with a particular number of elements, or with elements of different -//types. +// the given element types. This can be used, for example, to require an +// array with a particular number of elements, or with elements of different +// types. // //`null` is a valid value of any type, and not a type itself. @@ -278,26 +278,26 @@ func (*Spec) XXX_OneofWrappers() []interface{} { // //```hcl //Attr { -//name = "document_root" -//type = string -//required = true +// name = "document_root" +// type = string +// required = true //} //``` // //`Attr` spec blocks accept the following arguments: // // `name` (required) - The attribute name to expect within the HCL input file. -//This may be omitted when a default name selector is created by a parent -//`Object` spec, if the input attribute name should match the output JSON -//object property name. +// This may be omitted when a default name selector is created by a parent +// `Object` spec, if the input attribute name should match the output JSON +// object property name. // // `type` (optional) - A [type expression](#type-expressions) that the given -//attribute value must conform to. If this argument is set, `hcldec` will -//automatically convert the given input value to this type or produce an -//error if that is not possible. +// attribute value must conform to. If this argument is set, `hcldec` will +// automatically convert the given input value to this type or produce an +// error if that is not possible. // // `required` (optional) - If set to `true`, `hcldec` will produce an error -//if a value is not provided for the source attribute. +// if a value is not provided for the source attribute. // //`Attr` is a leaf spec type, so no nested spec blocks are permitted. type Attr struct { @@ -361,28 +361,28 @@ func (m *Attr) GetRequired() bool { // //```hcl //Block { -//name = "logging" +// name = "logging" // -//Object { -//Attr "level" { -//type = string -//} -//Attr "file" { -//type = string -//} -//} +// Object { +// Attr "level" { +// type = string +// } +// Attr "file" { +// type = string +// } +// } //} //``` // //`Block` spec blocks accept the following arguments: // // `name` (required) - The block type name to expect within the HCL -//input file. This may be omitted when a default name selector is created -//by a parent `Object` spec, if the input block type name should match the -//output JSON object property name. +// input file. This may be omitted when a default name selector is created +// by a parent `Object` spec, if the input block type name should match the +// output JSON object property name. // // `required` (optional) - If set to `true`, `hcldec` will produce an error -//if a block of the specified type is not present in the current body. +// if a block of the specified type is not present in the current body. // //`Block` creates a validation constraint that there must be zero or one blocks //of the given type name, or exactly one if `required` is set. @@ -446,37 +446,37 @@ func (m *Block) GetNested() *Spec { } // -//The BlockAttrs spec type is similar to an Attr spec block of a map type, -//but it produces a map from the attributes of a block rather than from an -//attribute's expression. +// The BlockAttrs spec type is similar to an Attr spec block of a map type, +// but it produces a map from the attributes of a block rather than from an +// attribute's expression. // -//```hcl -//BlockAttrs { -//name = "variables" -//type = string -//required = false -//} -//``` +// ```hcl +// BlockAttrs { +// name = "variables" +// type = string +// required = false +// } +// ``` // -//This allows a map with user-defined keys to be produced within block syntax, -//but due to the constraints of that syntax it also means that the user will -//be unable to dynamically-generate either individual key names using key -//expressions or the entire map value using a `for` expression. +// This allows a map with user-defined keys to be produced within block syntax, +// but due to the constraints of that syntax it also means that the user will +// be unable to dynamically-generate either individual key names using key +// expressions or the entire map value using a `for` expression. // -//`BlockAttrs` spec blocks accept the following arguments: +// `BlockAttrs` spec blocks accept the following arguments: // // `name` (required) - The block type name to expect within the HCL -//input file. This may be omitted when a default name selector is created -//by a parent `object` spec, if the input block type name should match the -//output JSON object property name. +// input file. This may be omitted when a default name selector is created +// by a parent `object` spec, if the input block type name should match the +// output JSON object property name. // // `type` (required) - The value type to require for each of the -//attributes within a matched block. The resulting value will be a JSON -//object whose property values are of this type. +// attributes within a matched block. The resulting value will be a JSON +// object whose property values are of this type. // // `required` (optional) - If `true`, an error will be produced if a block -//of the given type is not present. If `false` -- the default -- an absent -//block will be indicated by producing `null`. +// of the given type is not present. If `false` -- the default -- an absent +// block will be indicated by producing `null`. type BlockAttrs struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` @@ -538,33 +538,33 @@ func (m *BlockAttrs) GetRequired() bool { // //```hcl //BlockList { -//name = "log_file" +// name = "log_file" // -//Object { -//Attr "level" { -//type = string -//} -//Attr "filename" { -//type = string -//required = true -//} -//} +// Object { +// Attr "level" { +// type = string +// } +// Attr "filename" { +// type = string +// required = true +// } +// } //} //``` // //`BlockList` spec blocks accept the following arguments: // // `name` (required) - The block type name to expect within the HCL -//input file. This may be omitted when a default name selector is created -//by a parent `Object` spec, if the input block type name should match the -//output JSON object property name. +// input file. This may be omitted when a default name selector is created +// by a parent `Object` spec, if the input block type name should match the +// output JSON object property name. // // `min_items` (optional) - If set to a number greater than zero, `hcldec` will -//produce an error if fewer than the given number of blocks are present. +// produce an error if fewer than the given number of blocks are present. // // `max_items` (optional) - If set to a number greater than zero, `hcldec` will -//produce an error if more than the given number of blocks are present. This -//attribute must be greater than or equal to `min_items` if both are set. +// produce an error if more than the given number of blocks are present. This +// attribute must be greater than or equal to `min_items` if both are set. // //`Block` creates a validation constraint on the number of blocks of the given //type that must be present. @@ -640,17 +640,17 @@ func (m *BlockList) GetNested() *Spec { // //```hcl //BlockSet { -//name = "log_file" +// name = "log_file" // -//Object { -//Attr "level" { -//type = string -//} -//Attr "filename" { -//type = string -//required = true -//} -//} +// Object { +// Attr "level" { +// type = string +// } +// Attr "filename" { +// type = string +// required = true +// } +// } //} //``` // @@ -726,30 +726,30 @@ func (m *BlockSet) GetNested() *Spec { // //```hcl //BlockMap { -//name = "log_file" -//labels = ["filename"] +// name = "log_file" +// labels = ["filename"] // -//Object { -//Attr "level" { -//type = string -//required = true -//} -//} +// Object { +// Attr "level" { +// type = string +// required = true +// } +// } //} //``` // //`BlockMap` spec blocks accept the following arguments: // // `name` (required) - The block type name to expect within the HCL -//input file. This may be omitted when a default name selector is created -//by a parent `Object` spec, if the input block type name should match the -//output JSON object property name. +// input file. This may be omitted when a default name selector is created +// by a parent `Object` spec, if the input block type name should match the +// output JSON object property name. // // `labels` (required) - A list of user-oriented block label names. Each entry -//in this list creates one level of object within the output value, and -//requires one additional block header label on any child block of this type. -//Block header labels are the quoted strings that appear after the block type -//name but before the opening `{`. +// in this list creates one level of object within the output value, and +// requires one additional block header label on any child block of this type. +// Block header labels are the quoted strings that appear after the block type +// name but before the opening `{`. // //`Block` creates a validation constraint on the number of labels that blocks //of the given type must have. @@ -820,14 +820,14 @@ func (m *BlockMap) GetNested() *Spec { // //```hcl //Literal { -//value = "hello world" +// value = "hello world" //} //``` // //`Literal` spec blocks accept the following argument: // // `value` (required) - The value to return. This attribute may be an expression -//that uses [functions](#spec-definition-functions). +// that uses [functions](#spec-definition-functions). // //`Literal` is a leaf spec type, so no nested spec blocks are permitted. type Literal struct { @@ -876,13 +876,13 @@ func (m *Literal) GetValue() string { // //```hcl //Default { -//Attr { -//name = "private" -//type = bool -//} -//Literal { -//value = false -//} +// Attr { +// name = "private" +// type = bool +// } +// Literal { +// value = false +// } //} //``` // @@ -947,17 +947,17 @@ func (m *Default) GetDefault() *Spec { // //```hcl //Object { -//Attr "name" { -//type = "string" -//} -//Block "address" { -//Object { -//Attr "street" { -//type = "string" -//} -//# ... -//} -//} +// Attr "name" { +// type = "string" +// } +// Block "address" { +// Object { +// Attr "street" { +// type = "string" +// } +// # ... +// } +// } //} //``` // @@ -1014,14 +1014,14 @@ func (m *Object) GetAttributes() map[string]*Spec { // //```hcl //Array { -//Attr { -//name = "first_element" -//type = "string" -//} -//Attr { -//name = "second_element" -//type = "string" -//} +// Attr { +// name = "first_element" +// type = "string" +// } +// Attr { +// name = "second_element" +// type = "string" +// } //} //``` // diff --git a/scripts/release/Dockerfile b/scripts/release/Dockerfile index 65c75c057..0bc79cad9 100644 --- a/scripts/release/Dockerfile +++ b/scripts/release/Dockerfile @@ -24,8 +24,8 @@ RUN /tmp/scripts/vagrant-linux-priv-config.sh COPY ./scripts/vagrant-linux-priv-go.sh /tmp/scripts/vagrant-linux-priv-go.sh RUN /tmp/scripts/vagrant-linux-priv-go.sh -COPY ./scripts/vagrant-linux-priv-protoc.sh /tmp/scripts/vagrant-linux-priv-protoc.sh -RUN /tmp/scripts/vagrant-linux-priv-protoc.sh +COPY ./scripts/vagrant-linux-priv-buf.sh /tmp/scripts/vagrant-linux-priv-buf.sh +RUN /tmp/scripts/vagrant-linux-priv-buf.sh USER vagrant diff --git a/scripts/vagrant-linux-priv-buf.sh b/scripts/vagrant-linux-priv-buf.sh new file mode 100755 index 000000000..d28212525 --- /dev/null +++ b/scripts/vagrant-linux-priv-buf.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +set -o errexit + +# Make sure you grab the latest version +VERSION=0.30.1 +DOWNLOAD=https://github.com/bufbuild/buf/releases/download/v${VERSION}/buf-Linux-x86_64 + +function install() { + if command -v buf >/dev/null; then + if [ "${VERSION}" = "$(buf --version)" ] ; then + return + fi + fi + + # Download + curl -sSL --fail "$DOWNLOAD" -o /tmp/buf + + # make executable + chmod +x /tmp/buf + + # Move buf to /usr/bin + mv /tmp/buf /usr/bin/buf +} + +install diff --git a/scripts/vagrant-linux-priv-protoc.sh b/scripts/vagrant-linux-priv-protoc.sh deleted file mode 100755 index 8e8c6dbf2..000000000 --- a/scripts/vagrant-linux-priv-protoc.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit - -# Make sure you grab the latest version -VERSION=3.6.1 -DOWNLOAD=https://github.com/google/protobuf/releases/download/v${VERSION}/protoc-${VERSION}-linux-x86_64.zip - -function install_protoc() { - if [[ -e /usr/local/bin/protoc ]] ; then - if [ "${VERSION}" = "$(protoc --version | cut -d ' ' -f 2)" ] ; then - return - fi - fi - - # Download - curl -sSL --fail -o /tmp/protoc.zip ${DOWNLOAD} - - # Unzip - unzip /tmp/protoc.zip -d /tmp/protoc3 - - # all protoc files should be world-wide readable, specially the include files - chmod -R a+r /tmp/protoc3 - - # Move protoc to /usr/local/bin/ - mv /tmp/protoc3/bin/* /usr/local/bin/ - - # Move protoc3/include to /usr/local/include/ - mv /tmp/protoc3/include/* /usr/local/include/ - - # Link - ln -s /usr/local/bin/protoc /usr/bin/protoc - - rm -rf /tmp/protoc3 /tmp/protoc.zip -} - -install_protoc diff --git a/tools/buf/README.md b/tools/buf/README.md new file mode 100644 index 000000000..ee005ef20 --- /dev/null +++ b/tools/buf/README.md @@ -0,0 +1,14 @@ +# Buf + +> `buf` is a high-performance `protoc` replacement. + +## Installation + +See installation instructions [here](https://docs.buf.build/installation/). + +## Usage +`make proto` in the root of this repo will invoke `buf` using the configuration in this directory. + +## Why use `buf` instead of `protoc`? + +Buf is a user-friendly tool to work with Protobuf that outperforms `protoc` in every conceivable way. It was written by the author(s) of [`prototool`](https://github.com/uber/prototool), another tool that made generating Protobuf easier, but which is now deprecated in favor of `buf`. Buf also does linting and breaking-change detection. diff --git a/tools/buf/buf.gen.yaml b/tools/buf/buf.gen.yaml new file mode 100644 index 000000000..0013f9e88 --- /dev/null +++ b/tools/buf/buf.gen.yaml @@ -0,0 +1,16 @@ +version: v1beta1 + +plugins: + - name: go + out: . + ## The ",M=" below is required to tell + ## protoc-gen-go what the import path for a given proto file should be. This is + ## necessary when a proto file foo/a.proto imports a proto file from another + ## directory, e.g. bar/b.proto + opt: "plugins=grpc\ + ,Mplugins/shared/hclspec/hcl_spec.proto=github.com/hashicorp/nomad/plugins/shared/hclspec\ + ,Mplugins/shared/structs/proto/stats.proto=github.com/hashicorp/nomad/plugins/shared/structs/proto\ + ,Mplugins/shared/structs/proto/attribute.proto=github.com/hashicorp/nomad/plugins/shared/structs/proto\ + ,Mplugins/shared/structs/proto/recoverable_error.proto=github.com/hashicorp/nomad/plugins/shared/structs/proto\ + ,Mplugins/drivers/proto/driver.proto=github.com/hashicorp/nomad/plugins/drivers/proto\ + " diff --git a/tools/buf/buf.yaml b/tools/buf/buf.yaml new file mode 100644 index 000000000..8bf9cf4a0 --- /dev/null +++ b/tools/buf/buf.yaml @@ -0,0 +1,59 @@ +version: v1beta1 +build: + roots: + - . + excludes: + - vendor +lint: + use: + - DEFAULT + ignore_only: + ENUM_NO_ALLOW_ALIAS: + - plugins/drivers/proto/driver.proto + ENUM_VALUE_PREFIX: + - plugins/base/proto/base.proto + - plugins/drivers/proto/driver.proto + ENUM_ZERO_VALUE_SUFFIX: + - plugins/base/proto/base.proto + - plugins/drivers/proto/driver.proto + PACKAGE_DIRECTORY_MATCH: + - client/logmon/proto/logmon.proto + - drivers/docker/docklog/proto/docker_logger.proto + - drivers/shared/executor/proto/executor.proto + - plugins/base/proto/base.proto + - plugins/device/proto/device.proto + - plugins/drivers/proto/driver.proto + - plugins/shared/hclspec/hcl_spec.proto + - plugins/shared/structs/proto/attribute.proto + - plugins/shared/structs/proto/recoverable_error.proto + - plugins/shared/structs/proto/stats.proto + PACKAGE_VERSION_SUFFIX: + - client/logmon/proto/logmon.proto + - drivers/docker/docklog/proto/docker_logger.proto + - drivers/shared/executor/proto/executor.proto + - plugins/base/proto/base.proto + - plugins/device/proto/device.proto + - plugins/drivers/proto/driver.proto + - plugins/shared/hclspec/hcl_spec.proto + - plugins/shared/structs/proto/attribute.proto + - plugins/shared/structs/proto/recoverable_error.proto + - plugins/shared/structs/proto/stats.proto + RPC_REQUEST_RESPONSE_UNIQUE: + - drivers/shared/executor/proto/executor.proto + - plugins/drivers/proto/driver.proto + RPC_REQUEST_STANDARD_NAME: + - drivers/shared/executor/proto/executor.proto + RPC_RESPONSE_STANDARD_NAME: + - drivers/shared/executor/proto/executor.proto + - plugins/drivers/proto/driver.proto + SERVICE_SUFFIX: + - client/logmon/proto/logmon.proto + - drivers/docker/docklog/proto/docker_logger.proto + - drivers/shared/executor/proto/executor.proto + - plugins/base/proto/base.proto + - plugins/device/proto/device.proto + - plugins/drivers/proto/driver.proto + +breaking: + use: + - WIRE_JSON \ No newline at end of file