Beispiel #1
0
 def test_add_env_fromconref_has_env(self):
     pod_spec = V1PodSpec(containers=[
         V1Container(name='model',
                     image="image",
                     env=[client.V1EnvVar(name='var0', value='value0')])
     ], )
     env_vars = {'var1': {'name':'config1', 'key':'key1', 'type':'configmap'}, \
                 'var2': {'name':'secret2', 'key':'key2', 'type':'secret'}, \
                 'var3':'value3'
                 }
     k8s_utils.add_env(env_vars=env_vars)(None, pod_spec, "")
     actual = pod_spec.containers[0].env
     expected = [{
         'name': 'var0',
         'value': 'value0',
         'value_from': None
     }, {
         'name': 'var1',
         'value': 'value1',
         'value_from': None
     }, {
         'name': 'var2',
         'value': 'value2',
         'value_from': None
     }]
     # assert str(actual) == str(expected)
     print("actual:{}".format(str(actual)))
     print("expected:{}".format(str(expected)))
     print(pod_spec)
     self.assertTrue(str(actual) == str(expected))
Beispiel #2
0
 def test_add_env_no_env(self):
     pod_spec = V1PodSpec(
         containers=[V1Container(name='model', image="image")], )
     env_vars = {'var1': 'value1', 'var2': 'value2'}
     k8s_utils.add_env(env_vars=env_vars)(None, pod_spec, "")
     actual = pod_spec.containers[0].env
     expected = [{
         'name': 'var1',
         'value': 'value1',
         'value_from': None
     }, {
         'name': 'var2',
         'value': 'value2',
         'value_from': None
     }]
     assert str(actual) == str(expected)
Beispiel #3
0
def test_add_env_has_env():
    pod_spec = V1PodSpec(containers=[
        V1Container(name='model',
                    image="image",
                    env=[client.V1EnvVar(name='var0', value='value0')])
    ], )
    env_vars = {'var1': 'value1', 'var2': 'value2'}
    k8s_utils.add_env(env_vars=env_vars)(None, pod_spec, "")
    actual = pod_spec.containers[0].env
    expected = [{
        'name': 'var0',
        'value': 'value0',
        'value_from': None
    }, {
        'name': 'var1',
        'value': 'value1',
        'value_from': None
    }, {
        'name': 'var2',
        'value': 'value2',
        'value_from': None
    }]
    assert str(actual) == str(expected)