Skip to content
Snippets Groups Projects
Commit d138c7c5 authored by mla's avatar mla
Browse files

Start development for default deployments.

Defauitl deployments require only a minimal set of configuration
input. Most values will be taken from defaults. It is up to the
project to re-define those default values.
parent 2ff809ba
No related branches found
No related tags found
No related merge requests found
......@@ -217,7 +217,8 @@ class Container(YamlBase):
@property
def command(self):
"""Command to execute on container start. must be a list or tuple"""
"""Command to execute on container start. must be a list or tuple.
Overrides the image command."""
return self._yaml['command']
@command.setter
def command(self, value):
......@@ -229,14 +230,16 @@ class Container(YamlBase):
@property
def args(self):
"""Args passed to the startup command """
"""Args passed to the startup command. Must be a list or tuple.
Overrides the image args. """
return self._yaml['args']
@args.setter
def args(self, value):
if isinstance(value, Iterable) and not isinstance(value, basestring):
self._yaml['args'] = value
else:
raise InvalidType('Invalid type for value {0}. Must be list or tuple'.format(repr(value)))
raise InvalidType('Invalid type for value {0}. Must be list or tuple'
.format(repr(value)))
@property
def workingDir(self):
......@@ -254,7 +257,7 @@ class Container(YamlBase):
@ConfigClass
class PodSpec(YamlBase):
def __init__(self, name, image, containers):
def __init__(self, name, containers):
self._volumes = []
self._containers = containers
self._restartPolicy = 'Always'
......@@ -359,13 +362,25 @@ class Deployment(object):
print config_dump(y, Dumper = yaml.SafeDumper, default_flow_style=False)
def DefaultPorts():
return [PortSpec(8080, 'TCP'), PortSpec(8443, 'TCP')]
def DefaultContainer(name, image):
return Container(name, image, DefaultPorts())
def DefaultDeployment(namespace, name, image):
return Deployment(namespace, name,
PodSpec(name,
DefaultContainer(name, image)))
def main():
ports = [PortSpec(8080, 'TCP'), PortSpec(8443, 'TCP')]
c = Container('test1', '172.30.1.1:5000/myproject/python-project', ports)
p = PodSpec('test1', "NoSuchImage", [c])
p = PodSpec('test1', [c])
d = Deployment('myproject', 'test1', p)
d.as_yaml()
dd = DefaultDeployment('myproject', 'test2','172.30.1.1:5000/myproject/python-project')
dd.as_yaml()
if __name__ == '__main__':
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment