diff --git a/.circleci/config.yml b/.circleci/config.yml index bd61127561..5e7fa893f0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -377,6 +377,7 @@ jobs: - run: name: Check flag generation command: ./scripts/ci/lint/flags.bash + - run: make checkgenerate - run: make vet - run: make checkfmt - run: GO111MODULE=on go mod vendor # staticcheck looks in vendor for dependencies. diff --git a/.gitignore b/.gitignore index 48fe97c3ab..7216fb83ca 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,8 @@ influxd.bolt *.db *.sqlite -# GPG private keys +# Files generated in CI +rustup-init.sh private.key # TLS keys generated for testing diff --git a/.goreleaser.yml b/.goreleaser.yml index c417eaa0d0..de723172b6 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -27,7 +27,7 @@ builds: - -s -w -X main.version=nightly -X main.commit={{.ShortCommit}} -X main.date={{.Date}} {{if eq .Os "linux"}}-extldflags "-fno-PIC -static -Wl,-z,stack-size=8388608"{{end}} binary: influxd hooks: - pre: make generate + pre: make generate-web-assets nfpms: - id: "influxdb2" diff --git a/Makefile b/Makefile index 4ceb6a6293..4b2e5351e6 100644 --- a/Makefile +++ b/Makefile @@ -7,14 +7,7 @@ # # * All cmds must be added to this top level Makefile. # * All binaries are placed in ./bin, its recommended to add this directory to your PATH. -# * Each package that has a need to run go generate, must have its own Makefile for that purpose. -# * All recursive Makefiles must support the all and clean targets # - -# SUBDIRS are directories that have their own Makefile. -# It is required that all SUBDIRS have the `all` and `clean` targets. -SUBDIRS := static storage - export GOPATH=$(shell go env GOPATH) export GOOS=$(shell go env GOOS) export GOARCH=$(shell go env GOARCH) @@ -76,12 +69,7 @@ SOURCES_NO_VENDOR := $(shell find . -path ./vendor -prune -o -name "*.go" -not - CMDS := \ bin/$(GOOS)/influxd -all: $(SUBDIRS) generate $(CMDS) - -# Target to build subdirs. -# Each subdirs must support the `all` target. -$(SUBDIRS): - $(MAKE) -C $@ all +all: generate $(CMDS) # # Define targets for commands @@ -89,9 +77,18 @@ $(SUBDIRS): bin/$(GOOS)/influxd: $(SOURCES) $(GO_BUILD) -o $@ ./cmd/$(shell basename "$@") -# Ease of use build for just the go binary influxd: bin/$(GOOS)/influxd +static/data/build: scripts/fetch-ui-assets.sh + ./scripts/fetch-ui-assets.sh + +static/data/swagger.json: scripts/fetch-swagger.sh + ./scripts/fetch-swagger.sh + +# static/static_gen.go is the output of go-bindata, embedding all assets used by the UI. +static/static_gen.go: static/data/build static/data/swagger.json + $(GO_GENERATE) ./static + # # Define action only targets # @@ -112,7 +109,29 @@ checktidy: checkgenerate: ./etc/checkgenerate.sh -generate: $(SUBDIRS) +# generate-web-assets outputs all the files needed to link the UI to the back-end. +# Currently, none of these files are tracked by git. +generate-web-assets: static/static_gen.go + +# generate-sources outputs all the Go files generated from protobufs, tmpls, and other tooling. +# These files are tracked by git; CI will enforce that they are up-to-date. +generate-sources: gogo tmpl stringer goimports + $(GO_GENERATE) ./influxql/... ./models/... ./pkg/... ./storage/... ./tsdb/... ./v1/... + +generate: generate-web-assets generate-sources + +gogo: + $(GO_INSTALL) github.com/gogo/protobuf/protoc-gen-gogo + $(GO_INSTALL) github.com/gogo/protobuf/protoc-gen-gogofaster + +tmpl: + $(GO_INSTALL) github.com/benbjohnson/tmpl + +stringer: + $(GO_INSTALL) golang.org/x/tools/cmd/stringer + +goimports: + $(GO_INSTALL) golang.org/x/tools/cmd/goimports test-go: $(GO_TEST) $(GO_TEST_PATHS) @@ -141,10 +160,10 @@ bench: build: all pkg-config: - go build -o $(GOPATH)/bin/pkg-config github.com/influxdata/pkg-config + $(GO_INSTALL) github.com/influxdata/pkg-config clean: - @for d in $(SUBDIRS); do $(MAKE) -C $$d clean; done + $(RM) -r static/static_gen.go static/data $(RM) -r bin $(RM) -r dist diff --git a/etc/checkgenerate.sh b/etc/checkgenerate.sh index 8836e7cd54..53aba3943e 100755 --- a/etc/checkgenerate.sh +++ b/etc/checkgenerate.sh @@ -2,12 +2,15 @@ set -e -make clean -make generate +function check_changes () { + changes="$(git status --porcelain=v1 2>/dev/null)" + if [ -n "$changes" ] ; then + echo $1 + echo "$changes" + exit 1 + fi +} -status=$(git status --porcelain) -if [ -n "$status" ]; then - >&2 echo "generated code is not accurate, please run make generate" - >&2 echo -e "Files changed:\n$status" - exit 1 -fi +check_changes "git is dirty before running 'make generate-sources!'" +make generate-sources +check_changes "git is dirty after running 'make generate-sources'!" diff --git a/scripts/fetch-swagger.sh b/scripts/fetch-swagger.sh index da100bb0f8..dda1d1a4b1 100755 --- a/scripts/fetch-swagger.sh +++ b/scripts/fetch-swagger.sh @@ -5,11 +5,16 @@ set -e +declare -r SCRIPT_DIR=$(cd $(dirname ${0}) >/dev/null 2>&1 && pwd) +declare -r ROOT_DIR=$(dirname ${SCRIPT_DIR}) +declare -r STATIC_DIR="$ROOT_DIR/static" + # Pins the swagger that will be downloaded to a specific commit declare -r OPENAPI_SHA=c87a08f832e79bc338a37509028641cda9e1875b # Don't do a shallow clone since the commit we want might be several commits # back; but do only clone the main branch. git clone https://github.com/influxdata/openapi.git --single-branch -cd openapi && git checkout ${OPENAPI_SHA} --quiet && cp contracts/oss.json ../data/swagger.json +mkdir -p "$STATIC_DIR/data" +cd openapi && git checkout ${OPENAPI_SHA} --quiet && cp contracts/oss.json "$STATIC_DIR/data/swagger.json" cd ../ && rm -rf openapi diff --git a/scripts/fetch-ui-assets.sh b/scripts/fetch-ui-assets.sh index ed83b9ae5d..fb0099e702 100755 --- a/scripts/fetch-ui-assets.sh +++ b/scripts/fetch-ui-assets.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # This script is used to download built UI assets from the "influxdata/ui" # repository. The built UI assets are attached to a release in "influxdata/ui", @@ -14,6 +14,10 @@ set -e +declare -r SCRIPT_DIR=$(cd $(dirname ${0}) >/dev/null 2>&1 && pwd) +declare -r ROOT_DIR=$(dirname ${SCRIPT_DIR}) +declare -r STATIC_DIR="$ROOT_DIR/static" + # Download the SHA256 checksum attached to the release. To verify the integrity # of the download, this checksum will be used to check the download tar file # containing the built UI assets. @@ -27,7 +31,7 @@ echo "$(cat sha256.txt)" | sha256sum --check -- \ || { echo "Checksums did not match for downloaded UI assets!"; exit 1; } # Extract the assets and clean up. -mkdir data -tar -xzf build.tar.gz -C data +mkdir -p "$STATIC_DIR/data" +tar -xzf build.tar.gz -C "$STATIC_DIR/data" rm sha256.txt rm build.tar.gz diff --git a/static/Makefile b/static/Makefile deleted file mode 100644 index e59cb2a0cd..0000000000 --- a/static/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -# List any generated files here -TARGETS = static_gen.go -# List any source files used to generate the targets here -SOURCES = data/build data/swagger.json - -# Default target -all: $(TARGETS) data/build data/swagger.json - -# Clean all targets recursively -clean: - rm -f $(TARGETS) - rm -r data - -# Target for the built UI assets directory. -data/build: - ../scripts/fetch-ui-assets.sh - -# Target for the swagger.json from the openapi repo -data/swagger.json: - ../scripts/fetch-swagger.sh - -# Define go generate if not already defined -GO_GENERATE := go generate - -# Run go generate for the targets -$(TARGETS): $(SOURCES) - $(GO_GENERATE) -x - -.PHONY: all clean diff --git a/storage/Makefile b/storage/Makefile deleted file mode 100644 index 61856961b2..0000000000 --- a/storage/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -# List any generated files here -TARGETS = -# List any source files used to generate the targets here -SOURCES = -# List any directories that have their own Makefile here -SUBDIRS = flux - -# Default target -all: $(SUBDIRS) $(TARGETS) - -# Recurse into subdirs for same make goal -$(SUBDIRS): - $(MAKE) -C $@ $(MAKECMDGOALS) - -# Clean all targets recursively -clean: $(SUBDIRS) - rm -f $(TARGETS) - -# Define go generate if not already defined -GO_GENERATE := go generate - -# Run go generate for the targets -$(TARGETS): $(SOURCES) - $(GO_GENERATE) -x - -.PHONY: all clean $(SUBDIRS) diff --git a/storage/flux/Makefile b/storage/flux/Makefile deleted file mode 100644 index 068baa3b1c..0000000000 --- a/storage/flux/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -# List any generated files here -TARGETS = table.gen.go - -# List any source files used to generate the targets here -SOURCES = table.gen.go.tmpl - -# List any directories that have their own Makefile here -SUBDIRS = - -# Default target -all: $(SUBDIRS) $(TARGETS) - -# Recurse into subdirs for same make goal -$(SUBDIRS): - $(MAKE) -C $@ $(MAKECMDGOALS) - -# Clean all targets recursively -clean: $(SUBDIRS) - rm -f $(TARGETS) - -# Define go generate if not already defined -GO_GENERATE := go generate - -# Run go generate for the targets -$(TARGETS): $(SOURCES) - $(GO_GENERATE) -x - -.PHONY: all clean $(SUBDIRS) diff --git a/storage/reads/datatypes/predicate.pb.go b/storage/reads/datatypes/predicate.pb.go index 1546df83ed..81993b5a7f 100644 --- a/storage/reads/datatypes/predicate.pb.go +++ b/storage/reads/datatypes/predicate.pb.go @@ -1144,10 +1144,7 @@ func (m *Node) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthPredicate - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthPredicate } if (iNdEx + skippy) > l { @@ -1233,10 +1230,7 @@ func (m *Predicate) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthPredicate - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthPredicate } if (iNdEx + skippy) > l { diff --git a/storage/reads/datatypes/storage_common.pb.go b/storage/reads/datatypes/storage_common.pb.go index f6822b2800..48fc71eb60 100644 --- a/storage/reads/datatypes/storage_common.pb.go +++ b/storage/reads/datatypes/storage_common.pb.go @@ -3913,10 +3913,7 @@ func (m *ReadFilterRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -4168,10 +4165,7 @@ func (m *ReadGroupRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -4240,10 +4234,7 @@ func (m *Aggregate) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -4361,10 +4352,7 @@ func (m *Tag) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -4448,10 +4436,7 @@ func (m *ReadResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -4746,10 +4731,7 @@ func (m *ReadResponse_Frame) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -4863,10 +4845,7 @@ func (m *ReadResponse_GroupFrame) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -4969,10 +4948,7 @@ func (m *ReadResponse_SeriesFrame) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -5128,10 +5104,7 @@ func (m *ReadResponse_FloatPointsFrame) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -5309,10 +5282,7 @@ func (m *ReadResponse_IntegerPointsFrame) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -5490,10 +5460,7 @@ func (m *ReadResponse_UnsignedPointsFrame) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -5665,10 +5632,7 @@ func (m *ReadResponse_BooleanPointsFrame) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -5802,10 +5766,7 @@ func (m *ReadResponse_StringPointsFrame) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -5887,10 +5848,7 @@ func (m *Capability) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -6052,7 +6010,7 @@ func (m *CapabilitiesResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > postIndex { @@ -6069,10 +6027,7 @@ func (m *CapabilitiesResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -6160,10 +6115,7 @@ func (m *TimestampRange) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -6318,10 +6270,7 @@ func (m *TagKeysRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -6508,10 +6457,7 @@ func (m *TagValuesRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -6593,10 +6539,7 @@ func (m *StringValuesResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -6751,10 +6694,7 @@ func (m *MeasurementNamesRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -6941,10 +6881,7 @@ func (m *MeasurementTagKeysRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -7163,10 +7100,7 @@ func (m *MeasurementTagValuesRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -7353,10 +7287,7 @@ func (m *MeasurementFieldsRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -7440,10 +7371,7 @@ func (m *MeasurementFieldsResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -7554,10 +7482,7 @@ func (m *MeasurementFieldsResponse_MessageField) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -7820,10 +7745,7 @@ func (m *ReadWindowAggregateRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -7945,10 +7867,7 @@ func (m *Window) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { @@ -8056,10 +7975,7 @@ func (m *Duration) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStorageCommon - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStorageCommon } if (iNdEx + skippy) > l { diff --git a/v1/services/meta/internal/meta.proto b/v1/services/meta/internal/meta.proto index dd94d417a8..10afff7bc5 100644 --- a/v1/services/meta/internal/meta.proto +++ b/v1/services/meta/internal/meta.proto @@ -1,3 +1,5 @@ +syntax = "proto2"; + package meta; //========================================================================