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
b59e49fa
Commit
b59e49fa
authored
Oct 21, 2014
by
Brendan Burns
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for git volumes.
parent
87c77e5b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
294 additions
and
13 deletions
+294
-13
types.go
pkg/api/types.go
+8
-4
types.go
pkg/api/v1beta1/types.go
+10
-0
types.go
pkg/api/v1beta2/types.go
+10
-0
types.go
pkg/api/v1beta3/types.go
+10
-0
exec.go
pkg/util/exec/exec.go
+5
-0
fake_exec.go
pkg/util/exec/fake_exec.go
+92
-0
iptables_test.go
pkg/util/iptables/iptables_test.go
+0
-0
volume.go
pkg/volume/volume.go
+90
-9
volume_test.go
pkg/volume/volume_test.go
+69
-0
No files found.
pkg/api/types.go
View file @
b59e49fa
...
@@ -147,8 +147,8 @@ type VolumeSource struct {
...
@@ -147,8 +147,8 @@ type VolumeSource struct {
// GCEPersistentDisk represents a GCE Disk resource that is attached to a
// GCEPersistentDisk represents a GCE Disk resource that is attached to a
// kubelet's host machine and then exposed to the pod.
// kubelet's host machine and then exposed to the pod.
GCEPersistentDisk
*
GCEPersistentDisk
`json:"persistentDisk" yaml:"persistentDisk"`
GCEPersistentDisk
*
GCEPersistentDisk
`json:"persistentDisk" yaml:"persistentDisk"`
// Git
Volume
represents a git repository at a particular revision.
// Git
Repo
represents a git repository at a particular revision.
Git
Volume
*
GitVolume
`json:"gitVolume" yaml:"gitVolume
"`
Git
Repo
*
GitRepo
`json:"gitRepo" yaml:"gitRepo
"`
}
}
// HostDir represents bare host directory volume.
// HostDir represents bare host directory volume.
...
@@ -189,9 +189,13 @@ type GCEPersistentDisk struct {
...
@@ -189,9 +189,13 @@ type GCEPersistentDisk struct {
ReadOnly
bool
`yaml:"readOnly,omitempty" json:"readOnly,omitempty"`
ReadOnly
bool
`yaml:"readOnly,omitempty" json:"readOnly,omitempty"`
}
}
type
GitVolume
struct
{
// GitRepo represents a volume that is pulled from git when the pod is created.
type
GitRepo
struct
{
// Repository URL
// Repository URL
Repository
string
Repository
string
`yaml:"repository" json:"repository"`
// Commit hash, this is optional
Revision
string
`yaml:"revision" json:"revision"`
// TODO: Consider credentials here.
}
}
// Port represents a network port in a single container
// Port represents a network port in a single container
...
...
pkg/api/v1beta1/types.go
View file @
b59e49fa
...
@@ -93,6 +93,8 @@ type VolumeSource struct {
...
@@ -93,6 +93,8 @@ type VolumeSource struct {
// GCEPersistentDisk represents a GCE Disk resource that is attached to a
// GCEPersistentDisk represents a GCE Disk resource that is attached to a
// kubelet's host machine and then exposed to the pod.
// kubelet's host machine and then exposed to the pod.
GCEPersistentDisk
*
GCEPersistentDisk
`yaml:"persistentDisk" json:"persistentDisk"`
GCEPersistentDisk
*
GCEPersistentDisk
`yaml:"persistentDisk" json:"persistentDisk"`
// GitRepo represents a git repository at a particular revision.
GitRepo
*
GitRepo
`json:"gitRepo" yaml:"gitRepo"`
}
}
// HostDir represents bare host directory volume.
// HostDir represents bare host directory volume.
...
@@ -133,6 +135,14 @@ type GCEPersistentDisk struct {
...
@@ -133,6 +135,14 @@ type GCEPersistentDisk struct {
ReadOnly
bool
`yaml:"readOnly,omitempty" json:"readOnly,omitempty"`
ReadOnly
bool
`yaml:"readOnly,omitempty" json:"readOnly,omitempty"`
}
}
// GitRepo represents a volume that is pulled from git when the pod is created.
type
GitRepo
struct
{
// Repository URL
Repository
string
`yaml:"repository" json:"repository"`
// Commit hash, this is optional
Revision
string
`yaml:"revision" json:"revision"`
}
// Port represents a network port in a single container
// Port represents a network port in a single container
type
Port
struct
{
type
Port
struct
{
// Optional: If specified, this must be a DNS_LABEL. Each named port
// Optional: If specified, this must be a DNS_LABEL. Each named port
...
...
pkg/api/v1beta2/types.go
View file @
b59e49fa
...
@@ -69,6 +69,8 @@ type VolumeSource struct {
...
@@ -69,6 +69,8 @@ type VolumeSource struct {
// A persistent disk that is mounted to the
// A persistent disk that is mounted to the
// kubelet's host machine and then exposed to the pod.
// kubelet's host machine and then exposed to the pod.
GCEPersistentDisk
*
GCEPersistentDisk
`yaml:"persistentDisk" json:"persistentDisk"`
GCEPersistentDisk
*
GCEPersistentDisk
`yaml:"persistentDisk" json:"persistentDisk"`
// GitRepo represents a git repository at a particular revision.
GitRepo
*
GitRepo
`json:"gitRepo" yaml:"gitRepo"`
}
}
// HostDir represents bare host directory volume.
// HostDir represents bare host directory volume.
...
@@ -124,6 +126,14 @@ type GCEPersistentDisk struct {
...
@@ -124,6 +126,14 @@ type GCEPersistentDisk struct {
ReadOnly
bool
`yaml:"readOnly,omitempty" json:"readOnly,omitempty"`
ReadOnly
bool
`yaml:"readOnly,omitempty" json:"readOnly,omitempty"`
}
}
// GitRepo represents a volume that is pulled from git when the pod is created.
type
GitRepo
struct
{
// Repository URL
Repository
string
`yaml:"repository" json:"repository"`
// Commit hash, this is optional
Revision
string
`yaml:"revision" json:"revision"`
}
// VolumeMount describes a mounting of a Volume within a container.
// VolumeMount describes a mounting of a Volume within a container.
type
VolumeMount
struct
{
type
VolumeMount
struct
{
// Required: This must match the Name of a Volume [above].
// Required: This must match the Name of a Volume [above].
...
...
pkg/api/v1beta3/types.go
View file @
b59e49fa
...
@@ -178,6 +178,8 @@ type VolumeSource struct {
...
@@ -178,6 +178,8 @@ type VolumeSource struct {
// GCEPersistentDisk represents a GCE Disk resource that is attached to a
// GCEPersistentDisk represents a GCE Disk resource that is attached to a
// kubelet's host machine and then exposed to the pod.
// kubelet's host machine and then exposed to the pod.
GCEPersistentDisk
*
GCEPersistentDisk
`yaml:"persistentDisk" json:"persistentDisk"`
GCEPersistentDisk
*
GCEPersistentDisk
`yaml:"persistentDisk" json:"persistentDisk"`
// GitRepo represents a git repository at a particular revision.
GitRepo
*
GitRepo
`json:"gitRepo" yaml:"gitRepo"`
}
}
// HostDir represents bare host directory volume.
// HostDir represents bare host directory volume.
...
@@ -218,6 +220,14 @@ type GCEPersistentDisk struct {
...
@@ -218,6 +220,14 @@ type GCEPersistentDisk struct {
ReadOnly
bool
`yaml:"readOnly,omitempty" json:"readOnly,omitempty"`
ReadOnly
bool
`yaml:"readOnly,omitempty" json:"readOnly,omitempty"`
}
}
// GitRepo represents a volume that is pulled from git when the pod is created.
type
GitRepo
struct
{
// Repository URL
Repository
string
`yaml:"repository" json:"repository"`
// Commit hash, this is optional
Revision
string
`yaml:"revision" json:"revision"`
}
// Port represents a network port in a single container.
// Port represents a network port in a single container.
type
Port
struct
{
type
Port
struct
{
// Optional: If specified, this must be a DNS_LABEL. Each named port
// Optional: If specified, this must be a DNS_LABEL. Each named port
...
...
pkg/util/exec/exec.go
View file @
b59e49fa
...
@@ -36,6 +36,7 @@ type Cmd interface {
...
@@ -36,6 +36,7 @@ type Cmd interface {
// CombinedOutput runs the command and returns its combined standard output
// CombinedOutput runs the command and returns its combined standard output
// and standard error. This follows the pattern of package os/exec.
// and standard error. This follows the pattern of package os/exec.
CombinedOutput
()
([]
byte
,
error
)
CombinedOutput
()
([]
byte
,
error
)
SetDir
(
dir
string
)
}
}
// ExitError is an interface that presents an API similar to os.ProcessState, which is
// ExitError is an interface that presents an API similar to os.ProcessState, which is
...
@@ -64,6 +65,10 @@ func (executor *executor) Command(cmd string, args ...string) Cmd {
...
@@ -64,6 +65,10 @@ func (executor *executor) Command(cmd string, args ...string) Cmd {
// Wraps exec.Cmd so we can capture errors.
// Wraps exec.Cmd so we can capture errors.
type
cmdWrapper
osexec
.
Cmd
type
cmdWrapper
osexec
.
Cmd
func
(
cmd
*
cmdWrapper
)
SetDir
(
dir
string
)
{
cmd
.
Dir
=
dir
}
// CombinedOutput is part of the Cmd interface.
// CombinedOutput is part of the Cmd interface.
func
(
cmd
*
cmdWrapper
)
CombinedOutput
()
([]
byte
,
error
)
{
func
(
cmd
*
cmdWrapper
)
CombinedOutput
()
([]
byte
,
error
)
{
out
,
err
:=
(
*
osexec
.
Cmd
)(
cmd
)
.
CombinedOutput
()
out
,
err
:=
(
*
osexec
.
Cmd
)(
cmd
)
.
CombinedOutput
()
...
...
pkg/util/exec/fake_exec.go
0 → 100644
View file @
b59e49fa
/*
Copyright 2014 Google Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
exec
import
(
"fmt"
)
// A simple scripted Interface type.
type
FakeExec
struct
{
CommandScript
[]
FakeCommandAction
CommandCalls
int
}
type
FakeCommandAction
func
(
cmd
string
,
args
...
string
)
Cmd
func
(
fake
*
FakeExec
)
Command
(
cmd
string
,
args
...
string
)
Cmd
{
if
fake
.
CommandCalls
>
len
(
fake
.
CommandScript
)
-
1
{
panic
(
"ran out of Command() actions"
)
}
i
:=
fake
.
CommandCalls
fake
.
CommandCalls
++
return
fake
.
CommandScript
[
i
](
cmd
,
args
...
)
}
// A simple scripted Cmd type.
type
FakeCmd
struct
{
Argv
[]
string
CombinedOutputScript
[]
FakeCombinedOutputAction
CombinedOutputCalls
int
CombinedOutputLog
[][]
string
Dirs
[]
string
}
func
InitFakeCmd
(
fake
*
FakeCmd
,
cmd
string
,
args
...
string
)
Cmd
{
fake
.
Argv
=
append
([]
string
{
cmd
},
args
...
)
return
fake
}
type
FakeCombinedOutputAction
func
()
([]
byte
,
error
)
func
(
fake
*
FakeCmd
)
SetDir
(
dir
string
)
{
fake
.
Dirs
=
append
(
fake
.
Dirs
,
dir
)
}
func
(
fake
*
FakeCmd
)
CombinedOutput
()
([]
byte
,
error
)
{
if
fake
.
CombinedOutputCalls
>
len
(
fake
.
CombinedOutputScript
)
-
1
{
panic
(
"ran out of CombinedOutput() actions"
)
}
if
fake
.
CombinedOutputLog
==
nil
{
fake
.
CombinedOutputLog
=
[][]
string
{}
}
i
:=
fake
.
CombinedOutputCalls
fake
.
CombinedOutputLog
=
append
(
fake
.
CombinedOutputLog
,
append
([]
string
{},
fake
.
Argv
...
))
fake
.
CombinedOutputCalls
++
return
fake
.
CombinedOutputScript
[
i
]()
}
// A simple fake ExitError type.
type
FakeExitError
struct
{
Status
int
}
func
(
fake
*
FakeExitError
)
String
()
string
{
return
fmt
.
Sprintf
(
"exit %d"
,
fake
.
Status
)
}
func
(
fake
*
FakeExitError
)
Error
()
string
{
return
fake
.
String
()
}
func
(
fake
*
FakeExitError
)
Exited
()
bool
{
return
true
}
func
(
fake
*
FakeExitError
)
ExitStatus
()
int
{
return
fake
.
Status
}
pkg/util/iptables/iptables_test.go
View file @
b59e49fa
This diff is collapsed.
Click to expand it.
pkg/volume/volume.go
View file @
b59e49fa
...
@@ -18,12 +18,14 @@ package volume
...
@@ -18,12 +18,14 @@ package volume
import
(
import
(
"errors"
"errors"
"fmt"
"io/ioutil"
"io/ioutil"
"os"
"os"
"path"
"path"
"strconv"
"strconv"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/exec"
"github.com/golang/glog"
"github.com/golang/glog"
)
)
...
@@ -82,6 +84,82 @@ func (hostVol *HostDir) GetPath() string {
...
@@ -82,6 +84,82 @@ func (hostVol *HostDir) GetPath() string {
return
hostVol
.
Path
return
hostVol
.
Path
}
}
type
execInterface
interface
{
ExecCommand
(
cmd
[]
string
,
dir
string
)
([]
byte
,
error
)
}
type
GitDir
struct
{
Source
string
Revision
string
PodID
string
RootDir
string
Name
string
exec
exec
.
Interface
}
func
newGitRepo
(
volume
*
api
.
Volume
,
podID
,
rootDir
string
)
*
GitDir
{
return
&
GitDir
{
Source
:
volume
.
Source
.
GitRepo
.
Repository
,
Revision
:
volume
.
Source
.
GitRepo
.
Revision
,
PodID
:
podID
,
RootDir
:
rootDir
,
Name
:
volume
.
Name
,
exec
:
exec
.
New
(),
}
}
func
(
g
*
GitDir
)
ExecCommand
(
command
string
,
args
[]
string
,
dir
string
)
([]
byte
,
error
)
{
cmd
:=
g
.
exec
.
Command
(
command
,
args
...
)
cmd
.
SetDir
(
dir
)
return
cmd
.
CombinedOutput
()
}
func
(
g
*
GitDir
)
SetUp
()
error
{
volumePath
:=
g
.
GetPath
()
if
err
:=
os
.
MkdirAll
(
volumePath
,
0750
);
err
!=
nil
{
return
err
}
if
_
,
err
:=
g
.
ExecCommand
(
"git"
,
[]
string
{
"clone"
,
g
.
Source
},
g
.
GetPath
());
err
!=
nil
{
return
err
}
files
,
err
:=
ioutil
.
ReadDir
(
g
.
GetPath
())
if
err
!=
nil
{
return
err
}
if
len
(
g
.
Revision
)
==
0
{
return
nil
}
if
len
(
files
)
!=
1
{
return
fmt
.
Errorf
(
"Unexpected directory contents: %v"
,
files
)
}
dir
:=
path
.
Join
(
g
.
GetPath
(),
files
[
0
]
.
Name
())
if
_
,
err
:=
g
.
ExecCommand
(
"git"
,
[]
string
{
"checkout"
,
g
.
Revision
},
dir
);
err
!=
nil
{
return
err
}
if
_
,
err
:=
g
.
ExecCommand
(
"git"
,
[]
string
{
"reset"
,
"--hard"
},
dir
);
err
!=
nil
{
return
err
}
return
nil
}
func
(
g
*
GitDir
)
GetPath
()
string
{
return
path
.
Join
(
g
.
RootDir
,
g
.
PodID
,
"volumes"
,
"git"
,
g
.
Name
)
}
// TearDown simply deletes everything in the directory.
func
(
g
*
GitDir
)
TearDown
()
error
{
tmpDir
,
err
:=
renameDirectory
(
g
.
GetPath
(),
g
.
Name
+
"~deleting"
)
if
err
!=
nil
{
return
err
}
err
=
os
.
RemoveAll
(
tmpDir
)
if
err
!=
nil
{
return
err
}
return
nil
}
// EmptyDir volumes are temporary directories exposed to the pod.
// EmptyDir volumes are temporary directories exposed to the pod.
// These do not persist beyond the lifetime of a pod.
// These do not persist beyond the lifetime of a pod.
type
EmptyDir
struct
{
type
EmptyDir
struct
{
...
@@ -93,20 +171,15 @@ type EmptyDir struct {
...
@@ -93,20 +171,15 @@ type EmptyDir struct {
// SetUp creates new directory.
// SetUp creates new directory.
func
(
emptyDir
*
EmptyDir
)
SetUp
()
error
{
func
(
emptyDir
*
EmptyDir
)
SetUp
()
error
{
path
:=
emptyDir
.
GetPath
()
path
:=
emptyDir
.
GetPath
()
err
:=
os
.
MkdirAll
(
path
,
0750
)
return
os
.
MkdirAll
(
path
,
0750
)
if
err
!=
nil
{
return
err
}
return
nil
}
}
func
(
emptyDir
*
EmptyDir
)
GetPath
()
string
{
func
(
emptyDir
*
EmptyDir
)
GetPath
()
string
{
return
path
.
Join
(
emptyDir
.
RootDir
,
emptyDir
.
PodID
,
"volumes"
,
"empty"
,
emptyDir
.
Name
)
return
path
.
Join
(
emptyDir
.
RootDir
,
emptyDir
.
PodID
,
"volumes"
,
"empty"
,
emptyDir
.
Name
)
}
}
func
(
emptyDir
*
EmptyDir
)
renameDirectory
()
(
string
,
error
)
{
func
renameDirectory
(
oldPath
,
newName
string
)
(
string
,
error
)
{
oldPath
:=
emptyDir
.
GetPath
()
newPath
,
err
:=
ioutil
.
TempDir
(
path
.
Dir
(
oldPath
),
newName
)
newPath
,
err
:=
ioutil
.
TempDir
(
path
.
Dir
(
oldPath
),
emptyDir
.
Name
+
".deleting~"
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
...
@@ -119,7 +192,7 @@ func (emptyDir *EmptyDir) renameDirectory() (string, error) {
...
@@ -119,7 +192,7 @@ func (emptyDir *EmptyDir) renameDirectory() (string, error) {
// TearDown simply deletes everything in the directory.
// TearDown simply deletes everything in the directory.
func
(
emptyDir
*
EmptyDir
)
TearDown
()
error
{
func
(
emptyDir
*
EmptyDir
)
TearDown
()
error
{
tmpDir
,
err
:=
emptyDir
.
renameDirectory
(
)
tmpDir
,
err
:=
renameDirectory
(
emptyDir
.
GetPath
(),
emptyDir
.
Name
+
".deleting~"
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -279,6 +352,8 @@ func CreateVolumeBuilder(volume *api.Volume, podID string, rootDir string) (Buil
...
@@ -279,6 +352,8 @@ func CreateVolumeBuilder(volume *api.Volume, podID string, rootDir string) (Buil
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
}
else
if
source
.
GitRepo
!=
nil
{
vol
=
newGitRepo
(
volume
,
podID
,
rootDir
)
}
else
{
}
else
{
return
nil
,
ErrUnsupportedVolumeType
return
nil
,
ErrUnsupportedVolumeType
}
}
...
@@ -297,6 +372,12 @@ func CreateVolumeCleaner(kind string, name string, podID string, rootDir string)
...
@@ -297,6 +372,12 @@ func CreateVolumeCleaner(kind string, name string, podID string, rootDir string)
RootDir
:
rootDir
,
RootDir
:
rootDir
,
util
:
&
GCEDiskUtil
{},
util
:
&
GCEDiskUtil
{},
mounter
:
&
DiskMounter
{}},
nil
mounter
:
&
DiskMounter
{}},
nil
case
"git"
:
return
&
GitDir
{
Name
:
name
,
PodID
:
podID
,
RootDir
:
rootDir
,
},
nil
default
:
default
:
return
nil
,
ErrUnsupportedVolumeType
return
nil
,
ErrUnsupportedVolumeType
}
}
...
...
pkg/volume/volume_test.go
View file @
b59e49fa
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"testing"
"testing"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/exec"
)
)
type
MockDiskUtil
struct
{}
type
MockDiskUtil
struct
{}
...
@@ -224,3 +225,71 @@ func TestGetActiveVolumes(t *testing.T) {
...
@@ -224,3 +225,71 @@ func TestGetActiveVolumes(t *testing.T) {
}
}
}
}
}
}
type
fakeExec
struct
{
cmds
[][]
string
dirs
[]
string
data
[]
byte
err
error
action
func
([]
string
,
string
)
}
func
(
f
*
fakeExec
)
ExecCommand
(
cmd
[]
string
,
dir
string
)
([]
byte
,
error
)
{
f
.
cmds
=
append
(
f
.
cmds
,
cmd
)
f
.
dirs
=
append
(
f
.
dirs
,
dir
)
f
.
action
(
cmd
,
dir
)
return
f
.
data
,
f
.
err
}
func
TestGitVolume
(
t
*
testing
.
T
)
{
var
fcmd
exec
.
FakeCmd
fcmd
=
exec
.
FakeCmd
{
CombinedOutputScript
:
[]
exec
.
FakeCombinedOutputAction
{
func
()
([]
byte
,
error
)
{
os
.
MkdirAll
(
path
.
Join
(
fcmd
.
Dirs
[
0
],
"kubernetes"
),
0750
)
return
[]
byte
{},
nil
},
func
()
([]
byte
,
error
)
{
return
[]
byte
{},
nil
},
func
()
([]
byte
,
error
)
{
return
[]
byte
{},
nil
},
},
}
fake
:=
exec
.
FakeExec
{
CommandScript
:
[]
exec
.
FakeCommandAction
{
func
(
cmd
string
,
args
...
string
)
exec
.
Cmd
{
return
exec
.
InitFakeCmd
(
&
fcmd
,
cmd
,
args
...
)
},
func
(
cmd
string
,
args
...
string
)
exec
.
Cmd
{
return
exec
.
InitFakeCmd
(
&
fcmd
,
cmd
,
args
...
)
},
func
(
cmd
string
,
args
...
string
)
exec
.
Cmd
{
return
exec
.
InitFakeCmd
(
&
fcmd
,
cmd
,
args
...
)
},
},
}
dir
:=
os
.
TempDir
()
+
"/git"
g
:=
GitDir
{
Source
:
"https://github.com/GoogleCloudPlatform/kubernetes.git"
,
Revision
:
"2a30ce65c5ab586b98916d83385c5983edd353a1"
,
PodID
:
"foo"
,
RootDir
:
dir
,
Name
:
"test-pod"
,
exec
:
&
fake
,
}
err
:=
g
.
SetUp
()
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
expectedCmds
:=
[][]
string
{
{
"git"
,
"clone"
,
g
.
Source
},
{
"git"
,
"checkout"
,
g
.
Revision
},
{
"git"
,
"reset"
,
"--hard"
},
}
if
fake
.
CommandCalls
!=
len
(
expectedCmds
)
{
t
.
Errorf
(
"unexpected command calls: expected 3, saw: %d"
,
fake
.
CommandCalls
)
}
if
!
reflect
.
DeepEqual
(
expectedCmds
,
fcmd
.
CombinedOutputLog
)
{
t
.
Errorf
(
"unexpected commands: %v, expected: %v"
,
fcmd
.
CombinedOutputLog
,
expectedCmds
)
}
expectedDirs
:=
[]
string
{
g
.
GetPath
(),
g
.
GetPath
()
+
"/kubernetes"
,
g
.
GetPath
()
+
"/kubernetes"
}
if
len
(
fcmd
.
Dirs
)
!=
3
||
!
reflect
.
DeepEqual
(
expectedDirs
,
fcmd
.
Dirs
)
{
t
.
Errorf
(
"unexpected directories: %v, expected: %v"
,
fcmd
.
Dirs
,
expectedDirs
)
}
err
=
g
.
TearDown
()
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
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