2
2
# -*- coding: utf-8
3
3
4
4
# Copyright 2017-2019 The FIAAS Authors
5
- #
5
+ #
6
6
# Licensed under the Apache License, Version 2.0 (the "License");
7
7
# you may not use this file except in compliance with the License.
8
8
# You may obtain a copy of the License at
9
- #
9
+ #
10
10
# http://www.apache.org/licenses/LICENSE-2.0
11
- #
11
+ #
12
12
# Unless required by applicable law or agreed to in writing, software
13
13
# distributed under the License is distributed on an "AS IS" BASIS,
14
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
20
21
21
from k8s .client import NotFound
22
22
from k8s .models .common import ObjectMeta
23
- from k8s .models .pod import Pod , ContainerPort , Container , LocalObjectReference , PodSpec , Volume , VolumeMount , \
24
- SecretVolumeSource
23
+ from k8s .models .pod import (
24
+ Pod ,
25
+ ContainerPort ,
26
+ Container ,
27
+ LocalObjectReference ,
28
+ PodSpec ,
29
+ PodDNSConfig ,
30
+ Volume ,
31
+ VolumeMount ,
32
+ SecretVolumeSource ,
33
+ )
25
34
26
35
NAME = "my-name"
27
36
NAMESPACE = "my-namespace"
@@ -34,6 +43,14 @@ def test_create_blank_pod(self):
34
43
pod = _create_pod ()
35
44
assert pod .metadata .name == NAME
36
45
assert pod .as_dict ()["metadata" ]["name" ] == NAME
46
+ assert "dnsOptions" not in pod .as_dict ()["spec" ]
47
+
48
+ def test_create_pod_with_dns_options (self ):
49
+ pod = _create_pod ()
50
+ pod .spec .dnsConfig = PodDNSConfig (
51
+ searches = ["other-namespace.svc.cluster.local" ],
52
+ )
53
+ assert pod .as_dict ()["spec" ]["dnsConfig" ]["searches" ] == ["other-namespace.svc.cluster.local" ]
37
54
38
55
def test_pod_created_if_not_exists (self , post , api_get ):
39
56
api_get .side_effect = NotFound ()
0 commit comments