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
b2570ef1
Commit
b2570ef1
authored
Mar 22, 2016
by
jackgr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Repo struct public
parent
09ebdd36
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
97 additions
and
97 deletions
+97
-97
filebased_credential_provider.go
pkg/repo/filebased_credential_provider.go
+2
-2
filebased_credential_provider_test.go
pkg/repo/filebased_credential_provider_test.go
+1
-1
gcs_repo.go
pkg/repo/gcs_repo.go
+14
-14
gcs_repo_test.go
pkg/repo/gcs_repo_test.go
+1
-1
inmem_credential_provider.go
pkg/repo/inmem_credential_provider.go
+1
-1
inmem_credential_provider_test.go
pkg/repo/inmem_credential_provider_test.go
+2
-2
inmem_repo_service.go
pkg/repo/inmem_repo_service.go
+9
-9
repo.go
pkg/repo/repo.go
+15
-24
repoprovider.go
pkg/repo/repoprovider.go
+22
-22
repoprovider_test.go
pkg/repo/repoprovider_test.go
+2
-2
secrets_credential_provider.go
pkg/repo/secrets_credential_provider.go
+1
-1
types.go
pkg/repo/types.go
+27
-18
No files found.
pkg/repo/filebased_credential_provider.go
View file @
b2570ef1
...
...
@@ -27,7 +27,7 @@ import (
// FilebasedCredentialProvider provides credentials for registries.
type
FilebasedCredentialProvider
struct
{
// Actual backing store
backingCredentialProvider
CredentialProvider
backingCredentialProvider
I
CredentialProvider
}
// NamedRepoCredential associates a name with a RepoCredential.
...
...
@@ -37,7 +37,7 @@ type NamedRepoCredential struct {
}
// NewFilebasedCredentialProvider creates a file based credential provider.
func
NewFilebasedCredentialProvider
(
filename
string
)
(
CredentialProvider
,
error
)
{
func
NewFilebasedCredentialProvider
(
filename
string
)
(
I
CredentialProvider
,
error
)
{
icp
:=
NewInmemCredentialProvider
()
log
.
Printf
(
"Using credentials file %s"
,
filename
)
c
,
err
:=
readCredentialsFile
(
filename
)
...
...
pkg/repo/filebased_credential_provider_test.go
View file @
b2570ef1
...
...
@@ -47,7 +47,7 @@ func TestSetAndGetBasicAuthFilebased(t *testing.T) {
testGetCredential
(
t
,
cp
,
tc
)
}
func
getProvider
(
t
*
testing
.
T
)
CredentialProvider
{
func
getProvider
(
t
*
testing
.
T
)
I
CredentialProvider
{
cp
,
err
:=
NewFilebasedCredentialProvider
(
filename
)
if
err
!=
nil
{
t
.
Fatalf
(
"cannot create a new provider from file %s: %s"
,
filename
,
err
)
...
...
pkg/repo/gcs_repo.go
View file @
b2570ef1
...
...
@@ -53,21 +53,21 @@ const (
GCSPublicRepoBucket
=
GCSPublicRepoName
)
//
gcsRepo implements the Object
StorageRepo interface for Google Cloud Storage.
type
gcs
Repo
struct
{
r
epo
//
GCSRepo implements the I
StorageRepo interface for Google Cloud Storage.
type
GCS
Repo
struct
{
R
epo
bucket
string
httpClient
*
http
.
Client
service
*
storage
.
Service
}
// NewPublicGCSRepo creates a new an
Object
StorageRepo for the public GCS repository.
func
NewPublicGCSRepo
(
httpClient
*
http
.
Client
)
(
Object
StorageRepo
,
error
)
{
// NewPublicGCSRepo creates a new an
I
StorageRepo for the public GCS repository.
func
NewPublicGCSRepo
(
httpClient
*
http
.
Client
)
(
I
StorageRepo
,
error
)
{
return
NewGCSRepo
(
GCSPublicRepoName
,
GCSPublicRepoURL
,
""
,
nil
)
}
// NewGCSRepo creates a new
Object
StorageRepo for a given GCS repository.
func
NewGCSRepo
(
name
,
URL
,
credentialName
string
,
httpClient
*
http
.
Client
)
(
Object
StorageRepo
,
error
)
{
// NewGCSRepo creates a new
I
StorageRepo for a given GCS repository.
func
NewGCSRepo
(
name
,
URL
,
credentialName
string
,
httpClient
*
http
.
Client
)
(
I
StorageRepo
,
error
)
{
r
,
err
:=
newRepo
(
name
,
URL
,
credentialName
,
GCSRepoFormat
,
GCSRepoType
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -76,7 +76,7 @@ func NewGCSRepo(name, URL, credentialName string, httpClient *http.Client) (Obje
return
newGCSRepo
(
r
,
httpClient
)
}
func
newGCSRepo
(
r
*
repo
,
httpClient
*
http
.
Client
)
(
*
gcs
Repo
,
error
)
{
func
newGCSRepo
(
r
*
Repo
,
httpClient
*
http
.
Client
)
(
*
GCS
Repo
,
error
)
{
URL
:=
r
.
GetURL
()
m
:=
GCSRepoURLMatcher
.
FindStringSubmatch
(
URL
)
if
len
(
m
)
!=
2
{
...
...
@@ -96,8 +96,8 @@ func newGCSRepo(r *repo, httpClient *http.Client) (*gcsRepo, error) {
return
nil
,
fmt
.
Errorf
(
"cannot create storage service for %s: %s"
,
URL
,
err
)
}
gcsr
:=
&
gcs
Repo
{
r
epo
:
*
r
,
gcsr
:=
&
GCS
Repo
{
R
epo
:
*
r
,
httpClient
:
httpClient
,
service
:
gcs
,
bucket
:
m
[
1
],
...
...
@@ -117,7 +117,7 @@ func validateRepoType(repoType RepoType) error {
// ListCharts lists charts in this chart repository whose string values conform to the
// supplied regular expression, or all charts, if the regular expression is nil.
func
(
g
*
gcs
Repo
)
ListCharts
(
regex
*
regexp
.
Regexp
)
([]
string
,
error
)
{
func
(
g
*
GCS
Repo
)
ListCharts
(
regex
*
regexp
.
Regexp
)
([]
string
,
error
)
{
charts
:=
[]
string
{}
// List all objects in a bucket using pagination
...
...
@@ -155,7 +155,7 @@ func (g *gcsRepo) ListCharts(regex *regexp.Regexp) ([]string, error) {
}
// GetChart retrieves, unpacks and returns a chart by name.
func
(
g
*
gcs
Repo
)
GetChart
(
name
string
)
(
*
chart
.
Chart
,
error
)
{
func
(
g
*
GCS
Repo
)
GetChart
(
name
string
)
(
*
chart
.
Chart
,
error
)
{
// Charts should be named bucket/chart-X.Y.Z.tgz, so check that the name matches
if
!
ChartNameMatcher
.
MatchString
(
name
)
{
return
nil
,
fmt
.
Errorf
(
"name must be of the form <name>-<version>.tgz, was %s"
,
name
)
...
...
@@ -184,11 +184,11 @@ func (g *gcsRepo) GetChart(name string) (*chart.Chart, error) {
}
// GetBucket returns the repository bucket.
func
(
g
*
gcs
Repo
)
GetBucket
()
string
{
func
(
g
*
GCS
Repo
)
GetBucket
()
string
{
return
g
.
bucket
}
// Do performs an HTTP operation on the receiver's httpClient.
func
(
g
*
gcs
Repo
)
Do
(
req
*
http
.
Request
)
(
resp
*
http
.
Response
,
err
error
)
{
func
(
g
*
GCS
Repo
)
Do
(
req
*
http
.
Request
)
(
resp
*
http
.
Response
,
err
error
)
{
return
g
.
httpClient
.
Do
(
req
)
}
pkg/repo/gcs_repo_test.go
View file @
b2570ef1
...
...
@@ -125,7 +125,7 @@ func TestGetChartWithInvalidName(t *testing.T) {
}
}
func
getTestRepo
(
t
*
testing
.
T
)
Object
StorageRepo
{
func
getTestRepo
(
t
*
testing
.
T
)
I
StorageRepo
{
tr
,
err
:=
NewGCSRepo
(
TestRepoName
,
TestRepoURL
,
TestRepoCredentialName
,
nil
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
...
...
pkg/repo/inmem_credential_provider.go
View file @
b2570ef1
...
...
@@ -28,7 +28,7 @@ type InmemCredentialProvider struct {
}
// NewInmemCredentialProvider creates a new memory based credential provider.
func
NewInmemCredentialProvider
()
CredentialProvider
{
func
NewInmemCredentialProvider
()
I
CredentialProvider
{
return
&
InmemCredentialProvider
{
credentials
:
make
(
map
[
string
]
*
RepoCredential
)}
}
...
...
pkg/repo/inmem_credential_provider_test.go
View file @
b2570ef1
...
...
@@ -32,7 +32,7 @@ func createMissingError(name string) error {
return
fmt
.
Errorf
(
"no such credential: %s"
,
name
)
}
func
testGetCredential
(
t
*
testing
.
T
,
cp
CredentialProvider
,
tc
*
testCase
)
{
func
testGetCredential
(
t
*
testing
.
T
,
cp
I
CredentialProvider
,
tc
*
testCase
)
{
actual
,
actualErr
:=
cp
.
GetCredential
(
tc
.
name
)
if
!
reflect
.
DeepEqual
(
actual
,
tc
.
exp
)
{
t
.
Fatalf
(
"test case %s failed: want: %#v, have: %#v"
,
tc
.
name
,
tc
.
exp
,
actual
)
...
...
@@ -43,7 +43,7 @@ func testGetCredential(t *testing.T, cp CredentialProvider, tc *testCase) {
}
}
func
verifySetAndGetCredential
(
t
*
testing
.
T
,
cp
CredentialProvider
,
tc
*
testCase
)
{
func
verifySetAndGetCredential
(
t
*
testing
.
T
,
cp
I
CredentialProvider
,
tc
*
testCase
)
{
err
:=
cp
.
SetCredential
(
tc
.
name
,
tc
.
exp
)
if
err
!=
nil
{
t
.
Fatalf
(
"test case %s failed: cannot set credential: %v"
,
tc
.
name
,
err
)
...
...
pkg/repo/inmem_repo_service.go
View file @
b2570ef1
...
...
@@ -24,13 +24,13 @@ import (
type
inmemRepoService
struct
{
sync
.
RWMutex
repositories
map
[
string
]
Repo
repositories
map
[
string
]
I
Repo
}
// NewInmemRepoService returns a new memory based repository service.
func
NewInmemRepoService
()
Service
{
func
NewInmemRepoService
()
IRepo
Service
{
rs
:=
&
inmemRepoService
{
repositories
:
make
(
map
[
string
]
Repo
),
repositories
:
make
(
map
[
string
]
I
Repo
),
}
r
,
err
:=
NewPublicGCSRepo
(
nil
)
...
...
@@ -42,11 +42,11 @@ func NewInmemRepoService() Service {
}
// List returns the list of all known chart repositories
func
(
rs
*
inmemRepoService
)
List
()
([]
Repo
,
error
)
{
func
(
rs
*
inmemRepoService
)
List
()
([]
I
Repo
,
error
)
{
rs
.
RLock
()
defer
rs
.
RUnlock
()
ret
:=
[]
Repo
{}
ret
:=
[]
I
Repo
{}
for
_
,
r
:=
range
rs
.
repositories
{
ret
=
append
(
ret
,
r
)
}
...
...
@@ -55,7 +55,7 @@ func (rs *inmemRepoService) List() ([]Repo, error) {
}
// Create adds a known repository to the list
func
(
rs
*
inmemRepoService
)
Create
(
repository
Repo
)
error
{
func
(
rs
*
inmemRepoService
)
Create
(
repository
I
Repo
)
error
{
rs
.
Lock
()
defer
rs
.
Unlock
()
...
...
@@ -70,7 +70,7 @@ func (rs *inmemRepoService) Create(repository Repo) error {
}
// Get returns the repository with the given name
func
(
rs
*
inmemRepoService
)
Get
(
name
string
)
(
Repo
,
error
)
{
func
(
rs
*
inmemRepoService
)
Get
(
name
string
)
(
I
Repo
,
error
)
{
rs
.
RLock
()
defer
rs
.
RUnlock
()
...
...
@@ -83,11 +83,11 @@ func (rs *inmemRepoService) Get(name string) (Repo, error) {
}
// GetByURL returns the repository that backs the given URL
func
(
rs
*
inmemRepoService
)
GetByURL
(
URL
string
)
(
Repo
,
error
)
{
func
(
rs
*
inmemRepoService
)
GetByURL
(
URL
string
)
(
I
Repo
,
error
)
{
rs
.
RLock
()
defer
rs
.
RUnlock
()
var
found
Repo
var
found
I
Repo
for
_
,
r
:=
range
rs
.
repositories
{
rURL
:=
r
.
GetURL
()
if
strings
.
HasPrefix
(
URL
,
rURL
)
{
...
...
pkg/repo/repo.go
View file @
b2570ef1
...
...
@@ -21,21 +21,12 @@ import (
"net/url"
)
// repo describes a repository
type
repo
struct
{
Name
string
`json:"name"`
// Friendly name for this repository
URL
string
`json:"url"`
// URL to the root of this repository
CredentialName
string
`json:"credentialname"`
// Credential name used to access this repository
Format
RepoFormat
`json:"format"`
// Format of this repository
Type
RepoType
`json:"type"`
// Technology implementing this repository
}
// NewRepo takes params and returns a Repo
func
NewRepo
(
name
,
URL
,
credentialName
,
repoFormat
,
repoType
string
)
(
Repo
,
error
)
{
// NewRepo takes params and returns a IRepo
func
NewRepo
(
name
,
URL
,
credentialName
,
repoFormat
,
repoType
string
)
(
IRepo
,
error
)
{
return
newRepo
(
name
,
URL
,
credentialName
,
RepoFormat
(
repoFormat
),
RepoType
(
repoType
))
}
func
newRepo
(
name
,
URL
,
credentialName
string
,
repoFormat
RepoFormat
,
repoType
RepoType
)
(
*
r
epo
,
error
)
{
func
newRepo
(
name
,
URL
,
credentialName
string
,
repoFormat
RepoFormat
,
repoType
RepoType
)
(
*
R
epo
,
error
)
{
if
name
==
""
{
return
nil
,
fmt
.
Errorf
(
"name must not be empty"
)
}
...
...
@@ -53,7 +44,7 @@ func newRepo(name, URL, credentialName string, repoFormat RepoFormat, repoType R
return
nil
,
err
}
r
:=
&
r
epo
{
r
:=
&
R
epo
{
Name
:
name
,
Type
:
repoType
,
URL
:
URL
,
...
...
@@ -75,39 +66,39 @@ func validateRepoFormat(repoFormat RepoFormat) error {
}
// GetName returns the friendly name of this repository.
func
(
r
*
r
epo
)
GetName
()
string
{
func
(
r
*
R
epo
)
GetName
()
string
{
return
r
.
Name
}
// GetType returns the technology implementing this repository.
func
(
r
*
r
epo
)
GetType
()
RepoType
{
func
(
r
*
R
epo
)
GetType
()
RepoType
{
return
r
.
Type
}
// GetURL returns the URL to the root of this repository.
func
(
r
*
r
epo
)
GetURL
()
string
{
func
(
r
*
R
epo
)
GetURL
()
string
{
return
r
.
URL
}
// GetFormat returns the format of this repository.
func
(
r
*
r
epo
)
GetFormat
()
RepoFormat
{
func
(
r
*
R
epo
)
GetFormat
()
RepoFormat
{
return
r
.
Format
}
// GetCredentialName returns the credential name used to access this repository.
func
(
r
*
r
epo
)
GetCredentialName
()
string
{
func
(
r
*
R
epo
)
GetCredentialName
()
string
{
return
r
.
CredentialName
}
func
validateRepo
(
tr
Repo
,
wantName
,
wantURL
,
wantCredentialName
string
,
wantFormat
RepoFormat
,
wantType
RepoType
)
error
{
func
validateRepo
(
tr
I
Repo
,
wantName
,
wantURL
,
wantCredentialName
string
,
wantFormat
RepoFormat
,
wantType
RepoType
)
error
{
haveName
:=
tr
.
GetName
()
if
haveName
!=
wantName
{
return
fmt
.
Errorf
(
"unexpected repo name; want: %s, have %s"
,
wantName
,
haveName
)
return
fmt
.
Errorf
(
"unexpected repo
sitory
name; want: %s, have %s"
,
wantName
,
haveName
)
}
haveURL
:=
tr
.
GetURL
()
if
haveURL
!=
wantURL
{
return
fmt
.
Errorf
(
"unexpected repo url; want: %s, have %s"
,
wantURL
,
haveURL
)
return
fmt
.
Errorf
(
"unexpected repo
sitory
url; want: %s, have %s"
,
wantURL
,
haveURL
)
}
haveCredentialName
:=
tr
.
GetCredentialName
()
...
...
@@ -116,17 +107,17 @@ func validateRepo(tr Repo, wantName, wantURL, wantCredentialName string, wantFor
}
if
haveCredentialName
!=
wantCredentialName
{
return
fmt
.
Errorf
(
"unexpected repo credential name; want: %s, have %s"
,
wantCredentialName
,
haveCredentialName
)
return
fmt
.
Errorf
(
"unexpected repo
sitory
credential name; want: %s, have %s"
,
wantCredentialName
,
haveCredentialName
)
}
haveFormat
:=
tr
.
GetFormat
()
if
haveFormat
!=
wantFormat
{
return
fmt
.
Errorf
(
"unexpected repo format; want: %s, have %s"
,
wantFormat
,
haveFormat
)
return
fmt
.
Errorf
(
"unexpected repo
sitory
format; want: %s, have %s"
,
wantFormat
,
haveFormat
)
}
haveType
:=
tr
.
GetType
()
if
haveType
!=
wantType
{
return
fmt
.
Errorf
(
"unexpected repo type; want: %s, have %s"
,
wantType
,
haveType
)
return
fmt
.
Errorf
(
"unexpected repo
sitory
type; want: %s, have %s"
,
wantType
,
haveType
)
}
return
nil
...
...
pkg/repo/repoprovider.go
View file @
b2570ef1
...
...
@@ -29,28 +29,28 @@ import (
"sync"
)
// RepoProvider is a factory for ChartRepo instances.
// RepoProvider is a factory for
I
ChartRepo instances.
type
RepoProvider
interface
{
GetRepoByURL
(
URL
string
)
(
ChartRepo
,
error
)
GetRepoByName
(
repoName
string
)
(
ChartRepo
,
error
)
GetRepoByURL
(
URL
string
)
(
I
ChartRepo
,
error
)
GetRepoByName
(
repoName
string
)
(
I
ChartRepo
,
error
)
GetChartByReference
(
reference
string
)
(
*
chart
.
Chart
,
error
)
}
type
repoProvider
struct
{
sync
.
RWMutex
rs
Service
cp
CredentialProvider
rs
IRepo
Service
cp
I
CredentialProvider
gcsrp
GCSRepoProvider
repos
map
[
string
]
ChartRepo
repos
map
[
string
]
I
ChartRepo
}
// NewRepoProvider creates a new repository provider.
func
NewRepoProvider
(
rs
Service
,
gcsrp
GCSRepoProvider
,
cp
CredentialProvider
)
RepoProvider
{
func
NewRepoProvider
(
rs
IRepoService
,
gcsrp
GCSRepoProvider
,
cp
I
CredentialProvider
)
RepoProvider
{
return
newRepoProvider
(
rs
,
gcsrp
,
cp
)
}
// newRepoProvider creates a new repository provider.
func
newRepoProvider
(
rs
Service
,
gcsrp
GCSRepoProvider
,
cp
CredentialProvider
)
*
repoProvider
{
func
newRepoProvider
(
rs
IRepoService
,
gcsrp
GCSRepoProvider
,
cp
I
CredentialProvider
)
*
repoProvider
{
if
rs
==
nil
{
rs
=
NewInmemRepoService
()
}
...
...
@@ -63,18 +63,18 @@ func newRepoProvider(rs Service, gcsrp GCSRepoProvider, cp CredentialProvider) *
gcsrp
=
NewGCSRepoProvider
(
cp
)
}
repos
:=
make
(
map
[
string
]
ChartRepo
)
repos
:=
make
(
map
[
string
]
I
ChartRepo
)
rp
:=
&
repoProvider
{
rs
:
rs
,
gcsrp
:
gcsrp
,
cp
:
cp
,
repos
:
repos
}
return
rp
}
// GetRepoService returns the repository service used by this repository provider.
func
(
rp
*
repoProvider
)
GetRepoService
()
Service
{
func
(
rp
*
repoProvider
)
GetRepoService
()
IRepo
Service
{
return
rp
.
rs
}
// GetCredentialProvider returns the credential provider used by this repository provider.
func
(
rp
*
repoProvider
)
GetCredentialProvider
()
CredentialProvider
{
func
(
rp
*
repoProvider
)
GetCredentialProvider
()
I
CredentialProvider
{
return
rp
.
cp
}
...
...
@@ -84,7 +84,7 @@ func (rp *repoProvider) GetGCSRepoProvider() GCSRepoProvider {
}
// GetRepoByName returns the repository with the given name.
func
(
rp
*
repoProvider
)
GetRepoByName
(
repoName
string
)
(
ChartRepo
,
error
)
{
func
(
rp
*
repoProvider
)
GetRepoByName
(
repoName
string
)
(
I
ChartRepo
,
error
)
{
rp
.
Lock
()
defer
rp
.
Unlock
()
...
...
@@ -100,7 +100,7 @@ func (rp *repoProvider) GetRepoByName(repoName string) (ChartRepo, error) {
return
rp
.
createRepoByType
(
cr
)
}
func
(
rp
*
repoProvider
)
createRepoByType
(
r
Repo
)
(
ChartRepo
,
error
)
{
func
(
rp
*
repoProvider
)
createRepoByType
(
r
IRepo
)
(
I
ChartRepo
,
error
)
{
switch
r
.
GetType
()
{
case
GCSRepoType
:
cr
,
err
:=
rp
.
gcsrp
.
GetGCSRepo
(
r
)
...
...
@@ -114,7 +114,7 @@ func (rp *repoProvider) createRepoByType(r Repo) (ChartRepo, error) {
return
nil
,
fmt
.
Errorf
(
"unknown repository type: %s"
,
r
.
GetType
())
}
func
(
rp
*
repoProvider
)
createRepo
(
cr
ChartRepo
)
(
ChartRepo
,
error
)
{
func
(
rp
*
repoProvider
)
createRepo
(
cr
IChartRepo
)
(
I
ChartRepo
,
error
)
{
name
:=
cr
.
GetName
()
if
_
,
ok
:=
rp
.
repos
[
name
];
ok
{
return
nil
,
fmt
.
Errorf
(
"respository named %s already exists"
,
name
)
...
...
@@ -125,7 +125,7 @@ func (rp *repoProvider) createRepo(cr ChartRepo) (ChartRepo, error) {
}
// GetRepoByURL returns the repository whose URL is a prefix of the given URL.
func
(
rp
*
repoProvider
)
GetRepoByURL
(
URL
string
)
(
ChartRepo
,
error
)
{
func
(
rp
*
repoProvider
)
GetRepoByURL
(
URL
string
)
(
I
ChartRepo
,
error
)
{
rp
.
Lock
()
defer
rp
.
Unlock
()
...
...
@@ -141,8 +141,8 @@ func (rp *repoProvider) GetRepoByURL(URL string) (ChartRepo, error) {
return
rp
.
createRepoByType
(
cr
)
}
func
(
rp
*
repoProvider
)
findRepoByURL
(
URL
string
)
ChartRepo
{
var
found
ChartRepo
func
(
rp
*
repoProvider
)
findRepoByURL
(
URL
string
)
I
ChartRepo
{
var
found
I
ChartRepo
for
_
,
r
:=
range
rp
.
repos
{
rURL
:=
r
.
GetURL
()
if
strings
.
HasPrefix
(
URL
,
rURL
)
{
...
...
@@ -178,17 +178,17 @@ func (rp *repoProvider) GetChartByReference(reference string) (*chart.Chart, err
return
r
.
GetChart
(
name
)
}
// GCSRepoProvider is a factory for GCS Repo instances.
// GCSRepoProvider is a factory for GCS
I
Repo instances.
type
GCSRepoProvider
interface
{
GetGCSRepo
(
r
Repo
)
(
Object
StorageRepo
,
error
)
GetGCSRepo
(
r
IRepo
)
(
I
StorageRepo
,
error
)
}
type
gcsRepoProvider
struct
{
cp
CredentialProvider
cp
I
CredentialProvider
}
// NewGCSRepoProvider creates a GCSRepoProvider.
func
NewGCSRepoProvider
(
cp
CredentialProvider
)
GCSRepoProvider
{
func
NewGCSRepoProvider
(
cp
I
CredentialProvider
)
GCSRepoProvider
{
if
cp
==
nil
{
cp
=
NewInmemCredentialProvider
()
}
...
...
@@ -198,7 +198,7 @@ func NewGCSRepoProvider(cp CredentialProvider) GCSRepoProvider {
// GetGCSRepo returns a new Google Cloud Storage repository. If a credential is specified, it will try to
// fetch it and use it, and if the credential isn't found, it will fall back to an unauthenticated client.
func
(
gcsrp
gcsRepoProvider
)
GetGCSRepo
(
r
Repo
)
(
Object
StorageRepo
,
error
)
{
func
(
gcsrp
gcsRepoProvider
)
GetGCSRepo
(
r
IRepo
)
(
I
StorageRepo
,
error
)
{
client
,
err
:=
gcsrp
.
createGCSClient
(
r
.
GetCredentialName
())
if
err
!=
nil
{
return
nil
,
err
...
...
pkg/repo/repoprovider_test.go
View file @
b2570ef1
...
...
@@ -50,9 +50,9 @@ func TestRepoProvider(t *testing.T) {
t
.
Fatal
(
err
)
}
castRepo
,
ok
:=
haveRepo
.
(
Object
StorageRepo
)
castRepo
,
ok
:=
haveRepo
.
(
I
StorageRepo
)
if
!
ok
{
t
.
Fatalf
(
"invalid repo type, want:
Object
StorageRepo, have: %T."
,
haveRepo
)
t
.
Fatalf
(
"invalid repo type, want:
I
StorageRepo, have: %T."
,
haveRepo
)
}
wantBucket
:=
GCSPublicRepoBucket
...
...
pkg/repo/secrets_credential_provider.go
View file @
b2570ef1
...
...
@@ -53,7 +53,7 @@ type SecretsCredentialProvider struct {
}
// NewSecretsCredentialProvider creates a new secrets credential provider.
func
NewSecretsCredentialProvider
()
CredentialProvider
{
func
NewSecretsCredentialProvider
()
I
CredentialProvider
{
kubernetesConfig
:=
&
util
.
KubernetesConfig
{
KubePath
:
*
kubePath
,
KubeService
:
*
kubeService
,
...
...
pkg/repo/types.go
View file @
b2570ef1
...
...
@@ -44,8 +44,8 @@ type RepoCredential struct {
ServiceAccount
JWTTokenCredential
`json:"serviceaccount,omitempty"`
}
// CredentialProvider provides credentials for chart repositories.
type
CredentialProvider
interface
{
//
I
CredentialProvider provides credentials for chart repositories.
type
I
CredentialProvider
interface
{
// SetCredential sets the credential for a repository.
// May not be supported by some repository services.
SetCredential
(
name
string
,
credential
*
RepoCredential
)
error
...
...
@@ -68,8 +68,17 @@ const (
FlatRepoFormat
=
RepoFormat
(
"flat"
)
)
// Repo abstracts a repository.
type
Repo
interface
{
// Repo describes a repository
type
Repo
struct
{
Name
string
`json:"name"`
// Friendly name for this repository
URL
string
`json:"url"`
// URL to the root of this repository
CredentialName
string
`json:"credentialname"`
// Credential name used to access this repository
Format
RepoFormat
`json:"format"`
// Format of this repository
Type
RepoType
`json:"type"`
// Technology implementing this repository
}
// IRepo abstracts a repository.
type
IRepo
interface
{
// GetName returns the friendly name of this repository.
GetName
()
string
// GetURL returns the URL to the root of this repository.
...
...
@@ -82,10 +91,10 @@ type Repo interface {
GetType
()
RepoType
}
// ChartRepo abstracts a place that holds charts.
type
ChartRepo
interface
{
// A
ChartRepo is a
Repo
Repo
//
I
ChartRepo abstracts a place that holds charts.
type
I
ChartRepo
interface
{
// A
IChartRepo is a I
Repo
I
Repo
// ListCharts lists charts in this repository whose string values
// conform to the supplied regular expression, or all charts if regex is nil
...
...
@@ -95,27 +104,27 @@ type ChartRepo interface {
GetChart
(
name
string
)
(
*
chart
.
Chart
,
error
)
}
//
Object
StorageRepo abstracts a repository that resides in Object Storage,
//
I
StorageRepo abstracts a repository that resides in Object Storage,
// such as Google Cloud Storage, AWS S3, etc.
type
Object
StorageRepo
interface
{
// An
ObjectStorageRepo is a
ChartRepo
ChartRepo
type
I
StorageRepo
interface
{
// An
IStorageRepo is a I
ChartRepo
I
ChartRepo
// GetBucket returns the name of the bucket that contains this repository.
GetBucket
()
string
}
// Service maintains a list of chart repositories that defines the scope of all
//
IRepo
Service maintains a list of chart repositories that defines the scope of all
// repository based operations, such as search and chart reference resolution.
type
Service
interface
{
type
IRepo
Service
interface
{
// List returns the list of all known chart repositories
List
()
([]
Repo
,
error
)
List
()
([]
I
Repo
,
error
)
// Create adds a known repository to the list
Create
(
repository
Repo
)
error
Create
(
repository
I
Repo
)
error
// Get returns the repository with the given name
Get
(
name
string
)
(
Repo
,
error
)
Get
(
name
string
)
(
I
Repo
,
error
)
// GetByURL returns the repository that backs the given URL
GetByURL
(
URL
string
)
(
Repo
,
error
)
GetByURL
(
URL
string
)
(
I
Repo
,
error
)
// Delete removes a known repository from the list
Delete
(
name
string
)
error
}
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