# go-denvr A Go SDK for interacting with Denvr Cloud SDK [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/denvrdata/go-denvr/CI.yml)](https://github.com/denvrdata/go-denvr/actions/workflows/CI.yml) [![Coveralls](https://img.shields.io/coverallsCoverage/github/denvrdata/go-denvr)](https://coveralls.io/github/denvrdata/go-denvr?branch=main) [![Swagger Validator](https://img.shields.io/swagger/valid/3.0?specUrl=https%3A%2F%2Fapi.cloud.denvrdata.com%2Fswagger%2Fv1%2Fswagger.json)](https://api.cloud.denvrdata.com/swagger/index.html) [![go-denvr Docs](https://img.shields.io/badge/pkg.go.dev-docs-%234493c5?style=flat)](https://pkg.go.dev/github.com/denvrdata/go-denvr) [![Denvr Dataworks Docs](https://img.shields.io/badge/denvr_cloud-docs-%234493c5?style=flat)](https://docs.denvrdata.com/docs) [![Denvr Dataworks Registration](https://img.shields.io/badge/denvr_cloud-registration-%234493c5?style=flat)](https://console.cloud.denvrdata.com/account/register-tenant) ## Configuration ### Config File Most of the client configuration is done with a single tomle file. This file contains sensitive information and should be locked down with `chmod 600 denvr.toml`. - `~/.config/denvr.toml`: A centralized location for config information - `[defaults]` - `server`: A specific server to hit (e.g., `https://api.cloud.denvrdata.com`) - `api`: The version of the api to use - `cluster`: The default cluster to use (e.g., `Msc1`, `Hou1`) - `tenant`: The tenant/account name (e.g. `denvr`) - `vpcid`: The default vpc name to use (e.g., `denvr`) - `rpool`: The default rpool to use (e.g., `on-demand`, `reserved-denvr`) - `retries`: The number of retries to use when making requests - `[credentials]` - `apikey`: An api key created from the web interface - `username`: The users email address - `password`: The users password NOTES: - You can provide an `apikey` and/or `username`/`password`, however, the `apikey` will always take priority. ### Environment Variables These environment variables take priority over any values in the config if they exist. - `DENVR_CONFIG`: Alternative location of the `denvr.toml` file - `DENVR_APIKEY`: An api key created from the web interface - `DENVR_USERNAME`: The users email address - `DENVR_PASSWORD`: The users password ## Design Apart from a few specific components (e.g., `config`, `result`, `response`), most of the code is autogenerated with [oapi-codegen](github.com/oapi-codegen/oapi-codegen). The goal of this SDK is that a majority of the code can be autogenerated as API changes are released. Our [nightly](https://github.com/denvrdata/go-denvr/blob/main/.github/workflows/nightly.yml) github workflow identifies changes in the dev API and opens PR for us. ## FAQ *Why go-denvr?* It's a bit of a hack, so that the `go-` prefix can be excluded when using the package. The following reddit [thread](https://www.reddit.com/r/golang/comments/r3as15/how_should_i_name_my_package_repository_when/) explains. *Why a golang SDK?* We prioritised making [denvrpy](https://github.com/denvrdata/denvrpy) as many of our users are familiar with writing python code. This golang SDK is mostly just a means to writing a [terraform provider](https://github.com/denvrdata/terraform-provider-denvr). As a result, some of the nice-to-have features like waiters are not included. If you'd like to use this SDK directly and have feature requests, please create an issue. ## Contributing ### Issues The easiest way to help the go-denvr project is to open [issues](https://github.com/denvrdata/go-denvr/issues/new/choose). That being said, here is a list of common details we recommend including: - Objective - Code snippets - Logs - Stacktrace - Settings - Environments (e.g., docker container) ## Pull Requests (PRs) Our primary workflow for making changes to `go-denvr` is with pull requests (PRs). This process involves: 1. Forking the original repo (from the browser) 2. Clone your fork with `git clone` 3. Make your changes locally 4. Add your modified files with `git add` 5. Commit your changes with a descriptive message `git commit` 6. Push your change back up to your fork `git push` 7. Open a pull request on the original repository (from the browser) Again, the [GitHub docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) already have a detailed summary of this workflow. When opening a pull request it's best to: 1. Summarize what you're changing and why 2. Keep you changes minimial 2. Include any needed tests and docs 3. Ensure all tests, linting and coverage checks pass ## Checks We aren't golang experts, but we do ask that you run a few checks as part of any contributions. - `gofmt -w .` helps ensure that the code in this repo is consistent and easy to read (if/when things break) - `go mod tidy` helps us keep our `go.mod` file in sync and removes any unnecessary bloat - `go test ./...` just checks that our tests are still passing - `golangci-lint run -D errcheck -D staticcheck` just runs some basic linting (Optional) - We typically ignore errcheck and staticcheck as they're a bit noisy while this repo is still in development. The CI process checks these anyway, but running them locally can save a bit of time :) ## Adding a Service To add a service, simply copy one of the existing directories (e.g., [api/v1/servers/applications](https://github.com/denvrdata/go-denvr/tree/main/api/v1/servers/applications), [api/v1/servers/virtual](https://github.com/denvrdata/go-denvr/tree/main/api/v1/servers/virtual) and update the `generate.go` and `cfg.yaml` files accordingly. After that, you're good to run: ``` go generate -v -x ./... ``` to generate the new `.go` file. **NOTE** We also recommend including a basic `_test.go` file as well.