本文整理汇总了Golang中github.com/GoogleCloudPlatform/kubernetes/pkg/securitycontext.ValidSecurityContextWithContainerDefaults函数的典型用法代码示例。如果您正苦于以下问题:Golang ValidSecurityContextWithContainerDefaults函数的具体用法?Golang ValidSecurityContextWithContainerDefaults怎么用?Golang ValidSecurityContextWithContainerDefaults使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ValidSecurityContextWithContainerDefaults函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestDecodeSinglePod
func TestDecodeSinglePod(t *testing.T) {
pod := &api.Pod{
TypeMeta: api.TypeMeta{
APIVersion: "",
},
ObjectMeta: api.ObjectMeta{
Name: "test",
UID: "12345",
Namespace: "mynamespace",
},
Spec: api.PodSpec{
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
Containers: []api.Container{{
Name: "image",
Image: "test/image",
ImagePullPolicy: "IfNotPresent",
TerminationMessagePath: "/dev/termination-log",
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults(),
}},
},
}
json, err := testapi.Codec().Encode(pod)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
parsed, podOut, err := tryDecodeSinglePod(json, noDefault)
if !parsed {
t.Errorf("expected to have parsed file: (%s)", string(json))
}
if err != nil {
t.Errorf("unexpected error: %v (%s)", err, string(json))
}
if !reflect.DeepEqual(pod, podOut) {
t.Errorf("expected:\n%#v\ngot:\n%#v\n%s", pod, podOut, string(json))
}
for _, version := range registered.RegisteredVersions {
externalPod, err := testapi.Converter().ConvertToVersion(pod, version)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
yaml, err := yaml.Marshal(externalPod)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
parsed, podOut, err = tryDecodeSinglePod(yaml, noDefault)
if !parsed {
t.Errorf("expected to have parsed file: (%s)", string(yaml))
}
if err != nil {
t.Errorf("unexpected error: %v (%s)", err, string(yaml))
}
if !reflect.DeepEqual(pod, podOut) {
t.Errorf("expected:\n%#v\ngot:\n%#v\n%s", pod, podOut, string(yaml))
}
}
}
开发者ID:chenzhen411,项目名称:kubernetes,代码行数:59,代码来源:common_test.go
示例2: CreateValidPod
func CreateValidPod(name, namespace, source string) *api.Pod {
return &api.Pod{
ObjectMeta: api.ObjectMeta{
UID: types.UID(name), // for the purpose of testing, this is unique enough
Name: name,
Namespace: namespace,
Annotations: map[string]string{kubelet.ConfigSourceAnnotationKey: source},
},
Spec: api.PodSpec{
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
Containers: []api.Container{
{
Name: "ctr",
Image: "image",
ImagePullPolicy: "IfNotPresent",
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults(),
},
},
},
}
}
开发者ID:chenzhen411,项目名称:kubernetes,代码行数:22,代码来源:config_test.go
示例3: validNewPod
func validNewPod() *api.Pod {
return &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Namespace: api.NamespaceDefault,
},
Spec: api.PodSpec{
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
Containers: []api.Container{
{
Name: "foo",
Image: "test",
ImagePullPolicy: api.PullAlways,
TerminationMessagePath: api.TerminationMessagePathDefault,
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults(),
},
},
},
}
}
开发者ID:Ima8,项目名称:kubernetes,代码行数:22,代码来源:etcd_test.go
示例4: newReplicationController
func newReplicationController(replicas int) *api.ReplicationController {
rc := &api.ReplicationController{
TypeMeta: api.TypeMeta{APIVersion: testapi.Version()},
ObjectMeta: api.ObjectMeta{
UID: util.NewUUID(),
Name: "foobar",
Namespace: api.NamespaceDefault,
ResourceVersion: "18",
},
Spec: api.ReplicationControllerSpec{
Replicas: replicas,
Selector: map[string]string{"foo": "bar"},
Template: &api.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{
Labels: map[string]string{
"name": "foo",
"type": "production",
},
},
Spec: api.PodSpec{
Containers: []api.Container{
{
Image: "foo/bar",
TerminationMessagePath: api.TerminationMessagePathDefault,
ImagePullPolicy: api.PullIfNotPresent,
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults(),
},
},
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSDefault,
NodeSelector: map[string]string{
"baz": "blah",
},
},
},
},
}
return rc
}
开发者ID:rferris,项目名称:kubernetes,代码行数:39,代码来源:replication_controller_test.go
示例5: TestReadPodsFromFile
func TestReadPodsFromFile(t *testing.T) {
hostname := "random-test-hostname"
var testCases = []struct {
desc string
pod runtime.Object
expected kubelet.PodUpdate
}{
{
desc: "Simple pod",
pod: &api.Pod{
TypeMeta: api.TypeMeta{
Kind: "Pod",
APIVersion: "",
},
ObjectMeta: api.ObjectMeta{
Name: "test",
UID: "12345",
Namespace: "mynamespace",
},
Spec: api.PodSpec{
Containers: []api.Container{{Name: "image", Image: "test/image", SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults()}},
},
},
expected: CreatePodUpdate(kubelet.SET, kubelet.FileSource, &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "test-" + hostname,
UID: "12345",
Namespace: "mynamespace",
SelfLink: getSelfLink("test-"+hostname, "mynamespace"),
},
Spec: api.PodSpec{
NodeName: hostname,
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
Containers: []api.Container{{
Name: "image",
Image: "test/image",
TerminationMessagePath: "/dev/termination-log",
ImagePullPolicy: "IfNotPresent",
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults()}},
},
}),
},
{
desc: "Pod without ID",
pod: &api.Pod{
TypeMeta: api.TypeMeta{
Kind: "Pod",
APIVersion: "",
},
ObjectMeta: api.ObjectMeta{
// No name
UID: "12345",
},
Spec: api.PodSpec{
Containers: []api.Container{{Name: "image", Image: "test/image", SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults()}},
},
},
expected: CreatePodUpdate(kubelet.SET, kubelet.FileSource, &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "12345-" + hostname,
UID: "12345",
Namespace: kubelet.NamespaceDefault,
SelfLink: getSelfLink("12345-"+hostname, kubelet.NamespaceDefault),
},
Spec: api.PodSpec{
NodeName: hostname,
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
Containers: []api.Container{{
Name: "image",
Image: "test/image",
TerminationMessagePath: "/dev/termination-log",
ImagePullPolicy: "IfNotPresent",
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults()}},
},
}),
},
}
for _, testCase := range testCases {
func() {
var versionedPod runtime.Object
err := testapi.Converter().Convert(&testCase.pod, &versionedPod)
if err != nil {
t.Fatalf("error in versioning the pod: %s", testCase.desc, err)
}
fileContents, err := testapi.Codec().Encode(versionedPod)
if err != nil {
t.Fatalf("%s: error in encoding the pod: %v", testCase.desc, err)
}
file := writeTestFile(t, os.TempDir(), "test_pod_config", string(fileContents))
defer os.Remove(file.Name())
ch := make(chan interface{})
NewSourceFile(file.Name(), hostname, time.Millisecond, ch)
select {
case got := <-ch:
update := got.(kubelet.PodUpdate)
//.........这里部分代码省略.........
开发者ID:mbforbes,项目名称:kubernetes,代码行数:101,代码来源:file_test.go
示例6: TestEtcdUpdateStatus
func TestEtcdUpdateStatus(t *testing.T) {
registry, _, status, fakeClient, etcdStorage := newStorage(t)
ctx := api.NewDefaultContext()
fakeClient.TestIndex = true
key, _ := registry.KeyFunc(ctx, "foo")
key = etcdtest.AddPrefix(key)
podStart := api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Namespace: api.NamespaceDefault,
},
Spec: api.PodSpec{
NodeName: "machine",
Containers: []api.Container{
{
Image: "foo:v1",
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults(),
},
},
},
}
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &podStart), 1)
podIn := api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
ResourceVersion: "1",
Labels: map[string]string{
"foo": "bar",
},
},
Spec: api.PodSpec{
NodeName: "machine",
Containers: []api.Container{
{
Image: "foo:v2",
ImagePullPolicy: api.PullIfNotPresent,
TerminationMessagePath: api.TerminationMessagePathDefault,
},
},
},
Status: api.PodStatus{
Phase: api.PodRunning,
PodIP: "127.0.0.1",
Message: "is now scheduled",
},
}
expected := podStart
expected.ResourceVersion = "2"
expected.Spec.RestartPolicy = api.RestartPolicyAlways
expected.Spec.DNSPolicy = api.DNSClusterFirst
expected.Spec.Containers[0].ImagePullPolicy = api.PullIfNotPresent
expected.Spec.Containers[0].TerminationMessagePath = api.TerminationMessagePathDefault
expected.Labels = podIn.Labels
expected.Status = podIn.Status
_, _, err := status.Update(ctx, &podIn)
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
var podOut api.Pod
key, _ = registry.KeyFunc(ctx, "foo")
if err := etcdStorage.Get(key, &podOut, false); err != nil {
t.Fatalf("Unexpected error: %v", err)
}
if !api.Semantic.DeepEqual(expected, podOut) {
t.Errorf("unexpected object: %s", util.ObjectDiff(expected, podOut))
}
}
开发者ID:Ima8,项目名称:kubernetes,代码行数:71,代码来源:etcd_test.go
示例7: TestEtcdUpdateScheduled
func TestEtcdUpdateScheduled(t *testing.T) {
registry, _, _, fakeClient, _ := newStorage(t)
ctx := api.NewDefaultContext()
fakeClient.TestIndex = true
key, _ := registry.KeyFunc(ctx, "foo")
key = etcdtest.AddPrefix(key)
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Namespace: api.NamespaceDefault,
},
Spec: api.PodSpec{
NodeName: "machine",
Containers: []api.Container{
{
Name: "foobar",
Image: "foo:v1",
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults(),
},
},
},
}), 1)
podIn := api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
ResourceVersion: "1",
Labels: map[string]string{
"foo": "bar",
},
},
Spec: api.PodSpec{
NodeName: "machine",
Containers: []api.Container{
{
Name: "foobar",
Image: "foo:v2",
ImagePullPolicy: api.PullIfNotPresent,
TerminationMessagePath: api.TerminationMessagePathDefault,
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults(),
},
},
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
},
}
_, _, err := registry.Update(ctx, &podIn)
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
response, err := fakeClient.Get(key, false, false)
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
var podOut api.Pod
latest.Codec.DecodeInto([]byte(response.Node.Value), &podOut)
if !api.Semantic.DeepEqual(podOut, podIn) {
t.Errorf("expected: %#v, got: %#v", podOut, podIn)
}
}
开发者ID:Ima8,项目名称:kubernetes,代码行数:62,代码来源:etcd_test.go
示例8: TestReadContainerManifestFromFile
func TestReadContainerManifestFromFile(t *testing.T) {
// ContainerManifest is supported only for pre v1beta3 versions.
if !api.PreV1Beta3(testapi.Version()) {
return
}
hostname := "random-test-hostname"
var testCases = []struct {
desc string
fileContents string
expected kubelet.PodUpdate
}{
{
desc: "Manifest",
fileContents: fmt.Sprintf(`{
"version": "%s",
"uuid": "12345",
"id": "test",
"containers": [{ "name": "image", "image": "test/image", "imagePullPolicy": "PullAlways"}]
}`, testapi.Version()),
expected: CreatePodUpdate(kubelet.SET, kubelet.FileSource, &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "test-" + hostname,
UID: "12345",
Namespace: kubelet.NamespaceDefault,
SelfLink: getSelfLink("test-"+hostname, kubelet.NamespaceDefault),
},
Spec: api.PodSpec{
Host: hostname,
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
Containers: []api.Container{{
Name: "image",
Image: "test/image",
TerminationMessagePath: "/dev/termination-log",
ImagePullPolicy: "Always",
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults()}},
},
}),
},
{
desc: "Manifest without ID",
fileContents: fmt.Sprintf(`{
"version": "%s",
"uuid": "12345",
"containers": [{ "name": "image", "image": "test/image", "imagePullPolicy": "PullAlways"}]
}`, testapi.Version()),
expected: CreatePodUpdate(kubelet.SET, kubelet.FileSource, &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "12345-" + hostname,
UID: "12345",
Namespace: kubelet.NamespaceDefault,
SelfLink: getSelfLink("12345-"+hostname, kubelet.NamespaceDefault),
},
Spec: api.PodSpec{
Host: hostname,
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
Containers: []api.Container{{
Name: "image",
Image: "test/image",
TerminationMessagePath: "/dev/termination-log",
ImagePullPolicy: "Always",
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults()}},
},
}),
},
}
for _, testCase := range testCases {
func() {
file := writeTestFile(t, os.TempDir(), "test_pod_config", testCase.fileContents)
defer os.Remove(file.Name())
ch := make(chan interface{})
NewSourceFile(file.Name(), hostname, time.Millisecond, ch)
select {
case got := <-ch:
update := got.(kubelet.PodUpdate)
for _, pod := range update.Pods {
if errs := validation.ValidatePod(pod); len(errs) > 0 {
t.Errorf("%s: Invalid pod %#v, %#v", testCase.desc, pod, errs)
}
}
if !api.Semantic.DeepEqual(testCase.expected, update) {
t.Errorf("%s: Expected %#v, Got %#v", testCase.desc, testCase.expected, update)
}
case <-time.After(time.Second):
t.Errorf("%s: Expected update, timeout instead", testCase.desc)
}
}()
}
}
开发者ID:cjnygard,项目名称:origin,代码行数:92,代码来源:file_test.go
示例9: TestDecodePodList
func TestDecodePodList(t *testing.T) {
pod := &api.Pod{
TypeMeta: api.TypeMeta{
APIVersion: "",
},
ObjectMeta: api.ObjectMeta{
Name: "test",
UID: "12345",
Namespace: "mynamespace",
},
Spec: api.PodSpec{
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
Containers: []api.Container{{
Name: "image",
Image: "test/image",
ImagePullPolicy: "IfNotPresent",
TerminationMessagePath: "/dev/termination-log",
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults(),
}},
},
}
podList := &api.PodList{
Items: []api.Pod{*pod},
}
json, err := testapi.Codec().Encode(podList)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
parsed, podListOut, err := tryDecodePodList(json, noDefault)
if testapi.Version() == "v1beta1" {
// v1beta1 conversion leaves empty lists that should be nil
podListOut.Items[0].Spec.Containers[0].Resources.Limits = nil
podListOut.Items[0].Spec.Containers[0].Resources.Requests = nil
}
if !parsed {
t.Errorf("expected to have parsed file: (%s)", string(json))
}
if err != nil {
t.Errorf("unexpected error: %v (%s)", err, string(json))
}
if !reflect.DeepEqual(podList, &podListOut) {
t.Errorf("expected:\n%#v\ngot:\n%#v\n%s", podList, &podListOut, string(json))
}
externalPodList, err := testapi.Converter().ConvertToVersion(podList, "v1beta3")
if err != nil {
t.Errorf("unexpected error: %v", err)
}
yaml, err := yaml.Marshal(externalPodList)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
parsed, podListOut, err = tryDecodePodList(yaml, noDefault)
if !parsed {
t.Errorf("expected to have parsed file: (%s)", string(yaml))
}
if err != nil {
t.Errorf("unexpected error: %v (%s)", err, string(yaml))
}
if !reflect.DeepEqual(podList, &podListOut) {
t.Errorf("expected:\n%#v\ngot:\n%#v\n%s", pod, &podListOut, string(yaml))
}
}
开发者ID:cjnygard,项目名称:origin,代码行数:65,代码来源:common_test.go
示例10: TestExtractPodsFromHTTP
func TestExtractPodsFromHTTP(t *testing.T) {
hostname := "different-value"
var testCases = []struct {
desc string
pods runtime.Object
expected kubelet.PodUpdate
}{
{
desc: "Single pod",
pods: &api.Pod{
TypeMeta: api.TypeMeta{
Kind: "Pod",
APIVersion: "",
},
ObjectMeta: api.ObjectMeta{
Name: "foo",
UID: "111",
Namespace: "mynamespace",
},
Spec: api.PodSpec{
Host: hostname,
Containers: []api.Container{{Name: "1", Image: "foo", ImagePullPolicy: api.PullAlways}},
},
},
expected: CreatePodUpdate(kubelet.SET,
kubelet.HTTPSource,
&api.Pod{
ObjectMeta: api.ObjectMeta{
UID: "111",
Name: "foo" + "-" + hostname,
Namespace: "mynamespace",
SelfLink: getSelfLink("foo-"+hostname, "mynamespace"),
},
Spec: api.PodSpec{
Host: hostname,
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
Containers: []api.Container{{
Name: "1",
Image: "foo",
TerminationMessagePath: "/dev/termination-log",
ImagePullPolicy: "Always",
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults()}},
},
}),
},
{
desc: "Multiple pods",
pods: &api.PodList{
TypeMeta: api.TypeMeta{
Kind: "PodList",
APIVersion: "",
},
Items: []api.Pod{
{
ObjectMeta: api.ObjectMeta{
Name: "foo",
UID: "111",
},
Spec: api.PodSpec{
Host: hostname,
Containers: []api.Container{{Name: "1", Image: "foo", ImagePullPolicy: api.PullAlways}},
},
},
{
ObjectMeta: api.ObjectMeta{
Name: "bar",
UID: "222",
},
Spec: api.PodSpec{
Host: hostname,
Containers: []api.Container{{Name: "2", Image: "bar", ImagePullPolicy: ""}},
},
},
},
},
expected: CreatePodUpdate(kubelet.SET,
kubelet.HTTPSource,
&api.Pod{
ObjectMeta: api.ObjectMeta{
UID: "111",
Name: "foo" + "-" + hostname,
Namespace: "default",
SelfLink: getSelfLink("foo-"+hostname, kubelet.NamespaceDefault),
},
Spec: api.PodSpec{
Host: hostname,
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
Containers: []api.Container{{
Name: "1",
Image: "foo",
TerminationMessagePath: "/dev/termination-log",
ImagePullPolicy: "Always",
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults()}},
},
},
//.........这里部分代码省略.........
开发者ID:cjnygard,项目名称:origin,代码行数:101,代码来源:http_test.go
示例11: TestExtractManifestFromHTTP
func TestExtractManifestFromHTTP(t *testing.T) {
hostname := "random-hostname"
// ContainerManifests are not supported v1beta3 onwards.
if api.PreV1Beta3(testapi.Version()) {
return
}
var testCases = []struct {
desc string
manifests interface{}
expected kubelet.PodUpdate
}{
{
desc: "Single manifest",
manifests: v1beta1.ContainerManifest{Version: "v1beta1", ID: "foo", UUID: "111",
Containers: []v1beta1.Container{{Name: "1", Image: "foo", ImagePullPolicy: v1beta1.PullAlways}}},
expected: CreatePodUpdate(kubelet.SET,
kubelet.HTTPSource,
&api.Pod{
ObjectMeta: api.ObjectMeta{
UID: "111",
Name: "foo" + "-" + hostname,
Namespace: "foobar",
SelfLink: getSelfLink("foo-"+hostname, kubelet.NamespaceDefault),
},
Spec: api.PodSpec{
Host: hostname,
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
Containers: []api.Container{{
Name: "1",
Image: "foo",
TerminationMessagePath: "/dev/termination-log",
ImagePullPolicy: "Always",
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults()}},
},
}),
},
{
desc: "Single manifest without ID",
manifests: v1beta1.ContainerManifest{Version: "v1beta1", UUID: "111",
Containers: []v1beta1.Container{{Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent"}}},
expected: CreatePodUpdate(kubelet.SET,
kubelet.HTTPSource,
&api.Pod{
ObjectMeta: api.ObjectMeta{
UID: "111",
Name: "111" + "-" + hostname,
Namespace: "foobar",
SelfLink: getSelfLink("111-"+hostname, kubelet.NamespaceDefault),
},
Spec: api.PodSpec{
Host: hostname,
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
Containers: []api.Container{{
Name: "ctr",
Image: "image",
TerminationMessagePath: "/dev/termination-log",
ImagePullPolicy: "IfNotPresent",
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults()}},
},
}),
},
{
desc: "Single manifest with v1beta2",
manifests: v1beta1.ContainerManifest{Version: "v1beta2", ID: "foo", UUID: "111",
Containers: []v1beta1.Container{{Name: "1", Image: "foo", ImagePullPolicy: v1beta1.PullAlways}}},
expected: CreatePodUpdate(kubelet.SET,
kubelet.HTTPSource,
&api.Pod{
ObjectMeta: api.ObjectMeta{
UID: "111",
Name: "foo" + "-" + hostname,
Namespace: "foobar",
SelfLink: getSelfLink("foo-"+hostname, kubelet.NamespaceDefault),
},
Spec: api.PodSpec{
Host: hostname,
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
Containers: []api.Container{{
Name: "1",
Image: "foo",
TerminationMessagePath: "/dev/termination-log",
ImagePullPolicy: "Always",
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults()}},
},
}),
},
{
desc: "Multiple manifests",
manifests: []v1beta1.ContainerManifest{
{Version: "v1beta1", ID: "foo", UUID: "111",
Containers: []v1beta1.Container{{Name: "1", Image: "foo", ImagePullPolicy: v1beta1.PullAlways}}},
{Version: "v1beta1", ID: "bar", UUID: "222",
Containers: []v1beta1.Container{{Name: "1", Image: "foo", ImagePullPolicy: ""}}},
//.........这里部分代码省略.........
开发者ID:cjnygard,项目名称:origin,代码行数:101,代码来源:http_test.go
注:本文中的github.com/GoogleCloudPlatform/kubernetes/pkg/securitycontext.ValidSecurityContextWithContainerDefaults函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论