Add credential and libraries to session recording resource (#3374)
This commit is contained in:
20 files changed
+2055
-150
No files matched your search
@@ -80,6 +80,11 @@ type structInfo struct {
|
||||
// the attributes map.
|
||||
subtypeName string
|
||||
|
||||
// subtype specifies exactly the value expected in the resource's "type"
|
||||
// Field. This is used when checking if the attributes returned can be
|
||||
// marshaled into a specific generated attributes struct.
|
||||
subtype string
|
||||
|
||||
// For non-top-level collections, this can be used to indicate the name of
|
||||
// the argument that should be used
|
||||
parentTypeName string
|
||||
@@ -549,6 +554,7 @@ var inputStructs = []*structInfo{
|
||||
inProto: &credentiallibraries.VaultCredentialLibraryAttributes{},
|
||||
outFile: "credentiallibraries/vault_credential_library_attributes.gen.go",
|
||||
subtypeName: "VaultCredentialLibrary",
|
||||
subtype: "vault-generic",
|
||||
fieldOverrides: []fieldInfo{
|
||||
{
|
||||
Name: "Path",
|
||||
@@ -564,6 +570,7 @@ var inputStructs = []*structInfo{
|
||||
inProto: &credentiallibraries.VaultSSHCertificateCredentialLibraryAttributes{},
|
||||
outFile: "credentiallibraries/vault_ssh_certificate_credential_library_attributes.gen.go",
|
||||
subtypeName: "VaultSSHCertificateCredentialLibrary",
|
||||
subtype: "vault-ssh-certificate",
|
||||
fieldOverrides: []fieldInfo{
|
||||
{
|
||||
Name: "Path",
|
||||
@@ -626,6 +633,7 @@ var inputStructs = []*structInfo{
|
||||
inProto: &credentials.UsernamePasswordAttributes{},
|
||||
outFile: "credentials/username_password_attributes.gen.go",
|
||||
subtypeName: "UsernamePasswordCredential",
|
||||
subtype: "username_password",
|
||||
fieldOverrides: []fieldInfo{
|
||||
{
|
||||
Name: "Username",
|
||||
@@ -645,6 +653,7 @@ var inputStructs = []*structInfo{
|
||||
inProto: &credentials.SshPrivateKeyAttributes{},
|
||||
outFile: "credentials/ssh_private_key_attributes.gen.go",
|
||||
subtypeName: "SshPrivateKeyCredential",
|
||||
subtype: "ssh_private_key",
|
||||
fieldOverrides: []fieldInfo{
|
||||
{
|
||||
Name: "Username",
|
||||
@@ -1046,6 +1055,82 @@ var inputStructs = []*structInfo{
|
||||
inProto: &session_recordings.HostCatalog{},
|
||||
outFile: "sessionrecordings/host_catalog.gen.go",
|
||||
},
|
||||
{
|
||||
inProto: &session_recordings.Credential{},
|
||||
outFile: "sessionrecordings/credential.gen.go",
|
||||
},
|
||||
{
|
||||
inProto: &session_recordings.UsernamePasswordCredentialAttributes{},
|
||||
outFile: "sessionrecordings/username_password_credential_attributes.gen.go",
|
||||
subtype: "username_password",
|
||||
parentTypeName: "Credential",
|
||||
templates: []*template.Template{
|
||||
mapstructureConversionTemplate,
|
||||
},
|
||||
},
|
||||
{
|
||||
inProto: &session_recordings.JsonCredentialAttributes{},
|
||||
outFile: "sessionrecordings/json_credential_attributes.gen.go",
|
||||
subtype: "json",
|
||||
parentTypeName: "Credential",
|
||||
templates: []*template.Template{
|
||||
mapstructureConversionTemplate,
|
||||
},
|
||||
},
|
||||
{
|
||||
inProto: &session_recordings.SshPrivateKeyCredentialAttributes{},
|
||||
outFile: "sessionrecordings/ssh_private_key_credential_attributes.gen.go",
|
||||
subtype: "ssh_private_key",
|
||||
parentTypeName: "Credential",
|
||||
templates: []*template.Template{
|
||||
mapstructureConversionTemplate,
|
||||
},
|
||||
},
|
||||
{
|
||||
inProto: &session_recordings.CredentialLibrary{},
|
||||
outFile: "sessionrecordings/credential_library.gen.go",
|
||||
},
|
||||
{
|
||||
inProto: &session_recordings.VaultCredentialLibraryAttributes{},
|
||||
outFile: "sessionrecordings/vault_credential_library_attributes.gen.go",
|
||||
subtype: "vault-generic",
|
||||
parentTypeName: "CredentialLibrary",
|
||||
templates: []*template.Template{
|
||||
mapstructureConversionTemplate,
|
||||
},
|
||||
},
|
||||
{
|
||||
inProto: &session_recordings.VaultSSHCertificateCredentialLibraryAttributes{},
|
||||
outFile: "sessionrecordings/vault_ssh_certificate_credential_library_attributes.gen.go",
|
||||
subtype: "vault-ssh-certificate",
|
||||
parentTypeName: "CredentialLibrary",
|
||||
fieldOverrides: []fieldInfo{
|
||||
{
|
||||
Name: "CriticalOptions",
|
||||
FieldType: "map[string]string",
|
||||
},
|
||||
{
|
||||
Name: "Extensions",
|
||||
FieldType: "map[string]string",
|
||||
},
|
||||
},
|
||||
templates: []*template.Template{
|
||||
mapstructureConversionTemplate,
|
||||
},
|
||||
},
|
||||
{
|
||||
inProto: &session_recordings.CredentialStore{},
|
||||
outFile: "sessionrecordings/credential_store.gen.go",
|
||||
},
|
||||
{
|
||||
inProto: &session_recordings.VaultCredentialStoreAttributes{},
|
||||
outFile: "sessionrecordings/vault_credential_store_attributes.gen.go",
|
||||
subtype: "vault",
|
||||
parentTypeName: "CredentialStore",
|
||||
templates: []*template.Template{
|
||||
mapstructureConversionTemplate,
|
||||
},
|
||||
},
|
||||
{
|
||||
inProto: &session_recordings.ValuesAtTime{},
|
||||
outFile: "sessionrecordings/values_at_time.gen.go",
|
||||
|
||||
@@ -53,6 +53,7 @@ type templateInput struct {
|
||||
CreateResponseTypes []string
|
||||
SkipListFiltering bool
|
||||
RecursiveListing bool
|
||||
Subtype string
|
||||
}
|
||||
|
||||
func fillTemplates() {
|
||||
@@ -72,6 +73,7 @@ func fillTemplates() {
|
||||
CreateResponseTypes: in.createResponseTypes,
|
||||
SkipListFiltering: in.skipListFiltering,
|
||||
RecursiveListing: in.recursiveListing,
|
||||
Subtype: in.subtype,
|
||||
}
|
||||
if in.packageOverride != "" {
|
||||
input.Package = in.packageOverride
|
||||
@@ -850,8 +852,8 @@ func AttributesMapTo{{ .Name }}(in map[string]interface{}) (*{{ .Name }}, error)
|
||||
}
|
||||
|
||||
func (pt *{{ .ParentTypeName }}) Get{{ .Name }}() (*{{ .Name }}, error) {
|
||||
if pt.Type != "{{ typeFromSubtype .Name .ParentTypeName "Attributes"}}" {
|
||||
return nil, fmt.Errorf("asked to fetch %s-type attributes but {{ kebabCase .ParentTypeName }} is of type %s", "{{ typeFromSubtype .Name .ParentTypeName "Attributes"}}", pt.Type)
|
||||
if pt.Type != "{{ typeFromSubtype .Subtype .Name .ParentTypeName "Attributes"}}" {
|
||||
return nil, fmt.Errorf("asked to fetch %s-type attributes but {{ kebabCase .ParentTypeName }} is of type %s", "{{ typeFromSubtype .Subtype .Name .ParentTypeName "Attributes"}}", pt.Type)
|
||||
}
|
||||
return AttributesMapTo{{ .Name }}(pt.Attributes)
|
||||
}
|
||||
@@ -895,6 +897,9 @@ func removeDups(in []string) []string {
|
||||
return ret
|
||||
}
|
||||
|
||||
func typeFromSubtype(in, parent, extraSuffix string) string {
|
||||
func typeFromSubtype(subtype, in, parent, extraSuffix string) string {
|
||||
if subtype != "" {
|
||||
return subtype
|
||||
}
|
||||
return strings.ToLower(strings.TrimSuffix(strings.TrimSuffix(in, extraSuffix), parent))
|
||||
}
|
||||
Reference in new issue
Block a user