-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5fabb84
commit 4356d01
Showing
1 changed file
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Doppler Go SDK | ||
|
||
To start using this SDK, just: | ||
|
||
## 1. Install the package | ||
|
||
```bash | ||
go get github.com/videsk/doppler-go-sdk | ||
``` | ||
|
||
## 2. Import the package | ||
|
||
Using the method `GetSecrets` you will retrieve all secrets in once. | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/videsk/doppler-go-sdk" | ||
) | ||
|
||
func main() { | ||
|
||
dopplerClient, err := doppler.NewDoppler("projectName", "secretKey", "environment") | ||
if err != nil { | ||
log.Fatalf("Error with Doppler instance: %v", err) | ||
} | ||
|
||
dopplerClient.SetHTTPClient(http.DefaultClient) | ||
|
||
secrets, err := dopplerClient.GetSecrets() | ||
if err != nil { | ||
log.Fatalf("Error getting the secrets: %v", err) | ||
} | ||
|
||
for key, value := range secrets { | ||
log.Printf("Error getting: %s, Value: %s\n", key, value) | ||
} | ||
|
||
// The rest of the code ... | ||
} | ||
``` | ||
|
||
## 3. Get specific secret by name | ||
|
||
Using the method `GetOne` you will retrieve one secret in once, but calling `getSecrets`. Which is not efficient if you need get more than one at the same time. | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/videsk/doppler-go-sdk" | ||
) | ||
|
||
func main() { | ||
|
||
dopplerClient, err := doppler.NewDoppler("projectName", "secretKey", "environment") | ||
if err != nil { | ||
log.Fatalf("Error with Doppler instance: %v", err) | ||
} | ||
|
||
dopplerClient.SetHTTPClient(http.DefaultClient) | ||
|
||
secretName := "my_secret_name" | ||
secretValue, err := dopplerClient.GetOne(secretName) | ||
if err != nil { | ||
log.Fatalf("Error getting the secret %s: %v", secretName, err) | ||
} | ||
|
||
log.Printf("The secret value is '%s': %s\n", secretName, secretValue) | ||
|
||
// The rest of the code ... | ||
} | ||
``` | ||
## Efficient single value | ||
|
||
In case you want retrieve multiples values you can just: | ||
|
||
```go | ||
secrets, err := dopplerClient.GetSecrets() | ||
|
||
if err != nil { | ||
log.Fatalf("Error getting the secrets: %v", err) | ||
} | ||
|
||
mySecret1 := secrets["my_secret_name"] | ||
mySecret2 := secrets["my_super_secret"] | ||
``` |