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: machine proxy resource and data source #809

Merged
merged 5 commits into from
Nov 1, 2024
Merged

Conversation

domenicsim1
Copy link
Contributor

@domenicsim1 domenicsim1 commented Oct 30, 2024

Machine proxy resource and datasource.

resource "octopusdeploy_machine_proxy" "test_proxy" {
  space_id = "Spaces-1"
  name = "TestProxy"
  host = "192.168.0.1"
  username = "admin"
  password = "pass"
  port = 3000
}
data "octopusdeploy_machine_proxies" "prox" {
  skip = 0
  take = 10
  partial_name = "pietimeProxy"
}

closes #696

Copy link
Contributor

@denys-octopus denys-octopus left a comment

Choose a reason for hiding this comment

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

Looks good 👍

Copy link
Contributor

@mjhilton mjhilton left a comment

Choose a reason for hiding this comment

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

LGTM, my only concern is ensuring that none of the operations allow a proxy password to be retrievable through the TF State. I assume this has been covered, it's just not super-clear from reading the code.

})
}

data.ID = types.StringValue(fmt.Sprintf("Proxies-%s", time.Now().UTC().String()))
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this do for TF state if, for example, the datasource was directly set as the value of an output? Do we do this form of ID'ing in other datasources?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is how terraform recommends handling state for data sources, we do it in all our data sources. This ID is internal for terraform, it uses it to understand and track when the data source changes.

return
}

machineProxy, err := proxies.GetByID(r.Client, state.SpaceID.ValueString(), state.ID.ValueString())
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm sure it's handled, but just for my clarity: if the user doesn't provide a SpaceId on the Datasource, will this state.SpaceID be automatically set to the default Space from the Provider config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, that happens inside the Go client, if the space ID is "" (go will not let it be nil) we will use the space provided on the provider, if one is not provided by the provider it will use default space, if you don't have a default space set it will error gracefully.


updatedProxy := mapMachineProxyModelToRequest(&plan)
updatedProxy.ID = existingProxy.ID
updatedProxy.Links = existingProxy.Links
Copy link
Contributor

Choose a reason for hiding this comment

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

Eww :) do we have to? I assume so, but would love if TFP didn't need to concern itself with this detail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same. At least its not exposed to user.

@domenicsim1 domenicsim1 merged commit 51ec30c into main Nov 1, 2024
22 checks passed
@domenicsim1 domenicsim1 deleted the dom/machine-proxy branch November 1, 2024 00:40
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.

Support creation of machine proxies with terraform provider
3 participants