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
33ca00f8
Commit
33ca00f8
authored
Mar 18, 2016
by
jackgr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add GetChart method
parent
f8193c25
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
360 additions
and
6 deletions
+360
-6
chart_test.go
pkg/chart/chart_test.go
+1
-1
gcs_repo.go
pkg/repo/gcs_repo.go
+35
-5
gcs_repo_test.go
pkg/repo/gcs_repo_test.go
+103
-0
README.md
pkg/repo/testdata/README.md
+6
-0
frobnitz-0.0.1.tgz
pkg/repo/testdata/frobnitz-0.0.1.tgz
+0
-0
Chart.yaml
pkg/repo/testdata/frobnitz/Chart.yaml
+34
-0
LICENSE
pkg/repo/testdata/frobnitz/LICENSE
+1
-0
README.md
pkg/repo/testdata/frobnitz/README.md
+11
-0
README.md
pkg/repo/testdata/frobnitz/docs/README.md
+1
-0
pre-install.py
pkg/repo/testdata/frobnitz/hooks/pre-install.py
+1
-0
icon.svg
pkg/repo/testdata/frobnitz/icon.svg
+8
-0
wordpress-resources.yaml
...repo/testdata/frobnitz/templates/wordpress-resources.yaml
+12
-0
wordpress.jinja
pkg/repo/testdata/frobnitz/templates/wordpress.jinja
+72
-0
wordpress.jinja.schema
pkg/repo/testdata/frobnitz/templates/wordpress.jinja.schema
+69
-0
wordpress.yaml
pkg/repo/testdata/frobnitz/templates/wordpress.yaml
+6
-0
No files found.
pkg/chart/chart_test.go
View file @
33ca00f8
...
@@ -246,7 +246,7 @@ func compareContent(filename, content string) error {
...
@@ -246,7 +246,7 @@ func compareContent(filename, content string) error {
compare
:=
base64
.
StdEncoding
.
EncodeToString
(
b
)
compare
:=
base64
.
StdEncoding
.
EncodeToString
(
b
)
if
content
!=
compare
{
if
content
!=
compare
{
return
fmt
.
Errorf
(
"Expected member content
\n
%
s
\n
got
\n
%s"
,
compare
,
content
)
return
fmt
.
Errorf
(
"Expected member content
\n
%
v
\n
got
\n
%v"
,
[]
byte
(
compare
),
[]
byte
(
content
)
)
}
}
return
nil
return
nil
...
...
pkg/repo/gcs_repo.go
View file @
33ca00f8
...
@@ -25,6 +25,7 @@ import (
...
@@ -25,6 +25,7 @@ import (
"fmt"
"fmt"
"net/http"
"net/http"
"net/url"
"regexp"
"regexp"
)
)
...
@@ -43,7 +44,7 @@ type GCSRepo struct {
...
@@ -43,7 +44,7 @@ type GCSRepo struct {
// URLFormatMatcher matches the GCS URL format (gs:).
// URLFormatMatcher matches the GCS URL format (gs:).
var
URLFormatMatcher
=
regexp
.
MustCompile
(
"gs://(.*)"
)
var
URLFormatMatcher
=
regexp
.
MustCompile
(
"gs://(.*)"
)
var
GCSRepoFormat
=
common
.
RepoFormat
(
fmt
.
Sprintf
(
"%s;%s"
,
common
.
V
ersionedRepo
,
common
.
OneLevelRepo
))
var
GCSRepoFormat
=
common
.
RepoFormat
(
fmt
.
Sprintf
(
"%s;%s"
,
common
.
Unv
ersionedRepo
,
common
.
OneLevelRepo
))
// NewGCSRepo creates a GCS repository.
// NewGCSRepo creates a GCS repository.
func
NewGCSRepo
(
name
,
URL
string
,
httpClient
*
http
.
Client
)
(
*
GCSRepo
,
error
)
{
func
NewGCSRepo
(
name
,
URL
string
,
httpClient
*
http
.
Client
)
(
*
GCSRepo
,
error
)
{
...
@@ -106,7 +107,9 @@ func (g *GCSRepo) ListCharts(regex *regexp.Regexp) ([]string, error) {
...
@@ -106,7 +107,9 @@ func (g *GCSRepo) ListCharts(regex *regexp.Regexp) ([]string, error) {
continue
continue
}
}
charts
=
append
(
charts
,
object
.
Name
)
if
regex
==
nil
||
regex
.
MatchString
(
object
.
Name
)
{
charts
=
append
(
charts
,
object
.
Name
)
}
}
}
if
pageToken
=
res
.
NextPageToken
;
pageToken
==
""
{
if
pageToken
=
res
.
NextPageToken
;
pageToken
==
""
{
...
@@ -117,11 +120,38 @@ func (g *GCSRepo) ListCharts(regex *regexp.Regexp) ([]string, error) {
...
@@ -117,11 +120,38 @@ func (g *GCSRepo) ListCharts(regex *regexp.Regexp) ([]string, error) {
return
charts
,
nil
return
charts
,
nil
}
}
// TODO: Implement GetChart.
// GetChart retrieves, unpacks and returns a chart by name.
// GetChart retrieves, unpacks and returns a chart by name.
func
(
g
*
GCSRepo
)
GetChart
(
name
string
)
(
*
chart
.
Chart
,
error
)
{
func
(
g
*
GCSRepo
)
GetChart
(
name
string
)
(
*
chart
.
Chart
,
error
)
{
return
nil
,
fmt
.
Errorf
(
"not implemented: GCSRepo.GetChart"
)
// Charts should be named bucket/chart-X.Y.Z.tgz, so tease apart the version here
if
!
ChartNameMatcher
.
MatchString
(
name
)
{
return
nil
,
fmt
.
Errorf
(
"name must be of the form <name>-<version>.tgz, was %s"
,
name
)
}
call
:=
g
.
service
.
Objects
.
Get
(
g
.
bucket
,
name
)
object
,
err
:=
call
.
Do
()
if
err
!=
nil
{
return
nil
,
err
}
u
,
err
:=
url
.
Parse
(
object
.
MediaLink
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Cannot parse URL %s for chart %s/%s: %s"
,
object
.
MediaLink
,
object
.
Bucket
,
object
.
Name
,
err
)
}
getter
:=
util
.
NewHTTPClient
(
3
,
g
.
httpClient
,
util
.
NewSleeper
())
body
,
code
,
err
:=
getter
.
Get
(
u
.
String
())
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Cannot fetch URL %s for chart %s/%s: %d %s"
,
object
.
MediaLink
,
object
.
Bucket
,
object
.
Name
,
code
,
err
)
}
return
chart
.
Load
(
body
)
}
// Do performs an HTTP operation on the receiver's httpClient.
func
(
g
*
GCSRepo
)
Do
(
req
*
http
.
Request
)
(
resp
*
http
.
Response
,
err
error
)
{
return
g
.
httpClient
.
Do
(
req
)
}
}
// TODO: Remove GetShortURL when no longer needed.
// TODO: Remove GetShortURL when no longer needed.
...
...
pkg/repo/gcs_repo_test.go
View file @
33ca00f8
...
@@ -17,11 +17,23 @@ limitations under the License.
...
@@ -17,11 +17,23 @@ limitations under the License.
package
repo
package
repo
import
(
import
(
"github.com/kubernetes/helm/pkg/chart"
"github.com/kubernetes/helm/pkg/common"
"github.com/kubernetes/helm/pkg/common"
"os"
"reflect"
"regexp"
"testing"
"testing"
)
)
var
(
TestArchiveBucket
=
os
.
Getenv
(
"TEST_ARCHIVE_BUCKET"
)
TestArchiveName
=
"frobnitz-0.0.1.tgz"
TestChartFile
=
"testdata/frobnitz/Chart.yaml"
TestShouldFindRegex
=
regexp
.
MustCompile
(
TestArchiveName
)
TestShouldNotFindRegex
=
regexp
.
MustCompile
(
"foobar"
)
)
func
TestValidGSURL
(
t
*
testing
.
T
)
{
func
TestValidGSURL
(
t
*
testing
.
T
)
{
var
validURL
=
"gs://bucket"
var
validURL
=
"gs://bucket"
tr
,
err
:=
NewGCSRepo
(
"testName"
,
validURL
,
nil
)
tr
,
err
:=
NewGCSRepo
(
"testName"
,
validURL
,
nil
)
...
@@ -50,3 +62,94 @@ func TestInvalidGSURL(t *testing.T) {
...
@@ -50,3 +62,94 @@ func TestInvalidGSURL(t *testing.T) {
t
.
Fatalf
(
"expected error did not occur for invalid URL"
)
t
.
Fatalf
(
"expected error did not occur for invalid URL"
)
}
}
}
}
func
TestListCharts
(
t
*
testing
.
T
)
{
if
TestArchiveBucket
!=
""
{
tr
,
err
:=
NewGCSRepo
(
"testName"
,
TestArchiveBucket
,
nil
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
charts
,
err
:=
tr
.
ListCharts
(
nil
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
len
(
charts
)
!=
1
{
t
.
Fatalf
(
"expected one chart in test bucket, got %d"
,
len
(
charts
))
}
name
:=
charts
[
0
]
if
name
!=
TestArchiveName
{
t
.
Fatalf
(
"expected chart named %s in test bucket, got %s"
,
TestArchiveName
,
name
)
}
}
}
func
TestListChartsWithShouldFindRegex
(
t
*
testing
.
T
)
{
if
TestArchiveBucket
!=
""
{
tr
,
err
:=
NewGCSRepo
(
"testName"
,
TestArchiveBucket
,
nil
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
charts
,
err
:=
tr
.
ListCharts
(
TestShouldFindRegex
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
len
(
charts
)
!=
1
{
t
.
Fatalf
(
"expected one chart to match regex, got %d"
,
len
(
charts
))
}
}
}
func
TestListChartsWithShouldNotFindRegex
(
t
*
testing
.
T
)
{
if
TestArchiveBucket
!=
""
{
tr
,
err
:=
NewGCSRepo
(
"testName"
,
TestArchiveBucket
,
nil
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
charts
,
err
:=
tr
.
ListCharts
(
TestShouldNotFindRegex
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
len
(
charts
)
!=
0
{
t
.
Fatalf
(
"expected zero charts to match regex, got %d"
,
len
(
charts
))
}
}
}
func
TestGetChart
(
t
*
testing
.
T
)
{
if
TestArchiveBucket
!=
""
{
tr
,
err
:=
NewGCSRepo
(
"testName"
,
TestArchiveBucket
,
nil
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
tc
,
err
:=
tr
.
GetChart
(
TestArchiveName
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
have
:=
tc
.
Chartfile
()
want
,
err
:=
chart
.
LoadChartfile
(
TestChartFile
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
reflect
.
DeepEqual
(
want
,
have
)
{
t
.
Fatalf
(
"retrieved an invalid chart
\n
want:%#v
\n
have:
\n
%#v
\n
"
,
want
,
have
)
}
}
}
func
TestGetChartWithInvalidName
(
t
*
testing
.
T
)
{
var
invalidURL
=
"https://bucket"
_
,
err
:=
NewGCSRepo
(
"testName"
,
invalidURL
,
nil
)
if
err
==
nil
{
t
.
Fatalf
(
"expected error did not occur for invalid URL"
)
}
}
pkg/repo/testdata/README.md
0 → 100644
View file @
33ca00f8
The testdata directory here holds charts that match the specification.
The
`fromnitz/`
directory contains a chart that matches the chart
specification.
The
`frobnitz-0.0.1.tgz`
file is an archive of the
`frobnitz`
directory.
pkg/repo/testdata/frobnitz-0.0.1.tgz
0 → 100644
View file @
33ca00f8
File added
pkg/repo/testdata/frobnitz/Chart.yaml
0 → 100644
View file @
33ca00f8
#helm:generate foo
name
:
frobnitz
description
:
This is a frobniz.
version
:
"
1.2.3-alpha.1+12345"
keywords
:
-
frobnitz
-
sprocket
-
dodad
maintainers
:
-
name
:
The Helm Team
email
:
helm@example.com
-
name
:
Someone Else
email
:
nobody@example.com
source
:
-
https://example.com/foo/bar
home
:
http://example.com
dependencies
:
-
name
:
thingerbob
location
:
https://example.com/charts/thingerbob-3.2.1.tgz
version
:
^3
environment
:
-
name
:
Kubernetes
version
:
~1.1
extensions
:
-
extensions/v1beta1
-
extensions/v1beta1/daemonset
apiGroups
:
-
3rdParty
expander
:
name
:
Expandybird
entrypoint
:
templates/wordpress.jinja
schema
:
wordpress.jinja.schema
\ No newline at end of file
pkg/repo/testdata/frobnitz/LICENSE
0 → 100644
View file @
33ca00f8
LICENSE placeholder.
pkg/repo/testdata/frobnitz/README.md
0 → 100644
View file @
33ca00f8
# Frobnitz
This is an example chart.
## Usage
This is an example. It has no usage.
## Development
For developer info, see the top-level repository.
pkg/repo/testdata/frobnitz/docs/README.md
0 → 100644
View file @
33ca00f8
This is a placeholder for documentation.
pkg/repo/testdata/frobnitz/hooks/pre-install.py
0 → 100644
View file @
33ca00f8
# Placeholder.
pkg/repo/testdata/frobnitz/icon.svg
0 → 100644
View file @
33ca00f8
<?xml version="1.0"?>
<svg
xmlns:svg=
"http://www.w3.org/2000/svg"
xmlns=
"http://www.w3.org/2000/svg"
xmlns:xlink=
"http://www.w3.org/1999/xlink"
version=
"1.0"
width=
"256"
height=
"256"
id=
"test"
>
<desc>
Example icon
</desc>
<rect
id=
"first"
x=
"2"
y=
"2"
width=
"40"
height=
"60"
fill=
"navy"
/>
<rect
id=
"second"
x=
"15"
y=
"4"
width=
"40"
height=
"60"
fill=
"red"
/>
</svg>
pkg/repo/testdata/frobnitz/templates/wordpress-resources.yaml
0 → 100644
View file @
33ca00f8
# Google Cloud Deployment Manager template
resources
:
-
name
:
nfs-disk
type
:
compute.v1.disk
properties
:
zone
:
us-central1-b
sizeGb
:
200
-
name
:
mysql-disk
type
:
compute.v1.disk
properties
:
zone
:
us-central1-b
sizeGb
:
200
pkg/repo/testdata/frobnitz/templates/wordpress.jinja
0 → 100644
View file @
33ca00f8
#helm:generate dm_template
{% set PROPERTIES = properties or {} %}
{% set PROJECT = PROPERTIES['project'] or 'dm-k8s-testing' %}
{% set NFS_SERVER = PROPERTIES['nfs-server'] or {} %}
{% set NFS_SERVER_IP = NFS_SERVER['ip'] or '10.0.253.247' %}
{% set NFS_SERVER_PORT = NFS_SERVER['port'] or 2049 %}
{% set NFS_SERVER_DISK = NFS_SERVER['disk'] or 'nfs-disk' %}
{% set NFS_SERVER_DISK_FSTYPE = NFS_SERVER['fstype'] or 'ext4' %}
{% set NGINX = PROPERTIES['nginx'] or {} %}
{% set NGINX_PORT = 80 %}
{% set NGINX_REPLICAS = NGINX['replicas'] or 2 %}
{% set WORDPRESS_PHP = PROPERTIES['wordpress-php'] or {} %}
{% set WORDPRESS_PHP_REPLICAS = WORDPRESS_PHP['replicas'] or 2 %}
{% set WORDPRESS_PHP_PORT = WORDPRESS_PHP['port'] or 9000 %}
{% set MYSQL = PROPERTIES['mysql'] or {} %}
{% set MYSQL_PORT = MYSQL['port'] or 3306 %}
{% set MYSQL_PASSWORD = MYSQL['password'] or 'mysql-password' %}
{% set MYSQL_DISK = MYSQL['disk'] or 'mysql-disk' %}
{% set MYSQL_DISK_FSTYPE = MYSQL['fstype'] or 'ext4' %}
resources:
- name: nfs
type: github.com/kubernetes/application-dm-templates/storage/nfs:v1
properties:
ip: {{ NFS_SERVER_IP }}
port: {{ NFS_SERVER_PORT }}
disk: {{ NFS_SERVER_DISK }}
fstype: {{NFS_SERVER_DISK_FSTYPE }}
- name: nginx
type: github.com/kubernetes/application-dm-templates/common/replicatedservice:v2
properties:
service_port: {{ NGINX_PORT }}
container_port: {{ NGINX_PORT }}
replicas: {{ NGINX_REPLICAS }}
external_service: true
image: gcr.io/{{ PROJECT }}/nginx:latest
volumes:
- mount_path: /var/www/html
persistentVolumeClaim:
claimName: nfs
- name: mysql
type: github.com/kubernetes/application-dm-templates/common/replicatedservice:v2
properties:
service_port: {{ MYSQL_PORT }}
container_port: {{ MYSQL_PORT }}
replicas: 1
image: mysql:5.6
env:
- name: MYSQL_ROOT_PASSWORD
value: {{ MYSQL_PASSWORD }}
volumes:
- mount_path: /var/lib/mysql
gcePersistentDisk:
pdName: {{ MYSQL_DISK }}
fsType: {{ MYSQL_DISK_FSTYPE }}
- name: wordpress-php
type: github.com/kubernetes/application-dm-templates/common/replicatedservice:v2
properties:
service_name: wordpress-php
service_port: {{ WORDPRESS_PHP_PORT }}
container_port: {{ WORDPRESS_PHP_PORT }}
replicas: 2
image: wordpress:fpm
env:
- name: WORDPRESS_DB_PASSWORD
value: {{ MYSQL_PASSWORD }}
- name: WORDPRESS_DB_HOST
value: mysql-service
volumes:
- mount_path: /var/www/html
persistentVolumeClaim:
claimName: nfs
pkg/repo/testdata/frobnitz/templates/wordpress.jinja.schema
0 → 100644
View file @
33ca00f8
info:
title: Wordpress
description: |
Defines a Wordpress website by defining four replicated services: an NFS service, an nginx service, a wordpress-php service, and a MySQL service.
The nginx service and the Wordpress-php service both use NFS to share files.
properties:
project:
type: string
default: dm-k8s-testing
description: Project location to load the images from.
nfs-service:
type: object
properties:
ip:
type: string
default: 10.0.253.247
description: The IP of the NFS service.
port:
type: int
default: 2049
description: The port of the NFS service.
disk:
type: string
default: nfs-disk
description: The name of the persistent disk the NFS service uses.
fstype:
type: string
default: ext4
description: The filesystem the disk of the NFS service uses.
nginx:
type: object
properties:
replicas:
type: int
default: 2
description: The number of replicas for the nginx service.
wordpress-php:
type: object
properties:
replicas:
type: int
default: 2
description: The number of replicas for the wordpress-php service.
port:
type: int
default: 9000
description: The port the wordpress-php service runs on.
mysql:
type: object
properties:
port:
type: int
default: 3306
description: The port the MySQL service runs on.
password:
type: string
default: mysql-password
description: The root password of the MySQL service.
disk:
type: string
default: mysql-disk
description: The name of the persistent disk the MySQL service uses.
fstype:
type: string
default: ext4
description: The filesystem the disk of the MySQL service uses.
pkg/repo/testdata/frobnitz/templates/wordpress.yaml
0 → 100644
View file @
33ca00f8
imports
:
-
path
:
wordpress.jinja
resources
:
-
name
:
wordpress
type
:
wordpress.jinja
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