Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create GVC and identity terraform configs from templates #230

Merged

Conversation

zzaakiirr
Copy link
Contributor

@zzaakiirr zzaakiirr commented Aug 30, 2024

What does this PR do?

  1. This PR introduces TerraformConfig::Generator class which takes YAML template and transforms them to Terraform config (.tf format). For now, only 2 types of templates are supported - gvc and identity

Support for other template types will be added in later PRs

  1. cpflow terraform generate command now accepts 2 optional arguments: application name and directory to save generated terraform config files to.
  • If application name is not provided config files will be generated for each app defined in controlplane.yml in folder with app name
  • Default directory where config files are saved is ./terraform
  1. Each time command cpflow terraform generate is invoked configuration files are recreated

Terraform docs

https://registry.terraform.io/providers/controlplane-com/cpln/latest/docs/resources/gvc
https://registry.terraform.io/providers/controlplane-com/cpln/latest/docs/resources/identity

Examples

YAML template for CPLN gvc:

kind: gvc
name: app-name
description: app-description
tags:
  tag-name-1: "tag-value-1"
  tag-name-2: "tag-value-2"
spec:
  domain: "app.example.com"
  env:
    - name: DATABASE_URL
      value: "postgres://the_user:[email protected]:5432/app-name"
    - name: RAILS_ENV
      value: production
    - name: RAILS_SERVE_STATIC_FILES
      value: "true"
  staticPlacement:
    locationLinks:
      - "//location/aws-us-west-2"
  pullSecretLinks:
    - "/org/org-name/secret/some-secret"
  loadBalancer:
    dedicated: true
    trustedProxies: 0

Will transform to:

resource "cpln_gvc" "app-name" {
  name = "app-name"
  description = "app-description"
  tags = {
    tag_name_1 = "tag-value-1"
    tag_name_2 = "tag-value-2"
  }
  domain = "app.example.com"
  locations = ["aws-us-west-2"]
  pull_secrets = ["cpln_secret.some-secret.name"]
  env = {
    DATABASE_URL = "postgres://the_user:[email protected]:5432/app-name"
    RAILS_ENV = "production"
    RAILS_SERVE_STATIC_FILES = "true"
  }
  load_balancer {
    dedicated = true
    trusted_proxies = 0
  }
}

Summary by CodeRabbit

  • New Features

    • Updated documentation for the cpflow terraform generate command to include a new required argument, $APP_NAME.
    • Introduced new options for specifying output directories in command execution.
    • Added support for generating Terraform configuration files based on different templates, enhancing modularity and reusability.
  • Bug Fixes

    • Improved robustness of file handling in test setups.
  • Tests

    • Added comprehensive tests for the TerraformConfig::Generator, Gvc, and Identity classes to ensure correct configuration generation.

Copy link

coderabbitai bot commented Aug 30, 2024

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes introduce enhancements to the cpflow terraform generate command, requiring an application name as an argument. The Generate class in the Terraform module is updated to process templates and generate configuration files dynamically. New classes for managing Terraform configurations, Gvc and Identity, are added, along with tests to ensure correct functionality. Additional utility methods and regex patterns improve string handling and validation throughout the codebase.

Changes

Files Change Summary
docs/commands.md Updated command usage for cpflow terraform generate to include $APP_NAME as a required argument.
lib/command/base.rb Added dir_option method for specifying output directory; updated all_options to include this method.
lib/command/terraform/generate.rb Added OPTIONS constant, modified call method for template processing, and introduced templates method.
lib/core/terraform_config/dsl.rb Introduced REFERENCE_PATTERN constant for regex matching, updated put method for string handling.
lib/core/terraform_config/generator.rb Created Generator class for generating Terraform configurations based on templates.
lib/core/terraform_config/gvc.rb Added Gvc class to manage GVC-related Terraform configurations, including methods for resource generation.
lib/core/terraform_config/identity.rb Introduced Identity class for identity resource management in Terraform configurations.
lib/cpflow.rb Modified self.klass_for method to explicitly call process_option_params from Cpflow::Cli.
lib/patches/string.rb Added underscore method for string manipulation.
spec/command/terraform/generate_spec.rb Updated tests for Command::Terraform::Generate, expanding file existence checks.
spec/core/terraform_config/generator_spec.rb Added tests for TerraformConfig::Generator class to validate configuration generation.
spec/core/terraform_config/gvc_spec.rb Introduced tests for TerraformConfig::Gvc class focusing on the #to_tf method.
spec/core/terraform_config/identity_spec.rb Added tests for TerraformConfig::Identity class, validating the #to_tf method output.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Command
    participant Generator
    participant Gvc
    participant Identity

    User->>Command: cpflow terraform generate -a $APP_NAME
    Command->>Generator: Initialize with templates
    Generator->>Gvc: Generate GVC configuration
    Gvc-->>Generator: Return GVC configuration
    Generator->>Identity: Generate Identity configuration
    Identity-->>Generator: Return Identity configuration
    Generator-->>Command: Return generated files
    Command-->>User: Output generated files
