This change implements most of the cloud target and architecture detection logic, along with associated verification and a bunch of new error messages. There are two settings for picking a cloud destination: * Architecture: this specifies the combination of cloud (e.g., AWS, GCP, etc) plus scheduler (e.g., none, Swarm, ECS, etc). * Target: a named, preconfigured entity that includes both an Architecture and an assortment of extra default configuration options. The general idea here is that you can preconfigure a set of Targets for named environments like "prod", "stage", etc. Those can either exist in a single Mufile, or the Mucluster file if they are shared amongst multiple Mufiles. This can be specified at the command line as such: $ mu build --target=stage Furthermore, a given environment may be annointed the default, so that $ mu build selects that environment without needing to say so explicitly. It is also possible to specify an architecture at the command line for scenarios where you aren't intending to target an existing named environment. This is good for "anonymous" testing scenarios or even just running locally: $ mu build --arch=aws $ mu build --arch=aws:ecs $ mu build --arch=local:kubernetes $ .. and so on .. This change does little more than plumb these settings around, verify them, etc., however it sets us up to actually start dispating to the right backend.
37 lines
966 B
Go
37 lines
966 B
Go
// Copyright 2016 Marapongo, Inc. All rights reserved.
|
|
|
|
package compiler
|
|
|
|
import (
|
|
"github.com/marapongo/mu/pkg/compiler/clouds"
|
|
"github.com/marapongo/mu/pkg/compiler/schedulers"
|
|
"github.com/marapongo/mu/pkg/diag"
|
|
)
|
|
|
|
// Options contains all of the settings a user can use to control the compiler's behavior.
|
|
type Options struct {
|
|
Diag diag.Sink // a sink to use for all diagnostics.
|
|
Arch Arch // a target cloud architecture.
|
|
Target string // a named target to generate outputs against.
|
|
}
|
|
|
|
// DefaultOpts returns the default set of compiler options.
|
|
func DefaultOpts(pwd string) Options {
|
|
return Options{
|
|
Diag: diag.DefaultSink(pwd),
|
|
}
|
|
}
|
|
|
|
// Arch is the target cloud "architecture" we are compiling against.
|
|
type Arch struct {
|
|
Cloud clouds.Arch
|
|
Scheduler schedulers.Arch
|
|
}
|
|
|
|
func (a Arch) String() string {
|
|
s := clouds.ArchNames[a.Cloud]
|
|
if a.Scheduler != schedulers.NoArch {
|
|
s += ":" + schedulers.ArchNames[a.Scheduler]
|
|
}
|
|
return s
|
|
}
|