fix nil pointer issue with empty permissions
@@ -122,6 +122,12 @@ func parseAccessPolicy(policy *v1alpha1.AccessPolicyEntry, ctx context.Context)
return keyvault.AccessPolicyEntry{}, err
}
+ newEntry := keyvault.AccessPolicyEntry{
+ TenantID: &tenantID,
+ Permissions: &keyvault.Permissions{},
+ }
+
+ if policy.Permissions.Keys != nil {
var keyPermissions []keyvault.KeyPermissions
validKeyPermissions := keyvault.PossibleKeyPermissionsValues()
for _, key := range *policy.Permissions.Keys {
@@ -133,6 +139,10 @@ func parseAccessPolicy(policy *v1alpha1.AccessPolicyEntry, ctx context.Context)
}
}
+ newEntry.Permissions.Keys = &keyPermissions
+ }
+
+ if policy.Permissions.Secrets != nil {
var secretPermissions []keyvault.SecretPermissions
validSecretPermissions := keyvault.PossibleSecretPermissionsValues()
for _, key := range *policy.Permissions.Secrets {
@@ -144,6 +154,10 @@ func parseAccessPolicy(policy *v1alpha1.AccessPolicyEntry, ctx context.Context)
}
}
+ newEntry.Permissions.Secrets = &secretPermissions
+ }
+
+ if policy.Permissions.Secrets != nil {
var certificatePermissions []keyvault.CertificatePermissions
validCertificatePermissions := keyvault.PossibleCertificatePermissionsValues()
for _, key := range *policy.Permissions.Certificates {
@@ -155,6 +169,10 @@ func parseAccessPolicy(policy *v1alpha1.AccessPolicyEntry, ctx context.Context)
}
}
+ newEntry.Permissions.Certificates = &certificatePermissions
+ }
+
+ if policy.Permissions.Storage != nil {
var storagePermissions []keyvault.StoragePermissions
validStoragePermissions := keyvault.PossibleStoragePermissionsValues()
for _, key := range *policy.Permissions.Storage {
@@ -166,14 +184,7 @@ func parseAccessPolicy(policy *v1alpha1.AccessPolicyEntry, ctx context.Context)
}
}
- newEntry := keyvault.AccessPolicyEntry{
- TenantID: &tenantID,
- Permissions: &keyvault.Permissions{
- Keys: &keyPermissions,
- Secrets: &secretPermissions,
- Certificates: &certificatePermissions,
- Storage: &storagePermissions,
- },
+ newEntry.Permissions.Storage = &storagePermissions
}
if policy.ApplicationID != "" {
