-
Notifications
You must be signed in to change notification settings - Fork 0
AUT-11295 Manage secrets #30
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
Open
piotrek-janus
wants to merge
12
commits into
master
Choose a base branch
from
feature/secrets
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7040174
secret management
piotrek-janus 6c1155f
filter secrets from diff
piotrek-janus a871031
first iteration
piotrek-janus 1ce7a1b
rename interface
piotrek-janus 33b7383
fix lint
piotrek-janus 424ddf1
fix pull output
piotrek-janus 436ef99
improve trace level condition
piotrek-janus 0a55bd5
update golang
piotrek-janus 0e2f621
fix reading tenant data from storage
piotrek-janus 6c956e1
write secrets
piotrek-janus 79b3a1d
fix: collect server secret extensions when reading tenant config from…
piotrek-janus 5171efb
refactor: harden patch merge and pull --out output
piotrek-janus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| *.iml | ||
| .idea | ||
| /cac | ||
| /cac | ||
| /examples/e2e-local/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| FROM golang:1.22 AS build | ||
| FROM golang:1.24 AS build | ||
|
|
||
| WORKDIR /app | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| package api | ||
|
|
||
| import ( | ||
| "github.com/cloudentity/acp-client-go/clients/hub/models" | ||
| smodels "github.com/cloudentity/acp-client-go/clients/system/models" | ||
| "github.com/imdario/mergo" | ||
| ) | ||
|
|
||
| type ServerExtensions struct { | ||
| Secrets map[string]*smodels.Secret `json:"secrets,omitempty"` | ||
| } | ||
|
|
||
| type TenantExtensions struct { | ||
| Servers map[string]ServerExtensions `json:"servers,omitempty"` | ||
| } | ||
|
|
||
| func (te *TenantExtensions) GetServerExtensions(serverID string) *ServerExtensions { | ||
| if te.Servers == nil { | ||
| return nil | ||
| } | ||
|
|
||
| if ext, ok := te.Servers[serverID]; ok { | ||
| return &ext | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| type Patch interface { | ||
| GetData() models.Rfc7396PatchOperation | ||
| GetExtensions() any | ||
| Merge(other Patch) error | ||
| } | ||
|
|
||
| type PatchImpl[T any] struct { | ||
| Data models.Rfc7396PatchOperation `json:"data,omitempty"` | ||
| Ext *T `json:"ext,omitempty"` | ||
| } | ||
|
|
||
| // mergePatch merges another patch's data and extensions into the given data | ||
| // map and extension pointer, tolerating nil extensions on either side. | ||
| func mergePatch[T any](data *models.Rfc7396PatchOperation, ext **T, other Patch) error { | ||
| if err := mergo.Merge(data, other.GetData(), mergo.WithOverride); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| otherExt, _ := other.GetExtensions().(*T) | ||
| if otherExt == nil { | ||
| return nil | ||
| } | ||
|
|
||
| if *ext == nil { | ||
| *ext = otherExt | ||
| return nil | ||
| } | ||
|
|
||
| return mergo.Merge(*ext, otherExt, mergo.WithOverride) | ||
| } | ||
|
|
||
| type ServerPatch PatchImpl[ServerExtensions] | ||
|
|
||
| var _ Patch = &ServerPatch{} | ||
|
|
||
| func (sp *ServerPatch) GetData() models.Rfc7396PatchOperation { | ||
| return sp.Data | ||
| } | ||
| func (sp *ServerPatch) GetExtensions() any { | ||
| return sp.Ext | ||
| } | ||
| func (sp *ServerPatch) Merge(other Patch) error { | ||
| return mergePatch(&sp.Data, &sp.Ext, other) | ||
| } | ||
|
|
||
| type TenantPatch PatchImpl[TenantExtensions] | ||
|
|
||
| var _ Patch = &TenantPatch{} | ||
|
|
||
| func (tp *TenantPatch) GetData() models.Rfc7396PatchOperation { | ||
| return tp.Data | ||
| } | ||
| func (tp *TenantPatch) GetExtensions() any { | ||
| return tp.Ext | ||
| } | ||
| func (tp *TenantPatch) Merge(other Patch) error { | ||
| return mergePatch(&tp.Data, &tp.Ext, other) | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before merging extensions with mergo.Merge(sp.Ext, other.GetExtensions(), ...), ensure that sp.Ext is not nil to avoid a potential nil pointer dereference.