Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
gitlab-runner
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Andrew Greenwood
gitlab-runner
Commits
133b7113
Commit
133b7113
authored
Jul 18, 2019
by
Simon Jürgensmeyer
Committed by
Steve Azzopardi
Jul 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some linting issues
parent
215227b4
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
70 additions
and
35 deletions
+70
-35
cache/adapter_test.go
cache/adapter_test.go
+2
-1
cache/s3/bucket_location_tripper.go
cache/s3/bucket_location_tripper.go
+4
-1
commands/helpers/cache_archiver_test.go
commands/helpers/cache_archiver_test.go
+3
-1
commands/helpers/cache_extractor.go
commands/helpers/cache_extractor.go
+9
-3
commands/helpers/cache_extractor_test.go
commands/helpers/cache_extractor_test.go
+6
-2
commands/multi_test.go
commands/multi_test.go
+6
-5
commands/register.go
commands/register.go
+4
-1
common/config.go
common/config.go
+4
-1
common/shell.go
common/shell.go
+1
-3
executors/docker/executor_docker_test.go
executors/docker/executor_docker_test.go
+2
-1
executors/docker/machine/provider_test.go
executors/docker/machine/provider_test.go
+5
-2
executors/kubernetes/exec_test.go
executors/kubernetes/exec_test.go
+3
-3
helpers/archives/gzip_create_test.go
helpers/archives/gzip_create_test.go
+3
-1
helpers/archives/zip_create.go
helpers/archives/zip_create.go
+4
-1
helpers/archives/zip_extra_unix.go
helpers/archives/zip_extra_unix.go
+1
-1
helpers/archives/zip_extract.go
helpers/archives/zip_extract.go
+5
-2
helpers/archives/zip_extract_test.go
helpers/archives/zip_extract_test.go
+4
-2
helpers/certificate/x509_test.go
helpers/certificate/x509_test.go
+1
-0
helpers/docker/helperimage/info_test.go
helpers/docker/helperimage/info_test.go
+2
-3
shells/cmd.go
shells/cmd.go
+1
-1
No files found.
cache/adapter_test.go
View file @
133b7113
...
...
@@ -70,7 +70,8 @@ func TestCreateAdapter(t *testing.T) {
adapterTypeName
:=
"test"
if
test
.
adapter
!=
nil
{
factories
.
Register
(
adapterTypeName
,
makeTestFactory
(
test
))
err
:=
factories
.
Register
(
adapterTypeName
,
makeTestFactory
(
test
))
assert
.
NoError
(
t
,
err
)
}
factories
.
Register
(
"additional-adapter"
,
func
(
config
*
common
.
CacheConfig
,
timeout
time
.
Duration
,
objectName
string
)
(
Adapter
,
error
)
{
...
...
cache/s3/bucket_location_tripper.go
View file @
133b7113
...
...
@@ -19,7 +19,10 @@ type bucketLocationTripper struct {
// the library.
func
(
b
*
bucketLocationTripper
)
RoundTrip
(
req
*
http
.
Request
)
(
res
*
http
.
Response
,
err
error
)
{
var
buffer
bytes
.
Buffer
xml
.
NewEncoder
(
&
buffer
)
.
Encode
(
b
.
bucketLocation
)
err
=
xml
.
NewEncoder
(
&
buffer
)
.
Encode
(
b
.
bucketLocation
)
if
err
!=
nil
{
return
}
res
=
&
http
.
Response
{
StatusCode
:
http
.
StatusOK
,
Body
:
ioutil
.
NopCloser
(
&
buffer
),
...
...
commands/helpers/cache_archiver_test.go
View file @
133b7113
...
...
@@ -39,7 +39,9 @@ func TestCacheArchiverIsUpToDate(t *testing.T) {
// We need to wait one second, since the FS doesn't save milliseconds
time
.
Sleep
(
time
.
Second
)
os
.
Chtimes
(
cacheArchiverTestArchivedFile
,
time
.
Now
(),
time
.
Now
())
err
:=
os
.
Chtimes
(
cacheArchiverTestArchivedFile
,
time
.
Now
(),
time
.
Now
())
assert
.
NoError
(
t
,
err
)
cmd
.
Execute
(
nil
)
fi3
,
_
:=
os
.
Stat
(
cacheArchiverArchive
)
assert
.
NotEqual
(
t
,
fi
.
ModTime
(),
fi3
.
ModTime
(),
"archive should get updated"
)
...
...
commands/helpers/cache_extractor.go
View file @
133b7113
...
...
@@ -13,7 +13,7 @@ import (
"gitlab.com/gitlab-org/gitlab-runner/common"
"gitlab.com/gitlab-org/gitlab-runner/helpers/archives"
"gitlab.com/gitlab-org/gitlab-runner/helpers/url"
url_helpers
"gitlab.com/gitlab-org/gitlab-runner/helpers/url"
"gitlab.com/gitlab-org/gitlab-runner/log"
)
...
...
@@ -41,7 +41,10 @@ func checkIfUpToDate(path string, resp *http.Response) (bool, time.Time) {
}
func
(
c
*
CacheExtractorCommand
)
download
()
error
{
os
.
MkdirAll
(
filepath
.
Dir
(
c
.
File
),
0700
)
err
:=
os
.
MkdirAll
(
filepath
.
Dir
(
c
.
File
),
0700
)
if
err
!=
nil
{
return
err
}
resp
,
err
:=
c
.
getCache
()
if
err
!=
nil
{
...
...
@@ -68,7 +71,10 @@ func (c *CacheExtractorCommand) download() error {
if
err
!=
nil
{
return
retryableErr
{
err
:
err
}
}
os
.
Chtimes
(
file
.
Name
(),
time
.
Now
(),
date
)
err
=
os
.
Chtimes
(
file
.
Name
(),
time
.
Now
(),
date
)
if
err
!=
nil
{
return
err
}
err
=
file
.
Close
()
if
err
!=
nil
{
...
...
commands/helpers/cache_extractor_test.go
View file @
133b7113
...
...
@@ -26,7 +26,9 @@ func TestCacheExtractorValidArchive(t *testing.T) {
defer
os
.
Remove
(
cacheExtractorTestArchivedFile
)
archive
:=
zip
.
NewWriter
(
file
)
archive
.
Create
(
cacheExtractorTestArchivedFile
)
_
,
err
=
archive
.
Create
(
cacheExtractorTestArchivedFile
)
assert
.
NoError
(
t
,
err
)
archive
.
Close
()
_
,
err
=
os
.
Stat
(
cacheExtractorTestArchivedFile
)
...
...
@@ -163,7 +165,9 @@ func TestCacheExtractorRemoteServer(t *testing.T) {
_
,
err
:=
os
.
Stat
(
cacheExtractorTestArchivedFile
)
assert
.
NoError
(
t
,
err
)
os
.
Chtimes
(
cacheExtractorArchive
,
time
.
Now
()
.
Add
(
time
.
Hour
),
time
.
Now
()
.
Add
(
time
.
Hour
))
err
=
os
.
Chtimes
(
cacheExtractorArchive
,
time
.
Now
()
.
Add
(
time
.
Hour
),
time
.
Now
()
.
Add
(
time
.
Hour
))
assert
.
NoError
(
t
,
err
)
assert
.
NotPanics
(
t
,
func
()
{
cmd
.
Execute
(
nil
)
},
"archive is up to date"
)
...
...
commands/multi_test.go
View file @
133b7113
...
...
@@ -87,14 +87,15 @@ func TestProcessRunner_BuildLimit(t *testing.T) {
runners
:=
make
(
chan
*
common
.
RunnerConfig
)
// Start
5
builds.
// Start
2
builds.
wg
:=
sync
.
WaitGroup
{}
wg
.
Add
(
5
)
for
i
:=
0
;
i
<
5
;
i
++
{
wg
.
Add
(
2
)
for
i
:=
0
;
i
<
2
;
i
++
{
go
func
(
i
int
)
{
defer
wg
.
Done
()
cmd
.
processRunner
(
i
,
&
cfg
,
runners
)
err
:=
cmd
.
processRunner
(
i
,
&
cfg
,
runners
)
assert
.
NoError
(
t
,
err
)
}(
i
)
}
...
...
@@ -103,7 +104,7 @@ func TestProcessRunner_BuildLimit(t *testing.T) {
time
.
Sleep
(
10
*
time
.
Millisecond
)
}
err
:=
cmd
.
processRunner
(
6
,
&
cfg
,
runners
)
err
:=
cmd
.
processRunner
(
3
,
&
cfg
,
runners
)
assert
.
EqualError
(
t
,
err
,
"failed to request job, runner limit met"
)
// Wait for all builds to finish.
...
...
commands/register.go
View file @
133b7113
...
...
@@ -332,7 +332,10 @@ func (s *RegisterCommand) Execute(context *cli.Context) {
s
.
askExecutor
()
s
.
askExecutorOptions
()
s
.
addRunner
(
&
s
.
RunnerConfig
)
s
.
saveConfig
()
err
=
s
.
saveConfig
()
if
err
!=
nil
{
logrus
.
Panicln
(
err
)
}
logrus
.
Printf
(
"Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!"
)
}
...
...
common/config.go
View file @
133b7113
...
...
@@ -671,7 +671,10 @@ func (c *Config) SaveConfig(configFile string) error {
}
// create directory to store configuration
os
.
MkdirAll
(
filepath
.
Dir
(
configFile
),
0700
)
err
:=
os
.
MkdirAll
(
filepath
.
Dir
(
configFile
),
0700
)
if
err
!=
nil
{
return
err
}
// write config file
if
err
:=
ioutil
.
WriteFile
(
configFile
,
newConfig
.
Bytes
(),
0600
);
err
!=
nil
{
...
...
common/shell.go
View file @
133b7113
...
...
@@ -26,9 +26,7 @@ const (
func
(
s
*
ShellConfiguration
)
GetCommandWithArguments
()
[]
string
{
parts
:=
[]
string
{
s
.
Command
}
for
_
,
arg
:=
range
s
.
Arguments
{
parts
=
append
(
parts
,
arg
)
}
parts
=
append
(
parts
,
s
.
Arguments
...
)
return
parts
}
...
...
executors/docker/executor_docker_test.go
View file @
133b7113
...
...
@@ -1123,7 +1123,8 @@ func getAuthConfigTestExecutor(t *testing.T, precreateConfigFile bool) executor
if
precreateConfigFile
{
dockerConfigFile
:=
path
.
Join
(
tempHomeDir
,
".dockercfg"
)
ioutil
.
WriteFile
(
dockerConfigFile
,
[]
byte
(
testFileAuthConfigs
),
0600
)
err
=
ioutil
.
WriteFile
(
dockerConfigFile
,
[]
byte
(
testFileAuthConfigs
),
0600
)
require
.
NoError
(
t
,
err
)
docker_helpers
.
HomeDirectory
=
tempHomeDir
}
else
{
docker_helpers
.
HomeDirectory
=
""
...
...
executors/docker/machine/provider_test.go
View file @
133b7113
...
...
@@ -10,7 +10,7 @@ import (
"github.com/stretchr/testify/assert"
"gitlab.com/gitlab-org/gitlab-runner/common"
"gitlab.com/gitlab-org/gitlab-runner/helpers/docker"
docker_helpers
"gitlab.com/gitlab-org/gitlab-runner/helpers/docker"
)
var
machineDefaultConfig
=
&
common
.
RunnerConfig
{
...
...
@@ -315,7 +315,8 @@ func TestMachineCreationAndRemoval(t *testing.T) {
assert
.
NoError
(
t
,
<-
errCh
)
assert
.
Equal
(
t
,
machineStateUsed
,
d3
.
State
)
p
.
remove
(
d
.
Name
)
err
:=
p
.
remove
(
d
.
Name
)
assert
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
machineStateRemoving
,
d
.
State
)
}
...
...
@@ -435,11 +436,13 @@ func TestMachineLimitMax(t *testing.T) {
config
.
Limit
=
8
d
,
err
=
p
.
Acquire
(
config
)
assert
.
NoError
(
t
,
err
)
p
.
Release
(
config
,
d
)
assertIdleMachines
(
t
,
p
,
8
,
"it should upscale to 8 nodes"
)
config
.
Limit
=
2
d
,
err
=
p
.
Acquire
(
config
)
assert
.
NoError
(
t
,
err
)
p
.
Release
(
config
,
d
)
assertIdleMachines
(
t
,
p
,
2
,
"it should downscale to 2 nodes"
)
}
...
...
executors/kubernetes/exec_test.go
View file @
133b7113
...
...
@@ -45,9 +45,9 @@ func (f *fakeRemoteExecutor) Execute(method string, url *url.URL, config *restcl
func
TestExec
(
t
*
testing
.
T
)
{
version
,
codec
:=
testVersionAndCodec
()
tests
:=
[]
struct
{
name
,
version
,
podPath
,
execPath
,
container
string
pod
*
api
.
Pod
tty
,
execErr
bool
name
,
version
,
podPath
,
execPath
string
pod
*
api
.
Pod
tty
,
execErr
bool
}{
{
name
:
"pod exec"
,
...
...
helpers/archives/gzip_create_test.go
View file @
133b7113
...
...
@@ -47,7 +47,8 @@ func TestGzipArchiveOfMultipleFiles(t *testing.T) {
defer
file
.
Close
()
defer
os
.
Remove
(
file
.
Name
())
file
.
Write
(
testZipFileContent
)
_
,
err
=
file
.
Write
(
testZipFileContent
)
require
.
NoError
(
t
,
err
)
file
.
Close
()
var
buffer
bytes
.
Buffer
...
...
@@ -105,6 +106,7 @@ func TestGzipArchivesExistingAndNonExistingFile(t *testing.T) {
var
buffer
bytes
.
Buffer
err
=
CreateGzipArchive
(
&
buffer
,
[]
string
{
filePath
,
"non-existing-file"
})
require
.
NoError
(
t
,
err
)
// we have only one stream
testGzipStreams
(
t
,
&
buffer
,
[][]
byte
{
testGzipFileContent
})
...
...
helpers/archives/zip_create.go
View file @
133b7113
...
...
@@ -104,7 +104,10 @@ func CreateZipArchive(w io.Writer, fileNames []string) error {
func
CreateZipFile
(
fileName
string
,
fileNames
[]
string
)
error
{
// create directories to store archive
os
.
MkdirAll
(
filepath
.
Dir
(
fileName
),
0700
)
err
:=
os
.
MkdirAll
(
filepath
.
Dir
(
fileName
),
0700
)
if
err
!=
nil
{
return
err
}
tempFile
,
err
:=
ioutil
.
TempFile
(
filepath
.
Dir
(
fileName
),
"archive_"
)
if
err
!=
nil
{
...
...
helpers/archives/zip_extra_unix.go
View file @
133b7113
...
...
@@ -31,7 +31,7 @@ func createZipUIDGidField(w io.Writer, fi os.FileInfo) (err error) {
if
err
==
nil
{
err
=
binary
.
Write
(
w
,
binary
.
LittleEndian
,
&
ugField
)
}
return
nil
return
err
}
func
processZipUIDGidField
(
data
[]
byte
,
file
*
zip
.
FileHeader
)
error
{
...
...
helpers/archives/zip_extract.go
View file @
133b7113
...
...
@@ -61,7 +61,10 @@ func extractZipFileEntry(file *zip.File) (err error) {
func
extractZipFile
(
file
*
zip
.
File
)
(
err
error
)
{
// Create all parents to extract the file
os
.
MkdirAll
(
filepath
.
Dir
(
file
.
Name
),
0777
)
err
=
os
.
MkdirAll
(
filepath
.
Dir
(
file
.
Name
),
0777
)
if
err
!=
nil
{
return
err
}
switch
file
.
Mode
()
&
os
.
ModeType
{
case
os
.
ModeDir
:
...
...
@@ -72,7 +75,7 @@ func extractZipFile(file *zip.File) (err error) {
case
os
.
ModeNamedPipe
,
os
.
ModeSocket
,
os
.
ModeDevice
:
// Ignore the files that of these types
logrus
.
Warning
ln
(
"File ignored: %q"
,
file
.
Name
)
logrus
.
Warning
f
(
"File ignored: %q"
,
file
.
Name
)
default
:
err
=
extractZipFileEntry
(
file
)
...
...
helpers/archives/zip_extract_test.go
View file @
133b7113
...
...
@@ -16,13 +16,15 @@ import (
func
createDefaultArchive
(
t
*
testing
.
T
,
archive
*
zip
.
Writer
)
{
testFile
,
err
:=
archive
.
Create
(
"temporary_file.txt"
)
require
.
NoError
(
t
,
err
)
io
.
WriteString
(
testFile
,
"test file"
)
_
,
err
=
io
.
WriteString
(
testFile
,
"test file"
)
require
.
NoError
(
t
,
err
)
}
func
createArchiveWithGitPath
(
t
*
testing
.
T
,
archive
*
zip
.
Writer
)
{
testGitFile
,
err
:=
archive
.
Create
(
".git/test_file"
)
require
.
NoError
(
t
,
err
)
io
.
WriteString
(
testGitFile
,
"test git file"
)
_
,
err
=
io
.
WriteString
(
testGitFile
,
"test git file"
)
require
.
NoError
(
t
,
err
)
}
func
testOnArchive
(
t
*
testing
.
T
,
createArchive
func
(
t
*
testing
.
T
,
archive
*
zip
.
Writer
),
testCase
func
(
t
*
testing
.
T
,
fileName
string
))
{
...
...
helpers/certificate/x509_test.go
View file @
133b7113
...
...
@@ -17,6 +17,7 @@ func TestCertificate(t *testing.T) {
gen
:=
X509Generator
{}
cert
,
pem
,
err
:=
gen
.
Generate
(
"127.0.0.1"
)
require
.
NoError
(
t
,
err
)
tlsConfig
:=
tls
.
Config
{
Certificates
:
[]
tls
.
Certificate
{
cert
},
...
...
helpers/docker/helperimage/info_test.go
View file @
133b7113
...
...
@@ -10,9 +10,8 @@ import (
func
TestGetInfo
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
osType
string
expectedHelperImageType
interface
{}
expectedError
interface
{}
osType
string
expectedError
error
}{
{
osType
:
OSTypeLinux
,
expectedError
:
nil
},
{
osType
:
OSTypeWindows
,
expectedError
:
ErrUnsupportedOSVersion
},
...
...
shells/cmd.go
View file @
133b7113
...
...
@@ -152,7 +152,7 @@ func (b *CmdWriter) IfCmd(cmd string, arguments ...string) {
func
(
b
*
CmdWriter
)
IfCmdWithOutput
(
cmd
string
,
arguments
...
string
)
{
cmdline
:=
b
.
buildCommand
(
cmd
,
arguments
...
)
b
.
Line
(
fmt
.
Sprintf
(
"%s"
,
cmdline
)
)
b
.
Line
(
cmdline
)
errCheck
:=
"IF !errorlevel! EQU 0 ("
b
.
Line
(
b
.
updateErrLevelCheck
(
errCheck
))
b
.
Indent
()
...
...
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