mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-06-30 02:31:10 +00:00
* cleanup 1
* continue refactoring
* more refactoring
* move VMs under nodes
* move container and other apis under nodes
* cleanups
* enabled revive.exported linter & add comments to exported stuff
* enable godot linter
* enable wsl linter
* enable thelper linter
* enable govet linter
* cleanup after rebase
* cleanup after rebase
* extract SSH ops into a separate interface
* fix linter error
* move ssh code to its own package
* cleaning up VirtualEnvironmentClient receivers
* on the finish line
* not sure what else I forgot... 🤔
* fix ssh connection and upload
* renaming client interfaces
* final cleanups
55 lines
2.6 KiB
Go
55 lines
2.6 KiB
Go
/*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
package storage
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net/http"
|
|
"net/url"
|
|
)
|
|
|
|
// GetDatastore retrieves information about a datastore.
|
|
/*
|
|
Using undocumented API endpoints is not recommended, but sometimes it's the only way to get things done.
|
|
$ pvesh get /storage/local
|
|
┌─────────┬───────────────────────────────────────────┐
|
|
│ key │ value │
|
|
╞═════════╪═══════════════════════════════════════════╡
|
|
│ content │ images,vztmpl,iso,backup,snippets,rootdir │
|
|
├─────────┼───────────────────────────────────────────┤
|
|
│ digest │ 5b65ede80f34631d6039e6922845cfa4abc956be │
|
|
├─────────┼───────────────────────────────────────────┤
|
|
│ path │ /var/lib/vz │
|
|
├─────────┼───────────────────────────────────────────┤
|
|
│ shared │ 0 │
|
|
├─────────┼───────────────────────────────────────────┤
|
|
│ storage │ local │
|
|
├─────────┼───────────────────────────────────────────┤
|
|
│ type │ dir │
|
|
└─────────┴───────────────────────────────────────────┘.
|
|
*/
|
|
func (c *Client) GetDatastore(
|
|
ctx context.Context,
|
|
datastoreID string,
|
|
) (*DatastoreGetResponseData, error) {
|
|
resBody := &DatastoreGetResponseBody{}
|
|
|
|
err := c.DoRequest(
|
|
ctx,
|
|
http.MethodGet,
|
|
fmt.Sprintf("storage/%s", url.PathEscape(datastoreID)),
|
|
nil,
|
|
resBody,
|
|
)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("error retrieving datastore %s: %w", datastoreID, err)
|
|
}
|
|
|
|
return resBody.Data, nil
|
|
}
|