Loading

🐇 "In the meadow, changes bloom,
With commands that now have room.
Templates dance, configurations sing,
A rabbit's joy in every spring!
Hop along, new paths to find,
Terraform dreams, a joyful mind!"
🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@zzaakiirr zzaakiirr force-pushed the create-gvc-and-identity-tf-configs-from-templates branch from 66e4177 to 32e8790 Compare September 1, 2024 08:55
lib/cpflow.rb Show resolved Hide resolved
lib/patches/string.rb Show resolved Hide resolved
lib/core/terraform_config/identity.rb Show resolved Hide resolved
lib/command/terraform/generate.rb Outdated Show resolved Hide resolved
@zzaakiirr
Copy link
Contributor Author

@coderabbitai review

Copy link

coderabbitai bot commented Sep 1, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
lib/core/terraform_config/gvc.rb (1)

7-29: LGTM! Consider using keyword arguments to improve readability.

The code changes are approved. However, consider using keyword arguments to improve readability and maintainability. For example:

def initialize(name:, description: nil, tags: nil, domain: nil, locations: nil, pull_secrets: nil, env: nil, load_balancer: nil)
  super()
  @name = name
  @description = description
  @tags = tags
  @domain = domain
  @locations = locations
  @pull_secrets = pull_secrets
  @env = env
  @load_balancer = load_balancer&.transform_keys { |k| k.to_s.underscore.to_sym }
end
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3382a79 and 32e8790.

Files selected for processing (12)
  • docs/commands.md (1 hunks)
  • lib/command/terraform/generate.rb (2 hunks)
  • lib/core/terraform_config/dsl.rb (3 hunks)
  • lib/core/terraform_config/generator.rb (1 hunks)
  • lib/core/terraform_config/gvc.rb (1 hunks)
  • lib/core/terraform_config/identity.rb (1 hunks)
  • lib/cpflow.rb (1 hunks)
  • lib/patches/string.rb (1 hunks)
  • spec/command/terraform/generate_spec.rb (2 hunks)
  • spec/core/terraform_config/generator_spec.rb (1 hunks)
  • spec/core/terraform_config/gvc_spec.rb (1 hunks)
  • spec/core/terraform_config/identity_spec.rb (1 hunks)
Additional comments not posted (23)
lib/core/terraform_config/identity.rb (1)

1-27: LGTM!

The code changes are approved. The new Identity class is well-structured and correctly generates the Terraform resource block for cpln_identity.

lib/patches/string.rb (1)

21-23: LGTM!

The code changes are approved. The new underscore method is a useful utility for string manipulation and the regular expression correctly converts the string to underscore case.

spec/core/terraform_config/identity_spec.rb (1)

1-36: LGTM!

The code changes are approved. The new spec for the Identity class is well-written and covers the important aspects of the class. The use of a heredoc makes the spec readable and easy to understand. The spec passes and ensures that the to_tf method generates the correct Terraform config.

spec/command/terraform/generate_spec.rb (2)

12-12: LGTM!

The change enhances the test setup by providing a test app for each test case.


25-32: LGTM!

The changes enhance the test coverage by checking for multiple config files and improve the robustness of the test by using :aggregate_failures.

lib/command/terraform/generate.rb (3)

20-27: LGTM!

The changes enhance the command's capability to generate terraform configs dynamically based on the provided templates. The conditional check adds a layer of validation to the template handling.


36-39: LGTM!

