Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix service account helm chart #8

Merged
merged 3 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/config/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const storage = convict({
format: String,
nullable: !isProd(),
default: null,
env: 'MANAGED_IDENTITY_CLIENT_ID'
env: 'AZURE_CLIENT_ID'
},
clean: {
accountName: {
Expand Down
4 changes: 2 additions & 2 deletions app/utils/storage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { StorageSharedKeyCredential } from '@azure/storage-blob'
import { WorkloadIdentityCredential } from '@azure/identity'
import { DefaultAzureCredential } from '@azure/identity'

import { storageConfig } from '../config/index.js'

Expand All @@ -19,7 +19,7 @@ const getStorageCredential = (accountName, accessKey) => {

console.log('Using Azure Identity Credential for account:', accountName)

return new WorkloadIdentityCredential({ clientId: storageConfig.get('managedIdentityClientId') })
return new DefaultAzureCredential({ managedIdentityClientId: storageConfig.get('managedIdentityClientId') })
}

export {
Expand Down
1 change: 0 additions & 1 deletion helm/fcp-fd-file-retriever/templates/config-map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ data:
CLN_STORAGE_ACCOUNT_NAME: {{ quote .Values.container.clnStorageAccountName }}
AV_SCAN_POLLING_INTERVAL: {{ quote .Values.container.avScanPollingInterval }}
AV_SCAN_MAX_ATTEMPTS: {{ quote .Values.container.avScanMaxAttempts }}
MANAGED_IDENTITY_CLIENT_ID: {{ quote .Values.azureIdentity.clientID }}
{{- end -}}
4 changes: 2 additions & 2 deletions helm/fcp-fd-file-retriever/templates/service-account.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{{- include "ffc-helm-library.service-account" (list . "fcp-fd-file-processor.service-account") -}}
{{- define "fcp-fd-file-processor.service-account" -}}
{{- include "ffc-helm-library.service-account" (list . "fcp-fd-file-retriever.service-account") -}}
{{- define "fcp-fd-file-retriever.service-account" -}}
{{- end -}}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fcp-fd-file-retriever",
"version": "0.3.2",
"version": "0.3.3",
"description": "File retrieval service for Single Front Door",
"homepage": "https://github.com/DEFRA/fcp-fd-file-retriever",
"main": "app/index.js",
Expand Down
8 changes: 4 additions & 4 deletions test/unit/storage/blob/clean.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { beforeEach, describe, expect, jest, test } from '@jest/globals'

const mockSharedKeyCredential = jest.fn()
const mockWorkloadIdentityCredential = jest.fn()
const mockDefaultAzureCredential = jest.fn()

const mockCreateIfNotExists = jest.fn()

Expand All @@ -17,7 +17,7 @@ jest.unstable_mockModule('@azure/storage-blob', () => ({
}))

jest.unstable_mockModule('@azure/identity', () => ({
WorkloadIdentityCredential: mockWorkloadIdentityCredential
DefaultAzureCredential: mockDefaultAzureCredential
}))

describe('Clean Blob Storage Client', () => {
Expand Down Expand Up @@ -53,7 +53,7 @@ describe('Clean Blob Storage Client', () => {

expect(client).toBeDefined()
expect(mockSharedKeyCredential).toHaveBeenCalled()
expect(mockWorkloadIdentityCredential).not.toHaveBeenCalled()
expect(mockDefaultAzureCredential).not.toHaveBeenCalled()

process.env = orginalEnv
})
Expand All @@ -70,7 +70,7 @@ describe('Clean Blob Storage Client', () => {
const { client } = await import('../../../../app/storage/blob/clean')

expect(client).toBeDefined()
expect(mockWorkloadIdentityCredential).toHaveBeenCalled()
expect(mockDefaultAzureCredential).toHaveBeenCalled()
expect(mockSharedKeyCredential).not.toHaveBeenCalled()

process.env = orginalEnv
Expand Down