Commit Graph

116 Commits

Author SHA1 Message Date
Robert van Gent
cd32a686b1 wire: Add wire.InterfaceValue, required instead of wire.Value if the value is an interface value (google/go-cloud#322)
* Add wire.InterfaceValue, required instead of wire.Value if the value is an interface value.

* Update guestbook sample to use InterfaceValue where appropriate.

* Remove unnecessary ok := true

* Addressing comments from code review.
2018-11-13 13:16:46 -08:00
Ross Light
eedae3d8d0 all: change copyright notice to The Go Cloud Authors (google/go-cloud#306)
Added AUTHORS+CONTRIBUTORS files with the contributors already present
from the Git log.

Fixes google/go-cloud#225
2018-11-13 13:16:46 -08:00
shantuo
4328970c68 wire/internal/wire: run wire tests in parallel (google/go-cloud#309) 2018-11-13 13:16:46 -08:00
Robert van Gent
0e97bcaf0c wire: use cmp.Diff instead of shelling out to "diff" to compare against golden strings in tests (google/go-cloud#287) 2018-11-13 13:16:46 -08:00
Oleg Kovalov
0559d22dfe all: simplify and clarify some expressions (google/go-cloud#260) 2018-11-13 13:16:46 -08:00
Issac Trotts
105b7fde1c wire: respect -record flag for tests (google/go-cloud#282)
Fixes google/go-cloud#281
2018-11-13 13:16:46 -08:00
Robert van Gent
3a3760180d wire: fill in ProviderSet.VarName when the set is a package variable (google/go-cloud#279)
Rename ProviderSet.Name to ProviderSet.VarName.

Fixes google/go-cloud#277
2018-11-13 13:16:46 -08:00
Robert van Gent
85deb53791 wire: Build now returns an error if it has any unused arguments (google/go-cloud#268)
Fixes google/go-cloud#164
2018-11-13 13:16:46 -08:00
Robert van Gent
b348a78000 wire: use providerMap.Iterate instead of providerMap.Keys() + At() (google/go-cloud#265) 2018-11-13 13:16:46 -08:00
Issac Trotts
707f33ee6c all: replace more panic(wire.Build(...)) calls with wire.Build(...); return stuff (google/go-cloud#248)
Fixes google/go-cloud#246
2018-11-13 13:16:45 -08:00
Issac Trotts
d870f380dd Wire: fix typo in README: App -> Baz (google/go-cloud#239)
A function called initializeApp was returning a foobarbaz.Baz.
2018-11-13 13:16:45 -08:00
Issac Trotts
d214fc499d wire: show help when requested (google/go-cloud#238)
For now, it just shows usage.
2018-11-13 13:16:45 -08:00
Zachary Romero
0a45f324c7 wire: fix example in the ProvideBaz section (google/go-cloud#229) 2018-11-13 13:16:45 -08:00
Ross Light
1de1d101c7 wire/cmd/wire: rename from gowire (google/go-cloud#217)
@cflewis and @bradfitz were right: drop the "go". It's cleaner.
2018-11-13 13:16:45 -08:00
Ross Light
5f0dd9ee8f wire: add check command (google/go-cloud#207)
In the internal package, this expands the wire.Load function to run
the same solver as wire.Generate would on any injector function. For
completeness, I also print the injector functions in the gowire show
command.

A subsequent PR will add this as a step to Go Cloud CI.

Updates google/go-cloud#30
2018-11-13 13:16:45 -08:00
Ross Light
2943de1153 docs: remove references to vgo (google/go-cloud#206)
We should be instructing users to run stable things, and more
adventurous folks can adapt to use Go modules. I just ran the test suite
locally from a `go get` and it compiled and ran fine.

Updates google/go-cloud#78
Updates google/go-cloud#208
2018-11-13 13:16:45 -08:00
Ross Light
765b0228ac wire: don't fail at first error (google/go-cloud#204)
This changes both Generate and Load to try to advance as far as possible
while collecting errors. A small helper type, errorCollector, is used to
make control flow easier to read.

Fixes google/go-cloud#5
2018-11-13 13:16:45 -08:00
Ross Light
a2540bae2a wire: update internal functions to return []error (google/go-cloud#197)
This represents no functional change, it purely changes the signature
used for functions that can possibly return multiple errors. A
follow-up commit will change the control flow to proceed in the face
of errors.
2018-11-13 13:16:45 -08:00
Ross Light
fda05073e3 wire: add best practices for provider set compatibility (google/go-cloud#191) 2018-11-13 13:16:45 -08:00
Ross Light
777c1c4331 wire: handle build tags with relative paths correctly (google/go-cloud#188)
5cfd0141dd95acd1a98a1b7f6de5b8b304077634 worked correctly with
absolute import paths, but would fail with relative import paths
(most commonly when passing "." in the default invocation of
gowire). This commit introduces test infrastructure to allow
relative import paths to be given as test inputs, along with a test
case that addresses the regression.
2018-11-13 13:16:45 -08:00
Ross Light
0b7bb585fd wire: remove extra trim in parsing golden test output (google/go-cloud#185) 2018-11-13 13:16:45 -08:00
Ross Light
e1df90c68f wire: only apply wireinject build tag to generated package (google/go-cloud#176) 2018-11-13 13:16:45 -08:00
Ross Light
9537acefc2 wire: use return in tests instead of panic (google/go-cloud#169)
Fixes google/go-cloud#105
2018-11-13 13:16:45 -08:00
Ross Light
5e442802c0 wire: fix test data race (google/go-cloud#168)
This was introduced in 7d83fb8532c1455d4e81b587f31d090320f5eb9f and is
surprisingly not caught by the race detector. I suspect that the testing
package makes it not a strict data race, but the result is still
undefined.
2018-11-13 13:16:45 -08:00
Ross Light
54cdfee544 wire: speed up test execution (google/go-cloud#163)
1.  Runs subtests in parallel.
2.  Decreases the number of runs of the Determinism test to a constant 2.
2018-11-13 13:16:45 -08:00
Ross Light
69b0cf53ad all: move back to github.com/google/go-cloud (google/go-cloud#162)
Reverts changes made in google/go-cloud#120 for google/go-cloud#117
2018-11-13 13:16:45 -08:00
Ross Light
1d225cf371 wire: add error string assertions in tests (google/go-cloud#149)
out.txts that start with "ERROR" can now include substrings to assert
exist in the error messages, one per line.  This gives a very
coarse-grained way of testing for error message quality. It is not a
substitute for manual verification, but gives a "good enough" sanity
check that relevant details are reported.

Updates google/go-cloud#5
2018-11-13 13:16:45 -08:00
Ross Light
0bf9b3b5dd all: fix docs and examples (google/go-cloud#141)
Most notably, adds examples for the blob package.
2018-11-13 13:16:45 -08:00
Ross Light
338b1da068 wire: store value expressions in package variables (google/go-cloud#135)
The code assigns a local unnecessarily, but this should have no
appreciable effect on semantics, just readability.

Fixes google/go-cloud#104
2018-11-13 13:16:45 -08:00
Ross Light
2eb9d5ea1f wire: make solver iterative instead of recursive (google/go-cloud#137)
Primary reason is to make it easier to allow the process to continue and
collect errors. This has the side-effect of allowing larger depth graphs
since the solver no longer pushes Go stack frames.

Updates google/go-cloud#5
2018-11-13 13:16:45 -08:00
Ross Light
f7658c8a13 wire: change call sites to allow multiple errors (google/go-cloud#118)
Updated the call sites to allow multiple errors to be returned from
the package. Load is now permitted to return partial success.

Updates google/go-cloud#5
2018-11-13 13:16:45 -08:00
Ross Light
45a535a0bd all: s/go-cloud/go-x-cloud/ (google/go-cloud#120)
Fixes google/go-cloud#117
2018-11-13 13:16:45 -08:00
Ross Light
366207371e wire: detect cycles incrementally (google/go-cloud#102)
Idea originally mentioned in google/go-cloud#29. This means that any provider set
loaded must not have cycles, which is stricter than before. The cycle
error message now gives full detail on what caused the cycle.
2018-11-13 13:16:45 -08:00
Ross Light
cd52d44251 wire: clean up README (google/go-cloud#100)
Summary of changes:

-   Rewrote introduction (fixes google/go-cloud#81).
-   Simplified `go generate` explanation by automatically adding the
    comment line to the output.
-   Removed mentions of Dagger. Wire stands enough on its own now, but
    Dagger's influence lives on in our minds.
-   Moved best practices to bottom and removed provider set grouping
    guidance.
2018-11-13 13:16:45 -08:00
Ross Light
b12449f9e3 wire: build provider map incrementally (google/go-cloud#96)
One small breaking change: a provider set can no longer include an
interface binding to a concrete type that is not being provided
(directly or indirectly) by the provider set. I can't imagine a
reasonable use case for the previous behavior, so this likely will
catch more errors

In terms of operation, binding conflict error messages will now give
much more specific line numbers, since they will be reported closer to
where the problem occurred.

Now that provider sets gather this information, it can be exposed in
the package API. gowire now uses this information instead of
trying to build it itself.

Fixes google/go-cloud#29
2018-11-13 13:16:45 -08:00
Ross Light
b2d47f8fcc wire: allow non-panic version of injector (google/go-cloud#91)
Fixes google/go-cloud#7
2018-11-13 13:16:45 -08:00
Ross Light
6345348d86 wire: rename from Goose (google/go-cloud#59)
Rename Goose to wire, making it more obvious what the package does, and look more like the stdlib.

Fixes google/go-cloud#8
2018-11-13 13:16:45 -08:00
Chris Lewis
3e60790b34 Remove dead code from parse.go (google/go-cloud#48) 2018-11-13 13:16:45 -08:00
Ross Light
e9a61ba66b goose: require pointer for first argument to goose.Bind (google/go-cloud#31)
Fixes google/go-cloud#15
2018-11-13 13:16:45 -08:00
Ross Light
7a864edab7 goose: fix outdated docs (google/go-cloud#27) 2018-11-13 13:16:45 -08:00
Ross Light
962288c10a goose: s/Use/Build/
Fixes google/go-cloud#6
2018-11-13 13:16:45 -08:00
Ross Light
cc91a772b0 goose: add test that disambiguate contains the base name
No behavior change, just more unit testing.

Reviewed-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chris Lewis <cflewis@google.com>
2018-11-13 13:16:45 -08:00
Ross Light
3c0eaf830e goose: refactor *gen.inject
The function had grown too long. Several related cleanups:

- Factored out the function return value logic, which had been
  duplicated between providers and injectors.
- Moved code generation for different provider call types into separate
  functions. This moves injector-specific state to a new type
  injectorGen to keep the parameter count down.
- Since it's infeasible to keep the "shadow pass" collecting import
  identifiers in sync the spread out logic, the injector code
  generation is just run twice, with initial output discarded.
- Removed the zero value logic left over from Optional.

Reviewed-by: Tuo Shan <shantuo@google.com>
2018-11-13 13:16:45 -08:00
Ross Light
10676a814b goose: add goose.Value directive
Subsumes previous usage of goose.Optional.

Reviewed-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Tuo Shan <shantuo@google.com>
2018-11-13 13:16:45 -08:00
Ross Light
235a7d8f80 goose: allow non-injector code to live along with injectors
Previously, goose would ignore declarations in the //+build gooseinject
files that were not injectors. This meant that if you wanted to write
application-specific providers, you would need to place them in a
separate file, away from the goose injectors. This means that a typical
application would have three handwritten files: one for the abstract
business logic, one for the platform-specific providers, one for the
platform-specific injector declarations.

This change allows the two platform-specific files to be merged into
one: the //+build gooseinject file. goose will now copy these
declarations out to goose_gen.go. This requires a bit of hackery, since
the generated file may have different identifiers for the imported
packages, so goose will do some light AST rewriting to address these
cases.

(Historical note: this was the first change made externally, so also in
here are the copyright headers and other housekeeping changes.)

Reviewed-by: Tuo Shan <shantuo@google.com>
Reviewed-by: kokoro <noreply+kokoro@google.com>
2018-11-13 13:15:58 -08:00
Ross Light
f8e446fa17 goose: use marker functions instead of comments
To avoid making this CL too large, I did not migrate the existing goose
comments through the repository.  This will be addressed in a subsequent
CL.

Reviewed-by: Tuo Shan <shantuo@google.com>
2018-11-12 14:09:56 -08:00
Ross Light
13698e656a goose: clean up comments into full sentences
Capitalize and end with period where missing.

Reviewed-by: Chris Lewis <cflewis@google.com>
2018-11-12 14:09:56 -08:00
Ross Light
3345599aaf goose: remove optional directive
This introduces some short-term pain in practice, but I aim to fix that
with the goose.Value directive.

Reviewed-by: Tuo Shan <shantuo@google.com>
2018-11-12 14:09:56 -08:00
Ross Light
cfc6111ea5 goose: add show command
Lists provider sets in packages given on the command line, including
outputs grouped by what is needed to obtain them.

The goose package now exports the loading phase as an API.

Example output: https://paste.googleplex.com/5509965720584192

Reviewed-by: Tuo Shan <shantuo@google.com>
2018-11-12 14:09:56 -08:00
Ross Light
2044e2213b goose: add struct field injection
This makes options structs and application structs much simpler to
inject.

Reviewed-by: Tuo Shan <shantuo@google.com>
2018-11-12 14:09:56 -08:00