Skip to content

Commit

Permalink
Merge branch 'release/release-3.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
itakouna committed May 19, 2020
2 parents 4f6e96e + ada4700 commit 1f47e04
Show file tree
Hide file tree
Showing 28 changed files with 121 additions and 54 deletions.
17 changes: 12 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Changelog

## 3.0.0 (Unreleased)
## 3.0.1 (May 19, 2020)

FEATURES:
* Add K8S support (get k8s config, renew k8s cluster's credentials).

BUG FIXES:
* Fixed wrong import path in exmaples.
* Fixed wrong import path in README.

## 3.0.0 (May 6, 2020)

FEATURES:
* Add storage cloning.
Expand All @@ -16,7 +25,7 @@ IMPROVEMENTS:
## 2.2.2 (April 8, 2020)

DEPRECATED FEATURES:
* Deprecated and removed labels create/delete options.
* Deprecated and removed labels create/delete options.

BUG FIXES:
* Fixed "context is expired but still retrying".
Expand All @@ -25,7 +34,7 @@ BUG FIXES:
## 2.2.1 (January 21, 2020)

BUG FIXES:
* (Hot fix) Fix incompatible major version when using gomod due to missing `/v2` suffix in module path of `go.mod` file
* (Hot fix) Fix incompatible major version when using gomod due to missing `/v2` suffix in module path of `go.mod` file

## 2.2.0 (January 21, 2020)

Expand Down Expand Up @@ -86,7 +95,6 @@ IMPROVEMENTS:
* Power-off server if graceful shutdown fails
* Backward compatibility for server creation API


## 0.2.0 (August 23, 2019)

FEATURES:
Expand All @@ -108,4 +116,3 @@ IMPROVEMENTS:
## 0.1.0 (January 2, 2019)

- Initial release of gsclient-go.

5 changes: 2 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ enhancement requests, bug reports, or code contributions!
## Reporting Bugs or Enhancement Requests

Please submit bugs or enhancement requests through the public bug tracker within the
github project.
GitHub project.

## Submitting Patches

The gsclient-go source code is managed using the git distributed source control
The gsclient-go source code is managed using the git distributed source control
management tool <https://www.git-scm.org/>. Please submit patches accordingly.

24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# The gridscale Go Client

[![Build Status](https://travis-ci.com/gridscale/gsclient-go.svg?branch=master)](https://travis-ci.com/gridscale/gsclient-go) [![Go Report Card](https://goreportcard.com/badge/github.com/gridscale/gsclient-go)](https://goreportcard.com/report/github.com/gridscale/gsclient-go)
[![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/gridscale/gsclient-go?label=release)](https://github.com/gridscale/gsclient-go/releases)

This is a client for the gridscale API. It can be used to make an application interact with the gridscale cloud platform to create and manage resources.

Expand All @@ -10,36 +12,34 @@ To be able to use this client a number of steps need to be taken. First a gridsc
## Installation

First the Go programming language will need to be installed. This can be done by using [the official Go installation guide](https://golang.org/doc/install) or by using the packages provided by your distribution.

Downloading the gridscale Go client can be done with the following go command:

```
go get github.com/gridscale/gsclient-go/v3
```
$ go get github.com/gridscale/gsclient-go/v3

## Using the gridscale Client

To be able to use the gridscale Go client in an application it can be imported in a go file. This can be done with the following code:

```go
import (
"github.com/gridscale/gsclient-go"
"github.com/gridscale/gsclient-go/v3"
)
```

To get access to the functions of the Go client, a Client type needs to be created. This requires a Config type. Both of these can be created with the following code:
To get access to the functions of the Go client, a Client type needs to be created. This requires a Config type. Both of these can be created with the following code:

```go
//Using default config
config := gsclient.DefaultConfiguration("User-UUID", "API-token")

//OR Custom config
config := gsclient.NewConfiguration(
"API-URL",
"User-UUID",
"API-token",
"API-URL",
"User-UUID",
"API-token",
false, //Set debug mode
true, //Set sync mode
true, //Set sync mode
500, //Delay (in milliseconds) between requests
100, //Maximum number of retries
)
Expand Down Expand Up @@ -107,7 +107,7 @@ if poweronErr != nil{
}
```

What options are available for each create and update request can be found in the source code. After installing it should be located in:
What options are available for each create and update request can be found in the source code. After installing it should be located in:
```
~/go/src/github.com/gridscale/gsclient-go
```
Expand Down Expand Up @@ -261,7 +261,7 @@ Not all endpoints have been implemented in this client, but new ones will be add
* Firewall Create (CreateFirewall)
* Firewall Update (UpdateFirewall)
* Firewall Delete (DeleteFirewall)
* Firewall Events Get (GetFirewallEventList)
* Firewall Events Get (GetFirewallEventList)
* Event
* Events Get (GetEventList)
* Label
Expand Down
3 changes: 3 additions & 0 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import (
"github.com/google/uuid"
)

type emptyStruct struct {
}

//retryableFunc defines a function that can be retried
type retryableFunc func() (bool, error)

Expand Down
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type Config struct {
// + debugMode bool: true => run client in debug mode.
// + sync bool: true => client is in synchronous mode. The client will block until Create/Update/Delete processes
// are completely finished. It is safer to set this parameter to `true`.
// + delayIntervalMilliSecs int: delay (in MilliSecond) between requests when checking request (or retry 5xx, 424 error code)
// + delayIntervalMilliSecs int: delay (in milliseconds) between requests when checking request (or retry 5xx, 424 error code)
// + maxNumberOfRetries int: number of retries when server returns 5xx, 424 error code.
func NewConfiguration(apiURL string, uuid string, token string, debugMode, sync bool,
delayIntervalMilliSecs, maxNumberOfRetries int) *Config {
Expand Down
5 changes: 3 additions & 2 deletions examples/firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package main
import (
"bufio"
"context"
"github.com/gridscale/gsclient-go"
log "github.com/sirupsen/logrus"
"os"

"github.com/gridscale/gsclient-go/v3"
log "github.com/sirupsen/logrus"
)

var emptyCtx = context.Background()
Expand Down
5 changes: 3 additions & 2 deletions examples/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package main
import (
"bufio"
"context"
"github.com/gridscale/gsclient-go"
log "github.com/sirupsen/logrus"
"os"

"github.com/gridscale/gsclient-go/v3"
log "github.com/sirupsen/logrus"
)

var emptyCtx = context.Background()
Expand Down
5 changes: 3 additions & 2 deletions examples/isoimage.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package main
import (
"bufio"
"context"
"github.com/gridscale/gsclient-go"
"github.com/sirupsen/logrus"
"os"

"github.com/gridscale/gsclient-go/v3"
"github.com/sirupsen/logrus"
)

var emptyCtx = context.Background()
Expand Down
2 changes: 1 addition & 1 deletion examples/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"context"
"os"

"github.com/gridscale/gsclient-go"
"github.com/gridscale/gsclient-go/v3"
log "github.com/sirupsen/logrus"
)

Expand Down
5 changes: 3 additions & 2 deletions examples/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package main
import (
"bufio"
"context"
"github.com/gridscale/gsclient-go"
log "github.com/sirupsen/logrus"
"os"

"github.com/gridscale/gsclient-go/v3"
log "github.com/sirupsen/logrus"
)

var emptyCtx = context.Background()
Expand Down
2 changes: 1 addition & 1 deletion examples/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"context"
"os"

"github.com/gridscale/gsclient-go"
"github.com/gridscale/gsclient-go/v3"
log "github.com/sirupsen/logrus"
)

Expand Down
2 changes: 1 addition & 1 deletion examples/objectstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"context"
"os"

"github.com/gridscale/gsclient-go"
"github.com/gridscale/gsclient-go/v3"
log "github.com/sirupsen/logrus"
)

Expand Down
5 changes: 3 additions & 2 deletions examples/paas.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package main
import (
"bufio"
"context"
"github.com/gridscale/gsclient-go"
log "github.com/sirupsen/logrus"
"os"

"github.com/gridscale/gsclient-go/v3"
log "github.com/sirupsen/logrus"
)

var emptyCtx = context.Background()
Expand Down
2 changes: 1 addition & 1 deletion examples/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

log "github.com/sirupsen/logrus"

"github.com/gridscale/gsclient-go"
"github.com/gridscale/gsclient-go/v3"
)

const webServerFirewallTemplateUUID = "82aa235b-61ba-48ca-8f47-7060a0435de7"
Expand Down
5 changes: 3 additions & 2 deletions examples/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package main
import (
"bufio"
"context"
log "github.com/sirupsen/logrus"
"os"

"github.com/gridscale/gsclient-go"
log "github.com/sirupsen/logrus"

"github.com/gridscale/gsclient-go/v3"
)

var emptyCtx = context.Background()
Expand Down
5 changes: 3 additions & 2 deletions examples/snapshotschedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package main
import (
"bufio"
"context"
log "github.com/sirupsen/logrus"
"os"

"github.com/gridscale/gsclient-go"
log "github.com/sirupsen/logrus"

"github.com/gridscale/gsclient-go/v3"
)

var emptyCtx = context.Background()
Expand Down
5 changes: 3 additions & 2 deletions examples/sshkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package main
import (
"bufio"
"context"
"github.com/gridscale/gsclient-go"
log "github.com/sirupsen/logrus"
"os"

"github.com/gridscale/gsclient-go/v3"
log "github.com/sirupsen/logrus"
)

var emptyCtx = context.Background()
Expand Down
2 changes: 1 addition & 1 deletion examples/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

log "github.com/sirupsen/logrus"

"github.com/gridscale/gsclient-go"
"github.com/gridscale/gsclient-go/v3"
)

var emptyCtx = context.Background()
Expand Down
5 changes: 3 additions & 2 deletions examples/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package main
import (
"bufio"
"context"
"github.com/gridscale/gsclient-go"
log "github.com/sirupsen/logrus"
"os"

"github.com/gridscale/gsclient-go/v3"
log "github.com/sirupsen/logrus"
)

var emptyCtx = context.Background()
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.13

require (
github.com/google/uuid v1.1.1
github.com/gridscale/gsclient-go v2.1.0+incompatible
github.com/sirupsen/logrus v1.4.2
github.com/stretchr/testify v1.4.0
golang.org/x/net v0.0.0-20200421231249-e086a090c8fd
Expand Down
5 changes: 3 additions & 2 deletions location_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package gsclient
import (
"encoding/json"
"fmt"
"github.com/stretchr/testify/assert"
"net/http"
"path"
"testing"

"github.com/stretchr/testify/assert"
)

func TestClient_GetLocationList(t *testing.T) {
Expand All @@ -19,7 +20,7 @@ func TestClient_GetLocationList(t *testing.T) {
fmt.Fprintf(writer, prepareLocationListHTTPGet())
})
res, err := client.GetLocationList(emptyCtx)
assert.Nil(t, err, "GetLocationList returned an aerror %v", err)
assert.Nil(t, err, "GetLocationList returned an error %v", err)
assert.Equal(t, 1, len(res))
assert.Equal(t, fmt.Sprintf("[%v]", getMockLocation()), fmt.Sprintf("%v", res))
}
Expand Down
19 changes: 19 additions & 0 deletions paas.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ type Credential struct {

//The type of Service.
Type string `json:"type"`

//If the PaaS service is a k8s cluster, this field will be set.
KubeConfig string `json:"kubeconfig"`
}

//PaaSServiceCreateRequest is JSON struct of a request for creating a PaaS service
Expand Down Expand Up @@ -460,6 +463,22 @@ func (c *Client) GetPaaSServiceMetrics(ctx context.Context, id string) ([]PaaSSe
return metrics, err
}

//RenewK8sCredentials renew credentials of a k8s cluster.
//If the PaaS is not a k8s cluster, the function will return an error.
//
//See:
func (c *Client) RenewK8sCredentials(ctx context.Context, id string) error {
if !isValidUUID(id) {
return errors.New("'id' is invalid")
}
r := request{
uri: path.Join(apiPaaSBase, "services", id, "renew_credentials"),
method: http.MethodPatch,
body: emptyStruct{},
}
return r.execute(ctx, *c, nil)
}

//GetPaaSTemplateList returns a list of PaaS service templates
//
//See: https://gridscale.io/en//api-documentation/index.html#operation/getPaasServiceTemplates
Expand Down
Loading

0 comments on commit 1f47e04

Please sign in to comment.