Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
6dc99b52
Commit
6dc99b52
authored
Oct 01, 2015
by
Chao Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use http.client in ServerAPIVersions
parent
6a4c477a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
6 deletions
+28
-6
helper.go
pkg/client/unversioned/helper.go
+28
-6
No files found.
pkg/client/unversioned/helper.go
View file @
6dc99b52
...
@@ -191,12 +191,29 @@ func extractGroupVersions(l *api.APIGroupList) []string {
...
@@ -191,12 +191,29 @@ func extractGroupVersions(l *api.APIGroupList) []string {
// on the Version, Codec, and Prefix of the config, because it uses AbsPath and
// on the Version, Codec, and Prefix of the config, because it uses AbsPath and
// takes the raw response.
// takes the raw response.
func
ServerAPIVersions
(
c
*
Config
)
(
groupVersions
[]
string
,
err
error
)
{
func
ServerAPIVersions
(
c
*
Config
)
(
groupVersions
[]
string
,
err
error
)
{
client
,
err
:=
RESTClientFor
(
c
)
transport
,
err
:=
TransportFor
(
c
)
if
err
!=
nil
{
return
nil
,
err
}
client
:=
http
.
Client
{
Transport
:
transport
}
configCopy
:=
*
c
configCopy
.
Version
=
""
configCopy
.
Prefix
=
""
baseURL
,
err
:=
defaultServerUrlFor
(
c
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
// Get the groupVersions exposed at /api
// Get the groupVersions exposed at /api
body
,
err
:=
client
.
Get
()
.
AbsPath
(
"api"
)
.
Do
()
.
Raw
()
req
,
err
:=
http
.
NewRequest
(
"GET"
,
baseURL
.
String
()
+
"/api"
,
nil
)
if
err
!=
nil
{
return
nil
,
err
}
resp
,
err
:=
client
.
Do
(
req
)
if
err
!=
nil
{
return
nil
,
err
}
body
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -207,7 +224,15 @@ func ServerAPIVersions(c *Config) (groupVersions []string, err error) {
...
@@ -207,7 +224,15 @@ func ServerAPIVersions(c *Config) (groupVersions []string, err error) {
}
}
groupVersions
=
append
(
groupVersions
,
v
.
Versions
...
)
groupVersions
=
append
(
groupVersions
,
v
.
Versions
...
)
// Get the groupVersions exposed at /apis
// Get the groupVersions exposed at /apis
body
,
err
=
client
.
Get
()
.
AbsPath
(
"apis"
)
.
Do
()
.
Raw
()
req
,
err
=
http
.
NewRequest
(
"GET"
,
baseURL
.
String
()
+
"/apis"
,
nil
)
if
err
!=
nil
{
return
nil
,
err
}
resp
,
err
=
client
.
Do
(
req
)
if
err
!=
nil
{
return
nil
,
err
}
body
,
err
=
ioutil
.
ReadAll
(
resp
.
Body
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -519,9 +544,6 @@ func DefaultServerURL(host, prefix, version string, defaultTLS bool) (*url.URL,
...
@@ -519,9 +544,6 @@ func DefaultServerURL(host, prefix, version string, defaultTLS bool) (*url.URL,
if
host
==
""
{
if
host
==
""
{
return
nil
,
fmt
.
Errorf
(
"host must be a URL or a host:port pair"
)
return
nil
,
fmt
.
Errorf
(
"host must be a URL or a host:port pair"
)
}
}
if
version
==
""
{
return
nil
,
fmt
.
Errorf
(
"version must be set"
)
}
base
:=
host
base
:=
host
hostURL
,
err
:=
url
.
Parse
(
base
)
hostURL
,
err
:=
url
.
Parse
(
base
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment