Skip to content

Commit

Permalink
Respect host_only option in targets (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
zombiezen authored Nov 6, 2020
1 parent dc4037a commit 826bc4e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
8 changes: 6 additions & 2 deletions cmd/yb/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,19 @@ func doTargetList(ctx context.Context, pkg *yb.Package, targets []*yb.BuildTarge
}

func doTarget(ctx context.Context, pkg *yb.Package, target *yb.BuildTarget, opts *doOptions) error {
bio, err := newBiome(ctx, newBiomeOptions{
biomeOpts := newBiomeOptions{
packageDir: pkg.Path,
target: target.Name,
dataDirs: opts.dataDirs,
baseEnv: opts.baseEnv,
dockerClient: opts.dockerClient,
targetContainer: target.Container.ToNarwhal(),
dockerNetworkID: opts.dockerNetworkID,
})
}
if target.HostOnly {
biomeOpts = biomeOpts.disableDocker()
}
bio, err := newBiome(ctx, biomeOpts)
if err != nil {
return fmt.Errorf("target %s: %w", target.Name, err)
}
Expand Down
8 changes: 8 additions & 0 deletions cmd/yb/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ type newBiomeOptions struct {
dockerNetworkID string
}

func (opts newBiomeOptions) disableDocker() newBiomeOptions {
// Operating on copy, so free to modify fields.
opts.dockerClient = nil
opts.targetContainer = nil
opts.dockerNetworkID = ""
return opts
}

func newBiome(ctx context.Context, opts newBiomeOptions) (biome.BiomeCloser, error) {
if opts.dockerClient == nil {
l := biome.Local{
Expand Down
8 changes: 6 additions & 2 deletions cmd/yb/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,19 @@ func (b *runCmd) run(ctx context.Context, args []string) error {

// Run command.
execTarget := targets[len(targets)-1]
bio, err := newBiome(ctx, newBiomeOptions{
biomeOpts := newBiomeOptions{
packageDir: pkg.Path,
target: execTarget.Name,
dataDirs: dataDirs,
baseEnv: baseEnv,
dockerClient: dockerClient,
targetContainer: execTarget.Container.ToNarwhal(),
dockerNetworkID: dockerNetworkID,
})
}
if execTarget.HostOnly {
biomeOpts = biomeOpts.disableDocker()
}
bio, err := newBiome(ctx, biomeOpts)
if err != nil {
return err
}
Expand Down

0 comments on commit 826bc4e

Please sign in to comment.