vaikas-google 9 years ago
commit 9d1a5d8c91

@ -341,7 +341,7 @@ processing deployments. It uses the following process:
1. Create a new deployment with a manifest containing _inputConfig_ from the
user request
1. Call out to he **expandybird** service to expand the _inputConfig_
1. Call out to the **expandybird** service to expand the _inputConfig_
1. Store the resulting _expandedConfig_ and _layout_
1. Call out to the **resourcifier** service to perform processing on resources
from the _expandedConfig_

@ -1,17 +1,22 @@
# Makefile for the Docker image gcr.io/$(PROJECT)/expandybird
# Makefile for the Docker image $(DOCKER_REGISTRY)/$(PROJECT)/expandybird
# MAINTAINER: Jack Greenfield <jackgr@google.com>
# If you update this image please check the tag value before pushing.
.PHONY : all build test push container clean
PREFIX := gcr.io/$(PROJECT)
DOCKER_REGISTRY := gcr.io
PREFIX := $(DOCKER_REGISTRY)/$(PROJECT)
IMAGE := expandybird
TAG := latest
DIR := .
push: container
ifeq ($(DOCKER_REGISTRY),gcr.io)
gcloud docker push $(PREFIX)/$(IMAGE):$(TAG)
else
docker push $(PREFIX)/$(IMAGE):$(TAG)
endif
container: expandybird
cp $(shell which expandybird) .
@ -25,4 +30,4 @@ expandybird:
clean:
-docker rmi $(PREFIX)/$(IMAGE):$(TAG)
rm -f expandybird

