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

Machine data sources do not work correctly #580

Closed
mcasperson opened this issue Dec 5, 2023 · 1 comment
Closed

Machine data sources do not work correctly #580

mcasperson opened this issue Dec 5, 2023 · 1 comment
Assignees

Comments

@mcasperson
Copy link
Contributor

mcasperson commented Dec 5, 2023

Describe the bug

Given the following Terraform:

terraform {

  required_providers {
    octopusdeploy = { source = "OctopusDeployLabs/octopusdeploy", version = "0.13.2" }
  }
}

variable "octopus_server" {
  type        = string
  nullable    = false
  sensitive   = false
  description = "The URL of the Octopus server e.g. https://myinstance.octopus.app."
}
variable "octopus_apikey" {
  type        = string
  nullable    = false
  sensitive   = true
  description = "The API key used to access the Octopus server. See https://octopus.com/docs/octopus-rest-api/how-to-create-an-api-key for details on creating an API key."
}
variable "octopus_space_id" {
  type        = string
  nullable    = false
  sensitive   = false
  description = "The ID of the Octopus space to populate."
}

provider "octopusdeploy" {
  address  = "${var.octopus_server}"
  api_key  = "${var.octopus_apikey}"
  space_id = "${var.octopus_space_id}"
}

data "octopusdeploy_cloud_region_deployment_targets" "cloud_targets" {
  skip = 0
  take = 100
}

output "cloud-targets" {
  value = data.octopusdeploy_cloud_region_deployment_targets
}

And a space that has cloud region targets, the data.octopusdeploy_cloud_region_deployment_targets.cloud_region_deployment_targets property is null.

Steps to reproduce

  1. Run the example terraform above against a space with cloud region targets
  2. Note the output shows the cloud_region_deployment_targets is null.

Expected behavior
The cloud_region_deployment_targets property should be a list of cloud regions targets in the space.

Logs and other supporting information

Changes to Outputs:
  + cloud-targets = {
      + cloud_region_deployment_targets = null
      + deployment_id                   = null
      + environments                    = null
      + health_statuses                 = null
      + id                              = "CloudRegionDeploymentTargets 2023-12-05 04:27:03.293728771 +0000 UTC"
      + ids                             = null
      + is_disabled                     = null
      + name                            = null
      + partial_name                    = null
      + roles                           = null
      + shell_names                     = null
      + skip                            = 0
      + take                            = 4
      + tenant_tags                     = null
      + tenants                         = null
      + thumbprint                      = null
    }

Screenshots
If applicable, add screenshots to help explain your problem.

Environment and versions:

  • OS: 'Linux'
  • Octopus Server Version: [e.g. 2024.1]
  • Terraform Version: [e.g. 1.6.5]
  • Octopus Terraform Provider Version: [e.g. 0.13.2]

Additional context
Add any other context about the problem here.

The line d.Set("cloud_region_deployment_targets", flattenedCloudRegionDeploymentTargets) in data_source_cloud_region_deployment_targets.go attempts to set the cloud_region_deployment_targets property to the list of targets. However, this function call returns an error that is swallowed. This means Terraform returns a null list. I haven't yet worked out why this function call returns an error.

@mcasperson
Copy link
Contributor Author

The error that is swallowed is Invalid address to set: []string{"cloud_region_deployment_targets", "0", "endpoint"}

mcasperson added a commit that referenced this issue Dec 5, 2023
Splits tests to ensure they run quickly.
@mcasperson mcasperson self-assigned this Dec 5, 2023
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

No branches or pull requests

1 participant