mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 01:41:48 -06:00
ebcf7455eb
* Rename module name from "github.com/hashicorp/terraform" to "github.com/placeholderplaceholderplaceholder/opentf". Signed-off-by: Jakub Martin <kubam@spacelift.io> * Gofmt. Signed-off-by: Jakub Martin <kubam@spacelift.io> * Regenerate protobuf. Signed-off-by: Jakub Martin <kubam@spacelift.io> * Fix comments. Signed-off-by: Jakub Martin <kubam@spacelift.io> * Undo issue and pull request link changes. Signed-off-by: Jakub Martin <kubam@spacelift.io> * Undo comment changes. Signed-off-by: Jakub Martin <kubam@spacelift.io> * Fix comment. Signed-off-by: Jakub Martin <kubam@spacelift.io> * Undo some link changes. Signed-off-by: Jakub Martin <kubam@spacelift.io> * make generate && make protobuf Signed-off-by: Jakub Martin <kubam@spacelift.io> --------- Signed-off-by: Jakub Martin <kubam@spacelift.io>
51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package command
|
|
|
|
import (
|
|
"os"
|
|
"strconv"
|
|
|
|
"github.com/placeholderplaceholderplaceholder/opentf/internal/plans/planfile"
|
|
)
|
|
|
|
// NOTE: Temporary file until this branch is cleaned up.
|
|
|
|
// Input returns whether or not input asking is enabled.
|
|
func (m *Meta) Input() bool {
|
|
if test || !m.input {
|
|
return false
|
|
}
|
|
|
|
if envVar := os.Getenv(InputModeEnvVar); envVar != "" {
|
|
if v, err := strconv.ParseBool(envVar); err == nil && !v {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// PlanFile loads the plan file at the given path, which might be either a local
|
|
// or cloud plan.
|
|
//
|
|
// If the return value and error are both nil, the given path exists but seems
|
|
// to be a configuration directory instead.
|
|
//
|
|
// Error will be non-nil if path refers to something which looks like a plan
|
|
// file and loading the file fails.
|
|
func (m *Meta) PlanFile(path string) (*planfile.WrappedPlanFile, error) {
|
|
fi, err := os.Stat(path)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if fi.IsDir() {
|
|
// Looks like a configuration directory.
|
|
return nil, nil
|
|
}
|
|
|
|
return planfile.OpenWrapped(path)
|
|
}
|