Skip to content

Commit

Permalink
make addr, approle optional field in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucretius committed Jan 19, 2021
1 parent ba3817d commit 81bca43
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ If your configuration is right and Vault is running on the same host as the agen

## Configuration

`addr` The address of the Vault cluster. This is used to check the Vault cluster leader IP, as well as generate snapshots.
`addr` The address of the Vault cluster. This is used to check the Vault cluster leader IP, as well as generate snapshots. Defaults to "http://127.0.0.1:8200".

`retain` The number of backups to retain.

Expand All @@ -65,7 +65,7 @@ If your configuration is right and Vault is running on the same host as the agen

`secret_id` Specifies the secret_id used to call the Vault API.

`approle` Specifies the approle name used to login.
`approle` Specifies the approle name used to login. Defaults to "approle".

### Storage options

Expand Down
9 changes: 5 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@ func main() {
}

snapshotter, err := snapshot_agent.NewSnapshotter(c)
if err != nil {
log.Fatalln("Cannot instantiate snapshotter.", err)
}
frequency, err := time.ParseDuration(c.Frequency)

if err != nil {
frequency = time.Hour
}
if err != nil {
log.Fatalln("Error retrieving Current instance IP. Verify internet connectivity.")
}

for {
if snapshotter.TokenExpiration.Before(time.Now()) {
snapshotter.SetClientTokenFromAppRole(c)
Expand Down Expand Up @@ -94,4 +95,4 @@ func logSnapshotError(dest, snapshotPath string, err error) {
} else {
log.Printf("Successfully created %s snapshot to %s\n", dest, snapshotPath)
}
}
}
4 changes: 3 additions & 1 deletion snapshot_agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ func NewSnapshotter(config *config.Configuration) (*Snapshotter, error) {

func (s *Snapshotter) ConfigureVaultClient(config *config.Configuration) error {
vaultConfig := vaultApi.DefaultConfig()
vaultConfig.Address = config.Address
if config.Address != "" {
vaultConfig.Address = config.Address
}
tlsConfig := &vaultApi.TLSConfig{
Insecure: true,
}
Expand Down

0 comments on commit 81bca43

Please sign in to comment.