// Create persistent resources (in tf/persistent) that are used across tests. No
// cleanup is required
Create persistent resources (in tf/persistent) that are used across tests. No
cleanup is required
// Create persistent resources ( in tf / persistent ) that are used across tests . No // cleanup is required
func ApplyPersistent(
	ctx context.Context,
	projectID string,
	autoApprove bool,
	logger *log.Logger,
) error {
	logger.Println("Applying any changes to persistent resources")
	cmd := initCommand(ctx, projectID)
	cmd.Dir = tfPersistentDir
	if err := runWithOutput(cmd, logger); err != nil {
		return err
	}
	cmd = exec.CommandContext(ctx, "terraform", "workspace", "select", "default")
	cmd.Dir = tfPersistentDir
	if err := runWithOutput(cmd, logger); err != nil {
		return err
	}
	cmd = exec.CommandContext(
		ctx,
		"terraform",
		"apply",
		"-input=false",
		"-lock-timeout=10m",
		fmt.Sprintf("-var=project_id=%v", projectID),
	)
	if autoApprove {
		cmd.Args = append(cmd.Args, "-auto-approve")
	} else {
		cmd.Stdin = os.Stdin
	}
	cmd.Dir = tfPersistentDir
	if err := runWithOutput(cmd, logger); err != nil {
		return err
	}
	return nil
}
func ApplyPersistent ( ctx context . Context , projectID string , autoApprove bool , logger * log . Logger , ) error { logger . Println ( " " ) cmd := initCommand ( ctx , projectID ) cmd . Dir = tfPersistentDir if err := runWithOutput ( cmd , logger ) ; err != nil { return err } cmd = exec . CommandContext ( ctx , " " , " " , " " , " " ) cmd . Dir = tfPersistentDir if err := runWithOutput ( cmd , logger ) ; err != nil { return err } cmd = exec . CommandContext ( ctx , " " , " " , " " , " " , fmt . Sprintf ( " " , projectID ) , ) if autoApprove { cmd . Args = append ( cmd . Args , " " ) } else { cmd . Stdin = os . Stdin } cmd . Dir = tfPersistentDir if err := runWithOutput ( cmd , logger ) ; err != nil { return err } return nil }
Create persistent resources (in tf/persistent) that are used across tests.
Create persistent resources ( in tf / persistent ) that are used across tests .
// Run terraform init // Select default terraform workspace // Run terraform apply // lock may not be acquired immediately in CI if there are multiple // jobs, but should only be a short wait