Skip to content

Commit

Permalink
Manager (#2)
Browse files Browse the repository at this point in the history
* manager
* removed proto_vendor
* changelog
* cloudbuild folder nonsense
* added more comments about folder name
* fixed check code-gen
* fixed makefile
* copy tests are passing
* PR comments
* updated comments
* renamed to anyvendor
* got tests passing with new json modules
* regenerated
* formatting ftw
* fixed make target
* version of cloud-builder
* fixed tests
* comment weird capital pathing
* added comments and fixed up tests
* removed weird import
* go.sum diff
* try without git username
* pr comments
  • Loading branch information
EItanya authored and soloio-bulldozer[bot] committed Dec 31, 2019
1 parent 8053484 commit e14cd3a
Show file tree
Hide file tree
Showing 29 changed files with 1,608 additions and 111 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
vendor/
vendor*/
_output/
**/go-mock-reflect*
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#----------------------------------------------------------------------------------

ROOTDIR := $(shell pwd)
PACKAGE_PATH:=github.com/solo-io/protodep
PACKAGE_PATH:=github.com/solo-io/anyvendor
OUTPUT_DIR ?= $(ROOTDIR)/_output
SOURCES := $(shell find . -name "*.go" | grep -v test.go)
VERSION ?= $(shell git describe --tags)
Expand All @@ -23,10 +23,10 @@ init:

.PHONY: update-deps
update-deps: mod-download
$(shell cd vendor/github.com/solo-io/protoc-gen-ext; make install)
GO111MODULE=off go get -u golang.org/x/tools/cmd/goimports
GO111MODULE=off go get -u github.com/golang/protobuf/protoc-gen-go
GO111MODULE=off go get -u github.com/envoyproxy/protoc-gen-validate
GO111MODULE=off go install github.com/envoyproxy/protoc-gen-validate
GO111MODULE=off go get -u github.com/golang/mock/gomock
GO111MODULE=off go install github.com/golang/mock/mockgen

Expand All @@ -42,10 +42,9 @@ mod-download:
.PHONY: generated-code
generated-code: $(OUTPUT_DIR)/.generated-code

SUBDIRS:=pkg test
SUBDIRS:=pkg anyvendor
$(OUTPUT_DIR)/.generated-code:
mkdir -p ${OUTPUT_DIR}
$(GO_BUILD_FLAGS) go generate ./...
gofmt -w $(SUBDIRS)
goimports -w $(SUBDIRS)
touch $@
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# protodep
# anyvendor

protodep is an all purpose dependency management tool originally created to manage
anyvendor is an all purpose dependency management tool originally created to manage
vendoring protobuf files. However, it can also handle any non-language specific files
available through it's multiple gathering mechanisms.

## configuration

protodep is currently only available as a library, but the plan is to turn it into a standalone tool.
anyvendor is currently only available as a library, but the plan is to turn it into a standalone tool.

To use protodep create a new protodep manager by calling `NewManager()` and supplying the working
directory of the project. protodep is meant to work at any level of a repo/project, so therefore
To use anyvendor create a new anyvendor manager by calling `NewManager()` and supplying the working
directory of the project. anyvendor is meant to work at any level of a repo/project, so therefore
the working directory must be supplied. Then the `Ensure` function can be called to vendor in
all of the deps. The api for the `Ensure` function is reflected in the `protodep.proto` file in this
all of the deps. The api for the `Ensure` function is reflected in the `anyvendor.proto` file in this
directory.

Currently only gomod style dependencies are enabled, but git repo ones are coming soon.
Expand All @@ -36,7 +36,7 @@ imports:
patterns:
- api/**/*.proto
```
The package is the name of the gomod package which protodep will search for the files. It will call
The package is the name of the gomod package which anyvendor will search for the files. It will call
`go list -m all` to find the correct version, and then search the local go mod cache for it. In order to
use a package which is not explicitly required by any go projects, it can be brought in using the `tools.go`
pattern. More information on tools in go mod can be found [here](https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module).
Expand Down
83 changes: 49 additions & 34 deletions protodep/protodep.pb.go → anyvendor/anyvendor.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions anyvendor/anyvendor.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
syntax = "proto3";
package anyvendor;
option go_package = "github.com/solo-io/anyvendor/anyvendor";

import "validate/validate.proto";

/*
Config object used for running anyvendor. The top level config consists of 2 main sections.
Local is a set of matchers will be taken directly from the local module, and vendored in.
Imports is a list of import types which will be run, and then vendored.
*/
message Config {
Local local = 1;

repeated Import imports = 2;
}

message Import {
oneof ImportType {
option (validate.required) = true;
GoModImport go_mod = 2;
}
}

// A set of glob patters to be grabbed from the current module
message Local {
repeated string patterns = 1 [(validate.rules).repeated = { min_items: 1}];
}

/*
A go mod import represents a set of imports from a go module
patterns is a set glob matchers to find files in a go module.
package is the name of the go module which these should be pulled from.
The GoModImport uses the command `go list -f '{{.Path}}' -m all` to find
all of the package names
*/
message GoModImport {
repeated string patterns = 1 [(validate.rules).repeated = { min_items: 1}];
string package = 2 [(validate.rules).string = { min_len: 1}];
}
8 changes: 6 additions & 2 deletions protodep/defaults.go → anyvendor/defaults.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package protodep
package anyvendor

// need to reenable this once the functionality to vendor the protos is enabled
//-go:generate bash generate.sh
Expand All @@ -7,5 +7,9 @@ const (
// default directory into which proto, and other files will be vendored.
// Originally this was meant to be the vendor directory, but clashes with the go vendor directory
// meant it would be easier for this to inhabit it's own folder
DefaultDepDir = ".proto"
// See this section for more info: https://tip.golang.org/doc/go1.14#go-command
// This tool should not force to projects to build using vendor.
DefaultDepDir = "vendor_any"

ProtoMatchPattern = "**/*.proto"
)
5 changes: 3 additions & 2 deletions protodep/generate.sh → anyvendor/generate.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
# script to generate anyvendor.proto

set -e

Expand All @@ -9,7 +10,7 @@ set -o pipefail

IN=$(dirname "${BASH_SOURCE[0]}")
ROOT=$(go env GOMOD | rev | cut -c8- | rev)
VALIDATE=${ROOT}/.proto/github.com/envoyprocy/protoc-gen-validate
VALIDATE=${ROOT}/vendor_any/github.com/envoyproxy/protoc-gen-validate

# code-generator does work with go.mod but makes assumptions about
# the project living in $GOPATH/src. To work around this and support
Expand Down Expand Up @@ -39,6 +40,6 @@ protoc ${IMPORTS} \
${VALIDATE_FLAG} \
${INPUT_PROTOS}

cp -r ${TEMP_DIR}/github.com/solo-io/protodep/* ${ROOT}
cp -r ${TEMP_DIR}/github.com/solo-io/anyvendor/* ${ROOT}

goimports -w .
4 changes: 2 additions & 2 deletions changelog/v0.0.1/api.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
changelog:
- type: NEW_FEATURE
description: Create API for protodep.
issueLink: https://github.com/solo-io/protodep/issues/1
description: Create API for anyvendor.
issueLink: https://github.com/solo-io/anyvendor/issues/1
4 changes: 4 additions & 0 deletions changelog/v0.0.1/lib.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changelog:
- type: NEW_FEATURE
description: Expose anyvendor as a library.
issueLink: https://github.com/solo-io/anyvendor/issues/3
Loading

0 comments on commit e14cd3a

Please sign in to comment.