The method introduces a new dependency on the TemplateParser class to parse YAML template files from a specified directory.


43-43: LGTM!

The change ensures a clean state for the generated files by removing any existing directory before creating a new one.

spec/core/terraform_config/gvc_spec.rb (1)

1-52: LGTM!

The test case covers the required and optional arguments of the TerraformConfig::Gvc class and uses a heredoc to compare the generated config with the expected config.

lib/core/terraform_config/gvc.rb (2)

31-44: LGTM!

The code changes are approved.


48-55: LGTM!

The code changes are approved.

lib/core/terraform_config/dsl.rb (3)

7-7: LGTM!

The code changes are approved.


49-49: LGTM!

The code changes are approved.


67-67: LGTM!

The code changes are approved.

lib/core/terraform_config/generator.rb (5)

7-10: LGTM!

The code changes are approved.


12-21: LGTM!

The code changes are approved.


23-32: LGTM!

The code changes are approved.


37-56: LGTM!

The code changes are approved.


58-65: LGTM! But verify that the config.app matches the GVC name.

The code changes are approved. However, ensure that the config.app matches the GVC name.

Run the following script to verify that the config.app matches the GVC name:

Verification successful

Verification Successful: config.app correctly matches the GVC name.

The cpln_gvc resource is defined and used in the codebase, and the use of config.app to construct the GVC name in generator.rb is correct. The code changes are consistent with the intended functionality.

  • lib/core/terraform_config/generator.rb: gvc: "cpln_gvc.#{config.app}.name"
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the `config.app` matches the GVC name.

# Test: Search for the GVC name in the `gvc.tf` file. Expect: The GVC name matches the `config.app`.
rg --type terraform $'resource "cpln_gvc" "' | rg --only-matching $'"[^"]*"'

Length of output: 110


Script:

#!/bin/bash
# Description: Locate Terraform files and verify that the `config.app` matches the GVC name.

# Find all Terraform files and search for the `cpln_gvc` resource.
fd --extension tf --exec rg 'resource "cpln_gvc" "'

Length of output: 53


Script:

#!/bin/bash
# Description: Search for any occurrences of `cpln_gvc` in the entire repository.

# Search for `cpln_gvc` in all files to verify its existence.
rg 'cpln_gvc'

Length of output: 459

spec/core/terraform_config/generator_spec.rb (2)

10-67: LGTM!

The test for the "gvc" template looks comprehensive and is testing the generator thoroughly. It is checking the generated Terraform config object's attributes and the generated filename. No issues found.


70-91: LGTM!

The test for the "identity" template looks good and is testing the generator correctly. It is checking the generated Terraform config object's attributes and the generated filename. No issues found.

lib/cpflow.rb (1)

238-238: The existing comment explains the reason for the change. No further comments are needed.

docs/commands.md (1)

452-452: LGTM! But verify the implementation.

The documentation change looks good. The cpflow terraform generate command now requires the application name as an argument.

Verify that the cpflow terraform generate command implementation has been updated to require the application name argument.

Run the following script to verify the implementation:

Verification successful

Verification Successful: The cpflow terraform generate command requires the application name argument.

The implementation in lib/command/terraform/generate.rb includes app_option(required: true), confirming that the application name is a required argument for this command. This aligns with the documentation update.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the `cpflow terraform generate` command requires the application name argument.

# Test: Search for the command implementation. Expect: The command to have the `-a` or `--app` option.
rg --type ruby -A 5 $'desc \'terraform generate\''

Length of output: 55


Script:

#!/bin/bash
# Broaden the search to locate the `terraform generate` command implementation in the codebase.
rg 'terraform generate'

Length of output: 123


Script:

#!/bin/bash
# Search for `cpflow` in the codebase to locate command-line interface definitions.
rg 'cpflow'

Length of output: 60153


Script:

#!/bin/bash
# Search for command definitions or option parsing logic related to `terraform generate` or `cpflow`.
rg 'terraform generate' --type ruby
rg 'option' --type ruby

Length of output: 24988

@zzaakiirr zzaakiirr marked this pull request as ready for review September 1, 2024 09:03
@zzaakiirr zzaakiirr force-pushed the create-gvc-and-identity-tf-configs-from-templates branch from d47aa92 to 2630c3c Compare October 3, 2024 12:01
@zzaakiirr
Copy link
Contributor Author

