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

merge tfvars struct into vars struct #75

Merged

Conversation

jason-jackson
Copy link
Contributor

Removed

  • Removed TFVars struct as it was a strict subset of the Vars struct.

@jason-jackson jason-jackson requested a review from a team April 29, 2024 18:47
@@ -257,7 +249,7 @@ func ConvertHCLVariable(tfVar *TFVar) {

// GetCreateVariablePayload returns the json needed to make a Post to the
// Terraform vars api
func GetCreateVariablePayload(organization, workspaceName string, tfVar TFVar) string {
func GetCreateVariablePayload(organization, workspaceName string, tfVar Var) string {
return fmt.Sprintf(`
{
"data": {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was debating whether or not to update category here to be what was in tfVar, but left it as is for now. I can change it as needed. Also debated making the whole variable payload and using json.Marshal()

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps an important deciding factor is to make any changes now that would be breaking compatibility. Since this function is exported, any change to the signature or its functionality would be breaking. It might actually make sense to un-export this function now. I'm not sure if it's used anywhere outside this library, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good points, I can check.

Copy link
Contributor Author

@jason-jackson jason-jackson May 7, 2024

Choose a reason for hiding this comment

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

Also, I might as well fix the deprecated filter.

Copy link
Contributor Author

@jason-jackson jason-jackson May 7, 2024

Choose a reason for hiding this comment

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

Actually. Looking at it further, why not use https://github.com/hashicorp/go-tfe?

[EDIT: I see it has a different license, so yeah, we'd need to factor that in]
[EDIT2: Further reading seems to state that we can leave it as this license (Apache2)

Copy link
Contributor

Choose a reason for hiding this comment

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

tfc-ops predates the existence of go-tfe (perhaps only by days) so that's the primary reason why we haven't used go-tfe. The other would be because go-tfe appears to be a thin wrapper around the API, whereas tfc-ops aims to be more opinionated and feature-rich. I'm not sure whether your question was about moving to eliminate tfc-ops as a library, or whether it was to start using go-tfe within this library. I'm open to either one.

Copy link
Contributor

Choose a reason for hiding this comment

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

In looking to understand what you meant by "deprecated filter" I noticed that the variables API itself is marked as deprecated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking to use the go-tfe code in this library. It might solve some of the deprecation issues.

@@ -284,7 +276,7 @@ func GetCreateVariablePayload(organization, workspaceName string, tfVar TFVar) s

// GetUpdateVariablePayload returns the json needed to make a Post to the
// Terraform vars api
func GetUpdateVariablePayload(organization, workspaceName, variableID string, tfVar TFVar) string {
func GetUpdateVariablePayload(organization, workspaceName, variableID string, tfVar Var) string {
return fmt.Sprintf(`
{
"data": {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was debating whether or not to update category here to be what was in tfVar, but left it as is for now. I can change it as needed. Also debated making the whole variable payload and using json.Marshal()

Copy link
Contributor

Choose a reason for hiding this comment

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

(same as above)

Copy link
Contributor

@hobbitronics hobbitronics left a comment

Choose a reason for hiding this comment

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

Lgtm

@@ -257,7 +249,7 @@ func ConvertHCLVariable(tfVar *TFVar) {

// GetCreateVariablePayload returns the json needed to make a Post to the
// Terraform vars api
func GetCreateVariablePayload(organization, workspaceName string, tfVar TFVar) string {
func GetCreateVariablePayload(organization, workspaceName string, tfVar Var) string {
return fmt.Sprintf(`
{
"data": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps an important deciding factor is to make any changes now that would be breaking compatibility. Since this function is exported, any change to the signature or its functionality would be breaking. It might actually make sense to un-export this function now. I'm not sure if it's used anywhere outside this library, though.

@@ -284,7 +276,7 @@ func GetCreateVariablePayload(organization, workspaceName string, tfVar TFVar) s

// GetUpdateVariablePayload returns the json needed to make a Post to the
// Terraform vars api
func GetUpdateVariablePayload(organization, workspaceName, variableID string, tfVar TFVar) string {
func GetUpdateVariablePayload(organization, workspaceName, variableID string, tfVar Var) string {
return fmt.Sprintf(`
{
"data": {
Copy link
Contributor

Choose a reason for hiding this comment

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

(same as above)

lib/client.go Show resolved Hide resolved
@briskt
Copy link
Contributor

briskt commented May 16, 2024

@jason-jackson is this ready to merge?

@jason-jackson jason-jackson merged commit 90f5cc7 into feature/call-api-return-error May 21, 2024
3 checks passed
@jason-jackson jason-jackson deleted the feature/merge-vars-tfvars branch May 21, 2024 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants