Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions lib/rest_openshift.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module OpenShift
extend Helper

def self.populate(path, base_opts, opts)
populate_common("/oapi/<oapi_version>", path, base_opts, opts)
populate_common("/apis/user.openshift.io/<oapi_version>", path, base_opts, opts)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

::populate method is used by all calls. And I believe user.openshift.io is only for the user subsystem and will not work for ::list_projects for example.

I think that we need to drop this openshift/kube api calls separation because now openshift calls are not a separate endpoint, just extensions to kube API. And we can handle all calls in same way.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akostadinov do you mean get ride of lib/rest_openshift.rb and merge it into lib/rest_kubernetes.rb

end

class << self
Expand Down Expand Up @@ -52,11 +52,22 @@ def self.get_project(base_opts, opts)
end

def self.get_user(base_opts, opts)
base_opts_org = base_opts.dup
populate("/users/<username>", base_opts, opts)
return perform(**base_opts, method: "GET") { |res|
res = perform(**base_opts, method: "GET") { |res|
res[:props][:name] = res[:parsed]["metadata"]["name"]
res[:props][:uid] = res[:parsed]["metadata"]["uid"]
}
unless res[:success]
# failed with new url, fall back to old url path
populate_common("/oapi/<oapi_version>", "/users/<username>", base_opts_org, opts)
res = perform(**base_opts_org, method: "GET") { |res|
res[:props][:name] = res[:parsed]["metadata"]["name"]
res[:props][:uid] = res[:parsed]["metadata"]["uid"]
}
end

return res
end

# this usually creates a project in fact
Expand Down