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
39e0d0b1
Commit
39e0d0b1
authored
Nov 07, 2015
by
vaikas-google
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the new types structure
parent
ded401b3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
16 deletions
+11
-16
client.go
client/client.go
+7
-5
github_registry.go
client/registry/github_registry.go
+3
-9
registry.go
client/registry/registry.go
+1
-2
No files found.
client/client.go
View file @
39e0d0b1
...
...
@@ -35,7 +35,7 @@ var (
action
=
flag
.
String
(
"action"
,
"deploy"
,
"expand | deploy | list | get | delete | update | listtypes | listtypeinstances | types"
)
name
=
flag
.
String
(
"name"
,
""
,
"Name of template or deployment"
)
service
=
flag
.
String
(
"service"
,
"http://localhost:8080"
,
"URL for deployment manager"
)
type_registry
=
flag
.
String
(
"type_registry"
,
"kubernetes/deployment-manager
/examples/guestbook"
,
"Type registry [owner/repo/root
], defaults to kubernetes/deployment-manager/"
)
type_registry
=
flag
.
String
(
"type_registry"
,
"kubernetes/deployment-manager
"
,
"Type registry [owner/repo
], defaults to kubernetes/deployment-manager/"
)
binary
=
flag
.
String
(
"binary"
,
"../expandybird/expansion/expansion.py"
,
"Path to template expansion binary"
)
)
...
...
@@ -50,19 +50,21 @@ func main() {
flag
.
Parse
()
name
:=
getNameArgument
()
switch
*
action
{
case
"repolist"
:
git
:=
registry
.
NewGithubRegistry
(
"kubernetes"
,
"deployment-manager"
,
"examples/guestbook"
)
case
"types"
:
s
:=
strings
.
Split
(
*
type_registry
,
"/"
)
git
:=
registry
.
NewGithubRegistry
(
s
[
0
],
s
[
1
])
types
,
err
:=
git
.
List
()
if
err
!=
nil
{
log
.
Fatalf
(
"Cannot list %v err"
)
}
log
.
Printf
(
"Types:"
)
for
_
,
t
:=
range
types
{
log
.
Printf
(
"
Got type:
%s:%s"
,
t
.
Name
,
t
.
Version
)
log
.
Printf
(
"%s:%s"
,
t
.
Name
,
t
.
Version
)
downloadURL
,
err
:=
git
.
GetURL
(
t
)
if
err
!=
nil
{
log
.
Printf
(
"Failed to get download URL for %s:%s"
,
t
.
Name
,
t
.
Version
)
}
log
.
Printf
(
"
DOWNLOAD
URL: %s"
,
downloadURL
)
log
.
Printf
(
"
\t
download
URL: %s"
,
downloadURL
)
}
case
"expand"
:
...
...
client/registry/github_registry.go
View file @
39e0d0b1
...
...
@@ -23,21 +23,18 @@ import (
type
GithubRegistry
struct
{
owner
string
repository
string
root
string
client
*
github
.
Client
}
func
NewGithubRegistry
(
owner
string
,
repository
string
,
root
string
)
*
GithubRegistry
{
func
NewGithubRegistry
(
owner
string
,
repository
string
)
*
GithubRegistry
{
return
&
GithubRegistry
{
owner
:
owner
,
repository
:
repository
,
root
:
root
,
client
:
github
.
NewClient
(
nil
),
}
}
func
(
g
*
GithubRegistry
)
List
()
([]
Type
,
error
)
{
log
.
Printf
(
"Calling ListRefs"
)
// First list all the types at the top level.
types
,
err
:=
g
.
getDirs
(
TypesDir
)
if
err
!=
nil
{
...
...
@@ -46,7 +43,6 @@ func (g *GithubRegistry) List() ([]Type, error) {
}
var
retTypes
[]
Type
for
_
,
t
:=
range
types
{
log
.
Printf
(
"Got TYPE: %s, fetching : %s"
,
t
,
TypesDir
+
"/"
+
t
)
// Then we need to fetch the versions (directories for this type)
versions
,
err
:=
g
.
getDirs
(
TypesDir
+
"/"
+
t
)
if
err
!=
nil
{
...
...
@@ -54,7 +50,6 @@ func (g *GithubRegistry) List() ([]Type, error) {
return
nil
,
err
}
for
_
,
v
:=
range
versions
{
log
.
Printf
(
"Got VERSION: %s"
,
v
)
retTypes
=
append
(
retTypes
,
Type
{
Name
:
t
,
Version
:
v
})
}
}
...
...
@@ -71,7 +66,7 @@ func (g *GithubRegistry) GetURL(t Type) (string, error) {
}
for
_
,
f
:=
range
dc
{
if
*
f
.
Type
==
"file"
{
if
*
f
.
Name
==
t
.
Version
+
".jinja"
||
*
f
.
Name
==
t
.
Version
+
".py"
{
if
*
f
.
Name
==
t
.
Name
+
".jinja"
||
*
f
.
Name
==
t
.
Name
+
".py"
{
return
*
f
.
DownloadURL
,
nil
}
}
...
...
@@ -80,12 +75,11 @@ func (g *GithubRegistry) GetURL(t Type) (string, error) {
}
func
(
g
*
GithubRegistry
)
getDirs
(
dir
string
)
([]
string
,
error
)
{
_
,
dc
,
resp
,
err
:=
g
.
client
.
Repositories
.
GetContents
(
g
.
owner
,
g
.
repository
,
dir
,
nil
)
_
,
dc
,
_
,
err
:=
g
.
client
.
Repositories
.
GetContents
(
g
.
owner
,
g
.
repository
,
dir
,
nil
)
if
err
!=
nil
{
log
.
Printf
(
"Failed to call ListRefs : %v"
,
err
)
return
nil
,
err
}
log
.
Printf
(
"Got: %v %v"
,
dc
,
resp
,
err
)
var
dirs
[]
string
for
_
,
entry
:=
range
dc
{
if
*
entry
.
Type
==
"dir"
{
...
...
client/registry/registry.go
View file @
39e0d0b1
...
...
@@ -29,8 +29,7 @@ package registry
// replicatedservice.python
// replicatedservice.python.schema
//const TypesDir string = "types"
const
TypesDir
string
=
"examples"
const
TypesDir
string
=
"types"
type
Type
struct
{
Name
string
...
...
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