@coderabbitai review

Copy link

coderabbitai bot commented Oct 3, 2024

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (5)
spec/command/terraform/generate_spec.rb (3)

12-12: LGTM! Consider adding a comment for clarity.

The addition of let!(:app) is a good practice for setting up the test environment. It ensures that the dummy app is created before each test run.

Consider adding a brief comment explaining what dummy_test_app represents, as it's not defined in this file:

# Create a dummy application instance for testing
let!(:app) { dummy_test_app }

24-28: Improved test case with better assertions and error aggregation.

The changes to the test case are excellent:

  1. Adding :aggregate_failures allows all expectations to be evaluated, improving test coverage.
  2. Checking for non-existence of files before running the command ensures a clean state.
  3. Using all(exist) provides a clear and concise way to check all generated files.

Consider adding a descriptive comment for the test case to explain its purpose:

# Ensures that the command generates all expected Terraform config files
it "generates terraform config files", :aggregate_failures do
  # ... (rest of the test case)
end

30-33: Well-structured helper method for managing config file paths.

The config_file_paths method is a great addition:

  1. It centralizes the logic for determining expected file paths.
  2. It improves maintainability and reduces duplication in the test.
  3. The method is flexible, allowing for easy addition of new config files in the future.

Consider adding a brief comment explaining the method's purpose and return value:

# Returns an array of Pathname objects for all expected Terraform config files
def config_file_paths
  [TERRAFORM_CONFIG_DIR_PATH.join("providers.tf")] + %w[gvc.tf identities.tf].map do |config_file_path|
    TERRAFORM_CONFIG_DIR_PATH.join(app, config_file_path)
  end
end
lib/command/base.rb (1)

457-468: LGTM! Consider enhancing with path validation and a more detailed description.

The dir_option method is a well-structured addition that follows the existing pattern for option methods in the class. It provides flexibility with the required parameter and uses appropriate types for the directory option.

To further improve this method, consider the following suggestions:

  1. Add path validation to ensure the provided directory is valid and accessible.
  2. Expand the description to provide more context, e.g., "Specify the output directory for generated files".

Here's a suggested enhancement to the method:

def self.dir_option(required: false)
  {
    name: :dir,
    params: {
      banner: "DIR",
      desc: "Specify the output directory for generated files",
      type: :string,
      required: required,
      validate: ->(value) { Dir.exist?(value) || raise("Directory does not exist: #{value}") }
    }
  }
end

This change adds a simple validation to check if the directory exists and provides a more informative description.

lib/command/terraform/generate.rb (1)

52-52: Review the file write mode for clarity

The File.write method is using mode: "a+", which opens the file in read-write mode and appends content to it:

File.write(terraform_app_dir.join(generator.filename), generator.tf_config.to_tf, mode: "a+")

Since the application directory is recreated each time with recreate_terraform_app_dir, and files within it are removed, using append mode might not be necessary.

Consider using the default write mode ("w"), which truncates the file before writing. This can prevent potential confusion and ensures that each generation produces a fresh set of configuration files:

-File.write(terraform_app_dir.join(generator.filename), generator.tf_config.to_tf, mode: "a+")
+File.write(terraform_app_dir.join(generator.filename), generator.tf_config.to_tf)

If there is a specific reason for using append mode (e.g., multiple writes to the same file within a single run), please ensure that this behavior is documented to avoid confusion.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 32e8790 and 2630c3c.

📒 Files selected for processing (3)
  • lib/command/base.rb (1 hunks)
  • lib/command/terraform/generate.rb (1 hunks)
  • spec/command/terraform/generate_spec.rb (1 hunks)
🔇 Additional comments (4)
spec/command/terraform/generate_spec.rb (1)

14-16: Improved file cleanup in the before block.

The change from FileUtils.rm_r to FileUtils.rm_rf is a good improvement. It ensures a more robust cleanup process before each test by forcibly removing the directory and its contents, even if it doesn't exist.

lib/command/base.rb (1)

470-472: LGTM! The new dir_option is automatically included in all_options.

The all_options method uses metaprogramming to collect all methods ending with _option. This approach ensures that the newly added dir_option is automatically included without requiring any changes to the all_options method itself.

