-
Notifications
You must be signed in to change notification settings - Fork 5
fix: Ensure Version field is handled correctly when bootstrapping TF module Promise #191
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
Open
aclevername
wants to merge
17
commits into
main
Choose a base branch
from
codex-ab-jk
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
54ba1c6
codex: did it work?
aclevername 5dc81d8
codex: remove deprecated flags
aclevername 3404745
codex: remove backwards compat and move logic into cli for validating
aclevername 95001de
codex: refactor
aclevername 80938cb
codex: remove unused MODULE_PATH variable
aclevername 62028d6
fix: handle mismatch of version and git env vars in stage
aclevername c78f805
codex: add sys test
aclevername 40abde4
codex: sys test against real world
aclevername a147012
codex: improve sys tests
aclevername bb47739
codex: improve sys tests
aclevername bf26830
use private repo in test
aclevername 81a3251
setup deploy key before running tests
aclevername eaa6f0d
delete unused files, refactor tests, use ssh for sys test
aclevername bd250f9
fix dockerloading
aclevername 144c612
PR feedback and fix incorrect version
aclevername b4359ee
use next released version of init tf module promise
aclevername db25e11
fix test version
aclevername File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,14 @@ jobs: | |
| check-latest: true | ||
| - name: Install Terraform CLI | ||
| uses: hashicorp/setup-terraform@v3 | ||
| - name: Setup SSH Agent | ||
| uses: webfactory/[email protected] | ||
| with: | ||
| ssh-private-key: ${{ secrets.SYNTASSO_KRATIX_CLI_PRIVATE_TF_MODULE_TEST_FIXTURE_REPO_DEPLOY_KEY }} | ||
| - name: Setup SSH | ||
| run: | | ||
| mkdir -p ~/.ssh | ||
| ssh-keyscan github.com >> ~/.ssh/known_hosts | ||
| - name: Run make test | ||
| run: make test | ||
| - name: Run govulncheck | ||
|
|
@@ -55,4 +63,4 @@ jobs: | |
| release-please \ | ||
| --token=$TOKEN \ | ||
| --repo-url=syntasso/kratix-cli \ | ||
| release-pr | ||
| release-pr | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,15 +39,15 @@ To pull modules from private registries, ensure your system is logged in to the | |
| # Initialize a Promise from a Terraform Module in Terraform registry | ||
| kratix init tf-module-promise iam \ | ||
| --module-source terraform-aws-modules/iam/aws \ | ||
| --module-version 6.2.3 \ | ||
| --module-registry-version 6.2.3 \ | ||
| --group syntasso.io \ | ||
| --kind IAM \ | ||
| --version v1alpha1`, | ||
| RunE: InitFromTerraformModule, | ||
| Args: cobra.ExactArgs(1), | ||
| } | ||
|
|
||
| moduleSource, moduleVersion string | ||
| moduleSource, moduleRegistryVersion string | ||
| ) | ||
|
|
||
| func init() { | ||
|
|
@@ -56,15 +56,21 @@ func init() { | |
| "This can be a Git URL, Terraform registry path, or a local directory path. \n"+ | ||
| "It follows the same format as the `source` argument in the Terraform module block.", | ||
| ) | ||
| terraformModuleCmd.Flags().StringVarP(&moduleVersion, "module-version", "m", "", "(Optional) version of the terraform module; "+ | ||
| terraformModuleCmd.Flags().StringVarP(&moduleRegistryVersion, "module-registry-version", "r", "", "(Optional) version of the Terraform module from a registry; "+ | ||
| "only use when pulling modules from Terraform registry", | ||
| ) | ||
| terraformModuleCmd.MarkFlagRequired("module-source") | ||
| } | ||
|
|
||
| func InitFromTerraformModule(cmd *cobra.Command, args []string) error { | ||
| fmt.Println("Fetching terraform module variables, this might take up to a minute...") | ||
| variables, err := internal.GetVariablesFromModule(moduleSource, moduleVersion) | ||
|
|
||
| if moduleRegistryVersion != "" && !internal.IsTerraformRegistrySource(moduleSource) { | ||
| fmt.Println("Error: --module-registry-version is only valid for Terraform registry sources like 'namespace/name/provider'. For git URLs (e.g., 'git::https://github.com/org/repo.git?ref=v1.0.0') or local paths, embed the ref directly in --module-source instead.") | ||
| return fmt.Errorf("invalid use of --module-registry-version with non-registry source") | ||
| } | ||
|
|
||
| variables, err := internal.GetVariablesFromModule(moduleSource, moduleRegistryVersion) | ||
| if err != nil { | ||
| fmt.Printf("Error: failed to download and convert terraform module to CRD: %s\n", err) | ||
| return nil | ||
|
|
@@ -82,16 +88,16 @@ func InitFromTerraformModule(cmd *cobra.Command, args []string) error { | |
| return nil | ||
| } | ||
|
|
||
| resourceConfigure, err := generateTerraformModuleResourceConfigurePipeline() | ||
| resourceConfigure, err := generateTerraformModuleResourceConfigurePipeline(moduleRegistryVersion) | ||
| if err != nil { | ||
| fmt.Printf("Error: failed to generate promise pipelines: %s\n", err) | ||
| return nil | ||
| } | ||
|
|
||
| promiseName := args[0] | ||
| extraFlags := fmt.Sprintf("--module-source %s", moduleSource) | ||
| if moduleVersion != "" { | ||
| extraFlags = fmt.Sprintf("%s --module-version %s", extraFlags, moduleVersion) | ||
| if moduleRegistryVersion != "" { | ||
| extraFlags = fmt.Sprintf("%s --module-registry-version %s", extraFlags, moduleRegistryVersion) | ||
| } | ||
| templateValues, err := generateTemplateValues(promiseName, "tf-module-promise", extraFlags, resourceConfigure, string(crdSchema)) | ||
| if err != nil { | ||
|
|
@@ -123,18 +129,18 @@ func InitFromTerraformModule(cmd *cobra.Command, args []string) error { | |
| return nil | ||
| } | ||
|
|
||
| func generateTerraformModuleResourceConfigurePipeline() (string, error) { | ||
| func generateTerraformModuleResourceConfigurePipeline(moduleRegistryVersion string) (string, error) { | ||
| envs := []corev1.EnvVar{ | ||
| { | ||
| Name: "MODULE_SOURCE", | ||
| Value: moduleSource, | ||
| }, | ||
| } | ||
|
|
||
| if moduleVersion != "" { | ||
| if moduleRegistryVersion != "" { | ||
| envs = append(envs, corev1.EnvVar{ | ||
| Name: "MODULE_VERSION", | ||
| Value: moduleVersion, | ||
| Name: "MODULE_REGISTRY_VERSION", | ||
| Value: moduleRegistryVersion, | ||
| }) | ||
| } | ||
|
|
||
|
|
@@ -150,7 +156,7 @@ func generateTerraformModuleResourceConfigurePipeline() (string, error) { | |
| "containers": []any{ | ||
| v1alpha1.Container{ | ||
| Name: "terraform-generate", | ||
| Image: "ghcr.io/syntasso/kratix-cli/terraform-generate:v0.2.0", | ||
| Image: "ghcr.io/syntasso/kratix-cli/terraform-generate:v0.4.0", | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was never updated to the latest image 0.3.1 😢 pre-empting the next release of this by adding v0.4.0 |
||
| Env: envs, | ||
| }, | ||
| }, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.