mirror of
https://github.com/Quiq/docker-registry-ui.git
synced 2025-09-10 01:18:57 +00:00
Major rewrite with just breaking changes
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"os"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
@@ -60,14 +59,18 @@ func ItemInSlice(item string, slice []string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Sprit repo path by namespace and repo name
|
||||
func SplitRepoPath(repoPath string) (string, string) {
|
||||
namespace := "library"
|
||||
repo := repoPath
|
||||
if strings.Contains(repoPath, "/") {
|
||||
f := strings.SplitN(repoPath, "/", 2)
|
||||
namespace = f[0]
|
||||
repo = f[1]
|
||||
// UniqueSortedSlice filter out duplicate items from slice
|
||||
func UniqueSortedSlice(slice []string) []string {
|
||||
sort.Strings(slice)
|
||||
seen := make(map[string]struct{}, len(slice))
|
||||
j := 0
|
||||
for _, i := range slice {
|
||||
if _, ok := seen[i]; ok {
|
||||
continue
|
||||
}
|
||||
seen[i] = struct{}{}
|
||||
slice[j] = i
|
||||
j++
|
||||
}
|
||||
return namespace, repo
|
||||
return slice[:j]
|
||||
}
|
||||
|
Reference in New Issue
Block a user