2016-11-16 17:19:26 +01:00
|
|
|
// Copyright 2016 Marapongo, Inc. All rights reserved.
|
|
|
|
|
2016-11-16 18:29:44 +01:00
|
|
|
package encoding
|
2016-11-16 17:19:26 +01:00
|
|
|
|
|
|
|
import (
|
2017-01-15 23:26:48 +01:00
|
|
|
"github.com/marapongo/mu/pkg/util/contract"
|
2016-11-16 17:19:26 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
// Ensure a marshaler is available for every possible Mufile extension
|
|
|
|
Marshalers = make(map[string]Marshaler)
|
Support Workspaces
This change adds support for Workspaces, a convenient way of sharing settings
among many Stacks, like default cluster targets, configuration settings, and the
like, which are not meant to be distributed as part of the Stack itself.
The following things are included in this checkin:
* At workspace initialization time, detect and parse the .mu/workspace.yaml
file. This is pretty rudimentary right now and contains just the default
cluster targets. The results are stored in a new ast.Workspace type.
* Rename "target" to "cluster". This impacts many things, including ast.Target
being changed to ast.Cluster, and all related fields, the command line --target
being changed to --cluster, various internal helper functions, and so on. This
helps to reinforce the desired mental model.
* Eliminate the ast.Metadata type. Instead, the metadata moves directly onto
the Stack. This reflects the decision to make Stacks "the thing" that is
distributed, versioned, and is the granularity of dependency.
* During cluster targeting, add the workspace settings into the probing logic.
We still search in the same order: CLI > Stack > Workspace.
2016-11-22 19:41:07 +01:00
|
|
|
for _, ext := range Exts {
|
2016-11-16 17:19:26 +01:00
|
|
|
switch ext {
|
|
|
|
case ".json":
|
2016-11-25 21:58:29 +01:00
|
|
|
Marshalers[ext] = JSON
|
2016-11-16 17:19:26 +01:00
|
|
|
case ".yml":
|
|
|
|
fallthrough
|
|
|
|
case ".yaml":
|
2016-11-25 21:58:29 +01:00
|
|
|
Marshalers[ext] = YAML
|
2016-11-16 17:19:26 +01:00
|
|
|
default:
|
2017-01-15 23:26:48 +01:00
|
|
|
contract.FailMF("No Marshaler available for MufileExt %v", ext)
|
2016-11-16 17:19:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|