@ -68,14 +68,14 @@ func NewExpansionHandler(backend expander.Expander) restful.RouteFunction {
output, err := backend.ExpandTemplate(template)
if err != nil {
message := fmt.Sprintf("error (%s) expanding template:\n%v\n", err, template)
message := fmt.Sprintf("error expanding template: %s", err)
logAndReturnErrorFromHandler(http.StatusBadRequest, message, resp)
return
}
response, err := expander.NewExpansionResponse(output)
if err != nil {
message := fmt.Sprintf("error (%s) marshaling output:\n%v\n", err, output)
message := fmt.Sprintf("error marshaling output: %s", err)
logAndReturnErrorFromHandler(http.StatusBadRequest, message, resp)
return
}

@ -1,10 +1,11 @@
# Makefile for the Docker image gcr.io/$(PROJECT)/manager
# Makefile for the Docker image $(DOCKER_REGISTRY)/$(PROJECT)/manager
# MAINTAINER: Jack Greenfield <jackgr@google.com>
# If you update this image please check the tag value before pushing.
.PHONY : all build test push container clean .project
PREFIX := gcr.io/$(PROJECT)
DOCKER_REGISTRY := gcr.io
PREFIX := $(DOCKER_REGISTRY)/$(PROJECT)
IMAGE := manager
TAG := latest
@ -12,11 +13,15 @@ ROOT_DIR := $(abspath ./..)
DIR = $(ROOT_DIR)
push: container
ifeq ($(DOCKER_REGISTRY),gcr.io)
gcloud docker push $(PREFIX)/$(IMAGE):$(TAG)
else
docker push $(PREFIX)/$(IMAGE):$(TAG)
endif
container:
container:
docker build -t $(PREFIX)/$(IMAGE):$(TAG) -f Dockerfile $(DIR)
clean:
-docker rmi $(PREFIX)/$(IMAGE):$(TAG)

@ -100,7 +100,7 @@ func (d *deployer) PutConfiguration(configuration *Configuration) error {
func (d *deployer) callServiceWithConfiguration(method, operation string, configuration *Configuration) error {
callback := func(e error) error {
return fmt.Errorf("cannot %s configuration (%s)", operation, e)
return fmt.Errorf("cannot %s configuration: %s", operation, e)
}
y, err := yaml.Marshal(configuration)
@ -129,14 +129,14 @@ func (d *deployer) callService(method, url string, reader io.Reader, callback fo
}
defer response.Body.Close()
if response.StatusCode < http.StatusOK ||
response.StatusCode >= http.StatusMultipleChoices {
err := fmt.Errorf("deployer service response:\n%v\n", response)
body, err := ioutil.ReadAll(response.Body)
if err != nil {
return nil, callback(err)
}
body, err := ioutil.ReadAll(response.Body)
if err != nil {
if response.StatusCode < http.StatusOK ||
response.StatusCode >= http.StatusMultipleChoices {
err := fmt.Errorf("resourcifier response:\n%s", body)
return nil, callback(err)
}

@ -54,7 +54,7 @@ func (e *expander) getBaseURL() string {
}
func expanderError(t *Template, err error) error {
return fmt.Errorf("cannot expand template named %s (%s):\n%s\n", t.Name, err, t.Content)
return fmt.Errorf("cannot expand template named %s (%s):\n%s", t.Name, err, t.Content)
}
// ExpanderResponse gives back a layout, which has nested structure
@ -117,7 +117,7 @@ func (e *expander) ExpandTemplate(t Template) (*ExpandedTemplate, error) {
// 4. If type resolution resulted in new imports being available, return to 2.
config := &Configuration{}
if err := yaml.Unmarshal([]byte(t.Content), config); err != nil {
e := fmt.Errorf("Unable to unmarshal configuration (%s): %s\n", err, t.Content)
e := fmt.Errorf("Unable to unmarshal configuration (%s): %s", err, t.Content)
return nil, e
}
@ -127,7 +127,7 @@ func (e *expander) ExpandTemplate(t Template) (*ExpandedTemplate, error) {
// Start things off by attempting to resolve the templates in a first pass.
newImp, err := e.typeResolver.ResolveTypes(config, t.Imports)
if err != nil {
e := fmt.Errorf("type resolution failed:%s\n", err)
e := fmt.Errorf("type resolution failed: %s", err)
return nil, expanderError(&t, e)
}
@ -137,7 +137,7 @@ func (e *expander) ExpandTemplate(t Template) (*ExpandedTemplate, error) {
// Now expand with everything imported.
result, err := e.expandTemplate(&t)
if err != nil {
e := fmt.Errorf("template expansion:%s\n", err)
e := fmt.Errorf("template expansion: %s", err)
return nil, expanderError(&t, e)
}
@ -152,7 +152,7 @@ func (e *expander) ExpandTemplate(t Template) (*ExpandedTemplate, error) {
newImp, err = e.typeResolver.ResolveTypes(result.Config, nil)
if err != nil {
e := fmt.Errorf("type resolution failed:%s\n", err)
e := fmt.Errorf("type resolution failed: %s", err)
return nil, expanderError(&t, e)
}
@ -167,7 +167,7 @@ func (e *expander) ExpandTemplate(t Template) (*ExpandedTemplate, error) {
content, err = yaml.Marshal(result.Config)
t.Content = string(content)
if err != nil {
e := fmt.Errorf("Unable to unmarshal response from expander (%s): %s\n",
e := fmt.Errorf("Unable to unmarshal response from expander (%s): %s",
err, result.Config)
return nil, expanderError(&t, e)
}
@ -183,31 +183,31 @@ func (e *expander) expandTemplate(t *Template) (*ExpandedTemplate, error) {
response, err := http.Post(e.getBaseURL(), "application/json", ioutil.NopCloser(bytes.NewReader(j)))
if err != nil {
e := fmt.Errorf("http POST failed:%s\n", err)
e := fmt.Errorf("http POST failed: %s", err)
return nil, e
}
defer response.Body.Close()
if response.StatusCode != http.StatusOK {
err := fmt.Errorf("expander service response:%v", response)
return nil, err
}
defer response.Body.Close()
body, err := ioutil.ReadAll(response.Body)
if err != nil {
e := fmt.Errorf("error reading response:%s\n", err)
e := fmt.Errorf("error reading response: %s", err)
return nil, e
}
if response.StatusCode != http.StatusOK {
err := fmt.Errorf("expandybird response:\n%s", body)
return nil, err
}
er := &ExpansionResponse{}
if err := json.Unmarshal(body, er); err != nil {
e := fmt.Errorf("cannot unmarshal response body (%s):%s\n", err, body)
e := fmt.Errorf("cannot unmarshal response body (%s):%s", err, body)
return nil, e
}
template, err := er.Unmarshal()
if err != nil {
e := fmt.Errorf("cannot unmarshal response yaml (%s):%v\n", err, er)
e := fmt.Errorf("cannot unmarshal response yaml (%s):%v", err, er)
return nil, e
}

@ -1,10 +1,11 @@
# Makefile for the Docker image gcr.io/$(PROJECT)/resourcifier
# Makefile for the Docker image $(DOCKER_REGISTRY)/$(PROJECT)/resourcifier
# MAINTAINER: Jack Greenfield <jackgr@google.com>
# If you update this image please check the tag value before pushing.
.PHONY : all build test push container clean
PREFIX := gcr.io/$(PROJECT)
DOCKER_REGISTRY := gcr.io
PREFIX := $(DOCKER_REGISTRY)/$(PROJECT)
IMAGE := resourcifier
TAG := latest
@ -12,7 +13,11 @@ ROOT_DIR := $(abspath ./..)
DIR = $(ROOT_DIR)
push: container
ifeq ($(DOCKER_REGISTRY),gcr.io)
gcloud docker push $(PREFIX)/$(IMAGE):$(TAG)
else
docker push $(PREFIX)/$(IMAGE):$(TAG)
endif
container:
docker build -t $(PREFIX)/$(IMAGE):$(TAG) -f Dockerfile $(DIR)

@ -0,0 +1,7 @@
imports:
- path: redis.jinja
resources:
- name: redis
type: redis.jinja
properties: null

@ -99,10 +99,9 @@ def GenerateConfig(context):
return yaml.dump(config)
# Generates labels either from the context.properties['labels'] or generates
# a default label 'name':name
def GenerateLabels(context, name):
"""Generates labels from context.properties['labels'] or creates default.
"""Generates labels either from the context.properties['labels'] or
generates a default label 'name':name
We make a deep copy of the context.properties['labels'] section to avoid
linking in the yaml document, which I believe reduces readability of the

Loading…
Cancel
Save