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
efe31779
Commit
efe31779
authored
Mar 24, 2016
by
Michelle Noorali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(repo): add Name to Repo struct
* also added name as arg in helm repo add cmd
parent
0ccb8d75
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
19 deletions
+40
-19
repository.go
cmd/helm/repository.go
+17
-9
chartrepos.go
cmd/manager/chartrepos.go
+7
-3
gcs_repo.go
pkg/repo/gcs_repo.go
+3
-3
repo.go
pkg/repo/repo.go
+9
-3
repoprovider.go
pkg/repo/repoprovider.go
+1
-1
types.go
pkg/repo/types.go
+3
-0
No files found.
cmd/helm/repository.go
View file @
efe31779
...
@@ -19,6 +19,7 @@ package main
...
@@ -19,6 +19,7 @@ package main
import
(
import
(
"encoding/json"
"encoding/json"
"errors"
"errors"
"github.com/codegangsta/cli"
"github.com/codegangsta/cli"
"github.com/kubernetes/helm/pkg/format"
"github.com/kubernetes/helm/pkg/format"
"github.com/kubernetes/helm/pkg/repo"
"github.com/kubernetes/helm/pkg/repo"
...
@@ -39,7 +40,7 @@ func repoCommands() cli.Command {
...
@@ -39,7 +40,7 @@ func repoCommands() cli.Command {
{
{
Name
:
"add"
,
Name
:
"add"
,
Usage
:
"Add a chart repository to the remote manager."
,
Usage
:
"Add a chart repository to the remote manager."
,
ArgsUsage
:
"
REPOSITORY_URL
"
,
ArgsUsage
:
"
[NAME] [REPOSITORY_URL]
"
,
Action
:
func
(
c
*
cli
.
Context
)
{
run
(
c
,
addRepo
)
},
Action
:
func
(
c
*
cli
.
Context
)
{
run
(
c
,
addRepo
)
},
},
},
{
{
...
@@ -61,11 +62,12 @@ func repoCommands() cli.Command {
...
@@ -61,11 +62,12 @@ func repoCommands() cli.Command {
func
addRepo
(
c
*
cli
.
Context
)
error
{
func
addRepo
(
c
*
cli
.
Context
)
error
{
args
:=
c
.
Args
()
args
:=
c
.
Args
()
if
len
(
args
)
<
1
{
if
len
(
args
)
<
2
{
return
errors
.
New
(
"'helm repo add' requires a
repository url as an argument
"
)
return
errors
.
New
(
"'helm repo add' requires a
name and repository url as arguments
"
)
}
}
name
:=
args
[
0
]
repoURL
:=
args
[
0
]
repoURL
:=
args
[
0
]
payload
,
_
:=
json
.
Marshal
(
repo
.
Repo
{
URL
:
repoURL
})
payload
,
_
:=
json
.
Marshal
(
repo
.
Repo
{
URL
:
repoURL
,
Name
:
name
})
msg
:=
""
msg
:=
""
if
_
,
err
:=
NewClient
(
c
)
.
Post
(
chartRepoPath
,
payload
,
&
msg
);
err
!=
nil
{
if
_
,
err
:=
NewClient
(
c
)
.
Post
(
chartRepoPath
,
payload
,
&
msg
);
err
!=
nil
{
//TODO: Return more specific errors to the user
//TODO: Return more specific errors to the user
...
@@ -95,10 +97,16 @@ func removeRepo(c *cli.Context) error {
...
@@ -95,10 +97,16 @@ func removeRepo(c *cli.Context) error {
if
len
(
args
)
<
1
{
if
len
(
args
)
<
1
{
return
errors
.
New
(
"'helm repo remove' requires a repository url as an argument"
)
return
errors
.
New
(
"'helm repo remove' requires a repository url as an argument"
)
}
}
repoURL
:=
args
[
0
]
//arg := args[0]
if
_
,
err
:=
NewClient
(
c
)
.
Delete
(
chartRepoPath
,
repoURL
);
err
!=
nil
{
//u, err := url.Parse(arg)
return
err
//if err != nil {
}
//return err
format
.
Msg
(
repoURL
+
"has been removed.
\n
"
)
//}
//p := filepath.Join(chartRepoPath, u.String())
//if _, err := NewClient(c).Delete(p, nil); err != nil {
//return err
//}
//format.Msg(arg + " has been removed.\n")
format
.
Info
(
"TO BE IMPLEMENTED"
)
return
nil
return
nil
}
}
cmd/manager/chartrepos.go
View file @
efe31779
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
"github.com/kubernetes/helm/pkg/util"
"github.com/kubernetes/helm/pkg/util"
"encoding/json"
"encoding/json"
"fmt"
"net/http"
"net/http"
"net/url"
"net/url"
"regexp"
"regexp"
...
@@ -18,7 +19,7 @@ func registerChartRepoRoutes(c *router.Context, h *router.Handler) {
...
@@ -18,7 +19,7 @@ func registerChartRepoRoutes(c *router.Context, h *router.Handler) {
h
.
Add
(
"GET /repositories/*/charts"
,
listRepoChartsHandlerFunc
)
h
.
Add
(
"GET /repositories/*/charts"
,
listRepoChartsHandlerFunc
)
h
.
Add
(
"GET /repositories/*/charts/*"
,
getRepoChartHandlerFunc
)
h
.
Add
(
"GET /repositories/*/charts/*"
,
getRepoChartHandlerFunc
)
h
.
Add
(
"POST /repositories"
,
addChartRepoHandlerFunc
)
h
.
Add
(
"POST /repositories"
,
addChartRepoHandlerFunc
)
h
.
Add
(
"DELETE /repositories"
,
removeChartRepoHandlerFunc
)
h
.
Add
(
"DELETE /repositories
/*
"
,
removeChartRepoHandlerFunc
)
}
}
func
listChartReposHandlerFunc
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
c
*
router
.
Context
)
error
{
func
listChartReposHandlerFunc
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
c
*
router
.
Context
)
error
{
...
@@ -47,7 +48,7 @@ func addChartRepoHandlerFunc(w http.ResponseWriter, r *http.Request, c *router.C
...
@@ -47,7 +48,7 @@ func addChartRepoHandlerFunc(w http.ResponseWriter, r *http.Request, c *router.C
return
nil
return
nil
}
}
msg
,
_
:=
json
.
Marshal
(
cr
.
URL
+
" has been added to the list of chart repositories."
)
msg
,
_
:=
json
.
Marshal
(
cr
.
Name
+
" has been added to the list of chart repositories."
)
util
.
LogHandlerExitWithJSON
(
handler
,
w
,
msg
,
http
.
StatusCreated
)
util
.
LogHandlerExitWithJSON
(
handler
,
w
,
msg
,
http
.
StatusCreated
)
return
nil
return
nil
}
}
...
@@ -55,17 +56,20 @@ func addChartRepoHandlerFunc(w http.ResponseWriter, r *http.Request, c *router.C
...
@@ -55,17 +56,20 @@ func addChartRepoHandlerFunc(w http.ResponseWriter, r *http.Request, c *router.C
func
removeChartRepoHandlerFunc
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
c
*
router
.
Context
)
error
{
func
removeChartRepoHandlerFunc
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
c
*
router
.
Context
)
error
{
handler
:=
"manager: remove chart repository"
handler
:=
"manager: remove chart repository"
util
.
LogHandlerEntry
(
handler
,
r
)
util
.
LogHandlerEntry
(
handler
,
r
)
defer
r
.
Body
.
Close
()
URL
,
err
:=
pos
(
w
,
r
,
2
)
URL
,
err
:=
pos
(
w
,
r
,
2
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
fmt
.
Printf
(
"URL: %#v
\n
"
,
URL
)
err
=
c
.
Manager
.
RemoveChartRepo
(
URL
)
err
=
c
.
Manager
.
RemoveChartRepo
(
URL
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
util
.
LogHandlerExitWithText
(
handler
,
w
,
"removed"
,
http
.
StatusOK
)
msg
,
_
:=
json
.
Marshal
(
URL
+
" has been removed from the list of chart repositories."
)
util
.
LogHandlerExitWithJSON
(
handler
,
w
,
msg
,
http
.
StatusOK
)
return
nil
return
nil
}
}
...
...
pkg/repo/gcs_repo.go
View file @
efe31779
...
@@ -60,12 +60,12 @@ type GCSRepo struct {
...
@@ -60,12 +60,12 @@ type GCSRepo struct {
// NewPublicGCSRepo creates a new an IStorageRepo for the public GCS repository.
// NewPublicGCSRepo creates a new an IStorageRepo for the public GCS repository.
func
NewPublicGCSRepo
(
httpClient
*
http
.
Client
)
(
IStorageRepo
,
error
)
{
func
NewPublicGCSRepo
(
httpClient
*
http
.
Client
)
(
IStorageRepo
,
error
)
{
return
NewGCSRepo
(
GCSPublicRepoURL
,
""
,
nil
)
return
NewGCSRepo
(
GCSPublicRepoURL
,
""
,
GCSPublicRepoBucket
,
nil
)
}
}
// NewGCSRepo creates a new IStorageRepo for a given GCS repository.
// NewGCSRepo creates a new IStorageRepo for a given GCS repository.
func
NewGCSRepo
(
URL
,
credentialName
string
,
httpClient
*
http
.
Client
)
(
IStorageRepo
,
error
)
{
func
NewGCSRepo
(
URL
,
credentialName
,
repoName
string
,
httpClient
*
http
.
Client
)
(
IStorageRepo
,
error
)
{
r
,
err
:=
newRepo
(
URL
,
credentialName
,
GCSRepoFormat
,
GCSRepoType
)
r
,
err
:=
newRepo
(
URL
,
credentialName
,
repoName
,
GCSRepoFormat
,
GCSRepoType
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
pkg/repo/repo.go
View file @
efe31779
...
@@ -22,11 +22,11 @@ import (
...
@@ -22,11 +22,11 @@ import (
)
)
// NewRepo takes params and returns a IRepo
// NewRepo takes params and returns a IRepo
func
NewRepo
(
URL
,
credentialName
,
repoFormat
,
repoType
string
)
(
IRepo
,
error
)
{
func
NewRepo
(
URL
,
credentialName
,
repo
Name
,
repo
Format
,
repoType
string
)
(
IRepo
,
error
)
{
return
newRepo
(
URL
,
credentialName
,
ERepoFormat
(
repoFormat
),
ERepoType
(
repoType
))
return
newRepo
(
URL
,
credentialName
,
repoName
,
ERepoFormat
(
repoFormat
),
ERepoType
(
repoType
))
}
}
func
newRepo
(
URL
,
credentialName
string
,
repoFormat
ERepoFormat
,
repoType
ERepoType
)
(
*
Repo
,
error
)
{
func
newRepo
(
URL
,
credentialName
,
repoName
string
,
repoFormat
ERepoFormat
,
repoType
ERepoType
)
(
*
Repo
,
error
)
{
_
,
err
:=
url
.
Parse
(
URL
)
_
,
err
:=
url
.
Parse
(
URL
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"invalid URL (%s): %s"
,
URL
,
err
)
return
nil
,
fmt
.
Errorf
(
"invalid URL (%s): %s"
,
URL
,
err
)
...
@@ -41,6 +41,7 @@ func newRepo(URL, credentialName string, repoFormat ERepoFormat, repoType ERepoT
...
@@ -41,6 +41,7 @@ func newRepo(URL, credentialName string, repoFormat ERepoFormat, repoType ERepoT
}
}
r
:=
&
Repo
{
r
:=
&
Repo
{
Name
:
repoName
,
URL
:
URL
,
URL
:
URL
,
CredentialName
:
credentialName
,
CredentialName
:
credentialName
,
Type
:
repoType
,
Type
:
repoType
,
...
@@ -65,6 +66,11 @@ func (r *Repo) GetType() ERepoType {
...
@@ -65,6 +66,11 @@ func (r *Repo) GetType() ERepoType {
return
r
.
Type
return
r
.
Type
}
}
// GetName returns the name of this repository.
func
(
r
*
Repo
)
GetName
()
string
{
return
r
.
Name
}
// GetURL returns the URL to the root of this repository.
// GetURL returns the URL to the root of this repository.
func
(
r
*
Repo
)
GetURL
()
string
{
func
(
r
*
Repo
)
GetURL
()
string
{
return
r
.
URL
return
r
.
URL
...
...
pkg/repo/repoprovider.go
View file @
efe31779
...
@@ -225,7 +225,7 @@ func (gcsrp gcsRepoProvider) GetGCSRepo(r IRepo) (IStorageRepo, error) {
...
@@ -225,7 +225,7 @@ func (gcsrp gcsRepoProvider) GetGCSRepo(r IRepo) (IStorageRepo, error) {
return
nil
,
err
return
nil
,
err
}
}
return
NewGCSRepo
(
r
.
GetURL
(),
r
.
GetCredentialName
(),
client
)
return
NewGCSRepo
(
r
.
GetURL
(),
r
.
GetCredentialName
(),
r
.
GetName
(),
client
)
}
}
func
(
gcsrp
gcsRepoProvider
)
createGCSClient
(
credentialName
string
)
(
*
http
.
Client
,
error
)
{
func
(
gcsrp
gcsRepoProvider
)
createGCSClient
(
credentialName
string
)
(
*
http
.
Client
,
error
)
{
...
...
pkg/repo/types.go
View file @
efe31779
...
@@ -70,6 +70,7 @@ const (
...
@@ -70,6 +70,7 @@ const (
// Repo describes a repository
// Repo describes a repository
type
Repo
struct
{
type
Repo
struct
{
Name
string
`json:"name"`
// Name of repository
URL
string
`json:"url"`
// URL to the root of this repository
URL
string
`json:"url"`
// URL to the root of this repository
CredentialName
string
`json:"credentialname,omitempty"`
// Credential name used to access this repository
CredentialName
string
`json:"credentialname,omitempty"`
// Credential name used to access this repository
Format
ERepoFormat
`json:"format,omitempty"`
// Format of this repository
Format
ERepoFormat
`json:"format,omitempty"`
// Format of this repository
...
@@ -78,6 +79,8 @@ type Repo struct {
...
@@ -78,6 +79,8 @@ type Repo struct {
// IRepo abstracts a repository.
// IRepo abstracts a repository.
type
IRepo
interface
{
type
IRepo
interface
{
// GetName returns the name of the repository
GetName
()
string
// GetURL returns the URL to the root of this repository.
// GetURL returns the URL to the root of this repository.
GetURL
()
string
GetURL
()
string
// GetCredentialName returns the credential name used to access this repository.
// GetCredentialName returns the credential name used to access this repository.
...
...
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