-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds TemplateProcessor implementation using the default ExpressionValueGenerator, which is capable of transforming Template api objects into Config api objects. Authors: Michal Fojtik <mfojtik@redhat.com> Vojtech Vitek <vvitek@redhat.com>
- Loading branch information
1 parent
db1afb5
commit 1ba20a8
Showing
28 changed files
with
1,104 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
{ | ||
"id": "guestbook", | ||
"kind": "Template", | ||
"name": "guestbook-example", | ||
"description": "Example shows how to build a simple multi-tier application using Kubernetes and Docker", | ||
"parameters": [ | ||
{ | ||
"name": "ADMIN_USERNAME", | ||
"description": "Guestbook administrator username", | ||
"type": "string", | ||
"expression": "admin[A-Z0-9]{3}" | ||
}, | ||
{ | ||
"name": "ADMIN_PASSWORD", | ||
"description": "Guestboot administrator password", | ||
"type": "string", | ||
"expression": "[a-zA-Z0-9]{8}" | ||
}, | ||
{ | ||
"name": "REDIS_PASSWORD", | ||
"description": "The password Redis use for communication", | ||
"type": "string", | ||
"expression": "[a-zA-Z0-9]{8}" | ||
} | ||
], | ||
"items": [ | ||
{ | ||
"id": "frontend", | ||
"kind": "Service", | ||
"apiVersion": "v1beta1", | ||
"port": 5432, | ||
"selector": { | ||
"name": "frontend" | ||
} | ||
}, | ||
{ | ||
"id": "redismaster", | ||
"kind": "Service", | ||
"apiVersion": "v1beta1", | ||
"port": 10000, | ||
"selector": { | ||
"name": "redis-master" | ||
} | ||
}, | ||
{ | ||
"id": "redisslave", | ||
"kind": "Service", | ||
"apiVersion": "v1beta1", | ||
"port": 10001, | ||
"labels": { | ||
"name": "redisslave" | ||
}, | ||
"selector": { | ||
"name": "redisslave" | ||
} | ||
}, | ||
{ | ||
"id": "redis-master-2", | ||
"kind": "Pod", | ||
"apiVersion": "v1beta1", | ||
"desiredState": { | ||
"manifest": { | ||
"version": "v1beta1", | ||
"id": "redis-master-2", | ||
"containers": [{ | ||
"name": "master", | ||
"image": "dockerfile/redis", | ||
"env": [ | ||
{ | ||
"name": "REDIS_PASSWORD", | ||
"value": "${REDIS_PASSWORD}" | ||
} | ||
], | ||
"ports": [{ | ||
"containerPort": 6379 | ||
}] | ||
}] | ||
} | ||
}, | ||
"labels": { | ||
"name": "redis-master" | ||
} | ||
}, | ||
{ | ||
"id": "frontendController", | ||
"kind": "ReplicationController", | ||
"apiVersion": "v1beta1", | ||
"desiredState": { | ||
"replicas": 3, | ||
"replicaSelector": {"name": "frontend"}, | ||
"podTemplate": { | ||
"desiredState": { | ||
"manifest": { | ||
"version": "v1beta1", | ||
"id": "frontendController", | ||
"containers": [{ | ||
"name": "php-redis", | ||
"image": "brendanburns/php-redis", | ||
"env": [ | ||
{ | ||
"name": "ADMIN_USERNAME", | ||
"value": "${ADMIN_USERNAME}" | ||
}, | ||
{ | ||
"name": "ADMIN_PASSWORD", | ||
"value": "${ADMIN_PASSWORD}" | ||
}, | ||
{ | ||
"name": "REDIS_PASSWORD", | ||
"value": "${REDIS_PASSWORD}" | ||
} | ||
], | ||
"ports": [{"containerPort": 80, "hostPort": 8000}] | ||
}] | ||
} | ||
}, | ||
"labels": {"name": "frontend"} | ||
}}, | ||
"labels": {"name": "frontend"} | ||
}, | ||
{ | ||
"id": "redisSlaveController", | ||
"kind": "ReplicationController", | ||
"apiVersion": "v1beta1", | ||
"desiredState": { | ||
"replicas": 2, | ||
"replicaSelector": {"name": "redisslave"}, | ||
"podTemplate": { | ||
"desiredState": { | ||
"manifest": { | ||
"version": "v1beta1", | ||
"id": "redisSlaveController", | ||
"containers": [{ | ||
"name": "slave", | ||
"image": "brendanburns/redis-slave", | ||
"env": [ | ||
{ | ||
"name": "REDIS_PASSWORD", | ||
"value": "${REDIS_PASSWORD}" | ||
} | ||
], | ||
"ports": [{"containerPort": 6379, "hostPort": 6380}] | ||
}] | ||
} | ||
}, | ||
"labels": {"name": "redisslave"} | ||
}}, | ||
"labels": {"name": "redisslave"} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
package api | ||
|
||
import () | ||
import () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Package api defines and registers types for Config objects. | ||
package api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package api | ||
|
||
import "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" | ||
|
||
func init() { | ||
runtime.AddKnownTypes("", Config{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package api | ||
|
||
import ( | ||
kubeapi "github.com/GoogleCloudPlatform/kubernetes/pkg/api" | ||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" | ||
) | ||
|
||
// Config contains a set of Kubernetes resources to be applied. | ||
// TODO: Unify with Kubernetes Config | ||
// https://github.com/GoogleCloudPlatform/kubernetes/pull/1007 | ||
type Config struct { | ||
kubeapi.JSONBase `json:",inline" yaml:",inline"` | ||
|
||
// Required: Name identifies the Config. | ||
Name string `json:"name" yaml:"name"` | ||
|
||
// Optional: Description describes the Config. | ||
Description string `json:"description" yaml:"description"` | ||
|
||
// Required: Items is an array of Kubernetes resources of Service, | ||
// Pod and/or ReplicationController kind. | ||
// TODO: Handle unregistered types. Define custom []interface{} | ||
// type and its unmarshaller instead of []runtime.Object. | ||
Items []runtime.Object `json:"items" yaml:"items"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package v1beta1 | ||
|
||
import "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" | ||
|
||
func init() { | ||
runtime.AddKnownTypes("v1beta1", Config{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package v1beta1 | ||
|
||
import ( | ||
kubeapi "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1" | ||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" | ||
) | ||
|
||
// Config contains a set of Kubernetes resources to be applied. | ||
// TODO: Unify with Kubernetes Config | ||
// https://github.com/GoogleCloudPlatform/kubernetes/pull/1007 | ||
type Config struct { | ||
kubeapi.JSONBase `json:",inline" yaml:",inline"` | ||
|
||
// Required: Name identifies the Config. | ||
Name string `json:"name" yaml:"name"` | ||
|
||
// Optional: Description describes the Config. | ||
Description string `json:"description" yaml:"description"` | ||
|
||
// Required: Items is an array of Kubernetes resources of Service, | ||
// Pod and/or ReplicationController kind. | ||
// TODO: Handle unregistered types. Define custom []interface{} | ||
// type and its unmarshaller instead of []runtime.Object. | ||
Items []runtime.Object `json:"items" yaml:"items"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Package api defines and registers types for Template objects. | ||
package api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package api | ||
|
||
import "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" | ||
|
||
func init() { | ||
runtime.AddKnownTypes("", Template{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package api | ||
|
||
import ( | ||
kubeapi "github.com/GoogleCloudPlatform/kubernetes/pkg/api" | ||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" | ||
) | ||
|
||
// Template contains the inputs needed to produce a Config. | ||
type Template struct { | ||
kubeapi.JSONBase `json:",inline" yaml:",inline"` | ||
|
||
// Required: Name identifies the Template. | ||
Name string `json:"name" yaml:"name"` | ||
|
||
// Optional: Description describes the Template. | ||
Description string `json:"description" yaml:"description"` | ||
|
||
// Required: Items is an array of Kubernetes resources of Service, | ||
// Pod and/or ReplicationController kind. | ||
// TODO: Handle unregistered types. Define custom []interface{} | ||
// type and its unmarshaller instead of []runtime.Object. | ||
Items []runtime.Object `json:"items" yaml:"items"` | ||
|
||
// Optional: Parameters is an array of Parameters used during the | ||
// Template to Config transformation. | ||
Parameters []Parameter `json:"parameters,omitempty" yaml:"parameters,omitempty"` | ||
} | ||
|
||
// Parameter defines a name/value variable that is to be processed during | ||
// the Template to Config transformation. | ||
type Parameter struct { | ||
// Required: Name uniquely identifies the Parameter. A TemplateProcessor | ||
// searches given Template for all occurances of the Parameter name, ie. | ||
// ${PARAM_NAME}, and replaces it with it's corresponding Parameter value. | ||
Name string `json:"name" yaml:"name"` | ||
|
||
// Optional: Description describes the Parameter. | ||
Description string `json:"description" yaml:"description"` | ||
|
||
// Required: Type defines the type of the Parameter value. | ||
Type string `json:"type" yaml:"type"` | ||
|
||
// Optional: Expression generates new Value data using the | ||
// GeneratorExpressionValue expression. | ||
// TODO: Support more Generator types. | ||
Expression string `json:"expression,omitempty" yaml:"expression,omitempty"` | ||
|
||
// Optional: Value holds the Parameter data. The data replaces all occurances | ||
// of the Parameter name during the Template to Config transformation. | ||
// TODO: Change this to interface{} and support more types than just string. | ||
Value string `json:"value,omitempty" yaml:"value,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package v1beta1 | ||
|
||
import "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" | ||
|
||
func init() { | ||
runtime.AddKnownTypes("v1beta1", Template{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package v1beta1 | ||
|
||
import ( | ||
kubeapi "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1" | ||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" | ||
) | ||
|
||
// Template contains the inputs needed to produce a Config. | ||
type Template struct { | ||
kubeapi.JSONBase `json:",inline" yaml:",inline"` | ||
|
||
// Required: Name identifies the Template. | ||
Name string `json:"name" yaml:"name"` | ||
|
||
// Optional: Description describes the Template. | ||
Description string `json:"description" yaml:"description"` | ||
|
||
// Required: Items is an array of Kubernetes resources of Service, | ||
// Pod and/or ReplicationController kind. | ||
// TODO: Handle unregistered types. Define custom []interface{} | ||
// type and its unmarshaller instead of []runtime.Object. | ||
Items []runtime.Object `json:"items" yaml:"items"` | ||
|
||
// Optional: Parameters is an array of Parameters used during the | ||
// Template to Config transformation. | ||
Parameters []Parameter `json:"parameters,omitempty" yaml:"parameters,omitempty"` | ||
} | ||
|
||
// Parameter defines a name/value variable that is to be processed during | ||
// the Template to Config transformation. | ||
type Parameter struct { | ||
// Required: Name uniquely identifies the Parameter. A TemplateProcessor | ||
// searches given Template for all occurances of the Parameter name, ie. | ||
// ${PARAM_NAME}, and replaces it with it's corresponding Parameter value. | ||
Name string `json:"name" yaml:"name"` | ||
|
||
// Optional: Description describes the Parameter. | ||
Description string `json:"description" yaml:"description"` | ||
|
||
// Required: Type defines the type of the Parameter value. | ||
Type string `json:"type" yaml:"type"` | ||
|
||
// Optional: Expression generates new Value data using the | ||
// GeneratorExpressionValue expression. | ||
// TODO: Support more Generator types. | ||
Expression string `json:"expression,omitempty" yaml:"expression,omitempty"` | ||
|
||
// Optional: Value holds the Parameter data. The data replaces all occurances | ||
// of the Parameter name during the Template to Config transformation. | ||
// TODO: Change this to interface{} and support more types than just string. | ||
Value string `json:"value,omitempty" yaml:"value,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Package validation has functions for validating the correctness of | ||
// Template objects and explaining what is wrong with them when | ||
// they aren't valid. | ||
package validation |
Oops, something went wrong.