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
434058c6
Commit
434058c6
authored
Apr 01, 2016
by
Michelle Noorali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(repo): validate repo url format
parent
62c1bb38
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
inmem_repo_service.go
pkg/repo/inmem_repo_service.go
+6
-0
inmem_repo_service_test.go
pkg/repo/inmem_repo_service_test.go
+14
-1
No files found.
pkg/repo/inmem_repo_service.go
View file @
434058c6
...
@@ -17,6 +17,7 @@ limitations under the License.
...
@@ -17,6 +17,7 @@ limitations under the License.
package
repo
package
repo
import
(
import
(
"errors"
"fmt"
"fmt"
"strings"
"strings"
"sync"
"sync"
...
@@ -62,6 +63,11 @@ func (rs *inmemRepoService) CreateRepo(repository IRepo) error {
...
@@ -62,6 +63,11 @@ func (rs *inmemRepoService) CreateRepo(repository IRepo) error {
URL
:=
repository
.
GetURL
()
URL
:=
repository
.
GetURL
()
name
:=
repository
.
GetName
()
name
:=
repository
.
GetName
()
valid
:=
GCSRepoURLMatcher
.
MatchString
(
URL
)
if
!
valid
{
return
errors
.
New
(
URL
+
" is an invalid Repo URL"
)
}
for
u
,
r
:=
range
rs
.
repositories
{
for
u
,
r
:=
range
rs
.
repositories
{
if
u
==
URL
{
if
u
==
URL
{
return
fmt
.
Errorf
(
"Repository with URL %s already exists"
,
URL
)
return
fmt
.
Errorf
(
"Repository with URL %s already exists"
,
URL
)
...
...
pkg/repo/inmem_repo_service_test.go
View file @
434058c6
...
@@ -85,6 +85,19 @@ func TestCreateRepoWithDuplicateURL(t *testing.T) {
...
@@ -85,6 +85,19 @@ func TestCreateRepoWithDuplicateURL(t *testing.T) {
}
}
}
}
func
TestCreateRepoWithInvalidURL
(
t
*
testing
.
T
)
{
rs
:=
NewInmemRepoService
()
invalidURL
:=
"fake://sfds"
r
,
err
:=
newRepo
(
invalidURL
,
""
,
TestName
,
GCSRepoFormat
,
GCSRepoType
)
if
err
!=
nil
{
t
.
Fatalf
(
"cannot create test repo: %v"
,
err
)
}
if
err
=
rs
.
CreateRepo
(
r
);
err
==
nil
{
t
.
Fatalf
(
"created repo with invalid URL: %s"
,
invalidURL
)
}
}
func
TestGetRepoWithInvalidURL
(
t
*
testing
.
T
)
{
func
TestGetRepoWithInvalidURL
(
t
*
testing
.
T
)
{
invalidURL
:=
"https://not.a.valid/url"
invalidURL
:=
"https://not.a.valid/url"
rs
:=
NewInmemRepoService
()
rs
:=
NewInmemRepoService
()
...
@@ -96,7 +109,7 @@ func TestGetRepoWithInvalidURL(t *testing.T) {
...
@@ -96,7 +109,7 @@ func TestGetRepoWithInvalidURL(t *testing.T) {
func
TestGetRepoURLByName
(
t
*
testing
.
T
)
{
func
TestGetRepoURLByName
(
t
*
testing
.
T
)
{
rs
:=
NewInmemRepoService
()
rs
:=
NewInmemRepoService
()
testURL
:=
"g
c
s://helm-test-charts"
testURL
:=
"gs://helm-test-charts"
r
,
err
:=
newRepo
(
testURL
,
""
,
TestName
,
GCSRepoFormat
,
GCSRepoType
)
r
,
err
:=
newRepo
(
testURL
,
""
,
TestName
,
GCSRepoFormat
,
GCSRepoType
)
err
=
rs
.
CreateRepo
(
r
)
err
=
rs
.
CreateRepo
(
r
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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