(obj *unstructured.Unstructured, opts metav1.CreateOptions, subresources ...string)
| 92 | } |
| 93 | |
| 94 | func (c *dynamicResourceClient) Create(obj *unstructured.Unstructured, opts metav1.CreateOptions, subresources ...string) (*unstructured.Unstructured, error) { |
| 95 | outBytes, err := runtime.Encode(unstructured.UnstructuredJSONScheme, obj) |
| 96 | if err != nil { |
| 97 | return nil, err |
| 98 | } |
| 99 | name := "" |
| 100 | if len(subresources) > 0 { |
| 101 | accessor, err := meta.Accessor(obj) |
| 102 | if err != nil { |
| 103 | return nil, err |
| 104 | } |
| 105 | name = accessor.GetName() |
| 106 | if len(name) == 0 { |
| 107 | return nil, fmt.Errorf("name is required") |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | result := c.client.client. |
| 112 | Post(). |
| 113 | AbsPath(append(c.makeURLSegments(name), subresources...)...). |
| 114 | Body(outBytes). |
| 115 | SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1). |
| 116 | Do() |
| 117 | if err := result.Error(); err != nil { |
| 118 | return nil, err |
| 119 | } |
| 120 | |
| 121 | retBytes, err := result.Raw() |
| 122 | if err != nil { |
| 123 | return nil, err |
| 124 | } |
| 125 | uncastObj, err := runtime.Decode(unstructured.UnstructuredJSONScheme, retBytes) |
| 126 | if err != nil { |
| 127 | return nil, err |
| 128 | } |
| 129 | return uncastObj.(*unstructured.Unstructured), nil |
| 130 | } |
| 131 | |
| 132 | func (c *dynamicResourceClient) Update(obj *unstructured.Unstructured, opts metav1.UpdateOptions, subresources ...string) (*unstructured.Unstructured, error) { |
| 133 | accessor, err := meta.Accessor(obj) |
nothing calls this directly
no test coverage detected