This demonstrates good use of metaprogramming for extensibility, making it easy to add new options in the future without modifying existing code.

lib/command/terraform/generate.rb (2)

49-50: 🛠️ Refactor suggestion

Remove hardcoding of template kinds to support extensibility

Currently, the code skips processing templates unless their kind is either 'gvc' or 'identity':

next unless %w[gvc identity].include?(template["kind"])

Hardcoding template kinds can hinder future extensibility when new template types are added.

Consider handling all available template kinds dynamically or configuring the list of supported kinds. If certain kinds are not yet supported, you could log a warning or handle them appropriately.

Given the TODO comment indicates that this line should be deleted after all template kinds are supported, ensure that there is a plan to implement support for additional kinds. To verify if there are other template kinds present in the templates directory, you can run the following script:

#!/bin/bash
# Description: Check for template kinds other than 'gvc' and 'identity' in templates/*.yml

# Expected: No output if only 'gvc' and 'identity' are used.

rg '^kind:' templates/*.yml | sed 's/.*kind: //' | sort | uniq | grep -v -E '^(gvc|identity)$'

This script searches for all kind entries in your template files and lists any that are not 'gvc' or 'identity'. If the script outputs any kinds, it means there are templates that are currently being skipped and need to be supported or handled accordingly.


71-73: Ensure the terraform directory path is correctly resolved

When fetching the :dir option from config.options, if the provided path is relative, it might not resolve correctly:

full_path = config.options.fetch(:dir, Cpflow.root_path.join("terraform"))

Verify that when a relative path is provided via the :dir option, it is correctly expanded relative to the current working directory or the application's root path. If not, consider expanding it using File.expand_path or resolving it against a known base path.

To confirm this behavior, you can run the following script:

This will show how relative paths are resolved in your environment and help ensure that the terraform directory is created in the intended location.

lib/command/terraform/generate.rb Outdated Show resolved Hide resolved
lib/command/terraform/generate.rb Outdated Show resolved Hide resolved
@justin808
Copy link
Member

We need to clear out the temporary GVCs per the errors on CI.

Copy link
Collaborator

@rafaelgomesxyz rafaelgomesxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💯

Left just a few minors/nits, which you can address before merging if you want. No need to ask for a re-review.

lib/command/terraform/generate.rb Outdated Show resolved Hide resolved
lib/core/terraform_config/gvc.rb Show resolved Hide resolved
lib/command/terraform/generate.rb Outdated Show resolved Hide resolved
lib/command/terraform/generate.rb Outdated Show resolved Hide resolved
lib/command/terraform/generate.rb Outdated Show resolved Hide resolved
spec/command/terraform/generate_spec.rb Outdated Show resolved Hide resolved
spec/command/terraform/generate_spec.rb Outdated Show resolved Hide resolved
Copy link
Collaborator

@rafaelgomesxyz rafaelgomesxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zzaakiirr Actually, this line is causing issues in the tests, and may be affecting other areas as well:

config.class.define_method(:app) { app }

When doing the cleanup at the end of the tests, it tries to delete the incorrect app, because the app method has been overwritten and won't return the correct app:

wrong_app

This is why apps aren't being properly cleaned after running the tests.

We need to think of a better way to handle this.

lib/core/terraform_config/generator.rb Outdated Show resolved Hide resolved
lib/core/terraform_config/gvc.rb Outdated Show resolved Hide resolved
@zzaakiirr
Copy link
Contributor Author

@zzaakiirr Actually, this line is causing issues in the tests, and may be affecting other areas as well:

config.class.define_method(:app) { app }

When doing the cleanup at the end of the tests, it tries to delete the incorrect app, because the app method has been overwritten and won't return the correct app:

wrong_app

This is why apps aren't being properly cleaned after running the tests.

We need to think of a better way to handle this.

@rafaelgomesxyz Thanks for finding problematic place in the code! I replaced define_method with instance_variable_set and ran:

bundle exec rspec spec/command/terraform/generate_spec.rb spec/command/apply_template_spec.rb

Both specs passed and test GVCs were deleted in controlplane. Without this fix apply_template_spec.rb was failing

@zzaakiirr zzaakiirr merged commit b4bf309 into terraform-feature Oct 21, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants