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

smart completion in kubernetes to handle [[name = "something"]] for containers, volumes, env vars etc #28

Open
jstrachan opened this issue May 2, 2024 · 1 comment

Comments

@jstrachan
Copy link

jstrachan commented May 2, 2024

I love the pkl intellij plugin and it makes overriding kubernetes yaml structures super easy! There's one thing I'd really love though as a developer UX thing

imagine we are editing this template; its a kubernetes Deployment and the cursor is inside the containers {...} block:

amends "..."

deployment {
  spec {
    template {
      spec {
        containers {
          
        }
      }
    }
  }
}

what I'd love is the top 3 completions to be

  • new (its currently quite far down the list)
  • [...] (for index based override)
  • [[name = "..."]] which if you select the latter gives:
amends "..."

deployment {
  spec {
    template {
      spec {
        containers {
          [[name == "<cursor here>"]]  {
          }
        }
      }
    }
  }
}

FWIW the [[name == "..."]] completion should only appear if the type (in this case PodSpec.Container) has a name property.

I guess this is very kubernetes specific but its very common to want to override things in a Listing<T> by name in kubernetes.

e.g. customising any Deployment / Job / StatefulSet / Pod you usually want to configure a container / env var / volume and they all need to be done using the [[name == "..."]] syntax. Users should need to decide if they want a new or amend an existing item.

BTW it would be totally awesome if the plugin could grok what name values exist already in the parent template then smart completion could let you complete the string value on the right hand side of the "==" expression - so that you can only pick valid names :). Though thats probably much harder to do

@holzensp
Copy link
Contributor

holzensp commented May 2, 2024

This seems a reasonable (doable, sufficiently general) ask. It's not Kubernetes specific at all for member predicates to be part of suggestions inside Listings and Mappings. I think we can generally improve the use of == by using type information there (which we currently don't). It's finicky, though, because types of the operands of == only need to overlap (not be contained).

Evaluating upstream values is very quickly prohibitive perf-wise. We only do very limited evaluation in the plugin, because there's no telling how much time the plugin will need (and it needs to remain responsive).

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

2 participants