pulumi/pkg/compiler/opts.go
joeduffy 8fa1fd9082 Add some targeting tests
This adds some tests around cloud targeting, in addition to enabling builds
to use in-memory Mufiles (mostly to make testing simpler, but this is a
generally useful capability to have when hosting the compiler API).
2016-11-17 13:08:20 -08:00

38 lines
1 KiB
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.
SkipCodegen bool // if true, no code-generation phases run.
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
}