k8s/io/kubernetes/pkg/api.Namespace 示例代码

2022-03-03

以下示例是关于golang中包含api.Namespace用法的示例代码,想了解api.Namespace的具体用法?api.Namespace怎么用?api.Namespace使用的例子?那么可以参考以下10个相关示例代码来学习它的具体使用方法。

示例1:
client.go开发语言: Go项目名称: kubernetes代码行数: 349
106	result = &api.PodList{}
107	err = c.Get().Namespace(api.Namespace(ctx)).Path("pods").SelectorParam("labels", selector).Do().Into(result)
108	return
113	result = &api.Pod{}
114	err = c.Get().Namespace(api.Namespace(ctx)).Path("pods").Path(id).Do().Into(result)
115	return
119func (c *Client) DeletePod(ctx api.Context, id string) error {
120	return c.Delete().Namespace(api.Namespace(ctx)).Path("pods").Path(id).Do().Error()
121}
125	result = &api.Pod{}
126	err = c.Post().Namespace(api.Namespace(ctx)).Path("pods").Body(pod).Do().Into(result)
127	return
136	}
137	err = c.Put().Namespace(api.Namespace(ctx)).Path("pods").Path(pod.ID).Body(pod).Do().Into(result)
138	return
示例2:
validation.go开发语言: Go项目名称: kubernetes代码行数: 938
915// ValidateNamespace tests if required fields are set.
916func ValidateNamespace(namespace *api.Namespace) errs.ValidationErrorList {
917	allErrs := errs.ValidationErrorList{}
922// ValidateNamespaceUpdate tests to make sure a mamespace update can be applied.  Modifies oldNamespace.
923func ValidateNamespaceUpdate(oldNamespace *api.Namespace, namespace *api.Namespace) errs.ValidationErrorList {
924	allErrs := errs.ValidationErrorList{}
示例3:
namespaces.go开发语言: Go项目名称: docker代码行数: 121
29// NewNamespaceStoreFromClient returns a new namespace store
30func NewNamespaceStoreFromClient(client api.NamespacesClient) namespaces.Store {
31	return &remoteNamespaces{client: client}
34type remoteNamespaces struct {
35	client api.NamespacesClient
36}
40
41	req.Namespace = api.Namespace{
42		Name:   namespace,
68
69	req.Namespace = api.Namespace{
70		Name:   namespace,
示例4:
rest_test.go开发语言: Go项目名称: kubernetes代码行数: 185
39
40func testNamespace(name string) *api.Namespace {
41	return &api.Namespace{
50		ctx       api.Context
51		namespace *api.Namespace
52		valid     bool
154	namespaceC := testNamespace("baz")
155	reg.ObjectList = &api.NamespaceList{
156		Items: []api.Namespace{*namespaceA, *namespaceB, *namespaceC},
161	}
162	expect := &api.NamespaceList{
163		Items: []api.Namespace{*namespaceA, *namespaceB, *namespaceC},
示例5:
rest.go开发语言: Go项目名称: kubernetes代码行数: 127
46func (rs *REST) Create(ctx api.Context, obj runtime.Object) (runtime.Object, error) {
47	namespace := obj.(*api.Namespace)
48	if err := rest.BeforeCreate(rest.Namespaces, ctx, obj); err != nil {
59func (rs *REST) Update(ctx api.Context, obj runtime.Object) (runtime.Object, bool, error) {
60	namespace, ok := obj.(*api.Namespace)
61	if !ok {
69
70	oldNamespace := oldObj.(*api.Namespace)
71	if errs := validation.ValidateNamespaceUpdate(oldNamespace, namespace); len(errs) > 0 {
87	}
88	_, ok := obj.(*api.Namespace)
89	if !ok {
99	}
100	namespace, ok := obj.(*api.Namespace)
101	if !ok {
示例6:
namespaces.go开发语言: Go项目名称: kubernetes代码行数: 102
32type NamespaceInterface interface {
33	Create(item *api.Namespace) (*api.Namespace, error)
34	Get(name string) (result *api.Namespace, err error)
36	Delete(name string) error
37	Update(item *api.Namespace) (*api.Namespace, error)
38	Watch(label, field labels.Selector, resourceVersion string) (watch.Interface, error)
51// Create creates a new namespace.
52func (c *namespaces) Create(namespace *api.Namespace) (*api.Namespace, error) {
53	result := &api.Namespace{}
58// List lists all the namespaces in the cluster.
59func (c *namespaces) List(selector labels.Selector) (*api.NamespaceList, error) {
60	result := &api.NamespaceList{}
65// Update takes the representation of a namespace to update.  Returns the server's representation of the namespace, and an error, if it occurs.
66func (c *namespaces) Update(namespace *api.Namespace) (result *api.Namespace, err error) {
67	result = &api.Namespace{}
示例7:
types.go开发语言: Go项目名称: kubernetes代码行数: 157
147func (namespaceStrategy) ResetBeforeCreate(obj runtime.Object) {
148	_ = obj.(*api.Namespace)
149	// Namespace allow *all* fields, including status, to be set.
153func (namespaceStrategy) Validate(obj runtime.Object) errors.ValidationErrorList {
154	namespace := obj.(*api.Namespace)
155	return validation.ValidateNamespace(namespace)
示例8:
namespaces_test.go开发语言: Go项目名称: kubernetes代码行数: 145
28	// we create a namespace relative to another namespace
29	namespace := &api.Namespace{
30		ObjectMeta: api.ObjectMeta{Name: "foo"},
53func TestNamespaceGet(t *testing.T) {
54	namespace := &api.Namespace{
55		ObjectMeta: api.ObjectMeta{Name: "foo"},
77func TestNamespaceList(t *testing.T) {
78	namespaceList := &api.NamespaceList{
79		Items: []api.Namespace{
109func TestNamespaceUpdate(t *testing.T) {
110	requestNamespace := &api.Namespace{
111		ObjectMeta: api.ObjectMeta{
示例9:
fake_namespaces.go开发语言: Go项目名称: kubernetes代码行数: 60
32	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "list-namespaces"})
33	return api.Scheme.CopyOrDie(&c.Fake.NamespacesList).(*api.NamespaceList), nil
34}
35
36func (c *FakeNamespaces) Get(name string) (*api.Namespace, error) {
37	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "get-namespace", Value: name})
38	return &api.Namespace{ObjectMeta: api.ObjectMeta{Name: name}}, nil
39}
45
46func (c *FakeNamespaces) Create(namespace *api.Namespace) (*api.Namespace, error) {
47	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "create-namespace"})
50
51func (c *FakeNamespaces) Update(namespace *api.Namespace) (*api.Namespace, error) {
52	c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "update-namespace", Value: namespace.Name})
示例10:
kubecfg.go开发语言: Go项目名称: kubernetes代码行数: 513
364	case "update":
365		obj, err := c.Verb("GET").Namespace(api.Namespace(ctx)).Path(path).Do().Get()
366		if err != nil {
390
391	r := c.Verb(verb).Namespace(api.Namespace(ctx)).Path(path)
392	if len(*selector) > 0 {

本文地址:https://www.itbaoku.cn/snippets/415655.html