Skip to content

Commit

Permalink
better handling of device identifier storing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
maxlaverse committed Sep 30, 2024
1 parent c9817a7 commit edf75ae
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,17 @@ func getOrGenerateDeviceIdentifier(ctx context.Context) (string, error) {
}

deviceId := embedded.NewDeviceIdentifier()
os.WriteFile(".bitwarden/device_identifier", []byte(deviceId), 0600)
err = os.Mkdir(".bitwarden", 0700)
if err != nil {
tflog.Error(ctx, "Failed to create .bitwarden directory", map[string]interface{}{"error": err})
return "", err
}
err = os.WriteFile(".bitwarden/device_identifier", []byte(deviceId), 0600)
if err != nil {
tflog.Error(ctx, "Failed to store device identifier", map[string]interface{}{"error": err})
return "", err
}

tflog.Info(ctx, "Generated device identifier", map[string]interface{}{"device_id": deviceId})
return deviceId, nil
}
Expand Down

0 comments on commit edf75ae

Please sign in to comment.