Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Incorrectly prepends io.k8s.api to resources where apiVersion has a single '.' in name #135

Closed
gozer opened this issue Dec 3, 2020 · 2 comments · Fixed by #151
Closed
Labels
bug Something isn't working needs-investigation
Milestone

Comments

@gozer
Copy link

gozer commented Dec 3, 2020

Terraform Version and Provider Version

Terraform v0.13.5

  • provider registry.terraform.io/hashicorp/kubernetes-alpha v0.2.1

Kubernetes Version

Server Version: version.Info{Major:"1", Minor:"18+", GitVersion:"v1.18.9-eks-d1db3c", GitCommit:"d1db3c46e55f95d6a7d3e5578689371318f95ff9", GitTreeState:"clean", BuildDate:"2020-10-20T22:18:07Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}

Affected Resource(s)

  • kubernetes_manifest

Terraform Configuration Files

resource "kubernetes_manifest" "crd-broken" {
  manifest = {
    apiVersion = "kci.rocks/v1alpha1"
    kind       = "DbInstance"

    metadata = {
      name = "test"
    }
    [...]
}

resource "kubernetes_manifest" "crd-working" {
  manifest = {
    apiVersion = "foo.kci.rocks/v1alpha1"
    kind       = "DbInstance"

    metadata = {
      name = "test"
    }
    [...]
}

Expected Behavior

Terraform should be able to plan and apply the resource

Actual Behavior

Error: rpc error: code = Unknown desc = failed to get resource type from OpenAPI (ID io.k8s.api.kci.v1alpha1.DbInstance): invalid type identifier

It seems that when dealing with an apiVersion that has a single '.' in the domain component, Terraform incorrectly prepends io.k8s.api and strips away the last part of the domain.

When the apiVersion is, for instance, foo.kci.rocks/v1alpha1 the issue dissapears

Steps to Reproduce

  1. terraform plan

Important Factoids

References

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
@gozer gozer added the bug Something isn't working label Dec 3, 2020
@aareet aareet added this to the v0.3.0 milestone Feb 17, 2021
@mrjackdavis
Copy link

FWIW, I've observed incorrect prepend for an api version with multiple . in it.

resource "kubernetes_manifest" "target_group_binding" {
  provider = kubernetes-alpha

  for_each = { for k, v in
    # redacted
  }

  manifest = {
    "apiVersion" = "elbv2.k8s.aws/v1beta1"
    "kind"       = "TargetGroupBinding"
    "metadata" = {
      # redacted
    }
    "spec" = {
      # redacted
    }
  }

  lifecycle {
    create_before_destroy = true
  }
}

Resulting error

rpc error: code = Unknown desc = failed to get resource type from OpenAPI (ID io.k8s.api.elbv2.v1beta1.TargetGroupBinding): invalid type identifier

@ghost
Copy link

ghost commented Apr 8, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Apr 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working needs-investigation
Projects
None yet
3 participants