Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
775010f5
Commit
775010f5
authored
Mar 29, 2016
by
Jack Greenfield
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #467 from jackgr/repo-search
Fix repo prefix searchbug
parents
edb6187e
20c1ed3f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
22 deletions
+23
-22
inmem_repo_service.go
pkg/repo/inmem_repo_service.go
+17
-1
inmem_repo_service_test.go
pkg/repo/inmem_repo_service_test.go
+1
-1
repoprovider.go
pkg/repo/repoprovider.go
+4
-19
repoprovider_test.go
pkg/repo/repoprovider_test.go
+1
-1
No files found.
pkg/repo/inmem_repo_service.go
View file @
775010f5
...
...
@@ -92,10 +92,12 @@ func (rs *inmemRepoService) GetRepoByChartURL(URL string) (IRepo, error) {
rs
.
RLock
()
defer
rs
.
RUnlock
()
cSplit
:=
strings
.
Split
(
URL
,
"/"
)
var
found
IRepo
for
_
,
r
:=
range
rs
.
repositories
{
rURL
:=
r
.
GetURL
()
if
strings
.
HasPrefix
(
URL
,
rURL
)
{
rSplit
:=
strings
.
Split
(
rURL
,
"/"
)
if
hasPrefix
(
cSplit
,
rSplit
)
{
if
found
==
nil
||
len
(
found
.
GetURL
())
<
len
(
rURL
)
{
found
=
r
}
...
...
@@ -109,6 +111,20 @@ func (rs *inmemRepoService) GetRepoByChartURL(URL string) (IRepo, error) {
return
found
,
nil
}
func
hasPrefix
(
cSplit
,
rSplit
[]
string
)
bool
{
if
len
(
rSplit
)
>
len
(
cSplit
)
{
return
false
}
for
i
:=
range
rSplit
{
if
rSplit
[
i
]
!=
cSplit
[
i
]
{
return
false
}
}
return
true
}
// DeleteRepo removes a known repository from the list
func
(
rs
*
inmemRepoService
)
DeleteRepo
(
URL
string
)
error
{
rs
.
Lock
()
...
...
pkg/repo/inmem_repo_service_test.go
View file @
775010f5
...
...
@@ -54,7 +54,7 @@ func TestService(t *testing.T) {
t
.
Fatalf
(
"invalid repo returned; want: %#v, have %#v."
,
tr
,
r1
)
}
URL
:=
GCSPublicRepoURL
+
TestArchiveName
URL
:=
GCSPublicRepoURL
+
"/"
+
TestArchiveName
r2
,
err
:=
rs
.
GetRepoByChartURL
(
URL
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
...
...
pkg/repo/repoprovider.go
View file @
775010f5
...
...
@@ -25,7 +25,6 @@ import (
"fmt"
"log"
"net/http"
"strings"
"sync"
)
...
...
@@ -117,35 +116,21 @@ func (rp *repoProvider) createRepo(cr IChartRepo) (IChartRepo, error) {
return
cr
,
nil
}
// GetRepoByChartURL returns the repository
whose URL is a prefix of the given
URL.
// GetRepoByChartURL returns the repository
that backs a given chart
URL.
func
(
rp
*
repoProvider
)
GetRepoByChartURL
(
URL
string
)
(
IChartRepo
,
error
)
{
rp
.
Lock
()
defer
rp
.
Unlock
()
if
r
:=
rp
.
findRepoByChartURL
(
URL
);
r
!=
nil
{
return
r
,
nil
}
cr
,
err
:=
rp
.
rs
.
GetRepoByChartURL
(
URL
)
if
err
!=
nil
{
return
nil
,
err
}
return
rp
.
createRepoByType
(
cr
)
}
func
(
rp
*
repoProvider
)
findRepoByChartURL
(
URL
string
)
IChartRepo
{
var
found
IChartRepo
for
_
,
r
:=
range
rp
.
repos
{
rURL
:=
r
.
GetURL
()
if
strings
.
HasPrefix
(
URL
,
rURL
)
{
if
found
==
nil
||
len
(
found
.
GetURL
())
<
len
(
rURL
)
{
found
=
r
}
}
if
r
,
ok
:=
rp
.
repos
[
cr
.
GetURL
()];
ok
{
return
r
,
nil
}
return
found
return
rp
.
createRepoByType
(
cr
)
}
// GetChartByReference maps the supplied chart reference into a fully qualified
...
...
pkg/repo/repoprovider_test.go
View file @
775010f5
...
...
@@ -62,7 +62,7 @@ func TestRepoProvider(t *testing.T) {
}
wantRepo
:=
haveRepo
URL
:=
GCSPublicRepoURL
+
TestArchiveName
URL
:=
GCSPublicRepoURL
+
"/"
+
TestArchiveName
haveRepo
,
err
=
rp
.
GetRepoByChartURL
(
URL
)
if
err
!=
nil
{
t
.
Fatal
(
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