forked from kapicorp/generators
-
Notifications
You must be signed in to change notification settings - Fork 0
/
k8s.py
32 lines (24 loc) · 977 Bytes
/
k8s.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from kapitan.inputs.kadet import BaseObj
class Base(BaseObj):
def new(self):
self.need("apiVersion")
self.need("kind")
self.need("name")
def body(self):
self.root.apiVersion = self.kwargs.apiVersion
self.root.kind = self.kwargs.kind
self.name = self.kwargs.name
self.root.metadata.name = self.kwargs.get("rendered_name", self.name)
self.add_label("name", self.root.metadata.name)
def add_labels(self, labels):
for key, value in labels.items():
self.add_label(key, value)
def add_label(self, key, value):
self.root.metadata.labels[key] = value
def add_namespace(self, namespace):
self.root.metadata.namespace = namespace
def add_annotations(self, annotations):
for key, value in annotations.items():
self.add_annotation(key, value)
def add_annotation(self, key, value):
self.root.metadata.annotations[key] = value