Skip to content

Commit ea9415d

Browse files
authored
Merge pull request #36 from jungaretti/jungaretti/remove-secrets-provider
Remove secrets package
2 parents d0d5ccc + 03c1fd3 commit ea9415d

File tree

6 files changed

+11
-60
lines changed

6 files changed

+11
-60
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ You can use Bacon locally or in a GitHub Actions workflow. For local use, downlo
2626

2727
Sign into Porkbun and [generate a new API keyset](https://porkbun.com/account/api) for your account. Read the ["Generating API Keys" section of Porkbun's docs](https://kb.porkbun.com/article/190-getting-started-with-the-porkbun-dns-api) for more detailed instructions. Be sure to enable API access for the domain(s) that you would like to manage with Bacon.
2828

29-
Next, export your `PORKBUN_API_KEY` and `PORKBUN_SECRET_KEY` as environment variables. You can also use a `.env` file in the current directory (see [`.env.example`](https://github.com/jungaretti/bacon/blob/main/.env.example) for an example).
29+
Next, `export` the `PORKBUN_API_KEY` and `PORKBUN_SECRET_KEY` environment variables or add them to an `.env` file. Bacon uses these environment variables to authenticate with Porkbun. If the current directory contains an `.env` file, then Bacon will load its contents into environment variables. See [`.env.example`](https://github.com/jungaretti/bacon/blob/main/.env.example) for an example.
30+
31+
You can use [`bacon ping`](#ping) to check your authentication configuration.
3032

3133
## Usage
3234

main.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import (
44
"bacon/cmd"
55
"bacon/pkg/providers/porkbun"
6-
"bacon/pkg/secrets"
6+
"os"
77

88
"github.com/subosito/gotenv"
99
)
@@ -12,9 +12,11 @@ func main() {
1212
// Loads .env in the current directory
1313
gotenv.Load()
1414

15-
// Only supports Porkbun... for now :D
15+
var porkbunApiKey = os.Getenv("PORKBUN_API_KEY")
16+
var porkbunSecretApiKey = os.Getenv("PORKBUN_SECRET_KEY")
17+
1618
app := cmd.App{
17-
Provider: porkbun.NewPorkbunProvider(secrets.Provider{}),
19+
Provider: porkbun.NewPorkbunProvider(porkbunApiKey, porkbunSecretApiKey),
1820
}
1921

2022
cmd.Execute(&app)

pkg/providers/porkbun/porkbun.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bacon/pkg/dns"
55
"bacon/pkg/providers/porkbun/api"
66
"bacon/pkg/providers/porkbun/record"
7-
"bacon/pkg/secrets"
87
"fmt"
98
)
109

@@ -62,12 +61,12 @@ func (p PorkProvider) DeleteRecord(domain string, toDelete dns.Record) error {
6261
return p.Api.DeleteRecord(domain, target.Id)
6362
}
6463

65-
func NewPorkbunProvider(secretsProvider secrets.Provider) dns.Provider {
64+
func NewPorkbunProvider(apiKey, secretApiKey string) dns.Provider {
6665
return &PorkProvider{
6766
Api: api.Api{
6867
Auth: api.Auth{
69-
ApiKey: secretsProvider.Read(secrets.PorkbunApiKey),
70-
SecretApiKey: secretsProvider.Read(secrets.PorkbunSecretKey),
68+
ApiKey: apiKey,
69+
SecretApiKey: secretApiKey,
7170
},
7271
},
7372
}

pkg/secrets/provider.go

-28
This file was deleted.

pkg/secrets/provider_test.go

-18
This file was deleted.

pkg/secrets/secrets.go

-6
This file was deleted.

0 commit comments

Comments
 (0)