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

dealing with api/v1 vs apis/extensions/v1beta1 is annoying since they are split between url and version #284

Open
grosser opened this issue Jan 10, 2018 · 3 comments

Comments

@grosser
Copy link
Contributor

grosser commented Jan 10, 2018

url should be everything without the /api ... and version should be either api/v1 or maybe just v1 / extensions/v1beta1 and then smartly detect if it should be api or apis

atm I'm using this which is kinda wonky

  def client(version)
    (@client ||= {})[version] ||= begin
      path, version_number = version.scan(/(.*)\/(\S+)$/).first
      Kubeclient::Client.new(
        "#{@url}/#{path}",
        version_number,
        auth_options: (testing? ? {} : { bearer_token_file: BEARER_TOKEN_FILE }),
        ssl_options: (testing? ? {} : { ca_file: CA_FILE }),
        timeouts: {open: 2, read: 10}
      )
    end
  end
@cben
Copy link
Collaborator

cben commented Jan 11, 2018

Right! Here's our similar code, also spliting on /:
https://github.com/ManageIQ/manageiq-providers-openshift/blob/93009fcb167/app/models/manageiq/providers/openshift/container_manager_mixin.rb#L40-L52

  1. Any idea if this can be backward compatible?
  2. Does this interact with Allow different resources to use different apiVersion #208? I this would be a first step to make multi-version use by multiple Client instances a tiny bit less annoying, and doesn't affect/depend on ideas for multi-version with one instance...

@grosser
Copy link
Contributor Author

grosser commented Jan 11, 2018 via email

@cben
Copy link
Collaborator

cben commented Sep 18, 2020

For anyone tackling this: the tests added in #457 are a good starting point.
We should still support everything these tests cover, for compatibility.

However, if it makes things easier, can have new keyword params for new behavior, supporting only one scheme.
Something like

Kubeclient::Client.new(
  # Exactly what you get from `config.context(...).api_endpoint`.
  # No /api, /apis, /oapi allowed.
  endpoint: "http://example.com/k8s/clusters/c-somerancherID",  

  # Exactly the `apiVersion` in the JSON representation for resources you want to access.
  # (One should NOT pass here `config.context.api_version` which is version of kubeconfg file, 
  #  see commit c593c9eef58e56f00c396f4715437eed673ca98e).
  # Would `group:` can be a clearer name then `api_version:`?
  api_version: "autoscaling/v1",

  ssl_options: config.context.ssl_options,
  auth_options: config.context.auth_options
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants