mirror of
https://github.com/oddlama/nix-config.git
synced 2025-10-11 07:10:39 +02:00
fix(influxdb): also update auth token indices
This commit is contained in:
parent
301e7b353c
commit
e99253b9db
2 changed files with 22 additions and 6 deletions
|
@ -29,13 +29,19 @@ func main() {
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
err = db.Update(func(tx *bbolt.Tx) error {
|
err = db.Update(func(tx *bbolt.Tx) error {
|
||||||
bucket := tx.Bucket([]byte("authorizationsv1"))
|
authBucket := tx.Bucket([]byte("authorizationsv1"))
|
||||||
if bucket == nil {
|
if authBucket == nil {
|
||||||
fmt.Println("Bucket 'authorizationsv1' not found.")
|
fmt.Println("Bucket 'authorizationsv1' not found.")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
return bucket.ForEach(func(k, v []byte) error {
|
authIndex := tx.Bucket([]byte("authorizationindexv1"))
|
||||||
|
if authIndex == nil {
|
||||||
|
fmt.Println("Bucket 'authorizationindexv1' not found.")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return authBucket.ForEach(func(k, v []byte) error {
|
||||||
var obj map[string]interface{}
|
var obj map[string]interface{}
|
||||||
if err := json.Unmarshal(v, &obj); err != nil {
|
if err := json.Unmarshal(v, &obj); err != nil {
|
||||||
fmt.Printf("Error unmarshalling JSON: %v\n", err)
|
fmt.Printf("Error unmarshalling JSON: %v\n", err)
|
||||||
|
@ -83,8 +89,18 @@ func main() {
|
||||||
return nil // Continue processing other rows
|
return nil // Continue processing other rows
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := bucket.Put(k, updatedValue); err != nil {
|
if err := authIndex.Delete([]byte(oldToken)); err != nil {
|
||||||
fmt.Printf("Error updating bucket: %v\n", err)
|
fmt.Printf("Error deleting old token index in authorizationindexv1: %v\n", err)
|
||||||
|
return nil // Continue processing other rows
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := authIndex.Put([]byte(newToken), k); err != nil {
|
||||||
|
fmt.Printf("Error adding new token index in authorizationindexv1: %v\n", err)
|
||||||
|
return nil // Continue processing other rows
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := authBucket.Put(k, updatedValue); err != nil {
|
||||||
|
fmt.Printf("Error updating token in authorizationsv1: %v\n", err)
|
||||||
return nil // Continue processing other rows
|
return nil // Continue processing other rows
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -822,7 +822,7 @@ in {
|
||||||
listArgs
|
listArgs
|
||||||
++ [
|
++ [
|
||||||
"--description"
|
"--description"
|
||||||
(optionalString (apiToken.description != null) "${apiToken.description} - " + apiToken.id)
|
("${apiToken.name} - " + optionalString (apiToken.description != null) "${apiToken.description} - " + apiToken.id)
|
||||||
]
|
]
|
||||||
++ optional apiToken.operator "--operator"
|
++ optional apiToken.operator "--operator"
|
||||||
++ optional apiToken.allAccess "--all-access"
|
++ optional apiToken.allAccess "--all-access"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue