INNER CODE UNIT · Go

findOrInstallTerraform

cloudflare/cf-terraforming · internal/app/cf-terraforming/cmd/generate.go:1605

func findOrInstallTerraform() (string, error) {
	// Check if the user has provided an explicit path to the binary. This is the highest priority.
	if execPath := viper.GetString("terraform-binary-path"); execPath != "" {
		log.WithFields(logrus.Fields{
			"terraform-binary-path": execPath,
		}).Info("Using Terraform binary from explicit path")
		// Quick check to ensure the file actually exists
		if _, err := os.Stat(execPath); err != nil {
			return "", fmt.Errorf("binary specified in 'terraform-binary-path' not found at %s: %w", execPath, err)
		}
		return execPath, nil
	}
	log.Info("terraform-binary-path flag not set")

	// Determine the persistent installation directory.
	installPath := viper.GetString("terraform-install-path")
	if installPath == "" {
		log.Info("terraform-install-path flag not set")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…