(obj *unstructured.Unstructured, opts metav1.CreateOptions, subresources ...string)
| 87 | } |
| 88 | |
| 89 | func (c *dynamicResourceClient) Create(obj *unstructured.Unstructured, opts metav1.CreateOptions, subresources ...string) (*unstructured.Unstructured, error) { |
| 90 | var uncastRet runtime.Object |
| 91 | var err error |
| 92 | switch { |
| 93 | case len(c.namespace) == 0 && len(subresources) == 0: |
| 94 | uncastRet, err = c.client.Fake. |
| 95 | Invokes(testing.NewRootCreateAction(c.resource, obj), obj) |
| 96 | |
| 97 | case len(c.namespace) == 0 && len(subresources) > 0: |
| 98 | accessor, err := meta.Accessor(obj) |
| 99 | if err != nil { |
| 100 | return nil, err |
| 101 | } |
| 102 | name := accessor.GetName() |
| 103 | uncastRet, err = c.client.Fake. |
| 104 | Invokes(testing.NewRootCreateSubresourceAction(c.resource, name, strings.Join(subresources, "/"), obj), obj) |
| 105 | |
| 106 | case len(c.namespace) > 0 && len(subresources) == 0: |
| 107 | uncastRet, err = c.client.Fake. |
| 108 | Invokes(testing.NewCreateAction(c.resource, c.namespace, obj), obj) |
| 109 | |
| 110 | case len(c.namespace) > 0 && len(subresources) > 0: |
| 111 | accessor, err := meta.Accessor(obj) |
| 112 | if err != nil { |
| 113 | return nil, err |
| 114 | } |
| 115 | name := accessor.GetName() |
| 116 | uncastRet, err = c.client.Fake. |
| 117 | Invokes(testing.NewCreateSubresourceAction(c.resource, name, strings.Join(subresources, "/"), c.namespace, obj), obj) |
| 118 | |
| 119 | } |
| 120 | |
| 121 | if err != nil { |
| 122 | return nil, err |
| 123 | } |
| 124 | if uncastRet == nil { |
| 125 | return nil, err |
| 126 | } |
| 127 | |
| 128 | ret := &unstructured.Unstructured{} |
| 129 | if err := c.client.scheme.Convert(uncastRet, ret, nil); err != nil { |
| 130 | return nil, err |
| 131 | } |
| 132 | return ret, err |
| 133 | } |
| 134 | |
| 135 | func (c *dynamicResourceClient) Update(obj *unstructured.Unstructured, opts metav1.UpdateOptions, subresources ...string) (*unstructured.Unstructured, error) { |
| 136 | var uncastRet runtime.Object |
nothing calls this directly
no test coverage detected