Skip to content

Commit

Permalink
feat: improve api
Browse files Browse the repository at this point in the history
Signed-off-by: Ramiz Polic <ramiz.polic@hotmail.com>
  • Loading branch information
ramizpolic committed Sep 9, 2023
1 parent e884cd9 commit d69fc7e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
18 changes: 9 additions & 9 deletions cmd/testdata/syncjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,32 @@ mappings:

## Defines how the secrets will be synced.
strategy:
## 1. Key-to-key, usage: Sync key from source to target
## 1. Usage: Sync key from source to target
- secretRef:
key: /credentials/source/username
# if not specified, will be synced under the same key
# If not specified, will be synced under the same key
destKey: /credentials/target/username

## 2. Query-to-path, usage: Sync multiple keys from source to target
## 2. Usage: Sync queryable keys from source to target
- secretQuery:
path: /credentials/source
regexp:
key: .*
# if not specified, will be synced under the same path
# If not specified, will be synced under the same path
destPath: /credentials/target

## 3. Templated-keys, usage: Sync key from source to target via key and value templating
## 3. Usage: Sync key(s) from source to target via custom boilerplate
- secretRef:
key: /credentials/source/username
## Boilerplate defines how the secret key data will be synced to dest source
# Boilerplate defines how the secret key data will be synced to dest source.
# It is possible to specify multiple boilerplate items.
boilerplate:
- key: '/credentials/target/username'
# Reserved word "self" defines a mapping of the fetched secretRef.
# You can also use global mappings here, e.g. {{ valueOf "username" }}.
value: 'prefix-{{ valueOf "self" }}'

## 4. Templated-mappings, usage: Sync keys from global mappings to target via key and value templating
## 4. Usage: Sync key(s) from global mappings to target via custom boilerplate
- boilerplate:
- key: '/credentials/target/{{ keyOf "username"" }}'

Check failure on line 60 in cmd/testdata/syncjob.yaml

View workflow job for this annotation

GitHub Actions / Lint

60:5 [indentation] wrong indentation: expected 6 but found 4
value: '{{ valueOf "username" }}'
Expand All @@ -69,8 +70,7 @@ strategy:
username: '{{ valueOf "dynamic-query.username" }}'
password: '{{ valueOf "dynamic-query.password" }}'

## 5. Templated-queries, usage: Sync multiple keys based from source
## to dest using mapping and templating capabilities
## 5. Usage: Sync queryable keys from source to dest via custom boilerplate
- secretQuery:
path: /credentials/source
regexp:
Expand Down
7 changes: 5 additions & 2 deletions pkg/storesync/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/bank-vaults/secret-sync/pkg/apis/v1alpha1"
"golang.org/x/sync/errgroup"
"sync"
"text/template"

"golang.org/x/sync/errgroup"

"github.com/bank-vaults/secret-sync/pkg/apis/v1alpha1"
)

type kvData struct {
Expand Down
3 changes: 2 additions & 1 deletion pkg/storesync/storesync.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ import (
"sync/atomic"
"time"

"github.com/bank-vaults/secret-sync/pkg/apis/v1alpha1"
"github.com/sirupsen/logrus"

"github.com/bank-vaults/secret-sync/pkg/apis/v1alpha1"
)

// Status defines response data returned by Sync.
Expand Down

0 comments on commit d69fc7e

Please sign in to comment.