Skip to content

Commit

Permalink
Fix binding name
Browse files Browse the repository at this point in the history
  • Loading branch information
amitkma committed Apr 29, 2024
1 parent 2992e1c commit 8120c56
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/run-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ jobs:

env:
TEST_IMAGE_TAG: 'bs-${{ github.run_id }}'
TEST_CONTAINER_APP_NAME: 'gh_${{ github.run_id }}'
TEST_CONTAINER_APP_NAME: 'gh-${{ github.run_id }}'

steps:
- name: Checkout action repository
Expand Down Expand Up @@ -657,8 +657,8 @@ jobs:
imageToBuild: ${{ env.TEST_FULL_ACR_NAME }}/${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }}
disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }}
postgres: |
dmsdb1
dmsdb2, dmsdb3
dms-db1
dms-db2, dms-db3
redis: redis

- name: Delete created Azure Container App
Expand All @@ -670,10 +670,10 @@ jobs:
if: ${{ always()}}
shell: bash
run: |
az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }}postgresdmsdb1 -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y
az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }}postgresdmsdb2 -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y
az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }}postgresdmsdb3 -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y
az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }}redisredis -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y
az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }}-postgres-dms-db1 -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y
az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }}-postgres-dms-db2 -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y
az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }}-postgres-dms-db3 -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y
az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }}-redis-redis -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y
Expand Down
13 changes: 6 additions & 7 deletions azurecontainerapps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export class azurecontainerapps {
/**
* Create add-on services if required. A name for the service is generated by prefixing the given
* service name with container name. For example, if you have given redis add-on service "myredis" name,
* then the actual service name will be generated in the form '<containerAppName><addon-type>_myredis'.
* then the actual service name will be generated in the form '<containerAppName>-<addon-type>-myredis'.
*
* This is done to ensure that we have only one add-on service of a type for a given container.
*
Expand All @@ -355,9 +355,9 @@ export class azurecontainerapps {
if (!this.util.isNullOrEmpty(services)){
let bindings = this.util.parseServices(services)
for (const binding of bindings) {
let serviceName = `${containerAppName}${addOn}${binding}`
await this.addOnHelper.createAddOnService(addOn, serviceName, resourceGroup, environment)
createdServices.push(serviceName)
let bindingName = `${containerAppName}-${addOn}-${binding}`
await this.addOnHelper.createAddOnService(addOn, bindingName, resourceGroup, environment)
createdServices.push(bindingName)
}
}
}
Expand Down Expand Up @@ -613,11 +613,10 @@ export class azurecontainerapps {
if (!(this.addOnServices === null || this.addOnServices === undefined || this.addOnServices.length == 0)){
let services = []
for (const addOnService of this.addOnServices){
// Sanitize the binding name.
const bindingName = addOnService.replace(/-/g, '_')
services.push(`${bindingName}`)
services.push(`${addOnService}:${bindingName}`)
}
this.commandLineArgs.push(`--bind ${services.join(' ')}`)
this.commandLineArgs.push(`--bind ${services.join(' ')}'`)
}

// Determine default values only for the 'create' scenario to avoid overriding existing values for the 'update' scenario
Expand Down
13 changes: 6 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4219,7 +4219,7 @@ class azurecontainerapps {
/**
* Create add-on services if required. A name for the service is generated by prefixing the given
* service name with container name. For example, if you have given redis add-on service "myredis" name,
* then the actual service name will be generated in the form '<containerAppName><addon-type>_myredis'.
* then the actual service name will be generated in the form '<containerAppName>-<addon-type>-myredis'.
*
* This is done to ensure that we have only one add-on service of a type for a given container.
*
Expand All @@ -4236,9 +4236,9 @@ class azurecontainerapps {
if (!this.util.isNullOrEmpty(services)) {
let bindings = this.util.parseServices(services);
for (const binding of bindings) {
let serviceName = `${containerAppName}${addOn}${binding}`;
yield this.addOnHelper.createAddOnService(addOn, serviceName, resourceGroup, environment);
createdServices.push(serviceName);
let bindingName = `${containerAppName}-${addOn}-${binding}`;
yield this.addOnHelper.createAddOnService(addOn, bindingName, resourceGroup, environment);
createdServices.push(bindingName);
}
}
}
Expand Down Expand Up @@ -4465,11 +4465,10 @@ class azurecontainerapps {
if (!(this.addOnServices === null || this.addOnServices === undefined || this.addOnServices.length == 0)) {
let services = [];
for (const addOnService of this.addOnServices) {
// Sanitize the binding name.
const bindingName = addOnService.replace(/-/g, '_');
services.push(`${bindingName}`);
services.push(`${addOnService}:${bindingName}`);
}
this.commandLineArgs.push(`--bind ${services.join(' ')}`);
this.commandLineArgs.push(`--bind ${services.join(' ')}'`);
}
// Determine default values only for the 'create' scenario to avoid overriding existing values for the 'update' scenario
if (!this.containerAppExists) {
Expand Down

0 comments on commit 8120c56

Please sign in to comment.