Skip to content

Commit 5fbcc8a

Browse files
committed
add label support
1 parent 45ebfcd commit 5fbcc8a

File tree

10 files changed

+215
-174
lines changed

10 files changed

+215
-174
lines changed

__tests__/feature-flag-client.test.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ describe('Feature Flag Client', () => {
2727

2828
it('should list feature flags', async () => {
2929
const appConfigEndpoint = 'https://example.com'
30+
const label = 'test-label'
3031
const getMock = jest.spyOn(axios, 'get').mockResolvedValue({
3132
status: 200,
3233
data: featureListResponse
3334
})
3435

35-
const results = await listFeatureFlags(appConfigEndpoint)
36+
const results = await listFeatureFlags(appConfigEndpoint, label)
3637
expect(results.items.length).toEqual(1)
3738
expect(results.items[0].key).toEqual(
3839
'.appconfig.featureflag/featureFlagId1'
@@ -41,27 +42,36 @@ describe('Feature Flag Client', () => {
4142

4243
it('should throw error when list api fails', async () => {
4344
const appConfigEndpoint = 'https://example.com'
45+
const label = 'test-label'
4446

4547
const getMock = jest.spyOn(axios, 'get').mockResolvedValue({
4648
status: 500,
4749
statusText: 'Internal Server Error'
4850
})
4951

50-
await expect(listFeatureFlags(appConfigEndpoint)).rejects.toThrow(ApiError)
52+
await expect(listFeatureFlags(appConfigEndpoint, label)).rejects.toThrow(
53+
ApiError
54+
)
5155
})
5256

5357
it('create or update feature flag', async () => {
5458
const appConfigEndpoint = 'https://example.com'
5559
const featureFlagId = 'featureFlagId1'
60+
const label = 'test-label'
5661
const value = getDummyFeatureFlagItem(featureFlagId)
5762

5863
const getMock = jest.spyOn(axios, 'put').mockResolvedValue({
5964
status: 200
6065
})
6166

62-
await createOrUpdateFeatureFlag(appConfigEndpoint, featureFlagId, value)
67+
await createOrUpdateFeatureFlag(
68+
appConfigEndpoint,
69+
featureFlagId,
70+
value,
71+
label
72+
)
6373
expect(getMock).toBeCalledWith(
64-
`${appConfigEndpoint}/kv/.appconfig.featureflag%2FfeatureFlagId1?api-version=2023-11-01`,
74+
`${appConfigEndpoint}/kv/.appconfig.featureflag%2FfeatureFlagId1?api-version=2023-11-01&label=test-label`,
6575
{
6676
content_type:
6777
'application/vnd.microsoft.appconfig.ff+json;charset=utf-8',
@@ -80,6 +90,7 @@ describe('Feature Flag Client', () => {
8090
it('should throw error when create or update feature flag fails', async () => {
8191
const appConfigEndpoint = 'https://example.com'
8292
const featureFlagId = 'featureFlagId1'
93+
const label = 'test-label'
8394
const value = getDummyFeatureFlagItem(featureFlagId)
8495

8596
const getMock = jest.spyOn(axios, 'put').mockResolvedValue({
@@ -88,21 +99,22 @@ describe('Feature Flag Client', () => {
8899
})
89100

90101
await expect(
91-
createOrUpdateFeatureFlag(appConfigEndpoint, featureFlagId, value)
102+
createOrUpdateFeatureFlag(appConfigEndpoint, featureFlagId, value, label)
92103
).rejects.toThrow(ApiError)
93104
})
94105

95106
it('should delete feature flag', async () => {
96107
const appConfigEndpoint = 'https://example.com'
97108
const featureFlagId = 'featureFlagId1'
109+
const label = 'test-label'
98110

99111
const getMock = jest.spyOn(axios, 'delete').mockResolvedValue({
100112
status: 200
101113
})
102114

103-
await deleteFeatureFlag(appConfigEndpoint, featureFlagId)
115+
await deleteFeatureFlag(appConfigEndpoint, featureFlagId, label)
104116
expect(getMock).toBeCalledWith(
105-
`${appConfigEndpoint}/kv/.appconfig.featureflag%2FfeatureFlagId1?api-version=2023-11-01`,
117+
`${appConfigEndpoint}/kv/.appconfig.featureflag%2FfeatureFlagId1?api-version=2023-11-01&label=test-label`,
106118
{
107119
headers: {
108120
Accept: '*/*',
@@ -116,13 +128,14 @@ describe('Feature Flag Client', () => {
116128
it('should throw error when delete feature flag fails', async () => {
117129
const appConfigEndpoint = 'https://example.com'
118130
const featureFlagId = 'featureFlagId1'
131+
const label = 'test-label'
119132

120133
const getMock = jest.spyOn(axios, 'delete').mockResolvedValue({
121134
status: 500
122135
})
123136

124137
await expect(
125-
deleteFeatureFlag(appConfigEndpoint, featureFlagId)
138+
deleteFeatureFlag(appConfigEndpoint, featureFlagId, label)
126139
).rejects.toThrow(ApiError)
127140
})
128141

__tests__/input.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ describe('getActionInput', () => {
2525
configFile: 'configFile',
2626
strictSync: true,
2727
appConfigEndpoint: 'https://example.com',
28-
operation: 'deploy'
28+
operation: 'deploy',
29+
label: ''
2930
})
3031
})
3132

@@ -38,7 +39,8 @@ describe('getActionInput', () => {
3839
configFile: 'configFile',
3940
strictSync: false, // doesn't matter in validate mode
4041
appConfigEndpoint: '', // doesn't matter in validate mode
41-
operation: 'validate'
42+
operation: 'validate',
43+
label: ''
4244
})
4345
})
4446

__tests__/update-feature-flags.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ describe('updateFeatureFlags', () => {
5353
expect(createOrUpdateFeatureFlag).toHaveBeenCalledWith(
5454
input.appConfigEndpoint,
5555
'featureFlagId2',
56-
configs[1]
56+
configs[1],
57+
'test-label'
5758
)
5859
expect(infoMock).toHaveBeenCalledWith('Updated 1 feature flags')
5960
})
@@ -81,7 +82,8 @@ describe('updateFeatureFlags', () => {
8182
expect(createOrUpdateFeatureFlag).toHaveBeenCalledWith(
8283
input.appConfigEndpoint,
8384
'featureFlagId2',
84-
configs[1]
85+
configs[1],
86+
'test-label'
8587
)
8688
expect(infoMock).toHaveBeenCalledWith('Updated 1 feature flags')
8789
expect(infoMock).toHaveBeenCalledWith(
@@ -90,7 +92,8 @@ describe('updateFeatureFlags', () => {
9092
expect(deleteFeatureFlag).toHaveBeenCalledTimes(1)
9193
expect(deleteFeatureFlag).toHaveBeenCalledWith(
9294
input.appConfigEndpoint,
93-
'featureFlagId3'
95+
'featureFlagId3',
96+
'test-label'
9497
)
9598
})
9699

@@ -99,7 +102,8 @@ describe('updateFeatureFlags', () => {
99102
configFile: 'configFile',
100103
strictSync: false,
101104
appConfigEndpoint: 'https://example.com',
102-
operation: 'deploy'
105+
operation: 'deploy',
106+
label: 'test-label'
103107
}
104108
}
105109

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ inputs:
1919
description: 'Destination endpoint for the Azure App Configuration store'
2020
required: false
2121

22+
app-config-label:
23+
description: 'Label for the config'
24+
required: false
25+
default: None
26+
2227
operation: # Validate the configuration file only
2328
description:
2429
'Possible values: validate or deploy - deploy by default. validate: only

0 commit comments

Comments
 (0)