Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sync
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
unpacked
sync
Commits
555576db
There was a problem fetching the pipeline summary.
Commit
555576db
authored
6 years ago
by
odatskov
Browse files
Options
Downloads
Patches
Plain Diff
Adding file input function (with test)
parent
a32266e8
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitlab-ci.yml
+1
-1
1 addition, 1 deletion
.gitlab-ci.yml
sync.go
+43
-4
43 additions, 4 deletions
sync.go
sync_test.go
+22
-2
22 additions, 2 deletions
sync_test.go
with
66 additions
and
7 deletions
.gitlab-ci.yml
+
1
−
1
View file @
555576db
...
...
@@ -9,6 +9,6 @@ sync_test:
image
:
golang:latest
script
:
-
go version
-
go test
-
go test
-v
environment
:
name
:
test
This diff is collapsed.
Click to expand it.
sync.go
+
43
−
4
View file @
555576db
package
main
import
(
//"fmt"
"log"
"os"
"path/filepath"
"strings"
)
func
print_me
()
string
{
return
"We are running this"
func
getFileList
(
root
string
,
args
[]
string
)
[]
string
{
if
len
(
args
)
==
0
{
var
files
[]
string
// Recusively walk through the root path, creating list of files with *.yaml
filepath
.
Walk
(
root
,
func
(
path
string
,
info
os
.
FileInfo
,
err
error
)
error
{
if
!
info
.
IsDir
()
&&
strings
.
HasSuffix
(
path
,
".yaml"
)
{
files
=
append
(
files
,
path
)
}
return
nil
})
if
len
(
files
)
==
0
{
log
.
Fatalf
(
"No files found"
)
}
return
files
}
else
{
var
err_files
[]
string
// Check if files passed through arguments actually exist
for
_
,
file
:=
range
args
{
_
,
err
:=
os
.
Stat
(
file
)
if
err
!=
nil
{
if
os
.
IsNotExist
(
err
)
{
err_files
=
append
(
err_files
,
file
)
}
}
}
if
len
(
err_files
)
>
0
{
log
.
Fatalf
(
"File(s) not found: %s"
,
err_files
)
}
return
args
}
}
func
main
()
{
log
.
Printf
(
print_me
())
file_list
:=
getFileList
(
"."
,
os
.
Args
[
1
:
])
log
.
Printf
(
strings
.
Join
(
file_list
,
" "
))
// Check that the token still is valid
// For each file:
// Get the manifest and check for changes
// Fetch the layers
// Unpack the structure
// Adjust permissions on the files
// When done, merge changes to cvmfs
}
This diff is collapsed.
Click to expand it.
sync_test.go
+
22
−
2
View file @
555576db
...
...
@@ -2,8 +2,28 @@ package main
import
(
"testing"
//"log"
//"os/exec"
//"strings"
//"math/rand"
)
func
printme_test
(
t
*
testing
.
T
)
{
t
.
Error
(
print_me
())
func
Test_getFileList_FilesExists
(
t
*
testing
.
T
)
{
//cmd := strings.Split("find . -name *.yaml"," ")
//test_cmd, _ := exec.Command(cmd[0],cmd[1:]...).Output()
//test_str := strings.Split(string(test_cmd),"\n")
//log.Printf(len(test_str))
var
input_path
[]
string
input_path
=
append
(
input_path
,
"IT-Batch/cc7-gitlab.yaml"
)
out_test
:=
getFileList
(
"."
,
input_path
)
if
len
(
out_test
)
!=
1
{
t
.
Errorf
(
"For"
,
input_path
,
"expected size of 1"
,
"got"
,
len
(
out_test
))}
if
out_test
[
0
]
!=
input_path
[
0
]
{
t
.
Errorf
(
"For"
,
input_path
,
"received"
,
out_test
)}
//var err_path []string
//err_path = append(err_path,"IT-Batch/cc7-gitlab.yamlz")
//if len(out_test) != 1 {t.Errorf("For",input_path,"expected size of 1","got",len(out_test))}
//if out_test[0] != input_path[0] {t.Errorf("For",input_path,"received",out_test)}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment