Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

sg/msp: fix CustomTargetType reference in Target definition#62727

Merged
jac merged 1 commit into
mainfrom
jac/cd-target-fix
May 16, 2024
Merged

sg/msp: fix CustomTargetType reference in Target definition#62727
jac merged 1 commit into
mainfrom
jac/cd-target-fix

Conversation

@jac

@jac jac commented May 16, 2024

Copy link
Copy Markdown
Member

Changes the identifier used by targets to reference the custom target type they belong to. Previously this used targetType.Name() but should have been targetType.Id().
Fixes the following error encountered by repoferee

failed to validate custom target "projects/1058156036563/locations/us-central1/targets/prod-us-central1": failed to parse custom target type name referenced by target "projects/1058156036563/locations/us-central1/targets/prod-us-central1": invalid 3 name: invalid argument

docs:
Target:

custom_target_type - (Required) Required. The name of the CustomTargetType. Format must be projects/{project}/locations/{location}/customTargetTypes/{custom_target_type}.

Custom Target Type:

id - an identifier for the resource with format projects/{{project}}/locations/{{location}}/customTargetTypes/{{name}}

Test plan

inspection of terraform plan

# google_clouddeploy_target.cloudrun-rolloutpipeline-pipeline-target_stage-prod-us-central1 will be updated in-place
  ~ resource "google_clouddeploy_target" "cloudrun-rolloutpipeline-pipeline-target_stage-prod-us-central1" {
        id                    = "projects/repoferee-prod-5317/locations/us-central1/targets/prod-us-central1"
        name                  = "prod-us-central1"
        # (14 unchanged attributes hidden)

      ~ custom_target {
          ~ custom_target_type = "cloud-run-service" -> "projects/repoferee-prod-5317/locations/us-central1/customTargetTypes/cloud-run-service"
        }

        # (1 unchanged block hidden)
    }

@jac jac requested review from a team and burmudar May 16, 2024 12:26
@cla-bot cla-bot Bot added the cla-signed label May 16, 2024
@jac jac merged commit d140495 into main May 16, 2024
@jac jac deleted the jac/cd-target-fix branch May 16, 2024 12:32
@bobheadxi

Copy link
Copy Markdown
Member

Ah good catch, curious why this didn't show up elsewhere 🤔 Thanks for the fix!

@jac

jac commented May 20, 2024

Copy link
Copy Markdown
Member Author

Ah good catch, curious why this didn't show up elsewhere 🤔 Thanks for the fix!

Possibly because they were imported 🤔
Also even though terraform says it can do an in-place update of custom_target.custom_target_type it doesn't actually do anything even with a "successful" apply so it was only possible for this to break newly created targets

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants