diff --git a/.vscode/settings.json b/.vscode/settings.json index 6e6ab7ec..a2546ddf 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,7 @@ { "cSpell.words": [ "azuredevops", + "fabrikam", "Kubernetes" ] } \ No newline at end of file diff --git a/docs/server.md b/docs/server.md index e37936f4..99444912 100644 --- a/docs/server.md +++ b/docs/server.md @@ -92,6 +92,9 @@ The parameters file (`dependabot.parameters.json`): "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { + "name": { + "value": "dependabot-fabrikam" + }, "githubToken": { "value": "#{DependabotGithubToken}#" }, diff --git a/server/Tingle.Dependabot/Consumers/TriggerUpdateJobsEventConsumer.cs b/server/Tingle.Dependabot/Consumers/TriggerUpdateJobsEventConsumer.cs index 19e3d443..63b9874d 100644 --- a/server/Tingle.Dependabot/Consumers/TriggerUpdateJobsEventConsumer.cs +++ b/server/Tingle.Dependabot/Consumers/TriggerUpdateJobsEventConsumer.cs @@ -83,7 +83,8 @@ public async Task ConsumeAsync(EventContext context, Can // create the job job = new UpdateJob { - Id = $"job_{KSUID.Ksuid.Generate()}", + // no prefixing/formatting because we use this to create azure resources which have name restrictions + Id = FlakeId.Id.Create().ToString(), Created = DateTimeOffset.UtcNow, Status = UpdateJobStatus.Scheduled, diff --git a/server/Tingle.Dependabot/Tingle.Dependabot.csproj b/server/Tingle.Dependabot/Tingle.Dependabot.csproj index cfbcd887..5e1cdc56 100644 --- a/server/Tingle.Dependabot/Tingle.Dependabot.csproj +++ b/server/Tingle.Dependabot/Tingle.Dependabot.csproj @@ -23,6 +23,7 @@ + diff --git a/server/main.bicep b/server/main.bicep index fdaf22a0..865ca00b 100644 --- a/server/main.bicep +++ b/server/main.bicep @@ -4,7 +4,7 @@ param location string = resourceGroup().location @minLength(5) @maxLength(24) @description('Name of the resources. Make sure it is unique e.g. dependabotcontoso to avoid conflicts or failures') -param name string +param name string = 'dependabot' @description('JSON array string fo projects to setup. E.g. [{"url":"https://dev.azure.com/tingle/dependabot","token":"dummy","AutoComplete":true}]') param projectSetups string = '[]' @@ -22,7 +22,8 @@ var fileShares = [ { name: 'working-dir', writeable: true } ] -var storageAccountName = name == 'dependabot' ? 'dependabotstore' : name // dependabot is not available as of 2023-Sep-25 so we change just for the public deployment +// dependabot is not available as of 2023-Sep-25 so we change just for the public deployment +var storageAccountName = replace(replace((name == 'dependabot' ? 'dependabotstore' : name), '-', ''), '_', '') // remove underscores and hyphens var sqlServerAdministratorLogin = uniqueString(resourceGroup().id) // e.g. zecnx476et7xm (13 characters) var sqlServerAdministratorLoginPassword = '${skip(uniqueString(resourceGroup().id), 5)}%${uniqueString('sql-password', resourceGroup().id)}' // e.g. abcde%zecnx476et7xm (19 characters) var queueNames = [ diff --git a/server/main.json b/server/main.json index 10f2e75d..42a70f41 100644 --- a/server/main.json +++ b/server/main.json @@ -11,6 +11,7 @@ }, "name": { "type": "string", + "defaultValue": "dependabot", "minLength": 5, "maxLength": 24, "metadata": { @@ -77,7 +78,7 @@ "writeable": true } ], - "storageAccountName": "[if(equals(parameters('name'), 'dependabot'), 'dependabotstore', parameters('name'))]", + "storageAccountName": "[replace(replace(if(equals(parameters('name'), 'dependabot'), 'dependabotstore', parameters('name')), '-', ''), '_', '')]", "sqlServerAdministratorLogin": "[uniqueString(resourceGroup().id)]", "sqlServerAdministratorLoginPassword": "[format('{0}%{1}', skip(uniqueString(resourceGroup().id), 5), uniqueString('sql-password', resourceGroup().id))]", "queueNames": [