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
c66250dd
Commit
c66250dd
authored
May 03, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #24548 from pwittrock/kubectl
Automatic merge from submit-queue Delete unused helpers
parents
525515f5
1a3b1330
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
100 deletions
+0
-100
helpers.go
pkg/kubectl/cmd/util/helpers.go
+0
-40
helpers_test.go
pkg/kubectl/cmd/util/helpers_test.go
+0
-60
No files found.
pkg/kubectl/cmd/util/helpers.go
View file @
c66250dd
...
@@ -22,7 +22,6 @@ import (
...
@@ -22,7 +22,6 @@ import (
"fmt"
"fmt"
"io"
"io"
"io/ioutil"
"io/ioutil"
"net/http"
"net/url"
"net/url"
"os"
"os"
"strings"
"strings"
...
@@ -361,45 +360,6 @@ func ReadConfigDataFromReader(reader io.Reader, source string) ([]byte, error) {
...
@@ -361,45 +360,6 @@ func ReadConfigDataFromReader(reader io.Reader, source string) ([]byte, error) {
return
data
,
nil
return
data
,
nil
}
}
// ReadConfigData reads the bytes from the specified filesystem or network
// location or from stdin if location == "-".
// TODO: replace with resource.Builder
func
ReadConfigData
(
location
string
)
([]
byte
,
error
)
{
if
len
(
location
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"location given but empty"
)
}
if
location
==
"-"
{
// Read from stdin.
return
ReadConfigDataFromReader
(
os
.
Stdin
,
"stdin ('-')"
)
}
// Use the location as a file path or URL.
return
ReadConfigDataFromLocation
(
location
)
}
// TODO: replace with resource.Builder
func
ReadConfigDataFromLocation
(
location
string
)
([]
byte
,
error
)
{
// we look for http:// or https:// to determine if valid URL, otherwise do normal file IO
if
strings
.
Index
(
location
,
"http://"
)
==
0
||
strings
.
Index
(
location
,
"https://"
)
==
0
{
resp
,
err
:=
http
.
Get
(
location
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"unable to access URL %s: %v
\n
"
,
location
,
err
)
}
defer
resp
.
Body
.
Close
()
if
resp
.
StatusCode
!=
200
{
return
nil
,
fmt
.
Errorf
(
"unable to read URL, server reported %d %s"
,
resp
.
StatusCode
,
resp
.
Status
)
}
return
ReadConfigDataFromReader
(
resp
.
Body
,
location
)
}
else
{
file
,
err
:=
os
.
Open
(
location
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"unable to read %s: %v
\n
"
,
location
,
err
)
}
return
ReadConfigDataFromReader
(
file
,
location
)
}
}
// Merge requires JSON serialization
// Merge requires JSON serialization
// TODO: merge assumes JSON serialization, and does not properly abstract API retrieval
// TODO: merge assumes JSON serialization, and does not properly abstract API retrieval
func
Merge
(
codec
runtime
.
Codec
,
dst
runtime
.
Object
,
fragment
,
kind
string
)
(
runtime
.
Object
,
error
)
{
func
Merge
(
codec
runtime
.
Codec
,
dst
runtime
.
Object
,
fragment
,
kind
string
)
(
runtime
.
Object
,
error
)
{
...
...
pkg/kubectl/cmd/util/helpers_test.go
View file @
c66250dd
...
@@ -20,7 +20,6 @@ import (
...
@@ -20,7 +20,6 @@ import (
"fmt"
"fmt"
"io/ioutil"
"io/ioutil"
"net/http"
"net/http"
"net/http/httptest"
"reflect"
"reflect"
"strings"
"strings"
"syscall"
"syscall"
...
@@ -212,65 +211,6 @@ func (f *fileHandler) ServeHTTP(res http.ResponseWriter, req *http.Request) {
...
@@ -212,65 +211,6 @@ func (f *fileHandler) ServeHTTP(res http.ResponseWriter, req *http.Request) {
res
.
Write
(
f
.
data
)
res
.
Write
(
f
.
data
)
}
}
func
TestReadConfigData
(
t
*
testing
.
T
)
{
httpData
:=
[]
byte
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
}
// TODO: Close() this server when fix #19254
server
:=
httptest
.
NewServer
(
&
fileHandler
{
data
:
httpData
})
fileData
:=
[]
byte
{
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
,
19
}
f
,
err
:=
ioutil
.
TempFile
(
""
,
"config"
)
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error setting up config file"
)
t
.
Fail
()
}
defer
syscall
.
Unlink
(
f
.
Name
())
ioutil
.
WriteFile
(
f
.
Name
(),
fileData
,
0644
)
// TODO: test TLS here, requires making it possible to inject the HTTP client.
tests
:=
[]
struct
{
config
string
data
[]
byte
expectErr
bool
}{
{
config
:
server
.
URL
,
data
:
httpData
,
},
{
config
:
server
.
URL
+
"/error"
,
expectErr
:
true
,
},
{
config
:
"http://some.non.existent.foobar"
,
expectErr
:
true
,
},
{
config
:
f
.
Name
(),
data
:
fileData
,
},
{
config
:
"some-non-existent-file"
,
expectErr
:
true
,
},
{
config
:
""
,
expectErr
:
true
,
},
}
for
_
,
test
:=
range
tests
{
dataOut
,
err
:=
ReadConfigData
(
test
.
config
)
if
err
!=
nil
&&
!
test
.
expectErr
{
t
.
Errorf
(
"unexpected err: %v for %s"
,
err
,
test
.
config
)
}
if
err
==
nil
&&
test
.
expectErr
{
t
.
Errorf
(
"unexpected non-error for %s"
,
test
.
config
)
}
if
!
test
.
expectErr
&&
!
reflect
.
DeepEqual
(
test
.
data
,
dataOut
)
{
t
.
Errorf
(
"unexpected data: %v, expected %v"
,
dataOut
,
test
.
data
)
}
}
}
func
TestCheckInvalidErr
(
t
*
testing
.
T
)
{
func
TestCheckInvalidErr
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
tests
:=
[]
struct
{
err
error
err
error
...
...
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