diff --git a/.github/workflows/build-and-stage.yml b/.github/workflows/build-and-stage.yml new file mode 100644 index 0000000..6e107df --- /dev/null +++ b/.github/workflows/build-and-stage.yml @@ -0,0 +1,94 @@ +name: Build and stage +on: + push: + branches: + - main + pull_request: + branches: + - main +env: + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_VERSION: '8.0' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + checks: write + contents: read + statuses: write + +jobs: + build: + name: Build and publish app + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # avoid shallow clone so nbgv can do its work. + + - name: Set up .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: Set up dependency caching for faster builds + uses: actions/cache@v4 + with: + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} + restore-keys: | + ${{ runner.os }}-nuget- + + - name: dotnet restore + run: dotnet restore + + - name: dotnet build + run: dotnet build --no-restore /p:TreatWarningsAsErrors=True + + - name: dotnet test + run: dotnet test --logger trx --results-directory "${{ runner.temp }}" --no-build + + - name: dotnet test + uses: NasAmin/trx-parser@v0.5.0 + with: + TRX_PATH: "${{ runner.temp }}" + REPO_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + - name: dotnet publish + run: dotnet publish src/InitializrService/Steeltoe.InitializrService.csproj -o publish + + - name: Upload artifact for deployment job + if: ${{ github.event_name != 'pull_request' }} + uses: actions/upload-artifact@v4 + with: + name: published-app + path: publish + + deploy: + name: Deploy + environment: production + needs: + - build + runs-on: ubuntu-latest + if: ${{ github.event_name != 'pull_request' }} + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v4 + with: + name: published-app + + - name: Log into Azure CLI with service principal + uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v3 + with: + app-name: ${{ vars.AZURE_WEBAPP_NAME }} + package: '.' + slot-name: 'production' diff --git a/.gitignore b/.gitignore index ccd1e82..08dc468 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ obj/ # JetBrains Rider state /.idea/ + +# code coverage +coverage*.* \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props index c0f893f..5c1365a 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,13 +1,13 @@ - net6.0 + net8.0 false - 3.4.* + 3.6.* all diff --git a/Dockerfile b/Dockerfile index 694b6fb..46ec53e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build +FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build WORKDIR /source COPY . . RUN dotnet restore RUN dotnet publish -c release -o /srv --no-restore -FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine +FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine WORKDIR /srv RUN apk add bash RUN curl https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh > wait-for-it \ diff --git a/README.md b/README.md index 2184410..c7012bd 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,10 @@ Steeltoe Initializr Service reference implementation -[![Build Status](https://dev.azure.com/SteeltoeOSS/Steeltoe/_apis/build/status/Initializr/SteeltoeOSS.InitializrService?branchName=main)](https://dev.azure.com/SteeltoeOSS/Steeltoe/_build/latest?definitionId=31&branchName=main) - -[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=InitializrService&metric=alert_status)](https://sonarcloud.io/dashboard?id=InitializrService) - ## Using the Server _InitializrService_ provides 4 REST/HTTP endpoints: + * `api/` * `api/about` * `api/config` @@ -58,6 +55,7 @@ The returned document includes _all_ configuration. Sub-endpoints are availabl `api/config/projectMetadata` can be used by smart clients, such as [_InitializrWeb_](https://github.com/SteeltoeOSS/InitializrWeb), to assist in creating user interfaces. The following endpoints can be used by CLI users to determine what project configuration options are available: + * `api/config/archiveTypes` * `api/config/dependencies` * `api/config/dotNetFrameworks` @@ -125,13 +123,13 @@ $ http https://start.steeltoe.io/api/project dotNetFramework=netcoreapp3.1 depen The Initializr API configuration is a JSON document provided by a [Spring Cloud Config Server](https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_server.html) or a local file. The former is recommended for production deployments; the latter is intended primarily for local development. - ### Using Spring Cloud Config Server The Initializr API uses the [Steeltoe Config Server Provider](https://docs.steeltoe.io/api/v3/configuration/config-server-provider.html) to get configuration from a Spring Cloud Config Server. -The _InitializrAPI_ running at https://start.steeltoe.io/api/ uses a Spring Cloud Config Server backended at https://github.com/SteeltoeOSS/InitializrConfig. +The _InitializrAPI_ running at uses a Spring Cloud Config Server backended at . The following `appsettings.json` sample snippet is part of the _InitializrService_'s configuration: + ```json ..., "spring": { @@ -155,6 +153,7 @@ See the Steeltoe Config Server Provider documentation for other configuration op _**Note**_: configuring a local file overrides any Spring Cloud Config Server configuration The following `appsettings.json` sample snippet configures the use of a local configuration file: + ```json ..., "Initializr": { diff --git a/Steeltoe.InitializrService.sln b/Steeltoe.InitializrService.sln index 5f38547..6be5082 100644 --- a/Steeltoe.InitializrService.sln +++ b/Steeltoe.InitializrService.sln @@ -1,33 +1,35 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30320.27 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34414.90 MinimumVisualStudioVersion = 15.0.26124.0 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Steeltoe.InitializrService", "src\InitializrService\Steeltoe.InitializrService.csproj", "{7597F74D-528E-448B-BBE8-994092F04CA4}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Steeltoe.InitializrService.Config", "src\InitializrService.Config\Steeltoe.InitializrService.Config.csproj", "{ACE6FEE1-9CEA-4A95-9D76-C62A41947C8F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Steeltoe.InitializrService.Test.Utils", "test\InitializrService.Test.Utils\Steeltoe.InitializrService.Test.Utils.csproj", "{EC08DC14-11D5-40D3-8908-BDB0D789F48D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Steeltoe.InitializrService.Test.Utils", "test\InitializrService.Test.Utils\Steeltoe.InitializrService.Test.Utils.csproj", "{EC08DC14-11D5-40D3-8908-BDB0D789F48D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Steeltoe.InitializrService.Test.Unit", "test\InitializrService.Test.Unit\Steeltoe.InitializrService.Test.Unit.csproj", "{EA849C8F-7118-45DB-BBF2-D36CE1FD43B4}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Steeltoe.InitializrService.Test.Integration", "test\InitializrService.Test.Integration\Steeltoe.InitializrService.Test.Integration.csproj", "{24A2AB13-F4C4-4C88-B67D-D280610240B8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Steeltoe.InitializrService.Test.Integration", "test\InitializrService.Test.Integration\Steeltoe.InitializrService.Test.Integration.csproj", "{24A2AB13-F4C4-4C88-B67D-D280610240B8}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F80B44AC-7383-40DA-B353-16163BF279F1}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig .gitignore = .gitignore - azure-pipelines.yaml = azure-pipelines.yaml - codecov.yml = codecov.yml Directory.Build.props = Directory.Build.props docker-compose.yaml = docker-compose.yaml Dockerfile = Dockerfile - Steeltoe.InitializrService.sln.DotSettings = Steeltoe.InitializrService.sln.DotSettings LICENSE = LICENSE README.md = README.md + Steeltoe.InitializrService.sln.DotSettings = Steeltoe.InitializrService.sln.DotSettings stylecop.json = stylecop.json Version.props = Version.props EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{51C72D02-A6C4-48EA-B735-EAE2CEDE69CC}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{3B483F2E-42EE-4DE5-84B6-92F0D09D94FD}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -62,6 +64,18 @@ Global {ACE6FEE1-9CEA-4A95-9D76-C62A41947C8F}.Release|x64.Build.0 = Release|Any CPU {ACE6FEE1-9CEA-4A95-9D76-C62A41947C8F}.Release|x86.ActiveCfg = Release|Any CPU {ACE6FEE1-9CEA-4A95-9D76-C62A41947C8F}.Release|x86.Build.0 = Release|Any CPU + {EC08DC14-11D5-40D3-8908-BDB0D789F48D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EC08DC14-11D5-40D3-8908-BDB0D789F48D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EC08DC14-11D5-40D3-8908-BDB0D789F48D}.Debug|x64.ActiveCfg = Debug|Any CPU + {EC08DC14-11D5-40D3-8908-BDB0D789F48D}.Debug|x64.Build.0 = Debug|Any CPU + {EC08DC14-11D5-40D3-8908-BDB0D789F48D}.Debug|x86.ActiveCfg = Debug|Any CPU + {EC08DC14-11D5-40D3-8908-BDB0D789F48D}.Debug|x86.Build.0 = Debug|Any CPU + {EC08DC14-11D5-40D3-8908-BDB0D789F48D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EC08DC14-11D5-40D3-8908-BDB0D789F48D}.Release|Any CPU.Build.0 = Release|Any CPU + {EC08DC14-11D5-40D3-8908-BDB0D789F48D}.Release|x64.ActiveCfg = Release|Any CPU + {EC08DC14-11D5-40D3-8908-BDB0D789F48D}.Release|x64.Build.0 = Release|Any CPU + {EC08DC14-11D5-40D3-8908-BDB0D789F48D}.Release|x86.ActiveCfg = Release|Any CPU + {EC08DC14-11D5-40D3-8908-BDB0D789F48D}.Release|x86.Build.0 = Release|Any CPU {EA849C8F-7118-45DB-BBF2-D36CE1FD43B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EA849C8F-7118-45DB-BBF2-D36CE1FD43B4}.Debug|Any CPU.Build.0 = Debug|Any CPU {EA849C8F-7118-45DB-BBF2-D36CE1FD43B4}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -86,22 +100,17 @@ Global {24A2AB13-F4C4-4C88-B67D-D280610240B8}.Release|x64.Build.0 = Release|Any CPU {24A2AB13-F4C4-4C88-B67D-D280610240B8}.Release|x86.ActiveCfg = Release|Any CPU {24A2AB13-F4C4-4C88-B67D-D280610240B8}.Release|x86.Build.0 = Release|Any CPU - {EC08DC14-11D5-40D3-8908-BDB0D789F48D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EC08DC14-11D5-40D3-8908-BDB0D789F48D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EC08DC14-11D5-40D3-8908-BDB0D789F48D}.Debug|x64.ActiveCfg = Debug|Any CPU - {EC08DC14-11D5-40D3-8908-BDB0D789F48D}.Debug|x64.Build.0 = Debug|Any CPU - {EC08DC14-11D5-40D3-8908-BDB0D789F48D}.Debug|x86.ActiveCfg = Debug|Any CPU - {EC08DC14-11D5-40D3-8908-BDB0D789F48D}.Debug|x86.Build.0 = Debug|Any CPU - {EC08DC14-11D5-40D3-8908-BDB0D789F48D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EC08DC14-11D5-40D3-8908-BDB0D789F48D}.Release|Any CPU.Build.0 = Release|Any CPU - {EC08DC14-11D5-40D3-8908-BDB0D789F48D}.Release|x64.ActiveCfg = Release|Any CPU - {EC08DC14-11D5-40D3-8908-BDB0D789F48D}.Release|x64.Build.0 = Release|Any CPU - {EC08DC14-11D5-40D3-8908-BDB0D789F48D}.Release|x86.ActiveCfg = Release|Any CPU - {EC08DC14-11D5-40D3-8908-BDB0D789F48D}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {7597F74D-528E-448B-BBE8-994092F04CA4} = {51C72D02-A6C4-48EA-B735-EAE2CEDE69CC} + {ACE6FEE1-9CEA-4A95-9D76-C62A41947C8F} = {51C72D02-A6C4-48EA-B735-EAE2CEDE69CC} + {EC08DC14-11D5-40D3-8908-BDB0D789F48D} = {3B483F2E-42EE-4DE5-84B6-92F0D09D94FD} + {EA849C8F-7118-45DB-BBF2-D36CE1FD43B4} = {3B483F2E-42EE-4DE5-84B6-92F0D09D94FD} + {24A2AB13-F4C4-4C88-B67D-D280610240B8} = {3B483F2E-42EE-4DE5-84B6-92F0D09D94FD} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {F773FB5B-7619-4DA7-AA07-919DA1A5181C} EndGlobalSection diff --git a/Steeltoe.InitializrService.sln.DotSettings b/Steeltoe.InitializrService.sln.DotSettings index 3a27c7c..2632387 100644 --- a/Steeltoe.InitializrService.sln.DotSettings +++ b/Steeltoe.InitializrService.sln.DotSettings @@ -1,4 +1,5 @@ - + + True True True Licensed to the .NET Foundation under one or more agreements. diff --git a/Version.props b/Version.props index 4360508..ec12e1e 100644 --- a/Version.props +++ b/Version.props @@ -1,7 +1,7 @@ - 6.0.7 + 7.0.1 3.2.* 8.1.2 diff --git a/azure-pipelines.yaml b/azure-pipelines.yaml deleted file mode 100644 index e17c5f9..0000000 --- a/azure-pipelines.yaml +++ /dev/null @@ -1,129 +0,0 @@ -trigger: -- main - -variables: -- name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE - value: true -- name: DOTNET_CLI_TELEMETRY_OPTOUT - value: 1 -- group: PackageSigningSecrets - -stages: -- stage: assemble - displayName: Assemble - jobs: - - job: build - displayName: Build - pool: - vmImage: ubuntu-latest - steps: - - task: UseDotNet@2 - displayName: 'Install .NET Core SDK 6.0' - inputs: - packageType: sdk - version: 6.0.x - - task: UseDotNet@2 - displayName: 'Install .NET Core SDK 3.1' - inputs: - packageType: sdk - version: 3.1.x - # - task: SonarSource.sonarcloud.14d9cde6-c1da-4d55-aa01-2965cd301255.SonarCloudPrepare@1 - # displayName: Start SonarQube Analysis - # inputs: - # SonarCloud: SonarCloud - # organization: steeltoeoss - # projectKey: InitializrService - # extraProperties: | - # sonar.cs.opencover.reportsPaths=$(Build.SourcesDirectory)/**/*.opencover.xml - - task: DotNetCoreCLI@2 - displayName: dotnet restore - inputs: - command: restore - - task: DotNetCoreCLI@2 - displayName: dotnet build - inputs: - command: build - arguments: > - --no-restore - - task: DotNetCoreCLI@2 - displayName: dotnet test - inputs: - command: test - arguments: > - --no-build - /p:CollectCoverage=true - /p:CoverletOutputFormat=opencover - - task: DotNetCoreCLI@2 - displayName: dotnet publish - inputs: - command: publish - arguments: --no-build - zipAfterPublish: false - - task: DotNetCoreCLI@2 - displayName: dotnet pack - inputs: - command: pack - packagesToPack: src/InitializrService.Config - arguments: --no-build - - task: Powershell@2 - displayName: Sign NuGets - inputs: - filePath: sign/SignPackages.ps1 - env: - ArtifactStagingDirectory: $(Build.ArtifactStagingDirectory) - SignClientUser: $(SignClientUser) - SignClientSecret: $(SignClientSecret) - # - task: SonarSource.sonarcloud.ce096e50-6155-4de8-8800-4221aaeed4a1.SonarCloudAnalyze@1 - # displayName: Stop SonarQube Analysis - # - task: SonarSource.sonarcloud.38b27399-a642-40af-bb7d-9971f69712e8.SonarCloudPublish@1 - # displayName: Publish SonarQube Analysis - - task: PublishBuildArtifacts@1 - displayName: Publish Build Artifacts - inputs: - artifactName: nugets -- stage: Deploy - displayName: Deploy - dependsOn: assemble - condition: - not(eq(variables['build.reason'], 'PullRequest')) - jobs: - - job: push - displayName: Push - pool: - vmImage: ubuntu-latest - steps: - - task: Docker@2 - displayName: Build and Push Docker Image - inputs: - command: buildAndPush - containerRegistry: SteeltoeContainerRegistry - repository: initializr-service - tags: | - $(Build.BuildId) - latest - - task: ShellScript@2 - displayName: Generate Staging Manifest - inputs: - scriptPath: ./yttw.sh - args: > - -f kubernetes - -v image_tag=$(Build.BuildId) - -v dotnet_environment=Staging - -v hostname=start-staging.steeltoe.io - --output-files manifests/staging - - task: ShellScript@2 - displayName: Generate Production Manifest - inputs: - scriptPath: ./yttw.sh - args: > - -f kubernetes - -v image_tag=$(Build.BuildId) - -v replica_count=2 - -v dotnet_environment=Production - -v hostname=start.steeltoe.io - --output-files manifests/production - - task: PublishPipelineArtifact@1 - displayName: Publish Manifests - inputs: - targetPath: manifests - artifactName: manifests diff --git a/codecov.yml b/codecov.yml deleted file mode 100644 index 099f84a..0000000 --- a/codecov.yml +++ /dev/null @@ -1,6 +0,0 @@ -codecov: - ci: - - dev.azure.com - -ignore: - - "test/.*" diff --git a/global.json b/global.json deleted file mode 100644 index 5a0ab4a..0000000 --- a/global.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "sdk": { - "version": "6.0.0", - "rollForward": "latestFeature" - } -} diff --git a/kubernetes/defaults.yaml b/kubernetes/defaults.yaml deleted file mode 100644 index 0a04523..0000000 --- a/kubernetes/defaults.yaml +++ /dev/null @@ -1,12 +0,0 @@ -#@data/values-schema -#@schema/type any=True ---- -name: initializr-service -namespace: initializr -image_name: steeltoe.azurecr.io/initializr-service -image_tag: latest -container_port: 80 -service_port: 80 -replica_count: 1 -dotnet_environment: Development -args: "" diff --git a/kubernetes/initializr-service.yaml b/kubernetes/initializr-service.yaml deleted file mode 100644 index 207b253..0000000 --- a/kubernetes/initializr-service.yaml +++ /dev/null @@ -1,41 +0,0 @@ -#@ load("@ytt:data", "data") - ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: #@ data.values.name - namespace: #@ data.values.namespace -spec: - selector: - matchLabels: - app: #@ data.values.name - template: - metadata: - labels: - app: #@ data.values.name - spec: - nodeSelector: - "kubernetes.io/os": linux - containers: - - name: #@ data.values.name - image: #@ "{}:{}".format(data.values.image_name, data.values.image_tag) - env: - - name: ASPNETCORE_ENVIRONMENT - value: #@ data.values.dotnet_environment - ports: - - containerPort: #@ int(data.values.container_port) - replicas: #@ int(data.values.replica_count) - ---- -apiVersion: v1 -kind: Service -metadata: - name: #@ data.values.name - namespace: #@ data.values.namespace -spec: - ports: - - port: #@ int(data.values.service_port) - targetPort: #@ int(data.values.container_port) - selector: - app: #@ data.values.name diff --git a/sign/SignPackages.ps1 b/sign/SignPackages.ps1 deleted file mode 100755 index a5bb606..0000000 --- a/sign/SignPackages.ps1 +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env pwsh - -$baseDir = "$PSScriptRoot/.." -$toolDir = "$baseDir/tools" -$artifactStagingDirectory = $Env:ArtifactStagingDirectory - -$name = "Steeltoe" -$description = "Steeltoe" -$descriptionUrl = "https://github.com/SteeltoeOSS" -$appSettings = "$baseDir/sign/appsettings.json" -$signClientUser = $Env:SignClientUser -$signClientSecret = $Env:SignClientSecret - -"installing SignClient" -New-Item -ItemType Directory -Force -Path "$toolDir" -dotnet tool install --tool-path "$toolDir" SignClient - -"looking for artifacts" -$artifacts = Get-ChildItem $artifactStagingDirectory/Steeltoe*.*nupkg -recurse | Select-Object -ExpandProperty FullName -if ($artifacts) { - foreach ($artifact in $artifacts) - { - "signing $artifact" - & $toolDir/SignClient Sign --input $artifact --config $appSettings --user $signClientUser --secret $signClientSecret --name $name --description $description --descriptionUrl $descriptionUrl - } -} -else -{ - "no artifacts found" -} diff --git a/sign/appsettings.json b/sign/appsettings.json deleted file mode 100644 index 3276a45..0000000 --- a/sign/appsettings.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "SignClient": { - "AzureAd": { - "AADInstance": "https://login.microsoftonline.com/", - "ClientId": "c248d68a-ba6f-4aa9-8a68-71fe872063f8", - "TenantId": "16076fdc-fcc1-4a15-b1ca-32c9a255900e" - }, - "Service": { - "Url": "https://codesign.dotnetfoundation.org/", - "ResourceId": "https://SignService/3c30251f-36f3-490b-a955-520addb85001" - } - } -} \ No newline at end of file diff --git a/sign/filelist.txt b/sign/filelist.txt deleted file mode 100644 index 8c4ba1e..0000000 --- a/sign/filelist.txt +++ /dev/null @@ -1 +0,0 @@ -**/Steeltoe.* diff --git a/src/Directory.Build.props b/src/Directory.Build.props index a9f5d39..0ce28e3 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -19,12 +19,12 @@ SA1101;SA1309;SA1402;SA1649 - + true - + All diff --git a/src/InitializrService/Controllers/RootController.cs b/src/InitializrService/Controllers/RootController.cs index 4ef29c3..b38402c 100644 --- a/src/InitializrService/Controllers/RootController.cs +++ b/src/InitializrService/Controllers/RootController.cs @@ -109,25 +109,6 @@ from dependency in @group.Values return Ok(string.Join(newline, help)); } - private void LoadTextResource(string resource, List lineBuffer) - { - if (resource is null) - { - return; - } - - try - { - lineBuffer.Add(string.Empty); - System.IO.File.ReadAllLines(resource).ToList().ForEach(l => lineBuffer.Add(l)); - lineBuffer.Add(string.Empty); - } - catch (Exception e) - { - Logger.LogWarning("failed to load text resource: {Resource}, {Exception}", resource, e.Message); - } - } - private static IEnumerable ToTable(IReadOnlyList> rows) { var columnMaxWidth = new int[rows[0].Count]; @@ -169,5 +150,24 @@ private static IEnumerable ToTable(IReadOnlyList> rows) table.Add(borderRule); return table; } + + private void LoadTextResource(string resource, List lineBuffer) + { + if (resource is null) + { + return; + } + + try + { + lineBuffer.Add(string.Empty); + System.IO.File.ReadAllLines(resource).ToList().ForEach(l => lineBuffer.Add(l)); + lineBuffer.Add(string.Empty); + } + catch (Exception e) + { + Logger.LogWarning("failed to load text resource: {Resource}, {Exception}", resource, e.Message); + } + } } } diff --git a/src/InitializrService/Generators/NetCoreToolProjectGenerator.cs b/src/InitializrService/Generators/NetCoreToolProjectGenerator.cs index aabc323..d57ca31 100644 --- a/src/InitializrService/Generators/NetCoreToolProjectGenerator.cs +++ b/src/InitializrService/Generators/NetCoreToolProjectGenerator.cs @@ -15,7 +15,7 @@ namespace Steeltoe.InitializrService.Generators { /// - /// a A project generator that uses a NetCoreToolService. + /// A project generator that uses a NetCoreToolService. /// public class NetCoreToolProjectGenerator : InitializrServiceBase, IProjectGenerator { diff --git a/src/InitializrService/Services/IProjectGenerator.cs b/src/InitializrService/Services/IProjectGenerator.cs index a2784f5..6f6dde8 100644 --- a/src/InitializrService/Services/IProjectGenerator.cs +++ b/src/InitializrService/Services/IProjectGenerator.cs @@ -4,7 +4,6 @@ using Steeltoe.InitializrService.Models; using System; -using System.Runtime.Serialization; using System.Threading.Tasks; namespace Steeltoe.InitializrService.Services @@ -31,12 +30,6 @@ public NoProjectForSpecException(string message) : base(message) { } - - /// - protected NoProjectForSpecException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } /// @@ -48,11 +41,5 @@ public InvalidSpecException(string message) : base(message) { } - - /// - protected InvalidSpecException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } diff --git a/test/.gitignore b/test/.gitignore deleted file mode 100644 index 54ad947..0000000 --- a/test/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# code coverage -coverage*.* diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 43c606a..7d6b93b 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -5,13 +5,13 @@ - - - - - - - + + + + + + + diff --git a/test/InitializrService.Test.Integration/ProgramTests.cs b/test/InitializrService.Test.Integration/ProgramTests.cs index 11b000f..851a44b 100644 --- a/test/InitializrService.Test.Integration/ProgramTests.cs +++ b/test/InitializrService.Test.Integration/ProgramTests.cs @@ -21,7 +21,7 @@ public void About_Should_Contain_About_Details() about.Vendor.Should().Be("SteeltoeOSS/VMware"); about.Url.Should().Be("https://github.com/SteeltoeOSS/InitializrService/"); about.Version.Should().NotBeNull(); - about.Version.Should().Be("1.0.0-rc1"); + about.Version.Should().Contain("1.0.0"); about.Commit.Should().NotBeNull(); } diff --git a/test/InitializrService.Test.Utils/MockProjectTemplateWebRequest.cs b/test/InitializrService.Test.Utils/MockProjectTemplateWebRequest.cs deleted file mode 100644 index 76760e8..0000000 --- a/test/InitializrService.Test.Utils/MockProjectTemplateWebRequest.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System; -using System.Net; - -namespace Steeltoe.InitializrService.Test.Utils -{ - public class MockProjectTemplateWebRequest : WebRequest - { - private Uri _uri; - - public MockProjectTemplateWebRequest(Uri uri) - { - _uri = uri; - } - - public override WebResponse GetResponse() - { - return new MockProjectTemplateWebResponse(_uri); - } - } -} diff --git a/test/InitializrService.Test.Utils/MockProjectTemplateWebResponse.cs b/test/InitializrService.Test.Utils/MockProjectTemplateWebResponse.cs deleted file mode 100644 index 5097abf..0000000 --- a/test/InitializrService.Test.Utils/MockProjectTemplateWebResponse.cs +++ /dev/null @@ -1,161 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.Compression; -using System.Net; -using System.Text; - -namespace Steeltoe.InitializrService.Test.Utils -{ - public class MockProjectTemplateWebResponse : WebResponse - { - private Uri _uri; - - public MockProjectTemplateWebResponse(Uri uri) - { - _uri = uri; - } - - public override Stream GetResponseStream() - { - switch (_uri.AbsolutePath) - { - case "/error": - return Error(); - case "/izr": - return IzrSteam(); - case "/no/such/file": - return NoSuchFile(); - case "/no/such/dir/": - return NoSuchDirectory(); - case "/stream/empty": - return EmptyStream(); - case "/stream/null": - return NullSteam(); - case "/zip": - return ZipSteam(); - default: - throw new UriFormatException($"Don't know how to create test stream: {_uri}"); - } - } - - private Stream IzrSteam() - { - var buf = new MemoryStream(); - var archive = new ZipArchive(buf, ZipArchiveMode.Create, true); - - var queryParams = new Dictionary() - { - { "constraints", "yes" }, - { "description", "project template description" }, - { "dotNetFrameworkRange", "" }, - { "dotNetTemplate", "" }, - { "language", "" }, - { "manifest", "yes" }, - { "metadata", "yes" }, - { "missingfile", "" }, - { "steeltoeVersionRange", "" }, - }; - if (_uri.Query.StartsWith('?')) - { - foreach (var nameValuePair in _uri.Query.Substring(1).Split('&')) - { - var queryParam = nameValuePair.Split('=', 2); - queryParams[queryParam[0]] = queryParam[1]; - } - } - - if (!queryParams["metadata"].Equals("no")) - { - var metadata = new StringBuilder(); - if (queryParams["metadata"].Equals("malformed")) - { - metadata.Append("malformed yaml"); - } - else - { - metadata.Append("description: ").Append(queryParams["description"]).Append(Environment.NewLine); - if (!queryParams["constraints"].Equals("no")) - { - metadata.Append("constraints:").Append(Environment.NewLine); - metadata.Append($" steeltoeVersionRange: {queryParams["steeltoeVersionRange"]}") - .Append(Environment.NewLine); - metadata.Append( - $" dotNetFrameworkRange: {queryParams["dotNetFrameworkRange"]}") - .Append(Environment.NewLine); - metadata.Append($" dotNetTemplate: {queryParams["dotNetTemplate"]}") - .Append(Environment.NewLine); - metadata.Append($" language: {queryParams["language"]}").Append(Environment.NewLine); - } - - // manifest - if (!queryParams["manifest"].Equals("no")) - { - metadata.Append("manifest:").Append(Environment.NewLine); - metadata.Append("- path: f1").Append(Environment.NewLine); - metadata.Append("- path: d1/").Append(Environment.NewLine); - metadata.Append("- path: r1").Append(Environment.NewLine); - metadata.Append(" rename: n1").Append(Environment.NewLine); - } - } - - WriteEntryText(archive.CreateEntry(".IZR/metadata.yaml"), metadata.ToString()); - } - - if (!queryParams["missingfile"].Equals("yes")) - { - WriteEntryText(archive.CreateEntry("f1"), "my file f1"); - } - - archive.CreateEntry("d1/"); - WriteEntryText(archive.CreateEntry("r1"), "my file r1->n1"); - - archive.Dispose(); - return buf; - } - - private static void WriteEntryText(ZipArchiveEntry entry, string text) - { - using var stream = entry.Open(); - using var writer = new StreamWriter(stream); - writer.Write(text); - } - - private Stream ZipSteam() - { - var buf = new MemoryStream(); - var archive = new ZipArchive(buf, ZipArchiveMode.Create, true); - archive.Dispose(); - return buf; - } - - private Stream EmptyStream() - { - return new MemoryStream(); - } - - private Stream NullSteam() - { - return null; - } - - private Stream NoSuchFile() - { - throw new WebException("URI not found", new FileNotFoundException(_uri.ToString())); - } - - private Stream NoSuchDirectory() - { - throw new WebException("URI not found", new DirectoryNotFoundException(_uri.ToString())); - } - - private Stream Error() - { - throw new Exception($"some error message"); - } - } -} diff --git a/test/InitializrService.Test.Utils/MockProjectTemplateWebScheme.cs b/test/InitializrService.Test.Utils/MockProjectTemplateWebScheme.cs deleted file mode 100644 index 0cfd89f..0000000 --- a/test/InitializrService.Test.Utils/MockProjectTemplateWebScheme.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System; -using System.Net; - -namespace Steeltoe.InitializrService.Test.Utils -{ - public class MockProjectTemplateWebScheme : IWebRequestCreate - { - public WebRequest Create(Uri uri) - { - return new MockProjectTemplateWebRequest(uri); - } - } -} diff --git a/tool.properties b/tool.properties deleted file mode 100644 index 19e80de..0000000 --- a/tool.properties +++ /dev/null @@ -1,2 +0,0 @@ -ytt_version=v0.36.0 -ytt_mirror=https://github.com/vmware-tanzu/carvel-ytt/releases/download diff --git a/tools/.gitignore b/tools/.gitignore deleted file mode 100644 index 512a530..0000000 --- a/tools/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.store/ -/SignClient diff --git a/yttw.sh b/yttw.sh deleted file mode 100755 index 669ec30..0000000 --- a/yttw.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# =========================================================================== # -# wrapper for ytt # -# =========================================================================== # - -base_dir=$(dirname $0) -ytt=$base_dir/tools/ytt - -if [ ! -x $ytt ]; then - ytt_version=$(grep '^ytt_version=' $base_dir/tool.properties | cut -d= -f2) - ytt_mirror=$(grep '^ytt_mirror=' $base_dir/tool.properties | cut -d= -f2) - case $(uname -s) in - Darwin) platform=darwin ;; - Linux) platform=linux ;; - *) - echo "unsupported platform: $(uname -s)" - exit 1 - ;; - esac - ytt_url=$ytt_mirror/$ytt_version/ytt-$platform-amd64 - mkdir -p $(dirname $ytt) - wget $ytt_url -O $ytt - chmod +x $ytt -fi - -exec $ytt $*