Example #1
0
func TestManifestSet(t *testing.T) {
	mid := sous.ManifestID{
		Source: sous.SourceLocation{
			Repo: project1.Repo,
		},
	}
	baseState := makeTestState()
	mani, present := baseState.Manifests.Get(mid)
	require.True(t, present)
	mani.Flavor = "vanilla"
	yml, err := yaml.Marshal(mani)
	require.NoError(t, err)
	in := bytes.NewBuffer(yml)

	state := makeTestState()

	dummyWriter := sous.DummyStateManager{State: state}
	writer := graph.StateWriter{StateWriter: &dummyWriter}
	sms := &SousManifestSet{
		TargetManifestID: graph.TargetManifestID(mid),
		State:            state,
		InReader:         graph.InReader(in),
		StateWriter:      writer,
	}

	assert.Equal(t, 0, dummyWriter.WriteCount)
	res := sms.Execute([]string{})
	assert.Equal(t, 0, res.ExitCode())
	assert.Equal(t, 1, dummyWriter.WriteCount)

	upManifest, present := state.Manifests.Get(mid)
	require.True(t, present)
	assert.Equal(t, upManifest.Flavor, "vanilla")

}
Example #2
0
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()
}
Example #3
0
func outputMetadata(metadata sous.Metadata, clusterName string, args []string, out io.Writer) error {
	if len(args) == 0 {
		yml, err := yaml.Marshal(metadata)
		if err != nil {
			return EnsureErrorResult(err)
		}
		out.Write(yml)
		return nil
	}

	value, present := metadata[args[0]]
	if !present {
		return errors.Errorf("No value for %q in cluster %s", args[0], clusterName)
	}
	fmt.Fprint(out, value)

	return nil
}
Example #4
0
func Marshal(in interface{}) ([]byte, error) {
	return y.Marshal(in, y.OPT_NOLOWERCASE)
}