Beispiel #1
0
// GetSingleDeploySpec returns a single sous.DeploySpec from the working
// directory of wd. It assumes that this directory contains at least a file
// called singularity.json, and optionally an additional file called
// singularity-requst.json.
func (dsp *DeploySpecParser) GetSingleDeploySpec(wd shell.Shell) *sous.DeploySpec {
	v := SingularityJSON{}
	if !wd.Exists("singularity.json") {
		dsp.debugf("no singularity.json in %s", wd.Dir())
		return nil
	}
	if err := wd.JSON(&v, "cat", "singularity.json"); err != nil {
		dsp.debugf("error reading %s: %s", path.Join(wd.Dir(),
			"singularity.json"), err)
		return nil
	}
	deploySpec := sous.DeploySpec{
		DeployConfig: sous.DeployConfig{
			Resources: v.Resources.SousResources(),
			Env:       v.Env,
		},
	}
	request := SingularityRequestJSON{}
	if !wd.Exists("singularity-request.json") {
		dsp.debugf("no singularity-request.json in %s", wd.Dir())
		return &deploySpec
	}
	dsp.debugf("%s/singularity-request.json exists, parsing it", wd.Dir())
	if err := wd.JSON(&request, "cat", "singularity-request.json"); err != nil {
		dsp.debugf("error reading singularity-request.json: %s", err)
		return &deploySpec
	}
	deploySpec.NumInstances = request.Instances
	return &deploySpec
}