Commit b8633391 authored by odatskov's avatar odatskov
Browse files

Backup

parent fcb89e8e
Pipeline #459431 failed with stage
in 43 seconds
......@@ -22,33 +22,36 @@ import (
//"net/http"
)
//----------- Global constants ----------------//
// Global constants for available registries
const docker = "docker.registry.io"
const gitlab = "gitlab-registry.cern.ch"
type Repo struct {
url string // Clean url path without registry
registry string // Registry path for API calls
url string // Clean repository path
registry string // Registry path for API access
target string // CVMFS target path
}
//--- Repo struct constructor -----------------//
func makeRepo(path string) Repo {
var url []string
func makeRepo(path string, file string) Repo {
var url string
var registry string
if strings.HasPrefix(path, "docker://") {
registry = docker
url = strings.Split(path, "//")
} else if strings.HasPrefix(path, "docker.io") {
registry = docker
url = strings.Split(path, ".io/")
} else if strings.HasPrefix(path, "gitlab-registry.cern.ch") {
registry = gitlab
url = strings.Split(path, ".cern.ch/")
} else {
prefix := strings.Split(path,"/")
log.Printf("This is a prefix: %s",prefix)
switch prefix[0] {
case "docker:":
registry = docker ; url = strings.TrimLeft(path,"docker://")
case "docker.io":
registry = docker; url = strings.TrimLeft(path,"docker.io/")
case gitlab:
registry = gitlab ; url = strings.TrimLeft(path,gitlab)
default:
log.Printf("Unknown repository specified: %s", path)
}
return Repo{url[1], registry}
log.Printf("URL: %s, Registry: %s, File: %s",url)
return Repo{url, registry, file}
}
//--- Retrieve file line containing a field ----//
......@@ -67,7 +70,7 @@ func getField(field string, path string) string {
}
log.Printf("Field %s not found in: %s", field, path)
}
return "none"
return "na"
}
//--- Return list of repositories --------//
......@@ -79,7 +82,7 @@ func getRepoList(root string, args *[]string, repos *[]Repo) {
filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if !info.IsDir() && strings.HasSuffix(path, ".yaml") {
*repos = append(*repos, makeRepo(getField("url:", path)))
*repos = append(*repos, makeRepo(getField("url:", path),path))
}
return nil
})
......@@ -97,7 +100,7 @@ func getRepoList(root string, args *[]string, repos *[]Repo) {
err_files = append(err_files, file)
}
} else {
*repos = append(*repos, makeRepo(getField("url:", file)))
*repos = append(*repos, makeRepo(getField("url:", file),file))
}
}
if len(err_files) > 0 {
......@@ -106,9 +109,11 @@ func getRepoList(root string, args *[]string, repos *[]Repo) {
}
}
//func getManifest(repo string) {
// log.Printf("Checking out repository: %s",repo)
//}
func getManifest(repo Repo) {
log.Printf("Checking out repository: %s",repo)
// Perform a GET request to the repository
// Find diffs
}
//----------------------------------------//
func main() {
......@@ -121,7 +126,7 @@ func main() {
// For each file:
// Get the manifest and check for changes
//getManifest(repos[0])
getManifest(repos[0])
// Fetch the layers
// Unpack the structure
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment