Remove cobra.Command from some deployment methods

This commit is contained in:
Matt Ellis 2017-08-17 15:08:38 -07:00
parent c837aa6024
commit 9fa92c0236
6 changed files with 12 additions and 12 deletions

View file

@ -49,7 +49,7 @@ func newDeployCmd() *cobra.Command {
if err != nil {
return err
}
return deployLatest(cmd, info, deployOptions{
return deployLatest(info, deployOptions{
Debug: debug,
Destroy: false,
DryRun: dryRun,
@ -113,8 +113,8 @@ type deployOptions struct {
Output string // the place to store the output, if any.
}
func deployLatest(cmd *cobra.Command, info *envCmdInfo, opts deployOptions) error {
result, err := plan(cmd, info, opts)
func deployLatest(info *envCmdInfo, opts deployOptions) error {
result, err := plan(info, opts)
if err != nil {
return err
}

View file

@ -35,7 +35,7 @@ func newDestroyCmd() *cobra.Command {
name := info.Target.Name
if dryRun || yes ||
confirmPrompt("This will permanently destroy all resources in the '%v' environment!", name) {
return deployLatest(cmd, info, deployOptions{
return deployLatest(info, deployOptions{
Debug: debug,
Destroy: true,
DryRun: dryRun,

View file

@ -48,7 +48,7 @@ func NewLumiCmd() *cobra.Command {
return cmd
}
func prepareCompiler(cmd *cobra.Command, args []string) (compiler.Compiler, *pack.Package) {
func prepareCompiler(args []string) (compiler.Compiler, *pack.Package) {
// TODO[pulumi/pulumi-fabric#88]: enable arguments to flow to the package itself. In that case, we want to split the
// arguments at the --, if any, so we can still pass arguments to the compiler itself in these cases.
var pkgarg string
@ -83,9 +83,9 @@ func prepareCompiler(cmd *cobra.Command, args []string) (compiler.Compiler, *pac
// compile just uses the standard logic to parse arguments, options, and to locate/compile a package. It returns the
// compilation result, or nil if an error occurred (in which case, we would expect diagnostics to have been output).
func compile(cmd *cobra.Command, args []string) *compileResult {
func compile(args []string) *compileResult {
// Prepare the compiler info and, provided it succeeds, perform the compilation.
if comp, pkg := prepareCompiler(cmd, args); comp != nil {
if comp, pkg := prepareCompiler(args); comp != nil {
var b binder.Binder
var pkgsym *symbols.Package
if pkg == nil {

View file

@ -35,7 +35,7 @@ func newPackEvalCmd() *cobra.Command {
contract.Assertf(!dotOutput, "TODO[pulumi/pulumi-fabric#235]: DOT files not yet supported")
// First, load and compile the package.
result := compile(cmd, args)
result := compile(args)
if result == nil {
return nil
}

View file

@ -38,7 +38,7 @@ func newPackVerifyCmd() *cobra.Command {
// succeeds, the return value is true; if verification fails, errors will have been output, and the return is false.
func verify(cmd *cobra.Command, args []string) bool {
// Prepare the compiler info and, provided it succeeds, perform the verification.
if comp, pkg := prepareCompiler(cmd, args); comp != nil {
if comp, pkg := prepareCompiler(args); comp != nil {
// Now perform the compilation and extract the heap snapshot.
if pkg == nil {
return comp.Verify()

View file

@ -64,7 +64,7 @@ func newPlanCmd() *cobra.Command {
Summary: summary,
DOT: dotOutput,
}
result, err := plan(cmd, info, opts)
result, err := plan(info, opts)
if err != nil {
return err
}
@ -110,7 +110,7 @@ func newPlanCmd() *cobra.Command {
}
// plan just uses the standard logic to parse arguments, options, and to create a snapshot and plan.
func plan(cmd *cobra.Command, info *envCmdInfo, opts deployOptions) (*planResult, error) {
func plan(info *envCmdInfo, opts deployOptions) (*planResult, error) {
contract.Assert(info != nil)
contract.Assert(info.Target != nil)
@ -127,7 +127,7 @@ func plan(cmd *cobra.Command, info *envCmdInfo, opts deployOptions) (*planResult
}
// First, compile the package, in preparatin for interpreting it and creating resources.
result := compile(cmd, info.Args)
result := compile(info.Args)
if result == nil || !result.B.Ctx().Diag.Success() {
return nil, fmt.Errorf("Errors during compilation: %v", result.B.Ctx().Diag.Errors())
}