Get retrieves an objects from a cluster using it's namespace name and API version.
(kind, namespace, name string, export bool)
| 183 | |
| 184 | // Get retrieves an objects from a cluster using it's namespace name and API version. |
| 185 | func (c *KubeCluster) Get(kind, namespace, name string, export bool) (KubeObject, error) { |
| 186 | kind = KubeShortForm(kind) |
| 187 | |
| 188 | req := c.Client.Get().Resource(kind).Namespace(namespace).Name(name) |
| 189 | |
| 190 | if export { |
| 191 | req.Param("export", "true") |
| 192 | } |
| 193 | |
| 194 | runObj, err := req.Do().Get() |
| 195 | if err != nil { |
| 196 | return nil, fmt.Errorf("Failed to retrieve resource '%s/%s (namespace=%s)' from Kube API server: %v", kind, name, namespace, err) |
| 197 | } |
| 198 | |
| 199 | kubeObj, err := AsKubeObject(runObj) |
| 200 | if err != nil { |
| 201 | return nil, fmt.Errorf("Unable to change into KubeObject: %v", err) |
| 202 | } |
| 203 | |
| 204 | return kubeObj, nil |
| 205 | } |
| 206 | |
| 207 | // get retrieves the object from the cluster. |
| 208 | func (c *KubeCluster) get(namespace, name string, export bool, mapping *meta.RESTMapping) (KubeObject, error) { |