Skip to content

Remove secrets package #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ You can use Bacon locally or in a GitHub Actions workflow. For local use, downlo

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.

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).
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.

You can use [`bacon ping`](#ping) to check your authentication configuration.

## Usage

Expand Down
8 changes: 5 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"bacon/cmd"
"bacon/pkg/providers/porkbun"
"bacon/pkg/secrets"
"os"

"github.com/subosito/gotenv"
)
Expand All @@ -12,9 +12,11 @@ func main() {
// Loads .env in the current directory
gotenv.Load()

// Only supports Porkbun... for now :D
var porkbunApiKey = os.Getenv("PORKBUN_API_KEY")
var porkbunSecretApiKey = os.Getenv("PORKBUN_SECRET_KEY")

app := cmd.App{
Provider: porkbun.NewPorkbunProvider(secrets.Provider{}),
Provider: porkbun.NewPorkbunProvider(porkbunApiKey, porkbunSecretApiKey),
}

cmd.Execute(&app)
Expand Down
7 changes: 3 additions & 4 deletions pkg/providers/porkbun/porkbun.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bacon/pkg/dns"
"bacon/pkg/providers/porkbun/api"
"bacon/pkg/providers/porkbun/record"
"bacon/pkg/secrets"
"fmt"
)

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

func NewPorkbunProvider(secretsProvider secrets.Provider) dns.Provider {
func NewPorkbunProvider(apiKey, secretApiKey string) dns.Provider {
return &PorkProvider{
Api: api.Api{
Auth: api.Auth{
ApiKey: secretsProvider.Read(secrets.PorkbunApiKey),
SecretApiKey: secretsProvider.Read(secrets.PorkbunSecretKey),
ApiKey: apiKey,
SecretApiKey: secretApiKey,
},
},
}
Expand Down
28 changes: 0 additions & 28 deletions pkg/secrets/provider.go

This file was deleted.

18 changes: 0 additions & 18 deletions pkg/secrets/provider_test.go

This file was deleted.

6 changes: 0 additions & 6 deletions pkg/secrets/secrets.go

This file was deleted.

Loading