Skip to content

Commit

Permalink
Remove default params (#175)
Browse files Browse the repository at this point in the history
* Remove default config params

* Fix tests

* Remove VRRP resource

* Add dynamic version for module

* Bump module version v3 -> v4

* Bump Go 1.21 -> 1.23
  • Loading branch information
sel-bukharov authored Nov 22, 2024
1 parent 0d63e68 commit 4760293
Show file tree
Hide file tree
Showing 53 changed files with 187 additions and 1,057 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/secure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ jobs:
p/comment
p/cwe-top-25
p/default
p/gitlab
p/gitleaks
p/golang
p/gosec
Expand Down Expand Up @@ -60,7 +59,7 @@ jobs:
scan-type: fs
format: sarif
output: trivy.sarif
exit-code: 0 # Change this after all events have resolved.
exit-code: 0 # Change this after all events have resolved.
severity: MEDIUM,CRITICAL,HIGH
- uses: github/codeql-action/upload-sarif@v3
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: "1.23"
- run: go test -v ./...

golangci-lint:
Expand All @@ -22,10 +22,10 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: "1.23"
- uses: golangci/golangci-lint-action@v6
with:
version: v1.53.3
version: v1.62.0
install-mode: goinstall
working-directory: selvpcclient

Expand All @@ -35,6 +35,6 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: "1.23"
- run: go mod tidy -v
- run: git diff --exit-code
103 changes: 54 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
# go-selvpcclient: a Go library for the Selectel VPC API
[![GoDoc](https://godoc.org/github.com/selectel/go-selvpcclient/v3/selvpcclient?status.svg)](https://godoc.org/github.com/selectel/go-selvpcclient/v3/selvpcclient)

[![GoDoc](https://godoc.org/github.com/selectel/go-selvpcclient/v4/selvpcclient?status.svg)](https://godoc.org/github.com/selectel/go-selvpcclient/v4/selvpcclient)
[![Go Report Card](https://goreportcard.com/badge/github.com/selectel/go-selvpcclient/v3)](https://goreportcard.com/report/github.com/selectel/go-selvpcclient/v3)
[![Coverage Status](https://coveralls.io/repos/github/selectel/go-selvpcclient/badge.svg?branch=master)](https://coveralls.io/github/selectel/go-selvpcclient?branch=master)

Package go-selvpcclient provides a Go library to work with the Selectel API:
- [Cloud Management API](https://developers.selectel.ru/docs/selectel-cloud-platform/main-services/selectel_cloud_management_api/)
- [Cloud Quota Management API ](https://developers.selectel.ru/docs/selectel-cloud-platform/main-services/cloud-quota-management/)

- [Cloud Management API](https://developers.selectel.ru/docs/selectel-cloud-platform/main-services/selectel_cloud_management_api/)
- [Cloud Quota Management API](https://developers.selectel.ru/docs/selectel-cloud-platform/main-services/cloud-quota-management/)

## Documentation

The Go library documentation is available at [godoc.org](https://godoc.org/github.com/selectel/go-selvpcclient/v3/selvpcclient).
The Go library documentation is available at [godoc.org](https://godoc.org/github.com/selectel/go-selvpcclient/v4/selvpcclient).

## What this library is capable of

You can use this library to work with the following objects of the
You can use this library to work with the following objects of the
[Cloud Management API](https://developers.selectel.ru/docs/selectel-cloud-platform/main-services/selectel_cloud_management_api/) and
[Cloud Quota Management API](https://developers.selectel.ru/docs/selectel-cloud-platform/main-services/cloud-quota-management/).

Cloud Management API:
* [capabilities](https://godoc.org/github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/capabilities)
* [floating ips](https://godoc.org/github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/floatingips)
* [keypairs](https://godoc.org/github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/keypairs)
* [licenses](https://godoc.org/github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/licenses)
* [projects](https://godoc.org/github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/projects)
* [roles](https://godoc.org/github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/roles)
* [subnets](https://godoc.org/github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/subnets)
* [tokens](https://godoc.org/github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/tokens)
* [traffic](https://godoc.org/github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/traffic)
* [users](https://godoc.org/github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/users)
* [vrrp subnets](https://godoc.org/github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/vrrpsubnets)

- [capabilities](https://godoc.org/github.com/selectel/go-selvpcclient/v4/selvpcclient/resell/v2/capabilities)
- [floating ips](https://godoc.org/github.com/selectel/go-selvpcclient/v4/selvpcclient/resell/v2/floatingips)
- [keypairs](https://godoc.org/github.com/selectel/go-selvpcclient/v4/selvpcclient/resell/v2/keypairs)
- [licenses](https://godoc.org/github.com/selectel/go-selvpcclient/v4/selvpcclient/resell/v2/licenses)
- [projects](https://godoc.org/github.com/selectel/go-selvpcclient/v4/selvpcclient/resell/v2/projects)
- [roles](https://godoc.org/github.com/selectel/go-selvpcclient/v4/selvpcclient/resell/v2/roles)
- [subnets](https://godoc.org/github.com/selectel/go-selvpcclient/v4/selvpcclient/resell/v2/subnets)
- [tokens](https://godoc.org/github.com/selectel/go-selvpcclient/v4/selvpcclient/resell/v2/tokens)
- [traffic](https://godoc.org/github.com/selectel/go-selvpcclient/v4/selvpcclient/resell/v2/traffic)
- [users](https://godoc.org/github.com/selectel/go-selvpcclient/v4/selvpcclient/resell/v2/users)

Cloud Quota Management API:
* [quotas](https://godoc.org/github.com/selectel/go-selvpcclient/v3/selvpcclient/quotamanager/quotas)

- [quotas](https://godoc.org/github.com/selectel/go-selvpcclient/v4/selvpcclient/quotamanager/quotas)

Selectel VPC Cloud is based on the [OpenStack](https://www.openstack.org), so you don't need this library to work with actual servers, volumes, networks, etc.
You can use the [Gophercloud](https://github.com/gophercloud/gophercloud) project to work with the OpenStack objects.
Expand All @@ -43,54 +46,56 @@ You can use the [Gophercloud](https://github.com/gophercloud/gophercloud) projec
You can install `go-selvpcclient` as a Go package:

```bash
go get github.com/selectel/go-selvpcclient/selvpcclient/v3
go get github.com/selectel/go-selvpcclient/selvpcclient/v4
```

### Authentication

To work with the Selectel VPC API you first need to:

* create a Selectel account: [registration page](https://my.selectel.ru/registration)
* create the service user: [users and roles](https://docs.selectel.ru/control-panel-actions/users-and-roles)
- create a Selectel account: [registration page](https://my.selectel.ru/registration)
- create the service user: [users and roles](https://docs.selectel.ru/control-panel-actions/users-and-roles)

### Usage example

```go
package main

import (
"context"
"fmt"
"log"
"context"
"fmt"
"log"

"github.com/selectel/go-selvpcclient/v3/selvpcclient"
"github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/projects"
"github.com/selectel/go-selvpcclient/v4/selvpcclient"
"github.com/selectel/go-selvpcclient/v4/selvpcclient/resell/v2/projects"
)

func main() {
ctx := context.Background()

options := &selvpcclient.ClientOptions{
Context: ctx,
DomainName: "999999",
Username: "admin",
Password: "m1-sup3r-p@ssw0rd-p3w-p3w",
}

client, err := selvpcclient.NewClient(options)
if err != nil {
log.Fatal(err)
}

result, resp, err := projects.List(client)
if err != nil {
log.Fatal(err)
}

fmt.Printf("Response StatusCode: %d \n", resp.StatusCode)

for _, project := range result {
fmt.Printf("Project name: %s, enabled: %t \n", project.Name, project.Enabled)
}
ctx := context.Background()

options := &selvpcclient.ClientOptions{
Context: ctx,
DomainName: "999999",
AuthRegion: "<pool>",
AuthURL: "https://cloud.api.selcloud.ru/identity/v3/",
Username: "admin",
Password: "m1-sup3r-p@ssw0rd-p3w-p3w",
}

client, err := selvpcclient.NewClient(options)
if err != nil {
log.Fatal(err)
}

result, resp, err := projects.List(client)
if err != nil {
log.Fatal(err)
}

fmt.Printf("Response StatusCode: %d \n", resp.StatusCode)

for _, project := range result {
fmt.Printf("Project name: %s, enabled: %t \n", project.Name, project.Enabled)
}
}
```
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/selectel/go-selvpcclient/v3
module github.com/selectel/go-selvpcclient/v4

go 1.21
go 1.23

require (
github.com/google/go-querystring v1.1.0
Expand Down
2 changes: 1 addition & 1 deletion selvpcclient/clients/quotamanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package clients
import (
"fmt"

clientservices "github.com/selectel/go-selvpcclient/v3/selvpcclient/clients/services"
clientservices "github.com/selectel/go-selvpcclient/v4/selvpcclient/clients/services"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion selvpcclient/clients/resell.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package clients
import (
"fmt"

clientservices "github.com/selectel/go-selvpcclient/v3/selvpcclient/clients/services"
clientservices "github.com/selectel/go-selvpcclient/v4/selvpcclient/clients/services"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions selvpcclient/quotamanager/quotas/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"net/http"
"strings"

"github.com/selectel/go-selvpcclient/v3/selvpcclient"
clientservices "github.com/selectel/go-selvpcclient/v3/selvpcclient/clients/services"
"github.com/selectel/go-selvpcclient/v4/selvpcclient"
clientservices "github.com/selectel/go-selvpcclient/v4/selvpcclient/clients/services"
)

const resourcePrefix = "projects"
Expand Down
2 changes: 1 addition & 1 deletion selvpcclient/quotamanager/quotas/testing/fixtures.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package testing

import (
"github.com/selectel/go-selvpcclient/v3/selvpcclient/quotamanager/quotas"
"github.com/selectel/go-selvpcclient/v4/selvpcclient/quotamanager/quotas"
)

// TestGetLimitsQuotasResponseRaw represents a raw response from the GetAll request.
Expand Down
4 changes: 2 additions & 2 deletions selvpcclient/quotamanager/quotas/testing/requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"strings"
"testing"

"github.com/selectel/go-selvpcclient/v3/selvpcclient/quotamanager/quotas"
"github.com/selectel/go-selvpcclient/v3/selvpcclient/testutils"
"github.com/selectel/go-selvpcclient/v4/selvpcclient/quotamanager/quotas"
"github.com/selectel/go-selvpcclient/v4/selvpcclient/testutils"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions selvpcclient/resell/v2/capabilities/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"net/http"
"strings"

"github.com/selectel/go-selvpcclient/v3/selvpcclient"
clientservices "github.com/selectel/go-selvpcclient/v3/selvpcclient/clients/services"
"github.com/selectel/go-selvpcclient/v4/selvpcclient"
clientservices "github.com/selectel/go-selvpcclient/v4/selvpcclient/clients/services"
)

const resourceURL = "capabilities"
Expand Down
4 changes: 2 additions & 2 deletions selvpcclient/resell/v2/capabilities/testing/requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"net/http"
"testing"

"github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/capabilities"
"github.com/selectel/go-selvpcclient/v3/selvpcclient/testutils"
"github.com/selectel/go-selvpcclient/v4/selvpcclient/resell/v2/capabilities"
"github.com/selectel/go-selvpcclient/v4/selvpcclient/testutils"
)

func TestGetCapabilities(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions selvpcclient/resell/v2/floatingips/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

"github.com/google/go-querystring/query"

"github.com/selectel/go-selvpcclient/v3/selvpcclient"
clientservices "github.com/selectel/go-selvpcclient/v3/selvpcclient/clients/services"
"github.com/selectel/go-selvpcclient/v4/selvpcclient"
clientservices "github.com/selectel/go-selvpcclient/v4/selvpcclient/clients/services"
)

const resourceURL = "floatingips"
Expand Down
2 changes: 1 addition & 1 deletion selvpcclient/resell/v2/floatingips/schemas.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package floatingips

import "github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/servers"
import "github.com/selectel/go-selvpcclient/v4/selvpcclient/resell/v2/servers"

// FloatingIP represents a single Resell Floating IP.
type FloatingIP struct {
Expand Down
4 changes: 2 additions & 2 deletions selvpcclient/resell/v2/floatingips/testing/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package testing
import (
"time"

"github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/floatingips"
"github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/servers"
"github.com/selectel/go-selvpcclient/v4/selvpcclient/resell/v2/floatingips"
"github.com/selectel/go-selvpcclient/v4/selvpcclient/resell/v2/servers"
)

// TestGetFloatingIPResponseRaw represents a raw response from the Get request.
Expand Down
4 changes: 2 additions & 2 deletions selvpcclient/resell/v2/floatingips/testing/requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"reflect"
"testing"

"github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/floatingips"
"github.com/selectel/go-selvpcclient/v3/selvpcclient/testutils"
"github.com/selectel/go-selvpcclient/v4/selvpcclient/resell/v2/floatingips"
"github.com/selectel/go-selvpcclient/v4/selvpcclient/testutils"
)

func TestGetFloatingIP(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions selvpcclient/resell/v2/keypairs/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

"github.com/google/go-querystring/query"

"github.com/selectel/go-selvpcclient/v3/selvpcclient"
clientservices "github.com/selectel/go-selvpcclient/v3/selvpcclient/clients/services"
"github.com/selectel/go-selvpcclient/v4/selvpcclient"
clientservices "github.com/selectel/go-selvpcclient/v4/selvpcclient/clients/services"
)

const resourceURL = "keypairs"
Expand Down
2 changes: 1 addition & 1 deletion selvpcclient/resell/v2/keypairs/testing/fixtures.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package testing

import "github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/keypairs"
import "github.com/selectel/go-selvpcclient/v4/selvpcclient/resell/v2/keypairs"

// TestListResponseRaw represents a raw response from List requests.
const TestListResponseRaw = `
Expand Down
4 changes: 2 additions & 2 deletions selvpcclient/resell/v2/keypairs/testing/requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"reflect"
"testing"

"github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/keypairs"
"github.com/selectel/go-selvpcclient/v3/selvpcclient/testutils"
"github.com/selectel/go-selvpcclient/v4/selvpcclient/resell/v2/keypairs"
"github.com/selectel/go-selvpcclient/v4/selvpcclient/testutils"
)

func TestListKeypairs(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions selvpcclient/resell/v2/licenses/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

"github.com/google/go-querystring/query"

"github.com/selectel/go-selvpcclient/v3/selvpcclient"
clientservices "github.com/selectel/go-selvpcclient/v3/selvpcclient/clients/services"
"github.com/selectel/go-selvpcclient/v4/selvpcclient"
clientservices "github.com/selectel/go-selvpcclient/v4/selvpcclient/clients/services"
)

const resourceURL = "licenses"
Expand Down
2 changes: 1 addition & 1 deletion selvpcclient/resell/v2/licenses/schemas.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package licenses

import "github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/servers"
import "github.com/selectel/go-selvpcclient/v4/selvpcclient/resell/v2/servers"

// License represents a single Resell License.
type License struct {
Expand Down
4 changes: 2 additions & 2 deletions selvpcclient/resell/v2/licenses/testing/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package testing
import (
"time"

"github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/licenses"
"github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/servers"
"github.com/selectel/go-selvpcclient/v4/selvpcclient/resell/v2/licenses"
"github.com/selectel/go-selvpcclient/v4/selvpcclient/resell/v2/servers"
)

// TestGetLicenseResponseRaw represents a raw response from the Get request.
Expand Down
4 changes: 2 additions & 2 deletions selvpcclient/resell/v2/licenses/testing/requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"reflect"
"testing"

"github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/licenses"
"github.com/selectel/go-selvpcclient/v3/selvpcclient/testutils"
"github.com/selectel/go-selvpcclient/v4/selvpcclient/resell/v2/licenses"
"github.com/selectel/go-selvpcclient/v4/selvpcclient/testutils"
)

func TestGetLicense(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions selvpcclient/resell/v2/projects/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"net/http"
"strings"

"github.com/selectel/go-selvpcclient/v3/selvpcclient"
clientservices "github.com/selectel/go-selvpcclient/v3/selvpcclient/clients/services"
"github.com/selectel/go-selvpcclient/v4/selvpcclient"
clientservices "github.com/selectel/go-selvpcclient/v4/selvpcclient/clients/services"
)

const resourceURL = "projects"
Expand Down
Loading

0 comments on commit 4760293

Please sign in to comment.