Skip to content
This repository has been archived by the owner on Aug 18, 2022. It is now read-only.

rovergo can't use caf_solutions/addons #142

Open
arne21a opened this issue Feb 8, 2022 · 0 comments
Open

rovergo can't use caf_solutions/addons #142

arne21a opened this issue Feb 8, 2022 · 0 comments
Labels
bug 🐞 rover-go Reimplement rover in Go

Comments

@arne21a
Copy link

arne21a commented Feb 8, 2022

rovergo only expects you to use caf_launchpad or caf_solutions. When using caf_solution/addons the cli parser fails.

Rover(sh) has the -lz option with which you can point to every terraform root directory on you machine. Here is an example how to apply the devops_v1 addon from launchpad docs using rover(sh)

rover -lz /tf/caf/caf_solution/add-ons/azure_devops_v1 \
  -tfstate azure_devops-contoso_demo.tfstate \
  -var-folder /tf/caf/caf_solution/add-ons/azure_devops_v1/scenario/200-contoso_demo \
  -parallelism 30 \
  -level level0 \
  -env sandpit \
  -a apply

when using rovergo, you can't just point to that folder, because the cli parser expects you to have one of those suffixes in your path to determine if you are rolling out caf_launchpad or caf_solution:

const cafLaunchPadDir = "/caf_launchpad"
const cafLandingzoneDir = "/caf_solution"

// SetSourcePath ensures the source path is correct and absolute
func (o *Options) SetSourcePath(sourcePath string) {
	if strings.HasSuffix(sourcePath, cafLaunchPadDir) || strings.HasSuffix(sourcePath, cafLandingzoneDir) {
		cobra.CheckErr(fmt.Sprintf("source should not include %s or %s", cafLandingzoneDir, cafLaunchPadDir))
	}

	// Convert to absolute paths as a precaution
	sourcePath, err := filepath.Abs(sourcePath)
	cobra.CheckErr(err)

	if o.LaunchPadMode {
		o.SourcePath = path.Join(sourcePath, cafLaunchPadDir)
	} else {
		o.SourcePath = path.Join(sourcePath, cafLandingzoneDir)
	}

So when I run

rover plan \
  --level level0 \
  --config-dir ./terraform-landingzones-configuration/configuration/prod/level0-addon-devops \
  --source ./terraform-landingzones/caf_solution/add-ons/azure_devops_v1/ \
  --environment prod \
  --statename azure_devops.tfstate \
  --debug

I get this response:

> $HOME/custom_actions directory exists - will not extract example files
>Unable to open source directory: /Users/me/Documents/......./terraform-landingzones/caf_solution/add-ons/azure_devops_v1/caf_solution
> Error: Source directory must exist for rover to run

Workaround:
Move the addon content to a nested caf_solution folder so the path is: /Users/me/Documents/......./terraform-landingzones/caf_solution/add-ons/azure_devops_v1/caf_solution/.
then use this command to configure your source:

--source ./terraform-landingzones/caf_solution/add-ons/azure_devops_v1/

Expected Behavior

Either of those:

  1. Have a way to disable input validation for --source parameter
  2. Have rovergo recognize that it is using an landingzone addon

Actual Behavior

rovergo fails with a misleading error message and does not allow to rollout the addon.

Steps to Reproduce the Problem

Theoretically it should be reproducible with every addon. In my specific case, I used the azure_devops_v1 with modified defaults.

Environment Details

@arne21a arne21a added bug 🐞 rover-go Reimplement rover in Go labels Feb 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug 🐞 rover-go Reimplement rover in Go
Projects
None yet
Development

No branches or pull requests

1 participant