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

feat: introduce json format for inline module (#165) #283

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

denniskniep
Copy link
Contributor

Description of your changes

API Change:
Added a new property InlineFormat to WorkspaceParameters which specifies the format of the inline Terraform content. It could be HCL or JSON

Change:
If InlineFormat is set to JSON the file which is created is named main.tf.json instead of main.tf

Fixes #165

I have:

  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

Wrote a UnitTest and already tested it in my environment

@Upbound-CLA
Copy link

Upbound-CLA commented Aug 8, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@bobh66 bobh66 left a comment

Choose a reason for hiding this comment

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

Overall I think it looks fine - a couple of comments inline. Also maybe add an example file to document what the JSON format looks like in the inline module. Thanks!

apis/v1beta1/workspace_types.go Outdated Show resolved Hide resolved
@@ -249,8 +250,12 @@ func (c *connector) Connect(ctx context.Context, mg resource.Managed) (managed.E
}

case v1beta1.ModuleSourceInline:
if err := c.fs.WriteFile(filepath.Join(dir, tfMain), []byte(cr.Spec.ForProvider.Module), 0600); err != nil {
return nil, errors.Wrap(err, errWriteMain)
filename := tfMain
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I think we prefer short variable names, so maybe fn or f instead of filename

Signed-off-by: Dennis Kniep <kniepdennis@gmail.com>
@denniskniep denniskniep force-pushed the feature/inline-module-format-json branch from 588d051 to db0eb9e Compare August 9, 2024 13:56
@denniskniep
Copy link
Contributor Author

@bobh66 addressed your review comments

@denniskniep
Copy link
Contributor Author

@bobh66 can we merge this?

Copy link
Collaborator

@bobh66 bobh66 left a comment

Choose a reason for hiding this comment

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

Thhanks @denniskniep - LGTM. It would be nice to have an example Workspace that shows the JSON format, but presumably anyone interested in using the JSON format already knows what it looks like.

@bobh66 bobh66 merged commit 9db20a3 into upbound:main Aug 26, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.tf.json format support
3 participants