Controllers



Base Controller

Controller that handles the base command, mpaas.

All other commands are nested inside this controller.

Handles commands such as:

  • Use

  • Download

class src.mpaas.controllers.base.Base(*args, **kw)

Bases: cement.ext.ext_argparse.ArgparseController

Child class of Controller class.

class Meta

Bases: object

Meta class attributes. base represents base ‘mpaas’ command.

arguments = [(['-v', '--version'], {'action': 'version', 'version': '\nCLI for helm chart customization and deployment 0.1.1\nCement Framework 3.0.4\nPython 3.8.1\nPlatform Linux-4.15.0-74-generic-x86_64-with-glibc2.2.5\n'})]
description = 'CLI for helm chart customization and deployment'
epilog = 'Usage: kompaas command1 --foo bar'
label = 'base'
usage = 'kompaas [SUB-COMMANDS]'
context()

Prints current context.


Chart Controller

Module that handles charts.

Charts are standard helm charts stored in a project.

They are created from templates.

Supports:

  • Creating

  • Using

  • Getting

  • Deleting

class src.mpaas.controllers.chart.Chart(*args, **kw)

Bases: cement.ext.ext_argparse.ArgparseController

Child class of the Controller class. Handles the ‘chart’ sub-commands.

class Meta

Bases: object

Meta class attributes. ‘chart’ is a nested sub-command of the base ‘mpaas’ command

aliases = ['charts']
help = 'Handle charts.'
label = 'chart'
stacked_on = 'base'
stacked_type = 'nested'
usage = 'kompaas [SUB-COMMANDS]'
check_dependancy(chart_name)

Check if a requirement.yaml is present in chart

create()

Adds a helm chart from a template to the current project and names it.

define_helm_repo_add(chart_dict)

Loop to add repo in helm

delete()

Method that deletes target chart from current project.

fill_dependancy(chart_name)

Organize dependancy flow

get()

Lists all charts from the current project. Renders output using a jinja2 template.

parse_requirements(requirement_path)

Read requirements.yaml in a chart and parse it

update_dependency(chart_name)

Launch helm dependency command

use()

Method that sets chart context to target chart


Config Controller

Module that handles configs. A config is nothing more than a kubeconfig file. Multiple configs can be created to easily switch between clusters for example.

Supports:

  • Creating

  • Using

  • Getting

  • Deleting

class src.mpaas.controllers.config.Config(*args, **kw)

Bases: cement.ext.ext_argparse.ArgparseController

Child class of the Controller class. Handles the ‘configs’ sub-commands.

class Meta

Bases: object

Meta class attributes. ‘config’ is a nested sub-command of the base ‘mpaas’ command

aliases = ['configs']
help = 'Handle configs.'
label = 'config'
stacked_on = 'base'
stacked_type = 'nested'
usage = 'kompaas [SUB-COMMANDS]'
create()

Handles creating configs

default()

Method that restores the default kube config.

delete()

Method that sets the current config.

describe()

Method that renders a list of target config’s attributes

get()

Method that returns a list of all current configs

use()

Method that sets the current config.


Museum Controller

Module that handles museums. Museums are repositories for helm charts.

class src.mpaas.controllers.museum.Museum(*args, **kw)

Bases: cement.ext.ext_argparse.ArgparseController

Child class of the Controller class. Handles the ‘museum’ sub-commands.

class Meta

Bases: object

Meta class attributes. ‘museum’ is a nested sub-command of the base ‘mpaas’ command

aliases = ['museums']
help = 'Handle museums.'
label = 'museum'
stacked_on = 'base'
stacked_type = 'nested'
usage = 'kompaas [SUB-COMMANDS]'
add()

Add a museum repo and do nothing more

download()

Downloads templates from a museum

get()

Downloads new templates from target chart museum. Places them in the app’s templates directory.


Project Controller

Module that handles projects

A project serves as a scope to store one or multiple charts together.

Supports:

  • Creating

  • Using

  • Getting

  • Deleting

class src.mpaas.controllers.project.Project(*args, **kw)

Bases: cement.ext.ext_argparse.ArgparseController

Child class of the Controller class. Handles the ‘project’ sub-commands.

class Meta

Bases: object

Meta class attributes. ‘project’ is a nested sub-command of the base ‘mpaas’ command

aliases = ['projects']
help = 'Handle projects.'
label = 'project'
stacked_on = 'base'
stacked_type = 'nested'
usage = 'kompaas [SUB-COMMANDS]'
create()

Method that creates a new project. Requires a name.

delete()

Deletes target project. Sets current context to none if the context was set to deleted project.

deploy()

Deploys current project using kubectl. You can choose destination namespace using -n . You can perform a dry-run by using –dryrun

get()

Lists current projects from the projects directory. Renders output using a jinja2 template.

render()

Outputs the yaml representation of current project using helm.

use()

Method to set current context to target project.

Template Controller

Module that handles templates.

Templates are nothing more than helm charts.

They are required to create a chart object in a project.

Supports:

  • Creating

  • Getting

  • Deleting

class src.mpaas.controllers.template.Template(*args, **kw)

Bases: cement.ext.ext_argparse.ArgparseController

Child class of the Controller class. Handles the ‘create’ sub-commands.

class Meta

Bases: object

Meta class attributes. ‘template’ is a nested sub-command of the base ‘mpaas’ command

aliases = ['templates']
help = 'Handle templates.'
label = 'template'
stacked_on = 'base'
stacked_type = 'nested'
usage = 'kompaas [SUB-COMMANDS]'
delete()

Method to delete target template

get()

Lists all templates currently in the mpaas template directory, or in target location if -l is specified.


Values Controller

Module that handles values.

Values are reprensentations of yaml key/value pairs.

Supports:

  • Updating

  • Replacing

  • Getting

  • Deleting

class src.mpaas.controllers.value.Value(*args, **kw)

Bases: cement.ext.ext_argparse.ArgparseController

Child class of the Controller class. Handles the ‘create’ sub-commands.

class Meta

Bases: object

Meta class attributes. ‘create’ is a nested sub-command of the base ‘mpaas’ command

aliases = ['values']
help = 'Handle values.'
label = 'value'
stacked_on = 'base'
stacked_type = 'nested'
usage = 'kompaas [SUB-COMMANDS]'
delete()

Deletes a value from target values.yaml file

get()

Lists all values from current chart in current project. Renders output using jinja2 template.

replace()

Method that replaces a value in a chart in target project.

test()
update()

Adds a value to a list or dictionary inside target values.yaml file