Skip to content

Commit

Permalink
Add Custom metadata field to alias (#12502)
Browse files Browse the repository at this point in the history
* adding changes

* removing q.Q

* removing empty lines

* testing

* checking tests

* fixing tests

* adding changes

* added requested changes

* added requested changes

* added policy templating changes and fixed tests

* adding proto changes

* making changes

* adding unit tests

* using suggested function
  • Loading branch information
akshya96 committed Sep 17, 2021
1 parent e2e4b50 commit d324066
Show file tree
Hide file tree
Showing 21 changed files with 335 additions and 112 deletions.
3 changes: 3 additions & 0 deletions changelog/12502.txt
@@ -0,0 +1,3 @@
```release-note:feature
core: adds custom_metadata field for aliases
```
2 changes: 1 addition & 1 deletion helper/forwarding/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions helper/identity/identity.go
Expand Up @@ -75,12 +75,13 @@ func ToSDKAlias(a *Alias) *logical.Alias {
}

return &logical.Alias{
Name: a.Name,
ID: a.ID,
MountAccessor: a.MountAccessor,
MountType: a.MountType,
Metadata: metadata,
NamespaceID: a.NamespaceID,
Name: a.Name,
ID: a.ID,
MountAccessor: a.MountAccessor,
MountType: a.MountType,
Metadata: metadata,
NamespaceID: a.NamespaceID,
CustomMetadata: a.CustomMetadata,
}
}

Expand Down
2 changes: 1 addition & 1 deletion helper/identity/mfa/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 52 additions & 32 deletions helper/identity/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions helper/identity/types.proto
Expand Up @@ -172,6 +172,9 @@ message Alias {
// NamespaceID is the identifier of the namespace to which this alias
// belongs.
string namespace_id = 11;

// Custom Metadata represents the custom data tied to this alias
map<string, string> customMetadata = 12;
}

// Deprecated. Retained for backwards compatibility.
Expand Down
2 changes: 1 addition & 1 deletion helper/storagepacker/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion physical/raft/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk/database/dbplugin/database.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk/database/dbplugin/v5/proto/database.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion sdk/helper/identitytpl/templating.go
Expand Up @@ -178,6 +178,15 @@ func performTemplating(input string, p *PopulateStringInput) (string, error) {
case strings.HasPrefix(trimmed, "metadata."):
split := strings.SplitN(trimmed, ".", 2)
return p.templateHandler(alias.Metadata, split[1])

case trimmed == "custom_metadata":
return p.templateHandler(alias.CustomMetadata)

case strings.HasPrefix(trimmed, "custom_metadata."):

split := strings.SplitN(trimmed, ".", 2)
return p.templateHandler(alias.CustomMetadata, split[1])

}

return "", ErrTemplateValueNotFound
Expand Down Expand Up @@ -222,7 +231,7 @@ func performTemplating(input string, p *PopulateStringInput) (string, error) {
}

// An empty alias is sufficient for generating defaults
alias = &logical.Alias{Metadata: make(map[string]string)}
alias = &logical.Alias{Metadata: make(map[string]string), CustomMetadata: make(map[string]string)}
}
return performAliasTemplating(split[1], alias)
}
Expand Down

0 comments on commit d324066

Please sign in to comment.