зеркало из
1
0
Форкнуть 0

Refactor secrets handling to prepare for configmap support (#2500)

* Refactor secrets handling to prepare for configmap support

Refactors some code which can be shared between configmap and secrets.

* Use generic Resolved implementation

This reduces a small amount of duplciate code and paves the way
for other types of resolved references such as for configmaps.

* Change golangci-lint installation
This commit is contained in:
Matthew Christopher 2022-09-19 11:26:26 -07:00 коммит произвёл GitHub
Родитель 6350c8d2e2
Коммит 0e4894e869
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
79 изменённых файлов: 367 добавлений и 368 удалений

Просмотреть файл

@ -160,14 +160,12 @@ go-install gen-crd-api-reference-docs github.com/ahmetb/gen-crd-api-reference-do
go-install setup-envtest sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
# Install golangci-lint
if [ "$DEVCONTAINER" != true ]; then
write-verbose "Checking for $TOOL_DEST/golangci-lint"
if should-install "$TOOL_DEST/golangci-lint"; then
write-info "Installing golangci-lint"
# golangci-lint is provided by base image if in devcontainer
# this command copied from there
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$TOOL_DEST" v1.46.2 2>&1
fi
write-verbose "Checking for $TOOL_DEST/golangci-lint"
if should-install "$TOOL_DEST/golangci-lint"; then
write-info "Installing golangci-lint"
# golangci-lint is provided by base image if in devcontainer
# this command copied from there
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$TOOL_DEST" v1.49.0 2>&1
fi
# Install Task

Просмотреть файл

@ -13,8 +13,12 @@ linters:
presets:
- bugs
- unused
disable:
disable:
- scopelint # obsoleted by exportloopref
# Disabled as deprecation was announced in golanci-lint 1.49
- structcheck
- deadcode
- varcheck
# The below rules are disabled due to bug with go1.18 and generics: https://github.com/golangci/golangci-lint/issues/2859
- staticcheck
- gosimple

Просмотреть файл

@ -414,7 +414,7 @@ func (assignment *RoleAssignment_Spec) ConvertToARM(resolved genruntime.ConvertT
result.Properties.PrincipalType = &principalType
}
if assignment.RoleDefinitionReference != nil {
roleDefinitionIdARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*assignment.RoleDefinitionReference)
roleDefinitionIdARMID, err := resolved.ResolvedReferences.Lookup(*assignment.RoleDefinitionReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -417,7 +417,7 @@ func (assignment *RoleAssignment_Spec) ConvertToARM(resolved genruntime.ConvertT
result.Properties.PrincipalType = &principalType
}
if assignment.RoleDefinitionReference != nil {
roleDefinitionIdARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*assignment.RoleDefinitionReference)
roleDefinitionIdARMID, err := resolved.ResolvedReferences.Lookup(*assignment.RoleDefinitionReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -1422,7 +1422,7 @@ func (properties *AutoStorageBaseProperties) ConvertToARM(resolved genruntime.Co
// Set property StorageAccountId:
if properties.StorageAccountReference != nil {
storageAccountReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*properties.StorageAccountReference)
storageAccountReferenceARMID, err := resolved.ResolvedReferences.Lookup(*properties.StorageAccountReference)
if err != nil {
return nil, err
}
@ -2074,7 +2074,7 @@ func (reference *KeyVaultReference) ConvertToARM(resolved genruntime.ConvertToAR
// Set property Id:
if reference.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*reference.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*reference.Reference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -1464,7 +1464,7 @@ func (properties *AutoStorageBaseProperties) ConvertToARM(resolved genruntime.Co
// Set property StorageAccountId:
if properties.StorageAccountReference != nil {
storageAccountReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*properties.StorageAccountReference)
storageAccountReferenceARMID, err := resolved.ResolvedReferences.Lookup(*properties.StorageAccountReference)
if err != nil {
return nil, err
}
@ -2129,7 +2129,7 @@ func (reference *KeyVaultReference) ConvertToARM(resolved genruntime.ConvertToAR
// Set property Id:
if reference.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*reference.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*reference.Reference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -383,7 +383,7 @@ func (server *Redis_LinkedServer_Spec) ConvertToARM(resolved genruntime.ConvertT
result.Properties.LinkedRedisCacheLocation = &linkedRedisCacheLocation
}
if server.LinkedRedisCacheReference != nil {
linkedRedisCacheIdARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*server.LinkedRedisCacheReference)
linkedRedisCacheIdARMID, err := resolved.ResolvedReferences.Lookup(*server.LinkedRedisCacheReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -474,7 +474,7 @@ func (redis *Redis_Spec) ConvertToARM(resolved genruntime.ConvertToARMResolvedDe
result.Properties.StaticIP = &staticIP
}
if redis.SubnetReference != nil {
subnetIdARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*redis.SubnetReference)
subnetIdARMID, err := resolved.ResolvedReferences.Lookup(*redis.SubnetReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -376,7 +376,7 @@ func (server *Redis_LinkedServer_Spec) ConvertToARM(resolved genruntime.ConvertT
result.Properties.LinkedRedisCacheLocation = &linkedRedisCacheLocation
}
if server.LinkedRedisCacheReference != nil {
linkedRedisCacheIdARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*server.LinkedRedisCacheReference)
linkedRedisCacheIdARMID, err := resolved.ResolvedReferences.Lookup(*server.LinkedRedisCacheReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -496,7 +496,7 @@ func (redis *Redis_Spec) ConvertToARM(resolved genruntime.ConvertToARMResolvedDe
result.Properties.StaticIP = &staticIP
}
if redis.SubnetReference != nil {
subnetIdARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*redis.SubnetReference)
subnetIdARMID, err := resolved.ResolvedReferences.Lookup(*redis.SubnetReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -3006,7 +3006,7 @@ func (link *EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink)
// Set property Id:
if link.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*link.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*link.Reference)
if err != nil {
return nil, err
}
@ -3702,7 +3702,7 @@ func (origins *Profiles_Endpoint_Properties_Origins_Spec) ConvertToARM(resolved
result.Properties.PrivateLinkApprovalMessage = &privateLinkApprovalMessage
}
if origins.PrivateLinkLocationReference != nil {
privateLinkLocationARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*origins.PrivateLinkLocationReference)
privateLinkLocationARMID, err := resolved.ResolvedReferences.Lookup(*origins.PrivateLinkLocationReference)
if err != nil {
return nil, err
}
@ -3710,7 +3710,7 @@ func (origins *Profiles_Endpoint_Properties_Origins_Spec) ConvertToARM(resolved
result.Properties.PrivateLinkLocation = &privateLinkLocation
}
if origins.PrivateLinkResourceReference != nil {
privateLinkResourceIdARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*origins.PrivateLinkResourceReference)
privateLinkResourceIdARMID, err := resolved.ResolvedReferences.Lookup(*origins.PrivateLinkResourceReference)
if err != nil {
return nil, err
}
@ -4023,7 +4023,7 @@ func (reference *ResourceReference) ConvertToARM(resolved genruntime.ConvertToAR
// Set property Id:
if reference.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*reference.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*reference.Reference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -432,7 +432,7 @@ func (disk *Disk_Spec) ConvertToARM(resolved genruntime.ConvertToARMResolvedDeta
result.Properties.CreationData = &creationData
}
if disk.DiskAccessReference != nil {
diskAccessIdARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*disk.DiskAccessReference)
diskAccessIdARMID, err := resolved.ResolvedReferences.Lookup(*disk.DiskAccessReference)
if err != nil {
return nil, err
}
@ -2007,7 +2007,7 @@ func (data *CreationData) ConvertToARM(resolved genruntime.ConvertToARMResolvedD
// Set property SourceResourceId:
if data.SourceResourceReference != nil {
sourceResourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*data.SourceResourceReference)
sourceResourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*data.SourceResourceReference)
if err != nil {
return nil, err
}
@ -2688,7 +2688,7 @@ func (encryption *Encryption) ConvertToARM(resolved genruntime.ConvertToARMResol
// Set property DiskEncryptionSetId:
if encryption.DiskEncryptionSetReference != nil {
diskEncryptionSetReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*encryption.DiskEncryptionSetReference)
diskEncryptionSetReferenceARMID, err := resolved.ResolvedReferences.Lookup(*encryption.DiskEncryptionSetReference)
if err != nil {
return nil, err
}
@ -3961,7 +3961,7 @@ func (reference *ImageDiskReference) ConvertToARM(resolved genruntime.ConvertToA
// Set property Id:
if reference.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*reference.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*reference.Reference)
if err != nil {
return nil, err
}
@ -4565,7 +4565,7 @@ func (vault *SourceVault) ConvertToARM(resolved genruntime.ConvertToARMResolvedD
// Set property Id:
if vault.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*vault.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*vault.Reference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -411,7 +411,7 @@ func (snapshot *Snapshot_Spec) ConvertToARM(resolved genruntime.ConvertToARMReso
result.Properties.CreationData = &creationData
}
if snapshot.DiskAccessReference != nil {
diskAccessIdARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*snapshot.DiskAccessReference)
diskAccessIdARMID, err := resolved.ResolvedReferences.Lookup(*snapshot.DiskAccessReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -5086,7 +5086,7 @@ func (profile *VirtualMachineScaleSet_Properties_VirtualMachineProfile_OsProfile
// Set property AdminPassword:
if profile.AdminPassword != nil {
adminPasswordSecret, err := resolved.ResolvedSecrets.LookupSecret(*profile.AdminPassword)
adminPasswordSecret, err := resolved.ResolvedSecrets.Lookup(*profile.AdminPassword)
if err != nil {
return nil, errors.Wrap(err, "looking up secret for property AdminPassword")
}
@ -6181,7 +6181,7 @@ func (reference *ApiEntityReference) ConvertToARM(resolved genruntime.ConvertToA
// Set property Id:
if reference.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*reference.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*reference.Reference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -4532,7 +4532,7 @@ func (resource *SubResource) ConvertToARM(resolved genruntime.ConvertToARMResolv
// Set property Id:
if resource.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*resource.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*resource.Reference)
if err != nil {
return nil, err
}
@ -4801,7 +4801,7 @@ func (profile *VirtualMachine_Properties_OsProfile_Spec) ConvertToARM(resolved g
// Set property AdminPassword:
if profile.AdminPassword != nil {
adminPasswordSecret, err := resolved.ResolvedSecrets.LookupSecret(*profile.AdminPassword)
adminPasswordSecret, err := resolved.ResolvedSecrets.Lookup(*profile.AdminPassword)
if err != nil {
return nil, errors.Wrap(err, "looking up secret for property AdminPassword")
}
@ -7688,7 +7688,7 @@ func (reference *ImageReference) ConvertToARM(resolved genruntime.ConvertToARMRe
// Set property Id:
if reference.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*reference.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*reference.Reference)
if err != nil {
return nil, err
}
@ -9975,7 +9975,7 @@ func (interfaces *VirtualMachine_Properties_NetworkProfile_NetworkInterfaces_Spe
// Set property Id:
if interfaces.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*interfaces.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*interfaces.Reference)
if err != nil {
return nil, err
}
@ -12638,7 +12638,7 @@ func (parameters *ManagedDiskParameters) ConvertToARM(resolved genruntime.Conver
// Set property Id:
if parameters.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*parameters.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*parameters.Reference)
if err != nil {
return nil, err
}
@ -14196,7 +14196,7 @@ func (parameters *DiskEncryptionSetParameters) ConvertToARM(resolved genruntime.
// Set property Id:
if parameters.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*parameters.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*parameters.Reference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -1592,7 +1592,7 @@ func (resource *SubResource) ConvertToARM(resolved genruntime.ConvertToARMResolv
// Set property Id:
if resource.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*resource.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*resource.Reference)
if err != nil {
return nil, err
}
@ -2901,7 +2901,7 @@ func (parameters *DiskEncryptionSetParameters) ConvertToARM(resolved genruntime.
// Set property Id:
if parameters.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*parameters.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*parameters.Reference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -465,7 +465,7 @@ func (disk *Disk_Spec) ConvertToARM(resolved genruntime.ConvertToARMResolvedDeta
result.Properties.CreationData = &creationData
}
if disk.DiskAccessReference != nil {
diskAccessIdARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*disk.DiskAccessReference)
diskAccessIdARMID, err := resolved.ResolvedReferences.Lookup(*disk.DiskAccessReference)
if err != nil {
return nil, err
}
@ -2129,7 +2129,7 @@ func (data *CreationData) ConvertToARM(resolved genruntime.ConvertToARMResolvedD
// Set property SourceResourceId:
if data.SourceResourceReference != nil {
sourceResourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*data.SourceResourceReference)
sourceResourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*data.SourceResourceReference)
if err != nil {
return nil, err
}
@ -2827,7 +2827,7 @@ func (encryption *Encryption) ConvertToARM(resolved genruntime.ConvertToARMResol
// Set property DiskEncryptionSetId:
if encryption.DiskEncryptionSetReference != nil {
diskEncryptionSetReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*encryption.DiskEncryptionSetReference)
diskEncryptionSetReferenceARMID, err := resolved.ResolvedReferences.Lookup(*encryption.DiskEncryptionSetReference)
if err != nil {
return nil, err
}
@ -4138,7 +4138,7 @@ func (reference *ImageDiskReference) ConvertToARM(resolved genruntime.ConvertToA
// Set property Id:
if reference.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*reference.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*reference.Reference)
if err != nil {
return nil, err
}
@ -4756,7 +4756,7 @@ func (vault *SourceVault) ConvertToARM(resolved genruntime.ConvertToARMResolvedD
// Set property Id:
if vault.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*vault.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*vault.Reference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -428,7 +428,7 @@ func (snapshot *Snapshot_Spec) ConvertToARM(resolved genruntime.ConvertToARMReso
result.Properties.CreationData = &creationData
}
if snapshot.DiskAccessReference != nil {
diskAccessIdARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*snapshot.DiskAccessReference)
diskAccessIdARMID, err := resolved.ResolvedReferences.Lookup(*snapshot.DiskAccessReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -5433,7 +5433,7 @@ func (profile *VirtualMachineScaleSet_Properties_VirtualMachineProfile_OsProfile
// Set property AdminPassword:
if profile.AdminPassword != nil {
adminPasswordSecret, err := resolved.ResolvedSecrets.LookupSecret(*profile.AdminPassword)
adminPasswordSecret, err := resolved.ResolvedSecrets.Lookup(*profile.AdminPassword)
if err != nil {
return nil, errors.Wrap(err, "looking up secret for property AdminPassword")
}
@ -6586,7 +6586,7 @@ func (reference *ApiEntityReference) ConvertToARM(resolved genruntime.ConvertToA
// Set property Id:
if reference.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*reference.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*reference.Reference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -4869,7 +4869,7 @@ func (resource *SubResource) ConvertToARM(resolved genruntime.ConvertToARMResolv
// Set property Id:
if resource.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*resource.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*resource.Reference)
if err != nil {
return nil, err
}
@ -5198,7 +5198,7 @@ func (profile *VirtualMachine_Properties_OsProfile_Spec) ConvertToARM(resolved g
// Set property AdminPassword:
if profile.AdminPassword != nil {
adminPasswordSecret, err := resolved.ResolvedSecrets.LookupSecret(*profile.AdminPassword)
adminPasswordSecret, err := resolved.ResolvedSecrets.Lookup(*profile.AdminPassword)
if err != nil {
return nil, errors.Wrap(err, "looking up secret for property AdminPassword")
}
@ -8277,7 +8277,7 @@ func (reference *ImageReference) ConvertToARM(resolved genruntime.ConvertToARMRe
// Set property Id:
if reference.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*reference.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*reference.Reference)
if err != nil {
return nil, err
}
@ -10705,7 +10705,7 @@ func (interfaces *VirtualMachine_Properties_NetworkProfile_NetworkInterfaces_Spe
// Set property Id:
if interfaces.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*interfaces.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*interfaces.Reference)
if err != nil {
return nil, err
}
@ -13521,7 +13521,7 @@ func (parameters *ManagedDiskParameters) ConvertToARM(resolved genruntime.Conver
// Set property Id:
if parameters.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*parameters.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*parameters.Reference)
if err != nil {
return nil, err
}
@ -15133,7 +15133,7 @@ func (parameters *DiskEncryptionSetParameters) ConvertToARM(resolved genruntime.
// Set property Id:
if parameters.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*parameters.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*parameters.Reference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -1647,7 +1647,7 @@ func (resource *SubResource) ConvertToARM(resolved genruntime.ConvertToARMResolv
// Set property Id:
if resource.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*resource.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*resource.Reference)
if err != nil {
return nil, err
}
@ -3056,7 +3056,7 @@ func (parameters *DiskEncryptionSetParameters) ConvertToARM(resolved genruntime.
// Set property Id:
if parameters.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*parameters.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*parameters.Reference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -1633,7 +1633,7 @@ func (resource *SubResource) ConvertToARM(resolved genruntime.ConvertToARMResolv
// Set property Id:
if resource.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*resource.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*resource.Reference)
if err != nil {
return nil, err
}
@ -3042,7 +3042,7 @@ func (parameters *DiskEncryptionSetParameters) ConvertToARM(resolved genruntime.
// Set property Id:
if parameters.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*parameters.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*parameters.Reference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -6068,7 +6068,7 @@ func (profile *VirtualMachineScaleSet_Properties_VirtualMachineProfile_OsProfile
// Set property AdminPassword:
if profile.AdminPassword != nil {
adminPasswordSecret, err := resolved.ResolvedSecrets.LookupSecret(*profile.AdminPassword)
adminPasswordSecret, err := resolved.ResolvedSecrets.Lookup(*profile.AdminPassword)
if err != nil {
return nil, errors.Wrap(err, "looking up secret for property AdminPassword")
}
@ -7481,7 +7481,7 @@ func (reference *ApiEntityReference) ConvertToARM(resolved genruntime.ConvertToA
// Set property Id:
if reference.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*reference.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*reference.Reference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -6054,7 +6054,7 @@ func (profile *VirtualMachine_Properties_OsProfile_Spec) ConvertToARM(resolved g
// Set property AdminPassword:
if profile.AdminPassword != nil {
adminPasswordSecret, err := resolved.ResolvedSecrets.LookupSecret(*profile.AdminPassword)
adminPasswordSecret, err := resolved.ResolvedSecrets.Lookup(*profile.AdminPassword)
if err != nil {
return nil, errors.Wrap(err, "looking up secret for property AdminPassword")
}
@ -9285,7 +9285,7 @@ func (reference *ImageReference) ConvertToARM(resolved genruntime.ConvertToARMRe
// Set property Id:
if reference.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*reference.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*reference.Reference)
if err != nil {
return nil, err
}
@ -12533,7 +12533,7 @@ func (interfaces *VirtualMachine_Properties_NetworkProfile_NetworkInterfaces_Spe
// Set property Id:
if interfaces.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*interfaces.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*interfaces.Reference)
if err != nil {
return nil, err
}
@ -13687,7 +13687,7 @@ func (application *VMGalleryApplication) ConvertToARM(resolved genruntime.Conver
// Set property PackageReferenceId:
if application.PackageReferenceReference != nil {
packageReferenceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*application.PackageReferenceReference)
packageReferenceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*application.PackageReferenceReference)
if err != nil {
return nil, err
}
@ -16470,7 +16470,7 @@ func (parameters *ManagedDiskParameters) ConvertToARM(resolved genruntime.Conver
// Set property Id:
if parameters.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*parameters.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*parameters.Reference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -2912,7 +2912,7 @@ func (credentials *ContainerGroup_Properties_ImageRegistryCredentials_Spec) Conv
// Set property Password:
if credentials.Password != nil {
passwordSecret, err := resolved.ResolvedSecrets.LookupSecret(*credentials.Password)
passwordSecret, err := resolved.ResolvedSecrets.Lookup(*credentials.Password)
if err != nil {
return nil, errors.Wrap(err, "looking up secret for property Password")
}
@ -3880,7 +3880,7 @@ func (subnetId *ContainerGroupSubnetId) ConvertToARM(resolved genruntime.Convert
// Set property Id:
if subnetId.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*subnetId.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*subnetId.Reference)
if err != nil {
return nil, err
}
@ -7605,7 +7605,7 @@ func (analytics *LogAnalytics) ConvertToARM(resolved genruntime.ConvertToARMReso
// Set property WorkspaceResourceId:
if analytics.WorkspaceResourceReference != nil {
workspaceResourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*analytics.WorkspaceResourceReference)
workspaceResourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*analytics.WorkspaceResourceReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -521,7 +521,7 @@ func (cluster *ManagedCluster_Spec) ConvertToARM(resolved genruntime.ConvertToAR
result.Properties.DisableLocalAccounts = &disableLocalAccounts
}
if cluster.DiskEncryptionSetIDReference != nil {
diskEncryptionSetIDARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*cluster.DiskEncryptionSetIDReference)
diskEncryptionSetIDARMID, err := resolved.ResolvedReferences.Lookup(*cluster.DiskEncryptionSetIDReference)
if err != nil {
return nil, err
}
@ -2790,7 +2790,7 @@ func (etschemasmanagedclusterpropertiespropertiesidentityprofileadditionalproper
// Set property ResourceId:
if etschemasmanagedclusterpropertiespropertiesidentityprofileadditionalproperties.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*etschemasmanagedclusterpropertiespropertiesidentityprofileadditionalproperties.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*etschemasmanagedclusterpropertiespropertiesidentityprofileadditionalproperties.ResourceReference)
if err != nil {
return nil, err
}
@ -4541,7 +4541,7 @@ func (profile *ManagedClusterAgentPoolProfile) ConvertToARM(resolved genruntime.
// Set property NodePublicIPPrefixID:
if profile.NodePublicIPPrefixIDReference != nil {
nodePublicIPPrefixIDReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*profile.NodePublicIPPrefixIDReference)
nodePublicIPPrefixIDReferenceARMID, err := resolved.ResolvedReferences.Lookup(*profile.NodePublicIPPrefixIDReference)
if err != nil {
return nil, err
}
@ -4586,7 +4586,7 @@ func (profile *ManagedClusterAgentPoolProfile) ConvertToARM(resolved genruntime.
// Set property PodSubnetID:
if profile.PodSubnetIDReference != nil {
podSubnetIDReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*profile.PodSubnetIDReference)
podSubnetIDReferenceARMID, err := resolved.ResolvedReferences.Lookup(*profile.PodSubnetIDReference)
if err != nil {
return nil, err
}
@ -4650,7 +4650,7 @@ func (profile *ManagedClusterAgentPoolProfile) ConvertToARM(resolved genruntime.
// Set property VnetSubnetID:
if profile.VnetSubnetIDReference != nil {
vnetSubnetIDReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*profile.VnetSubnetIDReference)
vnetSubnetIDReferenceARMID, err := resolved.ResolvedReferences.Lookup(*profile.VnetSubnetIDReference)
if err != nil {
return nil, err
}
@ -8910,7 +8910,7 @@ func (resource *PrivateLinkResource) ConvertToARM(resolved genruntime.ConvertToA
// Set property Id:
if resource.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*resource.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*resource.Reference)
if err != nil {
return nil, err
}
@ -11627,7 +11627,7 @@ func (reference *ResourceReference) ConvertToARM(resolved genruntime.ConvertToAR
// Set property Id:
if reference.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*reference.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*reference.Reference)
if err != nil {
return nil, err
}
@ -11782,7 +11782,7 @@ func (identity *UserAssignedIdentity) ConvertToARM(resolved genruntime.ConvertTo
// Set property ResourceId:
if identity.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*identity.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*identity.ResourceReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -1474,7 +1474,7 @@ func (pool *ManagedClusters_AgentPool_Spec) ConvertToARM(resolved genruntime.Con
}
}
if pool.NodePublicIPPrefixIDReference != nil {
nodePublicIPPrefixIDARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*pool.NodePublicIPPrefixIDReference)
nodePublicIPPrefixIDARMID, err := resolved.ResolvedReferences.Lookup(*pool.NodePublicIPPrefixIDReference)
if err != nil {
return nil, err
}
@ -1505,7 +1505,7 @@ func (pool *ManagedClusters_AgentPool_Spec) ConvertToARM(resolved genruntime.Con
result.Properties.OsType = &osType
}
if pool.PodSubnetIDReference != nil {
podSubnetIDARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*pool.PodSubnetIDReference)
podSubnetIDARMID, err := resolved.ResolvedReferences.Lookup(*pool.PodSubnetIDReference)
if err != nil {
return nil, err
}
@ -1551,7 +1551,7 @@ func (pool *ManagedClusters_AgentPool_Spec) ConvertToARM(resolved genruntime.Con
result.Properties.VmSize = &vmSize
}
if pool.VnetSubnetIDReference != nil {
vnetSubnetIDARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*pool.VnetSubnetIDReference)
vnetSubnetIDARMID, err := resolved.ResolvedReferences.Lookup(*pool.VnetSubnetIDReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -568,7 +568,7 @@ func (cluster *ManagedCluster_Spec) ConvertToARM(resolved genruntime.ConvertToAR
result.Properties.DisableLocalAccounts = &disableLocalAccounts
}
if cluster.DiskEncryptionSetIDReference != nil {
diskEncryptionSetIDARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*cluster.DiskEncryptionSetIDReference)
diskEncryptionSetIDARMID, err := resolved.ResolvedReferences.Lookup(*cluster.DiskEncryptionSetIDReference)
if err != nil {
return nil, err
}
@ -2923,7 +2923,7 @@ func (etschemasmanagedclusterpropertiespropertiesidentityprofileadditionalproper
// Set property ResourceId:
if etschemasmanagedclusterpropertiespropertiesidentityprofileadditionalproperties.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*etschemasmanagedclusterpropertiespropertiesidentityprofileadditionalproperties.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*etschemasmanagedclusterpropertiespropertiesidentityprofileadditionalproperties.ResourceReference)
if err != nil {
return nil, err
}
@ -4837,7 +4837,7 @@ func (profile *ManagedClusterAgentPoolProfile) ConvertToARM(resolved genruntime.
// Set property NodePublicIPPrefixID:
if profile.NodePublicIPPrefixIDReference != nil {
nodePublicIPPrefixIDReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*profile.NodePublicIPPrefixIDReference)
nodePublicIPPrefixIDReferenceARMID, err := resolved.ResolvedReferences.Lookup(*profile.NodePublicIPPrefixIDReference)
if err != nil {
return nil, err
}
@ -4882,7 +4882,7 @@ func (profile *ManagedClusterAgentPoolProfile) ConvertToARM(resolved genruntime.
// Set property PodSubnetID:
if profile.PodSubnetIDReference != nil {
podSubnetIDReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*profile.PodSubnetIDReference)
podSubnetIDReferenceARMID, err := resolved.ResolvedReferences.Lookup(*profile.PodSubnetIDReference)
if err != nil {
return nil, err
}
@ -4946,7 +4946,7 @@ func (profile *ManagedClusterAgentPoolProfile) ConvertToARM(resolved genruntime.
// Set property VnetSubnetID:
if profile.VnetSubnetIDReference != nil {
vnetSubnetIDReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*profile.VnetSubnetIDReference)
vnetSubnetIDReferenceARMID, err := resolved.ResolvedReferences.Lookup(*profile.VnetSubnetIDReference)
if err != nil {
return nil, err
}
@ -9510,7 +9510,7 @@ func (resource *PrivateLinkResource) ConvertToARM(resolved genruntime.ConvertToA
// Set property Id:
if resource.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*resource.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*resource.Reference)
if err != nil {
return nil, err
}
@ -12242,7 +12242,7 @@ func (reference *ResourceReference) ConvertToARM(resolved genruntime.ConvertToAR
// Set property Id:
if reference.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*reference.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*reference.Reference)
if err != nil {
return nil, err
}
@ -12402,7 +12402,7 @@ func (identity *UserAssignedIdentity) ConvertToARM(resolved genruntime.ConvertTo
// Set property ResourceId:
if identity.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*identity.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*identity.ResourceReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -1625,7 +1625,7 @@ func (pool *ManagedClusters_AgentPool_Spec) ConvertToARM(resolved genruntime.Con
}
}
if pool.NodePublicIPPrefixIDReference != nil {
nodePublicIPPrefixIDARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*pool.NodePublicIPPrefixIDReference)
nodePublicIPPrefixIDARMID, err := resolved.ResolvedReferences.Lookup(*pool.NodePublicIPPrefixIDReference)
if err != nil {
return nil, err
}
@ -1656,7 +1656,7 @@ func (pool *ManagedClusters_AgentPool_Spec) ConvertToARM(resolved genruntime.Con
result.Properties.OsType = &osType
}
if pool.PodSubnetIDReference != nil {
podSubnetIDARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*pool.PodSubnetIDReference)
podSubnetIDARMID, err := resolved.ResolvedReferences.Lookup(*pool.PodSubnetIDReference)
if err != nil {
return nil, err
}
@ -1702,7 +1702,7 @@ func (pool *ManagedClusters_AgentPool_Spec) ConvertToARM(resolved genruntime.Con
result.Properties.VmSize = &vmSize
}
if pool.VnetSubnetIDReference != nil {
vnetSubnetIDARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*pool.VnetSubnetIDReference)
vnetSubnetIDARMID, err := resolved.ResolvedReferences.Lookup(*pool.VnetSubnetIDReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -2325,7 +2325,7 @@ func (create *ServerPropertiesForDefaultCreate) ConvertToARM(resolved genruntime
}
// Set property AdministratorLoginPassword:
administratorLoginPasswordSecret, err := resolved.ResolvedSecrets.LookupSecret(create.AdministratorLoginPassword)
administratorLoginPasswordSecret, err := resolved.ResolvedSecrets.Lookup(create.AdministratorLoginPassword)
if err != nil {
return nil, errors.Wrap(err, "looking up secret for property AdministratorLoginPassword")
}

Просмотреть файл

@ -441,7 +441,7 @@ func (server *FlexibleServer_Spec) ConvertToARM(resolved genruntime.ConvertToARM
result.Properties.AdministratorLogin = &administratorLogin
}
if server.AdministratorLoginPassword != nil {
administratorLoginPasswordSecret, err := resolved.ResolvedSecrets.LookupSecret(*server.AdministratorLoginPassword)
administratorLoginPasswordSecret, err := resolved.ResolvedSecrets.Lookup(*server.AdministratorLoginPassword)
if err != nil {
return nil, errors.Wrap(err, "looking up secret for property AdministratorLoginPassword")
}
@ -2121,7 +2121,7 @@ func (encryption *DataEncryption) ConvertToARM(resolved genruntime.ConvertToARMR
// Set property GeoBackupUserAssignedIdentityId:
if encryption.GeoBackupUserAssignedIdentityReference != nil {
geoBackupUserAssignedIdentityReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*encryption.GeoBackupUserAssignedIdentityReference)
geoBackupUserAssignedIdentityReferenceARMID, err := resolved.ResolvedReferences.Lookup(*encryption.GeoBackupUserAssignedIdentityReference)
if err != nil {
return nil, err
}
@ -2137,7 +2137,7 @@ func (encryption *DataEncryption) ConvertToARM(resolved genruntime.ConvertToARMR
// Set property PrimaryUserAssignedIdentityId:
if encryption.PrimaryUserAssignedIdentityReference != nil {
primaryUserAssignedIdentityReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*encryption.PrimaryUserAssignedIdentityReference)
primaryUserAssignedIdentityReferenceARMID, err := resolved.ResolvedReferences.Lookup(*encryption.PrimaryUserAssignedIdentityReference)
if err != nil {
return nil, err
}
@ -3109,7 +3109,7 @@ func (network *Network) ConvertToARM(resolved genruntime.ConvertToARMResolvedDet
// Set property DelegatedSubnetResourceId:
if network.DelegatedSubnetResourceReference != nil {
delegatedSubnetResourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*network.DelegatedSubnetResourceReference)
delegatedSubnetResourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*network.DelegatedSubnetResourceReference)
if err != nil {
return nil, err
}
@ -3119,7 +3119,7 @@ func (network *Network) ConvertToARM(resolved genruntime.ConvertToARMResolvedDet
// Set property PrivateDnsZoneResourceId:
if network.PrivateDnsZoneResourceReference != nil {
privateDnsZoneResourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*network.PrivateDnsZoneResourceReference)
privateDnsZoneResourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*network.PrivateDnsZoneResourceReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -462,7 +462,7 @@ func (server *FlexibleServer_Spec) ConvertToARM(resolved genruntime.ConvertToARM
result.Properties.AdministratorLogin = &administratorLogin
}
if server.AdministratorLoginPassword != nil {
administratorLoginPasswordSecret, err := resolved.ResolvedSecrets.LookupSecret(*server.AdministratorLoginPassword)
administratorLoginPasswordSecret, err := resolved.ResolvedSecrets.Lookup(*server.AdministratorLoginPassword)
if err != nil {
return nil, errors.Wrap(err, "looking up secret for property AdministratorLoginPassword")
}
@ -2207,7 +2207,7 @@ func (encryption *DataEncryption) ConvertToARM(resolved genruntime.ConvertToARMR
// Set property GeoBackupUserAssignedIdentityId:
if encryption.GeoBackupUserAssignedIdentityReference != nil {
geoBackupUserAssignedIdentityReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*encryption.GeoBackupUserAssignedIdentityReference)
geoBackupUserAssignedIdentityReferenceARMID, err := resolved.ResolvedReferences.Lookup(*encryption.GeoBackupUserAssignedIdentityReference)
if err != nil {
return nil, err
}
@ -2223,7 +2223,7 @@ func (encryption *DataEncryption) ConvertToARM(resolved genruntime.ConvertToARMR
// Set property PrimaryUserAssignedIdentityId:
if encryption.PrimaryUserAssignedIdentityReference != nil {
primaryUserAssignedIdentityReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*encryption.PrimaryUserAssignedIdentityReference)
primaryUserAssignedIdentityReferenceARMID, err := resolved.ResolvedReferences.Lookup(*encryption.PrimaryUserAssignedIdentityReference)
if err != nil {
return nil, err
}
@ -3234,7 +3234,7 @@ func (network *Network) ConvertToARM(resolved genruntime.ConvertToARMResolvedDet
// Set property DelegatedSubnetResourceId:
if network.DelegatedSubnetResourceReference != nil {
delegatedSubnetResourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*network.DelegatedSubnetResourceReference)
delegatedSubnetResourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*network.DelegatedSubnetResourceReference)
if err != nil {
return nil, err
}
@ -3244,7 +3244,7 @@ func (network *Network) ConvertToARM(resolved genruntime.ConvertToARMResolvedDet
// Set property PrivateDnsZoneResourceId:
if network.PrivateDnsZoneResourceReference != nil {
privateDnsZoneResourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*network.PrivateDnsZoneResourceReference)
privateDnsZoneResourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*network.PrivateDnsZoneResourceReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -425,7 +425,7 @@ func (server *FlexibleServer_Spec) ConvertToARM(resolved genruntime.ConvertToARM
result.Properties.AdministratorLogin = &administratorLogin
}
if server.AdministratorLoginPassword != nil {
administratorLoginPasswordSecret, err := resolved.ResolvedSecrets.LookupSecret(*server.AdministratorLoginPassword)
administratorLoginPasswordSecret, err := resolved.ResolvedSecrets.Lookup(*server.AdministratorLoginPassword)
if err != nil {
return nil, errors.Wrap(err, "looking up secret for property AdministratorLoginPassword")
}
@ -477,7 +477,7 @@ func (server *FlexibleServer_Spec) ConvertToARM(resolved genruntime.ConvertToARM
result.Properties.PointInTimeUTC = &pointInTimeUTC
}
if server.SourceServerResourceReference != nil {
sourceServerResourceIdARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*server.SourceServerResourceReference)
sourceServerResourceIdARMID, err := resolved.ResolvedReferences.Lookup(*server.SourceServerResourceReference)
if err != nil {
return nil, err
}
@ -2378,7 +2378,7 @@ func (network *Network) ConvertToARM(resolved genruntime.ConvertToARMResolvedDet
// Set property DelegatedSubnetResourceId:
if network.DelegatedSubnetResourceReference != nil {
delegatedSubnetResourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*network.DelegatedSubnetResourceReference)
delegatedSubnetResourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*network.DelegatedSubnetResourceReference)
if err != nil {
return nil, err
}
@ -2388,7 +2388,7 @@ func (network *Network) ConvertToARM(resolved genruntime.ConvertToARMResolvedDet
// Set property PrivateDnsZoneArmResourceId:
if network.PrivateDnsZoneArmResourceReference != nil {
privateDnsZoneArmResourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*network.PrivateDnsZoneArmResourceReference)
privateDnsZoneArmResourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*network.PrivateDnsZoneArmResourceReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -442,7 +442,7 @@ func (server *FlexibleServer_Spec) ConvertToARM(resolved genruntime.ConvertToARM
result.Properties.AdministratorLogin = &administratorLogin
}
if server.AdministratorLoginPassword != nil {
administratorLoginPasswordSecret, err := resolved.ResolvedSecrets.LookupSecret(*server.AdministratorLoginPassword)
administratorLoginPasswordSecret, err := resolved.ResolvedSecrets.Lookup(*server.AdministratorLoginPassword)
if err != nil {
return nil, errors.Wrap(err, "looking up secret for property AdministratorLoginPassword")
}
@ -494,7 +494,7 @@ func (server *FlexibleServer_Spec) ConvertToARM(resolved genruntime.ConvertToARM
result.Properties.PointInTimeUTC = &pointInTimeUTC
}
if server.SourceServerResourceReference != nil {
sourceServerResourceIdARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*server.SourceServerResourceReference)
sourceServerResourceIdARMID, err := resolved.ResolvedReferences.Lookup(*server.SourceServerResourceReference)
if err != nil {
return nil, err
}
@ -2469,7 +2469,7 @@ func (network *Network) ConvertToARM(resolved genruntime.ConvertToARMResolvedDet
// Set property DelegatedSubnetResourceId:
if network.DelegatedSubnetResourceReference != nil {
delegatedSubnetResourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*network.DelegatedSubnetResourceReference)
delegatedSubnetResourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*network.DelegatedSubnetResourceReference)
if err != nil {
return nil, err
}
@ -2479,7 +2479,7 @@ func (network *Network) ConvertToARM(resolved genruntime.ConvertToARMResolvedDet
// Set property PrivateDnsZoneArmResourceId:
if network.PrivateDnsZoneArmResourceReference != nil {
privateDnsZoneArmResourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*network.PrivateDnsZoneArmResourceReference)
privateDnsZoneArmResourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*network.PrivateDnsZoneArmResourceReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -4819,7 +4819,7 @@ func (rule *VirtualNetworkRule) ConvertToARM(resolved genruntime.ConvertToARMRes
// Set property Id:
if rule.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*rule.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*rule.Reference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -5004,7 +5004,7 @@ func (rule *VirtualNetworkRule) ConvertToARM(resolved genruntime.ConvertToARMRes
// Set property Id:
if rule.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*rule.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*rule.Reference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -3794,7 +3794,7 @@ func (properties *StorageBlobDeadLetterDestinationProperties) ConvertToARM(resol
// Set property ResourceId:
if properties.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*properties.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*properties.ResourceReference)
if err != nil {
return nil, err
}
@ -5684,7 +5684,7 @@ func (properties *AzureFunctionEventSubscriptionDestinationProperties) ConvertTo
// Set property ResourceId:
if properties.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*properties.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*properties.ResourceReference)
if err != nil {
return nil, err
}
@ -5798,7 +5798,7 @@ func (properties *EventHubEventSubscriptionDestinationProperties) ConvertToARM(r
// Set property ResourceId:
if properties.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*properties.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*properties.ResourceReference)
if err != nil {
return nil, err
}
@ -5888,7 +5888,7 @@ func (properties *HybridConnectionEventSubscriptionDestinationProperties) Conver
// Set property ResourceId:
if properties.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*properties.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*properties.ResourceReference)
if err != nil {
return nil, err
}
@ -5978,7 +5978,7 @@ func (properties *ServiceBusQueueEventSubscriptionDestinationProperties) Convert
// Set property ResourceId:
if properties.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*properties.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*properties.ResourceReference)
if err != nil {
return nil, err
}
@ -6068,7 +6068,7 @@ func (properties *ServiceBusTopicEventSubscriptionDestinationProperties) Convert
// Set property ResourceId:
if properties.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*properties.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*properties.ResourceReference)
if err != nil {
return nil, err
}
@ -6165,7 +6165,7 @@ func (properties *StorageQueueEventSubscriptionDestinationProperties) ConvertToA
// Set property ResourceId:
if properties.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*properties.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*properties.ResourceReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -3899,7 +3899,7 @@ func (properties *StorageBlobDeadLetterDestinationProperties) ConvertToARM(resol
// Set property ResourceId:
if properties.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*properties.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*properties.ResourceReference)
if err != nil {
return nil, err
}
@ -5820,7 +5820,7 @@ func (properties *AzureFunctionEventSubscriptionDestinationProperties) ConvertTo
// Set property ResourceId:
if properties.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*properties.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*properties.ResourceReference)
if err != nil {
return nil, err
}
@ -5934,7 +5934,7 @@ func (properties *EventHubEventSubscriptionDestinationProperties) ConvertToARM(r
// Set property ResourceId:
if properties.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*properties.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*properties.ResourceReference)
if err != nil {
return nil, err
}
@ -6023,7 +6023,7 @@ func (properties *HybridConnectionEventSubscriptionDestinationProperties) Conver
// Set property ResourceId:
if properties.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*properties.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*properties.ResourceReference)
if err != nil {
return nil, err
}
@ -6113,7 +6113,7 @@ func (properties *ServiceBusQueueEventSubscriptionDestinationProperties) Convert
// Set property ResourceId:
if properties.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*properties.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*properties.ResourceReference)
if err != nil {
return nil, err
}
@ -6203,7 +6203,7 @@ func (properties *ServiceBusTopicEventSubscriptionDestinationProperties) Convert
// Set property ResourceId:
if properties.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*properties.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*properties.ResourceReference)
if err != nil {
return nil, err
}
@ -6302,7 +6302,7 @@ func (properties *StorageQueueEventSubscriptionDestinationProperties) ConvertToA
// Set property ResourceId:
if properties.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*properties.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*properties.ResourceReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -1028,7 +1028,7 @@ func (namespace *Namespace_Spec) ConvertToARM(resolved genruntime.ConvertToARMRe
result.Properties.AlternateName = &alternateName
}
if namespace.ClusterArmReference != nil {
clusterArmIdARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*namespace.ClusterArmReference)
clusterArmIdARMID, err := resolved.ResolvedReferences.Lookup(*namespace.ClusterArmReference)
if err != nil {
return nil, err
}
@ -2975,7 +2975,7 @@ func (endpoint *PrivateEndpoint) ConvertToARM(resolved genruntime.ConvertToARMRe
// Set property Id:
if endpoint.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*endpoint.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*endpoint.Reference)
if err != nil {
return nil, err
}
@ -3129,7 +3129,7 @@ func (properties *UserAssignedIdentityProperties) ConvertToARM(resolved genrunti
// Set property UserAssignedIdentity:
if properties.UserAssignedIdentityReference != nil {
userAssignedIdentityReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*properties.UserAssignedIdentityReference)
userAssignedIdentityReferenceARMID, err := resolved.ResolvedReferences.Lookup(*properties.UserAssignedIdentityReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -1602,7 +1602,7 @@ func (destination *Namespaces_Eventhub_Properties_CaptureDescription_Destination
result.Properties.DataLakeSubscriptionId = &dataLakeSubscriptionId
}
if destination.StorageAccountResourceReference != nil {
storageAccountResourceIdARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*destination.StorageAccountResourceReference)
storageAccountResourceIdARMID, err := resolved.ResolvedReferences.Lookup(*destination.StorageAccountResourceReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -1085,7 +1085,7 @@ func (namespace *Namespace_Spec) ConvertToARM(resolved genruntime.ConvertToARMRe
result.Properties.AlternateName = &alternateName
}
if namespace.ClusterArmReference != nil {
clusterArmIdARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*namespace.ClusterArmReference)
clusterArmIdARMID, err := resolved.ResolvedReferences.Lookup(*namespace.ClusterArmReference)
if err != nil {
return nil, err
}
@ -3082,7 +3082,7 @@ func (endpoint *PrivateEndpoint) ConvertToARM(resolved genruntime.ConvertToARMRe
// Set property Id:
if endpoint.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*endpoint.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*endpoint.Reference)
if err != nil {
return nil, err
}
@ -3239,7 +3239,7 @@ func (properties *UserAssignedIdentityProperties) ConvertToARM(resolved genrunti
// Set property UserAssignedIdentity:
if properties.UserAssignedIdentityReference != nil {
userAssignedIdentityReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*properties.UserAssignedIdentityReference)
userAssignedIdentityReferenceARMID, err := resolved.ResolvedReferences.Lookup(*properties.UserAssignedIdentityReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -1672,7 +1672,7 @@ func (destination *Namespaces_Eventhub_Properties_CaptureDescription_Destination
result.Properties.DataLakeSubscriptionId = &dataLakeSubscriptionId
}
if destination.StorageAccountResourceReference != nil {
storageAccountResourceIdARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*destination.StorageAccountResourceReference)
storageAccountResourceIdARMID, err := resolved.ResolvedReferences.Lookup(*destination.StorageAccountResourceReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -1223,7 +1223,7 @@ func (component *Component_Spec) ConvertToARM(resolved genruntime.ConvertToARMRe
result.Properties.SamplingPercentage = &samplingPercentage
}
if component.WorkspaceResourceReference != nil {
workspaceResourceIdARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*component.WorkspaceResourceReference)
workspaceResourceIdARMID, err := resolved.ResolvedReferences.Lookup(*component.WorkspaceResourceReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -1320,7 +1320,7 @@ func (component *Component_Spec) ConvertToARM(resolved genruntime.ConvertToARMRe
result.Properties.SamplingPercentage = &samplingPercentage
}
if component.WorkspaceResourceReference != nil {
workspaceResourceIdARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*component.WorkspaceResourceReference)
workspaceResourceIdARMID, err := resolved.ResolvedReferences.Lookup(*component.WorkspaceResourceReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -3879,7 +3879,7 @@ func (rule *VirtualNetworkRule) ConvertToARM(resolved genruntime.ConvertToARMRes
// Set property Id:
if rule.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*rule.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*rule.Reference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -474,7 +474,7 @@ func (workspace *Workspace_Spec) ConvertToARM(resolved genruntime.ConvertToARMRe
result.Properties.AllowPublicAccessWhenBehindVnet = &allowPublicAccessWhenBehindVnet
}
if workspace.ApplicationInsightsReference != nil {
applicationInsightsARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*workspace.ApplicationInsightsReference)
applicationInsightsARMID, err := resolved.ResolvedReferences.Lookup(*workspace.ApplicationInsightsReference)
if err != nil {
return nil, err
}
@ -482,7 +482,7 @@ func (workspace *Workspace_Spec) ConvertToARM(resolved genruntime.ConvertToARMRe
result.Properties.ApplicationInsights = &applicationInsights
}
if workspace.ContainerRegistryReference != nil {
containerRegistryARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*workspace.ContainerRegistryReference)
containerRegistryARMID, err := resolved.ResolvedReferences.Lookup(*workspace.ContainerRegistryReference)
if err != nil {
return nil, err
}
@ -518,7 +518,7 @@ func (workspace *Workspace_Spec) ConvertToARM(resolved genruntime.ConvertToARMRe
result.Properties.ImageBuildCompute = &imageBuildCompute
}
if workspace.KeyVaultReference != nil {
keyVaultARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*workspace.KeyVaultReference)
keyVaultARMID, err := resolved.ResolvedReferences.Lookup(*workspace.KeyVaultReference)
if err != nil {
return nil, err
}
@ -526,7 +526,7 @@ func (workspace *Workspace_Spec) ConvertToARM(resolved genruntime.ConvertToARMRe
result.Properties.KeyVault = &keyVault
}
if workspace.PrimaryUserAssignedIdentityReference != nil {
primaryUserAssignedIdentityARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*workspace.PrimaryUserAssignedIdentityReference)
primaryUserAssignedIdentityARMID, err := resolved.ResolvedReferences.Lookup(*workspace.PrimaryUserAssignedIdentityReference)
if err != nil {
return nil, err
}
@ -553,7 +553,7 @@ func (workspace *Workspace_Spec) ConvertToARM(resolved genruntime.ConvertToARMRe
result.Properties.SharedPrivateLinkResources = append(result.Properties.SharedPrivateLinkResources, *item_ARM.(*Workspace_Properties_SharedPrivateLinkResources_Spec_ARM))
}
if workspace.StorageAccountReference != nil {
storageAccountARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*workspace.StorageAccountReference)
storageAccountARMID, err := resolved.ResolvedReferences.Lookup(*workspace.StorageAccountReference)
if err != nil {
return nil, err
}
@ -3949,7 +3949,7 @@ func (resources *Workspace_Properties_SharedPrivateLinkResources_Spec) ConvertTo
result.Properties.GroupId = &groupId
}
if resources.PrivateLinkResourceReference != nil {
privateLinkResourceIdARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*resources.PrivateLinkResourceReference)
privateLinkResourceIdARMID, err := resolved.ResolvedReferences.Lookup(*resources.PrivateLinkResourceReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -1867,7 +1867,7 @@ func (computeAKS *Compute_AKS) ConvertToARM(resolved genruntime.ConvertToARMReso
// Set property ResourceId:
if computeAKS.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*computeAKS.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*computeAKS.ResourceReference)
if err != nil {
return nil, err
}
@ -2099,7 +2099,7 @@ func (compute *Compute_AmlCompute) ConvertToARM(resolved genruntime.ConvertToARM
// Set property ResourceId:
if compute.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*compute.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*compute.ResourceReference)
if err != nil {
return nil, err
}
@ -2331,7 +2331,7 @@ func (instance *Compute_ComputeInstance) ConvertToARM(resolved genruntime.Conver
// Set property ResourceId:
if instance.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*instance.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*instance.ResourceReference)
if err != nil {
return nil, err
}
@ -2563,7 +2563,7 @@ func (databricks *Compute_Databricks) ConvertToARM(resolved genruntime.ConvertTo
// Set property ResourceId:
if databricks.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*databricks.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*databricks.ResourceReference)
if err != nil {
return nil, err
}
@ -2782,7 +2782,7 @@ func (factory *Compute_DataFactory) ConvertToARM(resolved genruntime.ConvertToAR
// Set property ResourceId:
if factory.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*factory.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*factory.ResourceReference)
if err != nil {
return nil, err
}
@ -2977,7 +2977,7 @@ func (analytics *Compute_DataLakeAnalytics) ConvertToARM(resolved genruntime.Con
// Set property ResourceId:
if analytics.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*analytics.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*analytics.ResourceReference)
if err != nil {
return nil, err
}
@ -3209,7 +3209,7 @@ func (insight *Compute_HDInsight) ConvertToARM(resolved genruntime.ConvertToARMR
// Set property ResourceId:
if insight.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*insight.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*insight.ResourceReference)
if err != nil {
return nil, err
}
@ -3439,7 +3439,7 @@ func (spark *Compute_SynapseSpark) ConvertToARM(resolved genruntime.ConvertToARM
// Set property ResourceId:
if spark.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*spark.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*spark.ResourceReference)
if err != nil {
return nil, err
}
@ -3669,7 +3669,7 @@ func (machine *Compute_VirtualMachine) ConvertToARM(resolved genruntime.ConvertT
// Set property ResourceId:
if machine.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*machine.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*machine.ResourceReference)
if err != nil {
return nil, err
}
@ -6040,7 +6040,7 @@ func (configuration *AksNetworkingConfiguration) ConvertToARM(resolved genruntim
// Set property SubnetId:
if configuration.SubnetReference != nil {
subnetReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*configuration.SubnetReference)
subnetReferenceARMID, err := resolved.ResolvedReferences.Lookup(*configuration.SubnetReference)
if err != nil {
return nil, err
}
@ -6855,7 +6855,7 @@ func (resourceId *ResourceId) ConvertToARM(resolved genruntime.ConvertToARMResol
// Set property Id:
if resourceId.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*resourceId.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*resourceId.Reference)
if err != nil {
return nil, err
}
@ -7379,7 +7379,7 @@ func (credentials *UserAccountCredentials) ConvertToARM(resolved genruntime.Conv
// Set property AdminUserPassword:
if credentials.AdminUserPassword != nil {
adminUserPasswordSecret, err := resolved.ResolvedSecrets.LookupSecret(*credentials.AdminUserPassword)
adminUserPasswordSecret, err := resolved.ResolvedSecrets.Lookup(*credentials.AdminUserPassword)
if err != nil {
return nil, errors.Wrap(err, "looking up secret for property AdminUserPassword")
}
@ -7389,7 +7389,7 @@ func (credentials *UserAccountCredentials) ConvertToARM(resolved genruntime.Conv
// Set property AdminUserSshPublicKey:
if credentials.AdminUserSshPublicKey != nil {
adminUserSshPublicKeySecret, err := resolved.ResolvedSecrets.LookupSecret(*credentials.AdminUserSshPublicKey)
adminUserSshPublicKeySecret, err := resolved.ResolvedSecrets.Lookup(*credentials.AdminUserSshPublicKey)
if err != nil {
return nil, errors.Wrap(err, "looking up secret for property AdminUserSshPublicKey")
}
@ -7504,7 +7504,7 @@ func (image *VirtualMachineImage) ConvertToARM(resolved genruntime.ConvertToARMR
// Set property Id:
if image.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*image.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*image.Reference)
if err != nil {
return nil, err
}
@ -7597,7 +7597,7 @@ func (credentials *VirtualMachineSshCredentials) ConvertToARM(resolved genruntim
// Set property Password:
if credentials.Password != nil {
passwordSecret, err := resolved.ResolvedSecrets.LookupSecret(*credentials.Password)
passwordSecret, err := resolved.ResolvedSecrets.Lookup(*credentials.Password)
if err != nil {
return nil, errors.Wrap(err, "looking up secret for property Password")
}

Просмотреть файл

@ -3260,7 +3260,7 @@ func (resource *SubResource) ConvertToARM(resolved genruntime.ConvertToARMResolv
// Set property Id:
if resource.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*resource.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*resource.Reference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -457,7 +457,7 @@ func (gateway *VirtualNetworkGateway_Spec) ConvertToARM(resolved genruntime.Conv
result.Properties.Sku = &sku
}
if gateway.VNetExtendedLocationResourceReference != nil {
vNetExtendedLocationResourceIdARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*gateway.VNetExtendedLocationResourceReference)
vNetExtendedLocationResourceIdARMID, err := resolved.ResolvedReferences.Lookup(*gateway.VNetExtendedLocationResourceReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -3380,7 +3380,7 @@ func (resource *SubResource) ConvertToARM(resolved genruntime.ConvertToARMResolv
// Set property Id:
if resource.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*resource.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*resource.Reference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -481,7 +481,7 @@ func (gateway *VirtualNetworkGateway_Spec) ConvertToARM(resolved genruntime.Conv
result.Properties.Sku = &sku
}
if gateway.VNetExtendedLocationResourceReference != nil {
vNetExtendedLocationResourceIdARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*gateway.VNetExtendedLocationResourceReference)
vNetExtendedLocationResourceIdARMID, err := resolved.ResolvedReferences.Lookup(*gateway.VNetExtendedLocationResourceReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -1666,7 +1666,7 @@ func (features *WorkspaceFeatures) ConvertToARM(resolved genruntime.ConvertToARM
// Set property ClusterResourceId:
if features.ClusterResourceReference != nil {
clusterResourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*features.ClusterResourceReference)
clusterResourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*features.ClusterResourceReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -1728,7 +1728,7 @@ func (features *WorkspaceFeatures) ConvertToARM(resolved genruntime.ConvertToARM
// Set property ClusterResourceId:
if features.ClusterResourceReference != nil {
clusterResourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*features.ClusterResourceReference)
clusterResourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*features.ClusterResourceReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -2727,7 +2727,7 @@ func (properties *UserAssignedIdentityProperties) ConvertToARM(resolved genrunti
// Set property UserAssignedIdentity:
if properties.UserAssignedIdentityReference != nil {
userAssignedIdentityReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*properties.UserAssignedIdentityReference)
userAssignedIdentityReferenceARMID, err := resolved.ResolvedReferences.Lookup(*properties.UserAssignedIdentityReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -2805,7 +2805,7 @@ func (properties *UserAssignedIdentityProperties) ConvertToARM(resolved genrunti
// Set property UserAssignedIdentity:
if properties.UserAssignedIdentityReference != nil {
userAssignedIdentityReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*properties.UserAssignedIdentityReference)
userAssignedIdentityReferenceARMID, err := resolved.ResolvedReferences.Lookup(*properties.UserAssignedIdentityReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -6424,7 +6424,7 @@ func (identity *EncryptionIdentity) ConvertToARM(resolved genruntime.ConvertToAR
// Set property UserAssignedIdentity:
if identity.UserAssignedIdentityReference != nil {
userAssignedIdentityReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*identity.UserAssignedIdentityReference)
userAssignedIdentityReferenceARMID, err := resolved.ResolvedReferences.Lookup(*identity.UserAssignedIdentityReference)
if err != nil {
return nil, err
}
@ -7446,7 +7446,7 @@ func (rule *ResourceAccessRule) ConvertToARM(resolved genruntime.ConvertToARMRes
// Set property ResourceId:
if rule.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*rule.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*rule.ResourceReference)
if err != nil {
return nil, err
}
@ -8131,7 +8131,7 @@ func (rule *VirtualNetworkRule) ConvertToARM(resolved genruntime.ConvertToARMRes
// Set property Id:
if rule.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*rule.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*rule.Reference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -6651,7 +6651,7 @@ func (identity *EncryptionIdentity) ConvertToARM(resolved genruntime.ConvertToAR
// Set property UserAssignedIdentity:
if identity.UserAssignedIdentityReference != nil {
userAssignedIdentityReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*identity.UserAssignedIdentityReference)
userAssignedIdentityReferenceARMID, err := resolved.ResolvedReferences.Lookup(*identity.UserAssignedIdentityReference)
if err != nil {
return nil, err
}
@ -7702,7 +7702,7 @@ func (rule *ResourceAccessRule) ConvertToARM(resolved genruntime.ConvertToARMRes
// Set property ResourceId:
if rule.ResourceReference != nil {
resourceReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*rule.ResourceReference)
resourceReferenceARMID, err := resolved.ResolvedReferences.Lookup(*rule.ResourceReference)
if err != nil {
return nil, err
}
@ -8407,7 +8407,7 @@ func (rule *VirtualNetworkRule) ConvertToARM(resolved genruntime.ConvertToARMRes
// Set property Id:
if rule.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*rule.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*rule.Reference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -73,7 +73,7 @@ func Test_WhenObjectPullSecretsAndSecretAlreadyExists_WarningConditionIsSet(t *t
// We expect the ready condition to include details of the error
tc.Expect(acct.Status.Conditions[0].Severity).To(Equal(conditions.ConditionSeverityError))
tc.Expect(acct.Status.Conditions[0].Reason).To(Equal("FailedWritingSecret"))
tc.Expect(acct.Status.Conditions[0].Message).To(MatchRegexp("cannot overwrite secret.*which is not owned by"))
tc.Expect(acct.Status.Conditions[0].Message).To(MatchRegexp("cannot overwrite Secret.*which is not owned by"))
// Delete the resource, it should be able to proceed and delete the underlying Azure resource
tc.DeleteResourceAndWait(acct)
@ -105,7 +105,7 @@ func Test_TwoObjectsWriteSameSecret_WarningConditionIsSetOnSecond(t *testing.T)
// Note that the error is fatal as the customer must take some action in order to resolve the problem.
tc.Expect(acct2.Status.Conditions[0].Severity).To(Equal(conditions.ConditionSeverityError))
tc.Expect(acct2.Status.Conditions[0].Reason).To(Equal("FailedWritingSecret"))
tc.Expect(acct2.Status.Conditions[0].Message).To(MatchRegexp("cannot overwrite secret.*which is not owned by"))
tc.Expect(acct2.Status.Conditions[0].Message).To(MatchRegexp("cannot overwrite Secret.*which is not owned by"))
}
func Test_SameObjectHasTwoSecretsWritingToSameDestination_RejectedByWebhook(t *testing.T) {

Просмотреть файл

@ -37,7 +37,7 @@ func Test_NewResourceGroup(t *testing.T) {
resourceGroup := testContext.NewTestResourceGroup()
resolved := genruntime.ConvertToARMResolvedDetails{
Name: resourceGroup.Name,
ResolvedReferences: genruntime.MakeResolvedReferences(nil),
ResolvedReferences: genruntime.MakeResolved[genruntime.ResourceReference](nil),
}
resourceGroupSpec, err := resourceGroup.Spec.ConvertToARM(resolved)
g.Expect(err).ToNot(HaveOccurred())
@ -89,7 +89,7 @@ func Test_NewResourceGroup_Error(t *testing.T) {
resolved := genruntime.ConvertToARMResolvedDetails{
Name: rgName,
ResolvedReferences: genruntime.MakeResolvedReferences(nil),
ResolvedReferences: genruntime.MakeResolved[genruntime.ResourceReference](nil),
}
resourceGroupSpec, err := resourceGroup.Spec.ConvertToARM(resolved)
g.Expect(err).ToNot(HaveOccurred())

Просмотреть файл

@ -334,7 +334,7 @@ func (r *azureDeploymentReconcilerInstance) handleCreatePollerSuccess(ctx contex
err = r.saveAzureSecrets(ctx)
if err != nil {
if _, ok := secrets.AsSecretNotOwnedError(err); ok {
if _, ok := core.AsNotOwnedError(err); ok {
err = conditions.NewReadyConditionImpactingError(err, conditions.ConditionSeverityError, conditions.ReasonSecretWriteFailure)
}

Просмотреть файл

@ -90,7 +90,7 @@ func (r *MySQLUserReconciler) CreateOrUpdate(ctx context.Context, log logr.Logge
log.V(Status).Info("Creating MySQL user")
password, err := secrets.LookupSecretFromPtr(user.Spec.LocalUser.Password)
password, err := secrets.LookupFromPtr(user.Spec.LocalUser.Password)
if err != nil {
return ctrl.Result{}, errors.Wrap(err, "failed to look up .spec.localUser.Password")
}
@ -208,7 +208,7 @@ func (r *MySQLUserReconciler) UpdateStatus(ctx context.Context, log logr.Logger,
return nil
}
func (r *MySQLUserReconciler) connectToDB(ctx context.Context, _ logr.Logger, user *asomysql.User, secrets genruntime.ResolvedSecrets) (*sql.DB, error) {
func (r *MySQLUserReconciler) connectToDB(ctx context.Context, _ logr.Logger, user *asomysql.User, secrets genruntime.Resolved[genruntime.SecretReference]) (*sql.DB, error) {
// Get the owner - at this point it must exist
owner, err := r.ResourceResolver.ResolveOwner(ctx, user)
if err != nil {
@ -229,7 +229,7 @@ func (r *MySQLUserReconciler) connectToDB(ctx context.Context, _ logr.Logger, us
}
serverFQDN := *flexibleServer.Status.FullyQualifiedDomainName
adminPassword, err := secrets.LookupSecretFromPtr(user.Spec.LocalUser.ServerAdminPassword)
adminPassword, err := secrets.LookupFromPtr(user.Spec.LocalUser.ServerAdminPassword)
if err != nil {
err = errors.Wrap(err, "failed to look up .spec.localUser.ServerAdminPassword")
err = conditions.NewReadyConditionImpactingError(err, conditions.ConditionSeverityWarning, conditions.ReasonSecretNotFound)

Просмотреть файл

@ -87,25 +87,25 @@ func (r *Resolver) ResolveReferenceToARMID(ctx context.Context, ref genruntime.N
}
// ResolveReferencesToARMIDs resolves all provided references to their ARM IDs.
func (r *Resolver) ResolveReferencesToARMIDs(ctx context.Context, refs map[genruntime.NamespacedResourceReference]struct{}) (genruntime.ResolvedReferences, error) {
func (r *Resolver) ResolveReferencesToARMIDs(ctx context.Context, refs map[genruntime.NamespacedResourceReference]struct{}) (genruntime.Resolved[genruntime.ResourceReference], error) {
result := make(map[genruntime.ResourceReference]string, len(refs))
for ref := range refs {
armID, err := r.ResolveReferenceToARMID(ctx, ref)
if err != nil {
return genruntime.MakeResolvedReferences(nil), err
return genruntime.MakeResolved[genruntime.ResourceReference](nil), err
}
result[ref.ResourceReference] = armID
}
return genruntime.MakeResolvedReferences(result), nil
return genruntime.MakeResolved[genruntime.ResourceReference](result), nil
}
// ResolveResourceReferences resolves every reference found on the specified genruntime.ARMMetaObject to its corresponding ARM ID.
func (r *Resolver) ResolveResourceReferences(ctx context.Context, metaObject genruntime.ARMMetaObject) (genruntime.ResolvedReferences, error) {
func (r *Resolver) ResolveResourceReferences(ctx context.Context, metaObject genruntime.ARMMetaObject) (genruntime.Resolved[genruntime.ResourceReference], error) {
refs, err := reflecthelpers.FindResourceReferences(metaObject)
if err != nil {
return genruntime.ResolvedReferences{}, errors.Wrapf(err, "finding references on %q", metaObject.GetName())
return genruntime.Resolved[genruntime.ResourceReference]{}, errors.Wrapf(err, "finding references on %q", metaObject.GetName())
}
// Include the namespace
@ -117,7 +117,7 @@ func (r *Resolver) ResolveResourceReferences(ctx context.Context, metaObject gen
// resolve them
resolvedRefs, err := r.ResolveReferencesToARMIDs(ctx, namespacedRefs)
if err != nil {
return genruntime.ResolvedReferences{}, errors.Wrapf(err, "failed resolving ARM IDs for references")
return genruntime.Resolved[genruntime.ResourceReference]{}, errors.Wrapf(err, "failed resolving ARM IDs for references")
}
return resolvedRefs, nil
@ -221,15 +221,15 @@ func (r *Resolver) findGVK(ref genruntime.NamespacedResourceReference) (schema.G
func (r *Resolver) ResolveSecretReferences(
ctx context.Context,
refs set.Set[genruntime.NamespacedSecretReference],
) (genruntime.ResolvedSecrets, error) {
) (genruntime.Resolved[genruntime.SecretReference], error) {
return r.kubeSecretResolver.ResolveSecretReferences(ctx, refs)
}
// ResolveResourceSecretReferences resolves all of the specified genruntime.MetaObject's secret references.
func (r *Resolver) ResolveResourceSecretReferences(ctx context.Context, metaObject genruntime.MetaObject) (genruntime.ResolvedSecrets, error) {
func (r *Resolver) ResolveResourceSecretReferences(ctx context.Context, metaObject genruntime.MetaObject) (genruntime.Resolved[genruntime.SecretReference], error) {
refs, err := reflecthelpers.FindSecretReferences(metaObject)
if err != nil {
return genruntime.ResolvedSecrets{}, errors.Wrapf(err, "finding secrets on %q", metaObject.GetName())
return genruntime.Resolved[genruntime.SecretReference]{}, errors.Wrapf(err, "finding secrets on %q", metaObject.GetName())
}
// Include the namespace
@ -241,7 +241,7 @@ func (r *Resolver) ResolveResourceSecretReferences(ctx context.Context, metaObje
// resolve them
resolvedSecrets, err := r.ResolveSecretReferences(ctx, namespacedSecretRefs)
if err != nil {
return genruntime.ResolvedSecrets{}, errors.Wrapf(err, "failed resolving secret references")
return genruntime.Resolved[genruntime.SecretReference]{}, errors.Wrapf(err, "failed resolving secret references")
}
return resolvedSecrets, nil

Просмотреть файл

@ -463,7 +463,7 @@ func Test_ResolveSecrets_ReturnsExpectedSecretValue(t *testing.T) {
resolvedSecrets, err := test.resolver.ResolveSecretReferences(ctx, set.Make(namespacedRef))
g.Expect(err).ToNot(HaveOccurred())
actualSecret, err := resolvedSecrets.LookupSecret(ref)
actualSecret, err := resolvedSecrets.Lookup(ref)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(actualSecret).To(Equal(secretValue))
}

Просмотреть файл

@ -21,7 +21,7 @@ import (
// SecretResolver is a secret resolver
type SecretResolver interface {
ResolveSecretReference(ctx context.Context, ref genruntime.NamespacedSecretReference) (string, error)
ResolveSecretReferences(ctx context.Context, refs set.Set[genruntime.NamespacedSecretReference]) (genruntime.ResolvedSecrets, error)
ResolveSecretReferences(ctx context.Context, refs set.Set[genruntime.NamespacedSecretReference]) (genruntime.Resolved[genruntime.SecretReference], error)
}
// kubeSecretResolver resolves Kubernetes secrets
@ -67,16 +67,16 @@ func (r *kubeSecretResolver) ResolveSecretReference(ctx context.Context, ref gen
}
// ResolveSecretReferences resolves all provided secret references
func (r *kubeSecretResolver) ResolveSecretReferences(ctx context.Context, refs set.Set[genruntime.NamespacedSecretReference]) (genruntime.ResolvedSecrets, error) {
func (r *kubeSecretResolver) ResolveSecretReferences(ctx context.Context, refs set.Set[genruntime.NamespacedSecretReference]) (genruntime.Resolved[genruntime.SecretReference], error) {
result := make(map[genruntime.SecretReference]string, len(refs))
for ref := range refs {
value, err := r.ResolveSecretReference(ctx, ref)
if err != nil {
return genruntime.MakeResolvedSecrets(nil), err
return genruntime.MakeResolved[genruntime.SecretReference](nil), err
}
result[ref.SecretReference] = value
}
return genruntime.MakeResolvedSecrets(result), nil
return genruntime.MakeResolved[genruntime.SecretReference](result), nil
}

Просмотреть файл

@ -50,7 +50,6 @@ func (s *S) M() {}
var _ I = &S{}
type cloningMap[K comparable, V any] struct {
//nolint:structcheck // 2022-09 incorrectly flaggging inner as unused
inner map[K]V
}

Просмотреть файл

@ -17,11 +17,11 @@ type ConvertToARMResolvedDetails struct {
Name string
// ResolvedReferences is a set of references which have been resolved to their ARM IDs.
ResolvedReferences ResolvedReferences
ResolvedReferences Resolved[ResourceReference]
// ResolvedSecrets is a set of secret references which have been resolved to the corresponding
// secret value.
ResolvedSecrets ResolvedSecrets
ResolvedSecrets Resolved[SecretReference]
}
type ToARMConverter interface {

Просмотреть файл

@ -0,0 +1,71 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT license.
*/
package core
import (
"fmt"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/runtime/schema"
kerrors "k8s.io/apimachinery/pkg/util/errors"
)
func AsTypedError[T error](err error) (T, bool) {
var typedErr T
if errors.As(err, &typedErr) {
return typedErr, true
}
// Also deal with the possibility that this is a kerrors.Aggregate
var aggregate kerrors.Aggregate
if errors.As(err, &aggregate) {
for _, e := range aggregate.Errors() {
// This is a bit hacky but allows us to pick out the first error and raise on that
if result, ok := AsTypedError[T](e); ok {
return result, true
}
}
}
return typedErr, false
}
func AsNotOwnedError(err error) (*NotOwnedError, bool) {
return AsTypedError[*NotOwnedError](err)
}
// NotOwnedError indicates the target resource is not owned by the resource attempting to write it
type NotOwnedError struct {
Namespace string
TargetName string
TargetType string
SourceName string
SourceType string
}
func NewNotOwnedError(namespace string, name string, gvk schema.GroupVersionKind, sourceName string, sourceGvk schema.GroupVersionKind) error {
kindStr := gvk.GroupKind().String()
sourceKindStr := sourceGvk.GroupKind().String()
return &NotOwnedError{
Namespace: namespace,
TargetName: name,
TargetType: kindStr,
SourceName: sourceName,
SourceType: sourceKindStr,
}
}
var _ error = &NotOwnedError{}
func (e *NotOwnedError) Error() string {
return fmt.Sprintf("cannot overwrite %s %s/%s which is not owned by %s %s/%s",
e.TargetType,
e.Namespace,
e.TargetName,
e.SourceType,
e.Namespace,
e.SourceName)
}

Просмотреть файл

@ -0,0 +1,35 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT license.
*/
package genruntime
import (
"sigs.k8s.io/controller-runtime/pkg/client"
"github.com/Azure/azure-service-operator/v2/pkg/genruntime/core"
)
// CheckTargetOwnedByObj raises an error if the target object is not owned by obj.
func CheckTargetOwnedByObj(obj client.Object, target client.Object) error {
ownerRefs := target.GetOwnerReferences()
owned := false
for _, ref := range ownerRefs {
if ref.UID == obj.GetUID() {
owned = true
break
}
}
if !owned {
return core.NewNotOwnedError(
target.GetNamespace(),
target.GetName(),
target.GetObjectKind().GroupVersionKind(),
obj.GetName(),
obj.GetObjectKind().GroupVersionKind())
}
return nil
}

Просмотреть файл

@ -0,0 +1,49 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT license.
*/
package genruntime
import (
"fmt"
"github.com/pkg/errors"
)
type reference interface {
fmt.Stringer
comparable
}
// Resolved is a set of references which have been resolved for a particular resource.
type Resolved[T reference] struct {
// resolved is a map of T to value.
resolved map[T]string
}
// MakeResolved creates a Resolved
func MakeResolved[T reference](resolvedMap map[T]string) Resolved[T] {
return Resolved[T]{
resolved: resolvedMap,
}
}
// Lookup looks up the value for the given reference. If it cannot be found, an error is returned.
func (r Resolved[T]) Lookup(ref T) (string, error) {
result, ok := r.resolved[ref]
if !ok {
return "", errors.Errorf("couldn't find resolved %T %s", ref, ref.String())
}
return result, nil
}
// LookupFromPtr looks up the value for the given reference. If the reference is nil, an error is returned.
// If the value cannot be found, an error is returned
func (r Resolved[T]) LookupFromPtr(ref *T) (string, error) {
if ref == nil {
return "", errors.Errorf("cannot look up secret from nil SecretReference")
}
return r.Lookup(*ref)
}

Просмотреть файл

@ -1,40 +0,0 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT license.
*/
package genruntime
import (
"github.com/pkg/errors"
)
// ResolvedReferences is a set of references which have been resolved for a particular resource.
// The special self field is the fully qualified ARM ID of the resource that this ResolvedReferences applies to.
type ResolvedReferences struct {
// references is a map of ResourceReference to ARM ID.
references map[ResourceReference]string
}
// MakeResolvedReferences creates a ResolvedReferences from the fully qualified ARM ID of the resource and
// and ARM IDs that the resource refers to.
func MakeResolvedReferences(references map[ResourceReference]string) ResolvedReferences {
return ResolvedReferences{
references: references,
}
}
// ARMID looks up the fully qualified ARM ID for the given reference. If it cannot be found, false is returned for the second parameter.
func (r ResolvedReferences) ARMID(ref ResourceReference) (string, bool) {
result, ok := r.references[ref]
return result, ok
}
// ARMIDOrErr looks up the fully qualified ARM ID for the given reference. If it cannot be found, an error is returned.
func (r ResolvedReferences) ARMIDOrErr(ref ResourceReference) (string, error) {
result, ok := r.references[ref]
if !ok {
return "", errors.Errorf("couldn't find resolved reference %s", ref.String())
}
return result, nil
}

Просмотреть файл

@ -1,42 +0,0 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT license.
*/
package genruntime
import (
"github.com/pkg/errors"
)
// ResolvedSecrets is a set of secret references which have been resolved for a particular resource.
type ResolvedSecrets struct {
// secrets is a map of SecretReference to secret value.
secrets map[SecretReference]string
}
// MakeResolvedSecrets creates a ResolvedSecrets
func MakeResolvedSecrets(secrets map[SecretReference]string) ResolvedSecrets {
return ResolvedSecrets{
secrets: secrets,
}
}
// LookupSecret looks up the secret value for the given reference. If it cannot be found, an error is returned.
func (r ResolvedSecrets) LookupSecret(ref SecretReference) (string, error) {
result, ok := r.secrets[ref]
if !ok {
return "", errors.Errorf("couldn't find resolved secret %s", ref.String())
}
return result, nil
}
// LookupSecretFromPtr looks up the secret value for the given reference. If the reference is nil, an error is returned.
// If the secret cannot be found, an error is returned
func (r ResolvedSecrets) LookupSecretFromPtr(ref *SecretReference) (string, error) {
if ref == nil {
return "", errors.Errorf("cannot look up secret from nil SecretReference")
}
return r.LookupSecret(*ref)
}

Просмотреть файл

@ -1,58 +0,0 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT license.
*/
package secrets
import (
"fmt"
"github.com/pkg/errors"
kerrors "k8s.io/apimachinery/pkg/util/errors"
)
// SecretNotOwnedError indicates the secret is not owned by the resource attempting to write it
type SecretNotOwnedError struct {
Namespace string
SecretName string
ObjectName string
}
func NewSecretNotOwnedError(namespace string, secretName string, objectName string) error {
return &SecretNotOwnedError{
Namespace: namespace,
SecretName: secretName,
ObjectName: objectName,
}
}
var _ error = &SecretNotOwnedError{}
func AsSecretNotOwnedError(err error) (*SecretNotOwnedError, bool) {
var typedErr *SecretNotOwnedError
if errors.As(err, &typedErr) {
return typedErr, true
}
// Also deal with the possibility that this is a kerrors.Aggregate
var aggregate kerrors.Aggregate
if errors.As(err, &aggregate) {
for _, e := range aggregate.Errors() {
// This is a bit hacky but allows us to pick out the first error and raise on that
if result, ok := AsSecretNotOwnedError(e); ok {
return result, true
}
}
}
return nil, false
}
func (e *SecretNotOwnedError) Error() string {
return fmt.Sprintf("cannot overwrite secret %s/%s which is not owned by %s/%s",
e.Namespace,
e.SecretName,
e.Namespace,
e.ObjectName)
}

Просмотреть файл

@ -14,6 +14,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"github.com/Azure/azure-service-operator/v2/internal/ownerutil"
"github.com/Azure/azure-service-operator/v2/pkg/genruntime"
)
// ApplySecret applies the secret in a way similar to kubectl apply. If the secret doesn't exist
@ -69,7 +70,7 @@ func ApplySecretAndEnsureOwner(ctx context.Context, client client.Client, obj cl
// If the secret exists but isn't owned by our resource then it must have been created
// by the user. We want to avoid overwriting or otherwise modifying secrets of theirs.
if updatedSecret.GetResourceVersion() != "" {
if err := checkSecretOwner(obj, updatedSecret); err != nil {
if err := genruntime.CheckTargetOwnedByObj(obj, updatedSecret); err != nil {
return err
}
}
@ -111,20 +112,3 @@ func ApplySecretsAndEnsureOwner(ctx context.Context, client client.Client, obj c
return results, nil
}
func checkSecretOwner(obj client.Object, secret *v1.Secret) error {
ownerRefs := secret.GetOwnerReferences()
owned := false
for _, ref := range ownerRefs {
if ref.UID == obj.GetUID() {
owned = true
break
}
}
if !owned {
return NewSecretNotOwnedError(secret.GetNamespace(), secret.GetName(), obj.GetName())
}
return nil
}

Просмотреть файл

@ -375,7 +375,7 @@ func (builder *convertToARMBuilder) propertiesWithSameNameHandler(
// convertReferenceProperty handles conversion of reference properties.
// This function generates code that looks like this:
// <namehint>ARMID, err := resolved.ResolvedReferences.ARMIDOrErr(<source>)
// <namehint>ARMID, err := resolved.ResolvedReferences.Lookup(<source>)
// if err != nil {
// return nil, err
// }
@ -398,7 +398,7 @@ func (builder *convertToARMBuilder) convertReferenceProperty(_ *astmodel.Convers
token.DEFINE,
astbuilder.CallExpr(
astbuilder.Selector(dst.NewIdent(resolvedParameterString), "ResolvedReferences"),
"ARMIDOrErr",
"Lookup",
params.Source))
returnIfNotNil := astbuilder.ReturnIfNotNil(dst.NewIdent("err"), astbuilder.Nil(), dst.NewIdent("err"))
@ -410,7 +410,7 @@ func (builder *convertToARMBuilder) convertReferenceProperty(_ *astmodel.Convers
// convertSecretProperty handles conversion of secret properties.
// This function generates code that looks like this:
// <namehint>Secret, err := resolved.ResolvedSecrets.LookupSecret(<source>)
// <namehint>Secret, err := resolved.ResolvedSecrets.Lookup(<source>)
// if err != nil {
// return nil, errors.Wrap(err, "looking up secret for <source>")
// }
@ -434,7 +434,7 @@ func (builder *convertToARMBuilder) convertSecretProperty(_ *astmodel.Conversion
token.DEFINE,
astbuilder.CallExpr(
astbuilder.Selector(dst.NewIdent(resolvedParameterString), "ResolvedSecrets"),
"LookupSecret",
"Lookup",
params.Source))
wrappedError := astbuilder.WrapError(

Просмотреть файл

@ -1854,7 +1854,7 @@ func (resource *BResource) ConvertToARM(resolved genruntime.ConvertToARMResolved
// Set property Id:
if resource.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*resource.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*resource.Reference)
if err != nil {
return nil, err
}
@ -1937,7 +1937,7 @@ func (resource *CResource) ConvertToARM(resolved genruntime.ConvertToARMResolved
// Set property Id:
if resource.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*resource.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*resource.Reference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -1230,7 +1230,7 @@ func (resource *BResource) ConvertToARM(resolved genruntime.ConvertToARMResolved
// Set property Id:
if resource.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*resource.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*resource.Reference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -537,7 +537,7 @@ func (properties *FakeResourceProperties) ConvertToARM(resolved genruntime.Conve
// Set property Id:
if properties.Reference != nil {
referenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*properties.Reference)
referenceARMID, err := resolved.ResolvedReferences.Lookup(*properties.Reference)
if err != nil {
return nil, err
}
@ -547,7 +547,7 @@ func (properties *FakeResourceProperties) ConvertToARM(resolved genruntime.Conve
// Set property NsgIds:
for _, item := range properties.NsgReferences {
itemARMID, err := resolved.ResolvedReferences.ARMIDOrErr(item)
itemARMID, err := resolved.ResolvedReferences.Lookup(item)
if err != nil {
return nil, err
}
@ -558,7 +558,7 @@ func (properties *FakeResourceProperties) ConvertToARM(resolved genruntime.Conve
if properties.NsgMapReferences != nil {
result.NsgMap = make(map[string]string, len(properties.NsgMapReferences))
for key, value := range properties.NsgMapReferences {
valueARMID, err := resolved.ResolvedReferences.ARMIDOrErr(value)
valueARMID, err := resolved.ResolvedReferences.Lookup(value)
if err != nil {
return nil, err
}
@ -568,7 +568,7 @@ func (properties *FakeResourceProperties) ConvertToARM(resolved genruntime.Conve
// Set property SubnetId:
if properties.SubnetReference != nil {
subnetReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*properties.SubnetReference)
subnetReferenceARMID, err := resolved.ResolvedReferences.Lookup(*properties.SubnetReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -528,7 +528,7 @@ func (properties *FakeResourceProperties) ConvertToARM(resolved genruntime.Conve
// Set property OptionalVNet:
if properties.OptionalVNetReference != nil {
optionalVNetReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*properties.OptionalVNetReference)
optionalVNetReferenceARMID, err := resolved.ResolvedReferences.Lookup(*properties.OptionalVNetReference)
if err != nil {
return nil, err
}
@ -538,7 +538,7 @@ func (properties *FakeResourceProperties) ConvertToARM(resolved genruntime.Conve
// Set property RequiredVNet:
if properties.RequiredVNetReference != nil {
requiredVNetReferenceARMID, err := resolved.ResolvedReferences.ARMIDOrErr(*properties.RequiredVNetReference)
requiredVNetReferenceARMID, err := resolved.ResolvedReferences.Lookup(*properties.RequiredVNetReference)
if err != nil {
return nil, err
}

Просмотреть файл

@ -8,7 +8,6 @@ package readonly
import "golang.org/x/exp/maps"
type Map[K comparable, V any] struct {
//nolint:structcheck // 2022-09 incorrectly flaggging inner as unused
inner map[K]V
}