func (smg *SousManifestSet) Execute(args []string) cmdr.Result { mid := sous.ManifestID(smg.TargetManifestID) _, present := smg.State.Manifests.Get(mid) if !present { return EnsureErrorResult(errors.Errorf("No manifest matched by %v yet. See `sous init`", smg.ResolveFilter)) } yml := sous.Manifest{} bytes, err := ioutil.ReadAll(smg.InReader) if err != nil { return EnsureErrorResult(err) } err = yaml.Unmarshal(bytes, &yml) if err != nil { return EnsureErrorResult(err) } smg.State.Manifests.Set(mid, &yml) err = smg.StateWriter.WriteState(smg.State) if err != nil { return EnsureErrorResult(err) } return Success() }
func (smg *SousManifestGet) Execute(args []string) cmdr.Result { mid := sous.ManifestID(smg.TargetManifestID) mani, present := smg.State.Manifests.Get(mid) if !present { return EnsureErrorResult(errors.Errorf("No manifest matched by %v yet. See `sous init`", smg.ResolveFilter)) } yml, err := yaml.Marshal(mani) if err != nil { return EnsureErrorResult(err) } smg.OutWriter.Write(yml) return Success() }
func newTargetManifest(auto UserSelectedOTPLDeploySpecs, tmid TargetManifestID, s *sous.State) TargetManifest { mid := sous.ManifestID(tmid) m, ok := s.Manifests.Get(mid) if ok { return TargetManifest{m} } deploySpecs := auto.DeploySpecs if len(deploySpecs) == 0 { deploySpecs = defaultDeploySpecs(s.Defs.Clusters) } m = &sous.Manifest{ Deployments: deploySpecs, } m.SetID(mid) fls := m.Validate() sous.RepairAll(fls) return TargetManifest{m} }