Example #1
0
// FillDefaults fills in default values in this Config where they are currently
// zero values.
func (c *Config) FillDefaults() error {
	return firsterr.Set(
		func(e *error) {
			if c.StateLocation == "" {
				c.StateLocation, *e = c.defaultStateLocation()
			}
		},
		func(e *error) {
			*e = EnsureDirExists(c.StateLocation)
		},
	)
}
Example #2
0
// Resolve drives the Sous deployment resolution process. It calls out to the
// appropriate components to compute the intended deployment set, collect the
// actual set, compute the diffs and then issue the commands to rectify those
// differences.
func (r *Resolver) Resolve(intended Deployments, clusters Clusters) error {
	var ads Deployments
	var diffs DiffChans
	var namer *DeployableChans
	errs := make(chan error)
	return firsterr.Set(
		func(*error) { clusters = r.FilteredClusters(clusters) },
		func(e *error) { ads, *e = r.Deployer.RunningDeployments(r.Registry, clusters) },
		func(*error) { intended = intended.Filter(r.FilterDeployment) },
		func(*error) { ads = ads.Filter(r.FilterDeployment) },
		func(*error) { diffs = ads.Diff(intended) },
		func(*error) { namer = NewDeployableChans(10) },
		func(*error) { namer.ResolveNames(r.Registry, &diffs, errs) },
		func(*error) { r.rectify(namer, errs) },
		func(e *error) { *e = foldErrors(errs) },
	)
}
Example #3
0
// Build implements sous.Builder.Build
func (m *BuildManager) Build() (*BuildResult, error) {
	// TODO if BuildConfig.ForceClone, then clone
	var (
		bp Buildpack
		dr *DetectResult
		bc *BuildContext
		br *BuildResult
	)
	err := firsterr.Set(
		func(e *error) { *e = m.BuildConfig.Validate() },
		func(e *error) { bc = m.BuildConfig.NewContext() },
		func(e *error) { *e = m.BuildConfig.GuardStrict(bc) },
		func(e *error) { bp, *e = m.SelectBuildpack(bc) },
		// TODO: Maybe return the detected detect result from SelectBuildpack to
		// avoid running detect twice for the chosen buildpack.
		func(e *error) { dr, *e = bp.Detect(bc) },
		func(e *error) { br, *e = bp.Build(bc, dr) },
		func(e *error) { br.Advisories = bc.Advisories },
		func(e *error) { *e = m.ApplyMetadata(br, bc) },
		func(e *error) { *e = m.RegisterAndWarnAdvisories(br, bc) },
	)
	return br, err
}