// NewBuilder creates a new build using source code in the working // directory of sourceShell, and using the working dir of scratchShell as // temporary storage. func NewBuilder(nc sous.Inserter, drh string, sourceShell, scratchShell shell.Shell) (*Builder, error) { b := &Builder{ ImageMapper: nc, DockerRegistryHost: drh, SourceShell: sourceShell, ScratchShell: scratchShell, } files, err := scratchShell.List() if err != nil { return nil, err } if len(files) != 0 { return nil, fmt.Errorf("scratch dir %s was not empty", scratchShell.Dir()) } return b, nil }
// GetDeploySpecs searches the working directory of wd to find otpl-deploy // config files in their standard locations (config/{cluster-name}), and // converts them to sous.DeploySpecs. func (dsp *DeploySpecParser) GetDeploySpecs(wd shell.Shell) sous.DeploySpecs { wd = wd.Clone() if err := wd.CD("config"); err != nil { return nil } l, err := wd.List() if err != nil { dsp.debug(err) return nil } c := make(chan namedDeploySpec) wg := sync.WaitGroup{} wg.Add(len(l)) go func() { wg.Wait(); close(c) }() for _, f := range l { f := f go func() { defer wg.Done() if !f.IsDir() { return } wd := wd.Clone() if err := wd.CD(f.Name()); err != nil { dsp.debug(err) return } if otplConfig := dsp.GetSingleDeploySpec(wd); otplConfig != nil { name := path.Base(wd.Dir()) c <- namedDeploySpec{name, otplConfig} } }() } deployConfigs := sous.DeploySpecs{} for s := range c { deployConfigs[s.Name] = *s.Spec } return deployConfigs }