2018-05-22 19:43:36 +00:00
|
|
|
// Copyright 2016-2018, Pulumi Corporation.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
2016-11-16 16:19:26 +00:00
|
|
|
|
2016-11-16 17:29:44 +00:00
|
|
|
package encoding
|
2016-11-16 16:19:26 +00:00
|
|
|
|
|
|
|
import (
|
2021-03-17 13:20:05 +00:00
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
|
2016-11-16 16:19:26 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2018-03-04 21:34:20 +00:00
|
|
|
// Ensure a marshaler is available for every possible metadata extension.
|
2016-11-16 16:19:26 +00:00
|
|
|
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 18:41:07 +00:00
|
|
|
for _, ext := range Exts {
|
2016-11-16 16:19:26 +00:00
|
|
|
switch ext {
|
|
|
|
case ".json":
|
2016-11-25 20:58:29 +00:00
|
|
|
Marshalers[ext] = JSON
|
2016-11-16 16:19:26 +00:00
|
|
|
case ".yml":
|
|
|
|
fallthrough
|
|
|
|
case ".yaml":
|
2016-11-25 20:58:29 +00:00
|
|
|
Marshalers[ext] = YAML
|
2016-11-16 16:19:26 +00:00
|
|
|
default:
|
2018-03-04 21:34:20 +00:00
|
|
|
contract.Failf("No marshaler available for extension '%s'", ext)
|
2016-11-16 16:19:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|