├── .editorconfig ├── .env.example ├── .eslintrc.js ├── .github └── workflows │ └── nodejs.yml ├── .gitignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── SECURITY.md ├── azure-pipelines.yml ├── azure-pipelines └── templates │ ├── build-artifacts.yml │ ├── create-github-release.yml │ ├── infra-deployment-pipeline.yml │ ├── infra-generation-kv-pipeline.yml │ ├── infra-generation-pipeline.yml │ └── update-homebrew-formula.yml ├── bedrock-config.yaml ├── docs └── commands │ ├── bedrock.js │ ├── change-rels.js │ ├── data.json │ ├── data0.5.5.json │ ├── data0.5.6.json │ ├── data0.5.7.json │ ├── data0.5.8.json │ ├── data0.6.0.json │ ├── data0.6.1.json │ ├── data0.6.2.json │ ├── data0.6.3.json │ ├── data0.6.4.json │ ├── data0.6.5.json │ ├── data0.6.6.json │ ├── favicon.icon │ ├── images │ └── mslogo.png │ ├── index.html │ ├── releases.txt │ └── styles │ ├── bedrock.css │ ├── docons.cde890b9.woff2 │ ├── feb02e3b.site-ltr.css │ └── ms.css ├── guides ├── README.md ├── RELEASE.md ├── auth-private-helm-repos.md ├── bedrock-end-to-end-dx.md ├── building-helm-charts-for-bedrock.md ├── cloud-infra-management.md ├── command-implementation.md ├── config-file.md ├── contributing.md ├── error-handling.md ├── hld-management.md ├── images │ ├── Capture.png │ ├── bedrock-add-variable.png │ ├── bedrock-hld-chart-configuration-component-yaml.png │ ├── bedrock-hld-generated-ingress-route.png │ ├── bedrock-hld-generated.png │ ├── bedrock-hld-ring-configuration.png │ ├── bedrock-hld-top-level-config-generated.png │ ├── bedrock-infra-alertLogic.png │ ├── bedrock-infra-artifacts.png │ ├── bedrock-infra-azdo-repo.png │ ├── bedrock-infra-azdo.png │ ├── bedrock-infra-azuremonitorgate.png │ ├── bedrock-infra-buildartifact.png │ ├── bedrock-infra-cicd.png │ ├── bedrock-infra-complete-merge.png │ ├── bedrock-infra-conditiongate.png │ ├── bedrock-infra-downloadartifact.png │ ├── bedrock-infra-environmentService.png │ ├── bedrock-infra-environments.png │ ├── bedrock-infra-existing-yaml.png │ ├── bedrock-infra-github.png │ ├── bedrock-infra-new-pipeline.png │ ├── bedrock-infra-path-to-yaml.png │ ├── bedrock-infra-postdeploy.png │ ├── bedrock-infra-pr-approve.png │ ├── bedrock-infra-pr.png │ ├── bedrock-infra-repo.png │ ├── bedrock-infra-rollbackRelease.png │ ├── bedrock-infra-save-run.png │ ├── bedrock-infra-securefiles.png │ ├── bedrock-infra-successful-pipeline.png │ ├── bedrock-infra-vg.png │ ├── bedrock-rendered-deployment.png │ ├── bedrock-rendered-service.png │ ├── bedrock-resource-diagram.png │ ├── bedrock-rollback-upgrades.png │ ├── bedrock.png │ ├── kvsetupvg.png │ ├── permit_access.jpg │ ├── secrets-kv-vg.png │ ├── service_introspection.png │ └── variable_group.png ├── infra │ ├── README.md │ ├── bedrock-infra-deployment-pipeline.md │ ├── bedrock-infra-end-to-end.md │ ├── bedrock-infra-generation-pipeline.md │ ├── bedrock-infra-rollback.md │ ├── bedrock-infra-under-the-hood.md │ ├── bedrock-terragrunt-day-2-scenarios.md │ └── bedrock-terragrunt-overview.md ├── manual-guide-to-rings.md ├── project-management.md ├── project-service-management-guide.md ├── rings-101.md ├── sample-helm-chart │ ├── .helmignore │ ├── Chart.yaml │ ├── templates │ │ ├── deployment.yaml │ │ └── service.yaml │ └── values.yaml ├── service-introspection-onboarding.md ├── service-introspection.md └── service-management.md ├── jest.config.js ├── package.json ├── patches └── 001-azure-devops-node.patch ├── release-pipeline.yml ├── scripts ├── release-version-bump.sh ├── tag-release.sh └── update_introspection.sh ├── smoke-test-pipeline.yml ├── src ├── commands │ ├── command.ts │ ├── deployment │ │ ├── create.decorator.json │ │ ├── create.md │ │ ├── create.test.ts │ │ ├── create.ts │ │ ├── dashboard.decorator.json │ │ ├── dashboard.md │ │ ├── dashboard.test.ts │ │ ├── dashboard.ts │ │ ├── get.decorator.json │ │ ├── get.md │ │ ├── get.test.ts │ │ ├── get.ts │ │ ├── index.ts │ │ ├── mocks │ │ │ ├── author.json │ │ │ ├── cluster-sync.json │ │ │ ├── data.json │ │ │ ├── pr.json │ │ │ └── unmerged-pr.json │ │ ├── onboard.decorator.json │ │ ├── onboard.md │ │ ├── onboard.test.ts │ │ ├── onboard.ts │ │ ├── validate.decorator.json │ │ ├── validate.md │ │ ├── validate.test.ts │ │ └── validate.ts │ ├── hld │ │ ├── append-variable-group.decorator.json │ │ ├── append-variable-group.md │ │ ├── append-variable-group.test.ts │ │ ├── append-variable-group.ts │ │ ├── index.ts │ │ ├── init.decorator.json │ │ ├── init.md │ │ ├── init.test.ts │ │ ├── init.ts │ │ ├── pipeline.decorator.json │ │ ├── pipeline.md │ │ ├── pipeline.test.ts │ │ ├── pipeline.ts │ │ ├── reconcile-unit.test.ts │ │ ├── reconcile.decorator.json │ │ ├── reconcile.md │ │ ├── reconcile.test.ts │ │ └── reconcile.ts │ ├── infra │ │ ├── generate.decorator.json │ │ ├── generate.md │ │ ├── generate.test.ts │ │ ├── generate.ts │ │ ├── index.ts │ │ ├── infra_common.test.ts │ │ ├── infra_common.ts │ │ ├── mocks │ │ │ ├── fabrikam │ │ │ │ ├── central │ │ │ │ │ └── definition.yaml │ │ │ │ ├── definition.yaml │ │ │ │ └── west │ │ │ │ │ └── definition.yaml │ │ │ └── missing-parent-defn │ │ │ │ └── definition.yaml │ │ ├── scaffold.decorator.json │ │ ├── scaffold.md │ │ ├── scaffold.test.ts │ │ └── scaffold.ts │ ├── init.decorator.json │ ├── init.md │ ├── init.test.ts │ ├── init.ts │ ├── mocks │ │ └── bedrock-config.yaml │ ├── project │ │ ├── append-variable-group.decorator.json │ │ ├── append-variable-group.md │ │ ├── append-variable-group.test.ts │ │ ├── append-variable-group.ts │ │ ├── create-variable-group.decorator.json │ │ ├── create-variable-group.md │ │ ├── create-variable-group.test.ts │ │ ├── create-variable-group.ts │ │ ├── index.ts │ │ ├── init.decorator.json │ │ ├── init.md │ │ ├── init.test.ts │ │ ├── init.ts │ │ ├── pipeline.decorator.json │ │ ├── pipeline.md │ │ ├── pipeline.test.ts │ │ └── pipeline.ts │ ├── ring │ │ ├── create.decorator.json │ │ ├── create.md │ │ ├── create.test.ts │ │ ├── create.ts │ │ ├── delete.decorator.json │ │ ├── delete.md │ │ ├── delete.test.ts │ │ ├── delete.ts │ │ ├── index.ts │ │ ├── set-default.decorator.json │ │ ├── set-default.md │ │ ├── set-default.test.ts │ │ └── set-default.ts │ ├── service │ │ ├── create-revision.decorator.json │ │ ├── create-revision.md │ │ ├── create-revision.test.ts │ │ ├── create-revision.ts │ │ ├── create.decorator.json │ │ ├── create.md │ │ ├── create.test.ts │ │ ├── create.ts │ │ ├── get-display-name.decorator.json │ │ ├── get-display-name.md │ │ ├── get-display-name.test.ts │ │ ├── get-display-name.ts │ │ ├── index.ts │ │ ├── pipeline.decorator.json │ │ ├── pipeline.md │ │ ├── pipeline.test.ts │ │ └── pipeline.ts │ ├── setup.decorator.json │ ├── setup.md │ ├── setup.test.ts │ └── setup.ts ├── config.test.ts ├── config.ts ├── index.ts ├── lib │ ├── assertions.test.ts │ ├── assertions.ts │ ├── azdoClient.test.ts │ ├── azdoClient.ts │ ├── azure │ │ ├── azurecredentials.test.ts │ │ ├── azurecredentials.ts │ │ ├── containerRegistryService.test.ts │ │ ├── containerRegistryService.ts │ │ ├── deploymenttable.test.ts │ │ ├── deploymenttable.ts │ │ ├── keyvault.test.ts │ │ ├── keyvault.ts │ │ ├── resourceService.test.ts │ │ ├── resourceService.ts │ │ ├── servicePrincipalService.test.ts │ │ ├── servicePrincipalService.ts │ │ ├── storage.test.ts │ │ ├── storage.ts │ │ ├── subscriptionService.test.ts │ │ └── subscriptionService.ts │ ├── bedrockYaml │ │ ├── bedrockYaml.test.ts │ │ ├── bedrockYaml.ts │ │ ├── index.ts │ │ └── migrations │ │ │ ├── service-map-to-list.test.ts │ │ │ └── service-map-to-list.ts │ ├── commandBuilder.test.ts │ ├── commandBuilder.ts │ ├── constants.ts │ ├── errorBuilder.test.ts │ ├── errorBuilder.ts │ ├── errorStatusCode.ts │ ├── fileutils.test.ts │ ├── fileutils.ts │ ├── git │ │ ├── azure.test.ts │ │ ├── azure.ts │ │ └── index.ts │ ├── gitpr.test.ts │ ├── gitpr.ts │ ├── gitutils.test.ts │ ├── gitutils.ts │ ├── gitutils.with-exec.test.ts │ ├── i18n.json │ ├── ioUtil.test.ts │ ├── ioUtil.ts │ ├── net │ │ ├── dns.test.ts │ │ └── dns.ts │ ├── pipelines │ │ ├── azdoInterfaces.d.ts │ │ ├── pipelines.test.ts │ │ ├── pipelines.ts │ │ ├── serviceEndpoint.test.ts │ │ ├── serviceEndpoint.ts │ │ ├── variableGroup.test.ts │ │ └── variableGroup.ts │ ├── promptBuilder.ts │ ├── setup │ │ ├── azureStorage.test.ts │ │ ├── azureStorage.ts │ │ ├── constants.ts │ │ ├── fsUtil.test.ts │ │ ├── fsUtil.ts │ │ ├── gitService.test.ts │ │ ├── gitService.ts │ │ ├── helmTemplates.ts │ │ ├── pipelineService.test.ts │ │ ├── pipelineService.ts │ │ ├── projectService.test.ts │ │ ├── projectService.ts │ │ ├── prompt.test.ts │ │ ├── prompt.ts │ │ ├── scaffold.test.ts │ │ ├── scaffold.ts │ │ ├── setupLog.test.ts │ │ ├── setupLog.ts │ │ ├── variableGroup.test.ts │ │ └── variableGroup.ts │ ├── shell.test.ts │ ├── shell.ts │ ├── traefik │ │ ├── ingress-route.test.ts │ │ ├── ingress-route.ts │ │ ├── middleware.test.ts │ │ └── middleware.ts │ ├── util.test.ts │ ├── util.ts │ ├── validator.test.ts │ └── validator.ts ├── logger │ ├── index.test.ts │ └── index.ts ├── test │ └── mockFactory.ts └── types.d.ts ├── technical-docs └── designs │ ├── README.md │ ├── Versioning.md │ ├── commands │ ├── inheritFieldInOnBoardDoc.png │ └── inheritFromConfigYaml.md │ ├── documents │ ├── changesInCommands.png │ └── changesInCommandsOverReleases.md │ ├── exceptionHandling.md │ ├── infra │ ├── images │ │ └── infratestflow.png │ ├── managed-identity.md │ ├── relativepaths.md │ └── scaffoldVariables.md │ ├── initialization │ ├── interactiveModeForIntrospectionConfig.md │ ├── spkInitSupportIntrospection.png │ └── spkInitSupportIntrospection1.png │ ├── introspection │ ├── azureAPICalls.png │ ├── cache-flow-chart.png │ ├── currentDeployment.png │ ├── deploymentDashboard.md │ ├── deploymentDashboardCaching.md │ ├── devSetup.png │ ├── multipleBrowsersToBackend.png │ └── proposedDeployment.png │ ├── repos-merge.md │ ├── services │ └── acrBuildArguments.md │ └── spkmove.md ├── tests ├── .gitignore ├── README.md ├── bedrock-config-test.yaml ├── functions.sh ├── helm-artifacts │ ├── test.Chart.yaml │ ├── test.templates.yaml │ └── test.values.yaml ├── images │ └── definitionid.png ├── infra-validations.sh ├── introspection-clean-data-logic-app.json ├── introspection-validations.sh ├── single-app-repo-validation.sh └── validations.sh ├── tools ├── generateDoc.ts └── locateAliases.ts ├── tsconfig.json ├── typings └── ssh-url │ └── index.d.ts ├── webpack.config.js └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true ; top-most EditorConfig file 2 | 3 | ; Unix-style newlines with a newline ending every file 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_size = 2 8 | indent_style = space 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | INTROSPECTION_STORAGE_ACCESS_KEY="access key" 2 | AZURE_TENANT_ID="AAD tenant id" 3 | AZURE_CLIENT_ID="Azure service principal client Id" 4 | AZURE_CLIENT_SECRET="Azure service principal client secret/password" 5 | AZURE_SUBSCRIPTION_ID="Azure subscription id" 6 | 7 | AZDO_PERSONAL_ACCESS_TOKEN=" Azure DevOps Personal Access Token" 8 | 9 | AZDO_SERVICE_CONNECTION_SUBSCRIPTION_ID="Azure Key Vault Subscription Id" 10 | AZDO_SERVICE_CONNECTION_CLIENT_ID="Azure Service Principal Id with [get, list] access to Key Vault secrets" 11 | AZDO_SERVICE_CONNECTION_CLIENT_SECRET="Azure Service Principal secret/password" 12 | AZDO_SERVICE_CONNECTION_TENANT_ID="AAD Tenant Id for Azure Service Principal Id" 13 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true, 5 | }, 6 | parser: "@typescript-eslint/parser", 7 | plugins: ["@typescript-eslint"], 8 | extends: [ 9 | "eslint:recommended", 10 | "plugin:@typescript-eslint/eslint-recommended", 11 | "plugin:@typescript-eslint/recommended", 12 | "prettier", 13 | "prettier/@typescript-eslint", 14 | ], 15 | rules: { 16 | "@typescript-eslint/camelcase": "off", 17 | }, 18 | }; 19 | -------------------------------------------------------------------------------- /.github/workflows/nodejs.yml: -------------------------------------------------------------------------------- 1 | name: Node CI 2 | 3 | on: 4 | - push 5 | - pull_request 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | 11 | strategy: 12 | matrix: 13 | node-version: [8.x, 10.x, 12.x] 14 | 15 | steps: 16 | - uses: actions/checkout@v1 17 | - name: Use Node.js ${{ matrix.node-version }} 18 | uses: actions/setup-node@v1 19 | with: 20 | node-version: ${{ matrix.node-version }} 21 | - name: install az cli 22 | run: | 23 | curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash 24 | - name: yarn install, lint, build, and test 25 | run: | 26 | yarn 27 | yarn lint 28 | yarn build 29 | yarn test 30 | env: 31 | CI: true 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Custom 2 | dist 3 | package-lock.json 4 | .DS_Store 5 | .bedrock 6 | .idea 7 | 8 | # Logs 9 | logs 10 | *.log 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | lerna-debug.log* 15 | 16 | # Diagnostic reports (https://nodejs.org/api/report.html) 17 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 18 | 19 | # Runtime data 20 | pids 21 | *.pid 22 | *.seed 23 | *.pid.lock 24 | 25 | # Directory for instrumented libs generated by jscoverage/JSCover 26 | lib-cov 27 | 28 | # Coverage directory used by tools like istanbul 29 | coverage 30 | *.lcov 31 | 32 | # nyc test coverage 33 | .nyc_output 34 | 35 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 36 | .grunt 37 | 38 | # Bower dependency directory (https://bower.io/) 39 | bower_components 40 | 41 | # node-waf configuration 42 | .lock-wscript 43 | 44 | # Compiled binary addons (https://nodejs.org/api/addons.html) 45 | build/Release 46 | 47 | # Dependency directories 48 | node_modules/ 49 | jspm_packages/ 50 | 51 | # TypeScript cache 52 | *.tsbuildinfo 53 | 54 | # Optional npm cache directory 55 | .npm 56 | 57 | # Optional eslint cache 58 | .eslintcache 59 | 60 | # Optional REPL history 61 | .node_repl_history 62 | 63 | # Output of 'npm pack' 64 | *.tgz 65 | 66 | # Yarn Integrity file 67 | .yarn-integrity 68 | 69 | # dotenv environment variables file 70 | .env 71 | .env.test 72 | 73 | # parcel-bundler cache (https://parceljs.org/) 74 | .cache 75 | 76 | # next.js build output 77 | .next 78 | 79 | # nuxt.js build output 80 | .nuxt 81 | 82 | # vuepress build output 83 | .vuepress/dist 84 | 85 | # Serverless directories 86 | .serverless/ 87 | 88 | # FuseBox cache 89 | .fusebox/ 90 | 91 | # DynamoDB Local files 92 | .dynamodb/ 93 | 94 | # vscode 95 | .vscode/ 96 | 97 | # Local XUnit test results 98 | junit.xml 99 | 100 | # quick-start-temp-folder 101 | quick-start-env/ 102 | 103 | # Bedrock files --- 104 | spk.log 105 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Microsoft Open Source Code of Conduct 2 | 3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 4 | 5 | Resources: 6 | 7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) 8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) 9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets Microsoft's [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)) of a security vulnerability, please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd). 40 | 41 | -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | trigger: 2 | - master 3 | 4 | pr: 5 | - master 6 | 7 | strategy: 8 | matrix: 9 | node_12_x: 10 | node_version: 12.x 11 | node_13_x: 12 | node_version: 13.x 13 | maxParallel: 2 14 | 15 | pool: 16 | vmImage: "ubuntu-latest" 17 | 18 | variables: 19 | - group: 'bedrock-cli-vg' 20 | 21 | steps: 22 | - task: NodeTool@0 23 | inputs: 24 | versionSpec: "$(node_version)" 25 | displayName: "Install Node.js" 26 | 27 | - script: | 28 | curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash 29 | displayName: "Install az-cli" 30 | 31 | - script: | 32 | yarn 33 | displayName: "YARN INSTALL" 34 | 35 | - script: | 36 | yarn lint 37 | displayName: "YARN LINT" 38 | 39 | - script: | 40 | yarn md-lint 41 | displayName: "YARN MARKDOWN LINT" 42 | 43 | - script: | 44 | yarn build 45 | displayName: "YARN BUILD" 46 | 47 | - script: | 48 | yarn test 49 | displayName: "YARN TEST" 50 | timeoutInMinutes: 3 51 | 52 | - task: PublishCodeCoverageResults@1 53 | inputs: 54 | codeCoverageTool: Cobertura 55 | summaryFileLocation: "$(System.DefaultWorkingDirectory)/**/*coverage.xml" 56 | reportDirectory: "$(System.DefaultWorkingDirectory)/**/coverage" 57 | condition: and(eq(variables['Agent.JobStatus'], 'Succeeded'), endsWith(variables['Agent.JobName'], 'node_12_x')) 58 | 59 | - task: PublishTestResults@2 60 | inputs: 61 | testResultsFormat: 'JUnit' 62 | testResultsFiles: '**/junit.xml' 63 | condition: and(eq(variables['Agent.JobStatus'], 'Succeeded'), endsWith(variables['Agent.JobName'], 'node_12_x')) 64 | 65 | - bash: | 66 | [ -z "$COVERAGE_VARIANCE" ] && { echo "Missing COVERAGE_VARIANCE variable"; exit 1; } 67 | echo "Code coverage variance value is: $COVERAGE_VARIANCE" 68 | displayName: 'Build quality pre-validation' 69 | failOnStderr: true 70 | env: 71 | COVERAGE_VARIANCE: $(COVERAGE_VARIANCE) 72 | condition: and(eq(variables['Agent.JobStatus'], 'Succeeded'), endsWith(variables['Agent.JobName'], 'node_12_x')) 73 | 74 | - task: mspremier.BuildQualityChecks.QualityChecks-task.BuildQualityChecks@6 75 | displayName: 'Check build quality' 76 | inputs: 77 | checkWarnings: false 78 | warningFailOption: fixed 79 | warningFilters: '' 80 | showStatistics: true 81 | checkCoverage: true 82 | coverageFailOption: build # We are comparing against the previous build in baseBranchRef 83 | coverageType: branches # We are looking at code branch coverage, not line coverage 84 | coverageDeltaType: percentage 85 | allowCoverageVariance: true 86 | coverageVariance: $(COVERAGE_VARIANCE) # Prefer a value less 1.00 87 | baseDefinitionId: $(BEDROCK_CLI_DEFINITION_ID) 88 | baseBranchRef: refs/heads/master 89 | runTitle: 'Code Coverage Evaluation' 90 | condition: and(eq(variables['Agent.JobStatus'], 'Succeeded'), endsWith(variables['Agent.JobName'], 'node_12_x')) 91 | 92 | - task: PublishPipelineArtifact@1 93 | inputs: 94 | path: $(System.DefaultWorkingDirectory)/dist/bedrock-linux 95 | artifact: bedrock_linux_node_12 96 | condition: and(eq(variables['Agent.JobStatus'], 'Succeeded'), endsWith(variables['Agent.JobName'], 'node_12_x')) 97 | -------------------------------------------------------------------------------- /azure-pipelines/templates/build-artifacts.yml: -------------------------------------------------------------------------------- 1 | # https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops#job-templates-with-parameters 2 | jobs: 3 | - job: ${{ parameters.name }} 4 | pool: ${{ parameters.pool }} 5 | timeoutInMinutes: 15 # how long to run the job before automatically cancelling 6 | steps: 7 | - task: NodeTool@0 8 | displayName: "Use Node 12.x" 9 | inputs: 10 | versionSpec: 12.x 11 | 12 | - bash: | 13 | set -ex 14 | 15 | yarn install 16 | yarn build 17 | displayName: Build 18 | 19 | - publish: $(System.DefaultWorkingDirectory)/dist 20 | artifact: dist 21 | 22 | - script: | 23 | package_version=$(cat $(System.DefaultWorkingDirectory)/package.json | grep "version" | sed -e 's/"version": "//g') 24 | new_version=v${package_version%??} 25 | echo $new_version| sed -e 's/ //g' > version.txt 26 | 27 | - publish: $(System.DefaultWorkingDirectory)/version.txt 28 | artifact: BedrockVersion -------------------------------------------------------------------------------- /azure-pipelines/templates/create-github-release.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | GitHubConnection: "" # defaults for any parameters that aren't specified 3 | releaseNotesFilePath: "" 4 | addChangeLog: true 5 | isPreRelease: false 6 | isDraft: false 7 | tagSource: "gitTag" 8 | action: create 9 | target: $(Build.SourceVersion) 10 | 11 | jobs: 12 | - job: Create_Github_Release 13 | timeoutInMinutes: 30 # timeout on job if deploy is not completed in 30 minutes 14 | pool: 15 | vmImage: ubuntu-16.04 16 | steps: 17 | - download: current 18 | 19 | - task: ArchiveFiles@2 20 | inputs: 21 | rootFolderOrFile: $(Agent.BuildDirectory)/dist 22 | includeRootFolder: true 23 | archiveFile: $(Agent.BuildDirectory)/dist.tar.gz 24 | replaceExistingArchive: true 25 | 26 | - script: | 27 | echo "Get sha256 number for dist.tar.gz" 28 | file_sha=$(openssl dgst -sha256 $(Agent.BuildDirectory)/dist.tar.gz) 29 | sha_number=$(echo $file_sha| sed -e 's/SHA256(.*)= //g') 30 | version_tag=$(sed -n '1p' < $(Agent.BuildDirectory)/BedrockVersion/version.txt) 31 | echo -e $version_tag >> $(Agent.BuildDirectory)/package-info.txt 32 | echo -e $sha_number >> $(Agent.BuildDirectory)/package-info.txt 33 | 34 | - publish: $(Agent.BuildDirectory)/package-info.txt 35 | artifact: BedrockPackage 36 | 37 | - task: GitHubRelease@1 38 | displayName: "GitHub release ${{ parameters.action }}" 39 | inputs: 40 | action: ${{ parameters.action }} 41 | gitHubConnection: ${{ parameters.GitHubConnection }} 42 | repositoryName: "$(Build.Repository.Name)" 43 | releaseNotesFilePath: ${{ parameters.releaseNotesFilePath }} 44 | target: ${{ parameters.target }} 45 | assets: | 46 | $(Agent.BuildDirectory)/dist/bedrock-linux 47 | $(Agent.BuildDirectory)/dist/bedrock-macos 48 | $(Agent.BuildDirectory)/dist/bedrock-win.exe 49 | $(Agent.BuildDirectory)/dist.tar.gz 50 | tagSource: ${{ parameters.tagSource }} 51 | isDraft: ${{ parameters.isDraft }} 52 | isPreRelease: ${{ parameters.isPrelease }} 53 | addChangeLog: ${{ parameters.addChangeLog }} 54 | -------------------------------------------------------------------------------- /azure-pipelines/templates/update-homebrew-formula.yml: -------------------------------------------------------------------------------- 1 | 2 | jobs: 3 | - job: Update_Homebrew_Formula 4 | timeoutInMinutes: 30 # timeout on job if deploy is not completed in 30 minutes 5 | pool: 6 | vmImage: ubuntu-16.04 7 | steps: 8 | - download: current 9 | 10 | - task: DownloadPipelineArtifact@2 11 | inputs: 12 | artifact: 'BedrockPackage' 13 | path: $(Agent.BuildDirectory) 14 | 15 | - checkout: BedrockHomebrewCore 16 | persistCredentials: true 17 | clean: true 18 | 19 | - script: | 20 | # Read version and sha256 number 21 | sha_number=$(sed -n '2p' < $(Agent.BuildDirectory)/BedrockPackage/package-info.txt) 22 | version_tag=$(sed -n '1p' < $(Agent.BuildDirectory)/BedrockPackage/package-info.txt) 23 | echo "version tag" 24 | echo $version_tag 25 | 26 | dir $(Build.SourcesDirectory) 27 | cd $(Build.SourcesDirectory) 28 | 29 | # Add changes to the homebrew formula repository 30 | git pull origin master 31 | git checkout -b master 32 | 33 | # Set git identity 34 | git config user.email "admin@azuredevops.com" 35 | git config user.name "Automated Account" 36 | 37 | cd Formula 38 | # Parse homebrew formula file to update the version, commit and push 39 | echo "Updating bedrock-cli.rb formula file on bedrock homebrew repository." 40 | sed -i "s/\/v.*\//\/$version_tag\//g" bedrock-cli.rb 41 | cat bedrock-cli.rb 42 | sed -i "s/sha256 \".*\"/sha256 \"$sha_number\"/g" bedrock-cli.rb 43 | cat bedrock-cli.rb 44 | 45 | echo "Add and push new version changes." 46 | git add -f bedrock-cli.rb 47 | git commit -m "Update formula with new release." 48 | 49 | git push origin master 50 | -------------------------------------------------------------------------------- /bedrock-config.yaml: -------------------------------------------------------------------------------- 1 | # Azure DevOps Configuration 2 | azure_devops: 3 | access_token: "" # This is a Personal Access Token with permission to modify and access the HLD, manifest and infra repos. Leave this empty if project is public. Details for the PAT at: https://github.com/microsoft/bedrock-cli/blob/master/docs/project-service-management-guide.md#generating-personal-access-token 4 | hld_repository: "https://dev.azure.com///_git/" # Repository URL for your Bedrock HLDs 5 | manifest_repository: "https://dev.azure.com///_git/" # Repository URL for your materialized manifests generated by fabrikate. 6 | infra_repository: "https://dev.azure.com///_git/" # Repository URL that contains your terraform templates to be sed for scaffolding and generating infrastructure deployment templates. 7 | org: "" # Your AzDo Org 8 | project: "" # Your AzDo project 9 | infra: 10 | # DO NOT MODIFY THE FOLLOWING 11 | # Prerequisite versions are auto-generated upon executing `bedrock init` 12 | terraform: "v0.12.6" 13 | helm: "v2.14.3" 14 | git: "2.17.1" 15 | az: "2.0.71" 16 | 17 | introspection: 18 | dashboard: 19 | image: "mcr.microsoft.com/k8s/bedrock/spektate:latest" # Use this default docker image unless you would like to use a custom one 20 | name: "spektate" 21 | azure: # This is the storage account for the service introspection tool. 22 | account_name: "storage-account-name" # Must be defined to run bedrock deployment commands 23 | table_name: "storage-account-table-name" # Must be defined to run bedrock deployment commands 24 | partition_key: "storage-account-table-partition-key" # Must be defined to run bedrock deployment commands 25 | key: "storage-access-key" # Must be defined to run bedrock deployment commands. Use ${env:INTROSPECTION_STORAGE_ACCESS_KEY} and set it in .env file 26 | source_repo_access_token: "source_repo_access_token" # Optional. Required only when source repository is private (in order to render the author column in dashboard) 27 | 28 | # Following 5 fields are needed only if using bedrock to onboard to use introspection tool 29 | service_principal_id: "service-principal-id" 30 | service_principal_secret: "service-principal-secret" 31 | subscription_id: "subscription-id" 32 | tenant_id: "tenant-id" 33 | resource_group: "resource-group-name" 34 | key_vault_name: # azure key vault name" 35 | -------------------------------------------------------------------------------- /docs/commands/favicon.icon: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/docs/commands/favicon.icon -------------------------------------------------------------------------------- /docs/commands/images/mslogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/docs/commands/images/mslogo.png -------------------------------------------------------------------------------- /docs/commands/releases.txt: -------------------------------------------------------------------------------- 1 | 0.5.5 2 | 0.5.6 3 | 0.5.7 4 | 0.5.8 5 | 0.6.0 6 | 0.6.1 7 | 0.6.2 8 | 0.6.3 9 | 0.6.4 10 | 0.6.5 11 | 0.6.6 12 | -------------------------------------------------------------------------------- /docs/commands/styles/docons.cde890b9.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/docs/commands/styles/docons.cde890b9.woff2 -------------------------------------------------------------------------------- /guides/README.md: -------------------------------------------------------------------------------- 1 | # Bedrock CLI Guides 2 | 3 | Bedrock is a command line tool that automates common workflows around Bedrock 4 | principles. It targets several areas: cluster infrastructure, service 5 | management, service introspection. Below you will find guides to help you use 6 | Bedrock to adopt the Bedrock principles that you choose. 7 | 8 | [Bedrock Developer and Operations Experience](bedrock-end-to-end-dx.md): A 9 | scenario based description of how all the tools and components in Bedrock fit 10 | together to easily define, build, deploy, and maintain a workload running in a 11 | Kubernetes cluster. 12 | 13 | [Infrastructure Creation and Management](./infra/README.md): Information on how 14 | to create, manage and deploy your infrastructure. 15 | 16 | [Service Management](project-service-management-guide.md): A walkthrough for 17 | managing and deploying services. 18 | 19 | [Service Introspection](service-introspection.md): A walkthrough on how to setup 20 | service introspection. 21 | -------------------------------------------------------------------------------- /guides/RELEASE.md: -------------------------------------------------------------------------------- 1 | # Release 2 | 3 | [![Build Status](https://dev.azure.com/epicstuff/bedrock/_apis/build/status/myho/%5Bbedrock%5D%20create%20github%20release?branchName=master)](https://dev.azure.com/epicstuff/bedrock/_build/latest?definitionId=130&branchName=master) 4 | 5 | Instruction on how to cut a new release. 6 | 7 | ## Steps 8 | 9 | ### Bump Version 10 | 11 | 1. Run the following script to update `package.json`. This will also create and 12 | push to a new branch. 13 | 14 | ```bash 15 | # releasing new minor version & git remote is origin 16 | ./scripts/release-version-bump minor origin 17 | ``` 18 | 19 | 1. Update `CHANGELOG.md` as needed and push to branch. 20 | 21 | 1. Create PR 22 | 23 | ### Create GitHub Release 24 | 25 | 1. Once PR is merge 26 | 1. Run the following script to tag master branch. This will kick off 27 | [the release pipeline](https://dev.azure.com/epicstuff/bedrock/_build?definitionId=130&_a=summary) 28 | to auto build and create a GitHub release. 29 | 30 | ```bash 31 | # origin is my git remote, change it to whatever yours is 32 | ./scripts/tag-release.sh origin 33 | ``` 34 | 35 | 1. The release will also include a changelog of commits made since last release. 36 | This can be turn off. 37 | -------------------------------------------------------------------------------- /guides/config-file.md: -------------------------------------------------------------------------------- 1 | # bedrock-config.yaml 2 | 3 | The [`bedrock-config.yaml`](../bedrock-config.yaml) consists of three main 4 | sections: 5 | 6 | 1. `introspection` 7 | 2. `infra` 8 | 3. `azure_devops` 9 | 10 | #### Environment Variables 11 | 12 | To specify private keys or access tokens that should **not be stored in raw 13 | text** in the `bedrock-config.yaml` file, set the values in environment 14 | variables. 15 | 16 | For example: 17 | 18 | ``` 19 | account_name: "someHardcodedValue" 20 | table_name: "anotherNonPrivateKey" 21 | key: "${env:ACCESS_KEY}" 22 | partition_key: "canBeStoredInRawTextKey" 23 | ``` 24 | 25 | In this case, the value for `key` is taken from the environment variable 26 | `ACCESS_KEY`. 27 | 28 | #### Creating environment variables 29 | 30 | There are two options to create environment variables: 31 | 32 | 1. In a `.env` file 33 | 2. In your shell 34 | 35 | ##### Option 1: .env File 36 | 37 | A recommended approach is to have a `.env` file in your folder **(make sure it's 38 | gitignored!)** with all variables and their values. 39 | 40 | [Sample `.env`](../.env.example): 41 | 42 | ``` 43 | INTROSPECTION_STORAGE_ACCESS_KEY="access key" 44 | AZURE_TENANT_ID="AAD tenant id" 45 | AZURE_CLIENT_ID="Azure service principal client Id" 46 | AZURE_CLIENT_SECRET="Azure service principal client secret/password" 47 | AZURE_SUBSCRIPTION_ID="Azure subscription id" 48 | ``` 49 | 50 | ##### Option 2: shell 51 | 52 | To create an environment variable, run the `export` command. 53 | 54 | The following example creates the `ACCESS_KEY` environment variable. 55 | 56 | ``` 57 | export ACCESS_KEY="33DKHF933JID" 58 | ``` 59 | 60 | **Note:** Opening a new shell window erases the previously defined environment 61 | variables. Run the `export` command again to create them or use an `.env` file 62 | to define them instead. 63 | -------------------------------------------------------------------------------- /guides/hld-management.md: -------------------------------------------------------------------------------- 1 | # HLD - High Level Definition 2 | 3 | Initialize a Bedrock HLD (High Level Definition) repository and deploy pipelines 4 | to materalize manifests. 5 | 6 | ## Requirements 7 | 8 | There are a few base assumptions that `bedrock` makes, as this will affect the 9 | set up of pipelines: 10 | 11 | 1. Both HLD and manifest repositories are within a single Azure DevOps project. 12 | 2. The access token being utilized via `bedrock` has access to both 13 | repositories. 14 | - [Documentation on how to create a Personal Access Token](https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops) 15 | 16 | Configure Bedrock using the configuration provided in your `.bedrock-config` 17 | file. The configuration section under `azure_devops` _must_ be provided for 18 | Bedrock to properly configure pipelines in your Azure DevOps organization. 19 | 20 | An example configuration is as follows: 21 | 22 | ``` 23 | azure_devops: 24 | access_token: "hpe3a9oiswgcodtfdpzfiek3saxbrh5if1fp673xihgc5ap467a" # This is your Personal Access Token with permission to modify and access this private repo. Leave this empty if project is public 25 | hld_repository: "https://dev.azure.com/bhnook/fabrikam/_git/hld" # Repository URL for your Bedrock HLDs 26 | manifest_repository: "https://dev.azure.com/bhnook/fabrikam/_git/materialized" # Repository URL that is configured for flux. This holds the kubernetes manifests that is generated by fabrikate. 27 | org: "epicstuff" # Your AzDo Org 28 | project: "fabrikam" # Your AzDo project 29 | ``` 30 | 31 | ## Usage 32 | 33 | ``` 34 | bedrock hld [command] [options] 35 | ``` 36 | 37 | ## Commands: 38 | 39 | - [init](https://microsoft.github.io/bedrock-cli/commands/index.html#hld_init) 40 | - [install-manifest-pipeline](https://microsoft.github.io/bedrock-cli/commands/index.html#hld_install-manifest-pipeline) 41 | - [reconcile](https://microsoft.github.io/bedrock-cli/commands/index.html#hld_reconcile) 42 | 43 | ## Global options: 44 | 45 | ``` 46 | -V, --version output the version number 47 | -v, --verbose Enable verbose logging 48 | -h, --help Usage information 49 | ``` 50 | -------------------------------------------------------------------------------- /guides/images/Capture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/Capture.png -------------------------------------------------------------------------------- /guides/images/bedrock-add-variable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-add-variable.png -------------------------------------------------------------------------------- /guides/images/bedrock-hld-chart-configuration-component-yaml.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-hld-chart-configuration-component-yaml.png -------------------------------------------------------------------------------- /guides/images/bedrock-hld-generated-ingress-route.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-hld-generated-ingress-route.png -------------------------------------------------------------------------------- /guides/images/bedrock-hld-generated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-hld-generated.png -------------------------------------------------------------------------------- /guides/images/bedrock-hld-ring-configuration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-hld-ring-configuration.png -------------------------------------------------------------------------------- /guides/images/bedrock-hld-top-level-config-generated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-hld-top-level-config-generated.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-alertLogic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-alertLogic.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-artifacts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-artifacts.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-azdo-repo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-azdo-repo.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-azdo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-azdo.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-azuremonitorgate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-azuremonitorgate.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-buildartifact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-buildartifact.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-cicd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-cicd.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-complete-merge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-complete-merge.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-conditiongate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-conditiongate.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-downloadartifact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-downloadartifact.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-environmentService.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-environmentService.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-environments.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-environments.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-existing-yaml.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-existing-yaml.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-github.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-new-pipeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-new-pipeline.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-path-to-yaml.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-path-to-yaml.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-postdeploy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-postdeploy.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-pr-approve.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-pr-approve.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-pr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-pr.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-repo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-repo.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-rollbackRelease.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-rollbackRelease.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-save-run.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-save-run.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-securefiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-securefiles.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-successful-pipeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-successful-pipeline.png -------------------------------------------------------------------------------- /guides/images/bedrock-infra-vg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-infra-vg.png -------------------------------------------------------------------------------- /guides/images/bedrock-rendered-deployment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-rendered-deployment.png -------------------------------------------------------------------------------- /guides/images/bedrock-rendered-service.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-rendered-service.png -------------------------------------------------------------------------------- /guides/images/bedrock-resource-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-resource-diagram.png -------------------------------------------------------------------------------- /guides/images/bedrock-rollback-upgrades.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock-rollback-upgrades.png -------------------------------------------------------------------------------- /guides/images/bedrock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/bedrock.png -------------------------------------------------------------------------------- /guides/images/kvsetupvg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/kvsetupvg.png -------------------------------------------------------------------------------- /guides/images/permit_access.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/permit_access.jpg -------------------------------------------------------------------------------- /guides/images/secrets-kv-vg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/secrets-kv-vg.png -------------------------------------------------------------------------------- /guides/images/service_introspection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/service_introspection.png -------------------------------------------------------------------------------- /guides/images/variable_group.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bedrock-cli/986297851242e1395b159c130f83129d25739148/guides/images/variable_group.png -------------------------------------------------------------------------------- /guides/infra/README.md: -------------------------------------------------------------------------------- 1 | # Bedrock Infrastructure Creation and Management 2 | 3 | ## Design Documentations 4 | 5 | There have been several design iterations for Cluster/Infrastructure creation 6 | and management. The following pieces of information discuss the direction of how 7 | to create, manage, and deploy your infrastructure using `bedrock infra`. 8 | 9 | - [Bedrock Infrastructure end-to-end](./bedrock-infra-end-to-end.md) 10 | - [Under the Hood](bedrock-infra-under-the-hood.md) 11 | 12 | ## Guides 13 | 14 | If starting out with using `bedrock infra`, please refer to the 15 | [Cloud Infra Management](./../cloud-infra-management.md) documentation. In 16 | addition, there are walkthroughs for leveraging `bedrock infra` in pipelines 17 | using Azure DevOps to automate changes to a running Terraform deployment. 18 | 19 | - [Generation Pipeline](./bedrock-infra-generation-pipeline.md) 20 | - [Deployment Pipeline](./bedrock-infra-deployment-pipeline.md) 21 | -------------------------------------------------------------------------------- /guides/project-management.md: -------------------------------------------------------------------------------- 1 | # Project Management 2 | 3 | Create and manage components for a Bedrock project. All project management 4 | commands will need to run in the order as listed below due to dependencies. 5 | 6 | ## Prerequisites 7 | 8 | An Azure DevOps git repository. 9 | 10 | ## Usage 11 | 12 | ``` 13 | Usage: project [options] [command] 14 | 15 | Initialize and manage your Bedrock project. 16 | ``` 17 | 18 | ## Commands 19 | 20 | - [init](https://microsoft.github.io/bedrock-cli/commands/index.html#project_init) 21 | - [create-variable-group](https://microsoft.github.io/bedrock-cli/commands/index.html#project_create-variable-group) 22 | - [install-lifecycle-pipeline](https://microsoft.github.io/bedrock-cli/commands/index.html#project_install-lifecycle-pipeline) 23 | 24 | **Please note all project management commands must run in the order as listed 25 | above.** 26 | 27 | ## Global Options 28 | 29 | ``` 30 | -V, --version output the version number 31 | -v, --verbose Enable verbose logging 32 | -h, --help output usage information 33 | 34 | ``` 35 | -------------------------------------------------------------------------------- /guides/sample-helm-chart/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *~ 18 | # Various IDEs 19 | .project 20 | .idea/ 21 | *.tmproj 22 | .vscode/ 23 | -------------------------------------------------------------------------------- /guides/sample-helm-chart/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | appVersion: "1.0" 3 | description: A Helm chart for Bedrock 4 | name: sample-helm-chart 5 | version: 0.1.0 6 | -------------------------------------------------------------------------------- /guides/sample-helm-chart/templates/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: 5 | spec: 6 | replicas: {{ .Values.replicaCount }} 7 | selector: 8 | matchLabels: 9 | app: {{ .Values.serviceName }} 10 | template: 11 | metadata: 12 | labels: 13 | app: {{ .Values.serviceName }} 14 | spec: 15 | containers: 16 | - name: {{ .Values.serviceName }} 17 | image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" 18 | imagePullPolicy: {{ .Values.image.pullPolicy }} 19 | ports: 20 | - containerPort: 80 21 | protocol: TCP 22 | -------------------------------------------------------------------------------- /guides/sample-helm-chart/templates/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ .Values.serviceName }} 5 | spec: 6 | ports: 7 | - port: {{ .Values.service.port }} 8 | protocol: TCP 9 | selector: 10 | app: {{ .Values.serviceName }} 11 | -------------------------------------------------------------------------------- /guides/sample-helm-chart/values.yaml: -------------------------------------------------------------------------------- 1 | # Default values for sample-helm-chart. 2 | # This is a YAML-formatted file. 3 | # Declare variables to be passed into your templates. 4 | 5 | replicaCount: 3 6 | 7 | image: 8 | repository: fabrikam 9 | tag: stable 10 | pullPolicy: Always 11 | 12 | serviceName: "service" 13 | 14 | service: 15 | port: 80 16 | -------------------------------------------------------------------------------- /guides/service-introspection.md: -------------------------------------------------------------------------------- 1 | # Service Introspection 2 | 3 | Service Introspection shows information about Bedrock deployments: 4 | 5 | - Name of the person that changed the service 6 | - Time the service was changed or errored 7 | - Deployment state of the service 8 | 9 | **Important:** 10 | 11 | To use service introspection, begin with the steps on 12 | [Service Introspection: Getting Started](./service-introspection-onboarding.md). 13 | This will walk you through setting up a Bedrock GitOps pipeline workflow. 14 | 15 | Usage: 16 | 17 | ``` 18 | bedrock deployment [command] [options] 19 | ``` 20 | 21 | Commands: 22 | 23 | - [validate](https://microsoft.github.io/bedrock-cli/commands/index.html#deployment_validate) 24 | - [get](https://microsoft.github.io/bedrock-cli/commands/index.html#deployment_get) 25 | - [onboard](https://microsoft.github.io/bedrock-cli/commands/index.html#deployment_onboard) 26 | - [dashboard](https://microsoft.github.io/bedrock-cli/commands/index.html#deployment_dashboard) 27 | 28 | Global options: 29 | 30 | ``` 31 | -v, --verbose Enable verbose logging 32 | -h, --help Usage information 33 | ``` 34 | 35 | ## Requirements 36 | 37 | Fill out the service introspection settings in your bedrock config file, for 38 | example `bedrock-config.yaml`. [Sample config file](../bedrock-config.yaml). 39 | 40 | ``` 41 | introspection: 42 | azure: # This is the storage account for the service introspection tool 43 | account_name: "storage-account-name" 44 | table_name: "table-name" 45 | partition_key: "partition-key" 46 | key: "storage-access-key" 47 | ``` 48 | 49 | To create storage-account and table, use the `bedrock deployment onboard` 50 | command to create them where subscription Id, resource group name, service 51 | principal Id, password and tenant Id are required. 52 | 53 | ### Service Principal 54 | 55 | Create a service principal with owner access: 56 | 57 | ``` 58 | az ad sp create-for-rbac --role Owner --scopes /subscriptions/ 59 | ``` 60 | -------------------------------------------------------------------------------- /guides/service-management.md: -------------------------------------------------------------------------------- 1 | # Service Management 2 | 3 | Create and manage services for a Bedrock project. This is the command reference 4 | for all of the service commands, but we also have a 5 | [service management guide](./project-service-management-guide.md) to walk you 6 | through the workflow of managing services with Bedrock CLI. 7 | 8 | Usage: 9 | 10 | ``` 11 | bedrock service [command] [options] 12 | ``` 13 | 14 | ## Commands 15 | 16 | - [create](https://microsoft.github.io/bedrock-cli/commands/index.html#service_create) 17 | - [install-build-pipeline](https://microsoft.github.io/bedrock-cli/commands/index.html#service_install-build-pipeline) 18 | - [create-revision](https://microsoft.github.io/bedrock-cli/commands/index.html#service_create-revision) 19 | 20 | ## Global options 21 | 22 | ``` 23 | -V, --version output the version number 24 | -v, --verbose Enable verbose logging 25 | -h, --help Usage information 26 | ``` 27 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: "ts-jest", 3 | testEnvironment: "node", 4 | }; 5 | -------------------------------------------------------------------------------- /patches/001-azure-devops-node.patch: -------------------------------------------------------------------------------- 1 | --- WebApi.js 2019-09-12 17:26:28.000000000 -0700 2 | +++ WebApi.js 2019-10-03 22:58:02.000000000 -0700 3 | @@ -145,7 +145,7 @@ 4 | } 5 | } 6 | else { 7 | - const nodeApiVersion = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'package.json'), 'utf8')).version; 8 | + const nodeApiVersion = require('./package.json').version; 9 | const osName = os.platform(); 10 | const osVersion = os.release(); 11 | if (requestSettings) { 12 | -------------------------------------------------------------------------------- /release-pipeline.yml: -------------------------------------------------------------------------------- 1 | trigger: 2 | tags: 3 | include: 4 | - v* 5 | 6 | pr: none # disable CI build for PR 7 | 8 | resources: 9 | repositories: 10 | - repository: BedrockHomebrewCore # The name used to reference this repository in the checkout step 11 | type: github 12 | endpoint: "bedrock-homebrew" 13 | name: microsoft/homebrew-bedrock 14 | 15 | stages: 16 | - stage: package_build 17 | jobs: 18 | - template: azure-pipelines/templates/build-artifacts.yml 19 | parameters: 20 | name: Linux 21 | pool: 22 | vmImage: ubuntu-16.04 23 | 24 | - stage: github_release 25 | dependsOn: package_build 26 | jobs: 27 | - template: azure-pipelines/templates/create-github-release.yml 28 | parameters: 29 | GitHubConnection: "bedrock-cli" 30 | releaseNotesFilePath: "CHANGELOG.md" 31 | tagSource: "gitTag" # or "userSpecifiedTag" 32 | addChangeLog: true 33 | isDraft: true 34 | 35 | - stage: update_homebrew_package 36 | dependsOn: github_release 37 | jobs: 38 | - template: azure-pipelines/templates/update-homebrew-formula.yml 39 | -------------------------------------------------------------------------------- /scripts/release-version-bump.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | RELEASE_TYPE=$1 6 | 7 | if [[ -z "${RELEASE_TYPE}" ]]; then 8 | echo "Release type is not set. Please pass in either [major, minor or patch] or any commands supported here https://yarnpkg.com/lang/en/docs/cli/version/#toc-commands" 9 | return 1 10 | fi 11 | 12 | REMOTE=${2:-origin} 13 | 14 | RELEASE_BRANCH=$(whoami)/release 15 | 16 | # get the latest from master, create a release branch 17 | git checkout master 18 | git pull 19 | git checkout -b ${RELEASE_BRANCH} 20 | yarn build-cmd-docs 21 | 22 | # Do not tag commit 23 | yarn config set version-git-tag false 24 | 25 | # Commit message template 26 | yarn config set version-git-message "release: ${RELEASE_TYPE} bump to v%s" 27 | 28 | # Bump version following the specified release type format 29 | yarn version "--${RELEASE_TYPE}" 30 | 31 | # copy a version of the command docs 32 | VERSION=$(cat package.json | grep '"version"' | sed -En 's/ "version": "(.*)",/\1/p') 33 | echo "${VERSION}" >> docs/commands/releases.txt 34 | cp docs/commands/data.json "docs/commands/data${VERSION}.json" 35 | 36 | git push ${REMOTE} ${RELEASE_BRANCH} 37 | -------------------------------------------------------------------------------- /scripts/tag-release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | REMOTE=${1:-origin} 6 | 7 | ### Tag a commit for release 8 | git checkout master 9 | git pull 10 | 11 | PACKAGE_VERSION=$(node -p -e "require('./package.json').version") 12 | echo "Version found: ${PACKAGE_VERSION}" 13 | 14 | COMMIT=$(git rev-parse --short HEAD) 15 | TAG="v${PACKAGE_VERSION}" 16 | echo "Tagging commit ${COMMIT} with tag ${TAG}" 17 | 18 | git tag ${TAG} 19 | git push ${REMOTE} ${TAG} 20 | -------------------------------------------------------------------------------- /scripts/update_introspection.sh: -------------------------------------------------------------------------------- 1 | git clone https://github.com/microsoft/spektate.git 2 | cd spektate/pipeline-scripts 3 | 4 | sudo /usr/bin/easy_install virtualenv 5 | pip install virtualenv 6 | pip install --upgrade pip 7 | python -m virtualenv venv 8 | source venv/bin/activate 9 | python -m pip install --upgrade pip 10 | pip install -r requirements.txt 11 | 12 | echo "python update_pipeline.py $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12}" 13 | python update_pipeline.py $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} 14 | -------------------------------------------------------------------------------- /src/commands/deployment/create.decorator.json: -------------------------------------------------------------------------------- 1 | { 2 | "command": "create", 3 | "alias": "c", 4 | "description": "Insert the deployment in storage from pipelines", 5 | "options": [ 6 | { 7 | "arg": "-k, --access-key ", 8 | "description": "Access key of the storage account" 9 | }, 10 | { 11 | "arg": "-n, --name ", 12 | "description": "Name of the storage account" 13 | }, 14 | { 15 | "arg": "-p, --partition-key ", 16 | "description": "Partition key for the storage account" 17 | }, 18 | { 19 | "arg": "-t, --table-name ", 20 | "description": "Name of table in storage account" 21 | }, 22 | { 23 | "arg": "--p1 ", 24 | "description": "Identifier for the first pipeline" 25 | }, 26 | { 27 | "arg": "--image-tag ", 28 | "description": "Image tag" 29 | }, 30 | { 31 | "arg": "--commit-id ", 32 | "description": "Commit Id in source repository" 33 | }, 34 | { 35 | "arg": "--service ", 36 | "description": "Service name" 37 | }, 38 | { 39 | "arg": "--p2 ", 40 | "description": "Identifier for the second pipeline" 41 | }, 42 | { 43 | "arg": "--hld-commit-id ", 44 | "description": "Commit id in HLD repository" 45 | }, 46 | { 47 | "arg": "--env ", 48 | "description": "Release environment name", 49 | "defaultValue": "" 50 | }, 51 | { 52 | "arg": "--p3 ", 53 | "description": "Identifier for the third pipeline" 54 | }, 55 | { 56 | "arg": "--pr ", 57 | "description": "Pull request identifier for a PR opened/closed in the HLD" 58 | }, 59 | { 60 | "arg": "--manifest-commit-id ", 61 | "description": "Commit Id in the manifest repository" 62 | }, 63 | { 64 | "arg": "--repository ", 65 | "description": "URL of the repository (SRC, HLD, Manifest)" 66 | } 67 | ] 68 | } 69 | -------------------------------------------------------------------------------- /src/commands/deployment/create.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | This command inserts data about pipeline runs into Azure Table storage. 4 | 5 | ## Example 6 | 7 | The following command has parameters for Azure Table storage credential and 8 | various pipelines run details. It's used by the source build pipeline, the 9 | release stage and the manifest generation pipeline, and each of them pass in 10 | parameters depending on the information for that pipeline. Here are three 11 | examples: 12 | 13 | ``` 14 | bedrock deployment create -n $AZURE_STORAGE_ACCOUNT_NAME \ 15 | -k $AZURE_ACCOUNT_KEY \ 16 | -t $AZURE_TABLE_NAME \ 17 | -p $AZURE_TABLE_PARTITION_KEY \ 18 | --p1 $(Build.BuildId) \ 19 | --image-tag $tag_name \ 20 | --commit-id $commitId \ 21 | --service $service \ 22 | --repository $repourl 23 | ``` 24 | 25 | ``` 26 | bedrock deployment create -n $AZURE_STORAGE_ACCOUNT_NAME \ 27 | -k $AZURE_ACCOUNT_KEY \ 28 | -t $AZURE_TABLE_NAME \ 29 | -p $AZURE_TABLE_PARTITION_KEY \ 30 | --p2 $(Build.BuildId) \ 31 | --hld-commit-id $latest_commit \ 32 | --env $(Build.SourceBranchName) \ 33 | --image-tag $tag_name \ 34 | --pr $pr_id \ 35 | --repository $repourl 36 | ``` 37 | 38 | ``` 39 | bedrock deployment create -n $AZURE_STORAGE_ACCOUNT_NAME \ 40 | -k $AZURE_ACCOUNT_KEY \ 41 | -t $AZURE_TABLE_NAME \ 42 | -p $AZURE_TABLE_PARTITION_KEY \ 43 | --p3 $(Build.BuildId) \ 44 | --hld-commit-id $commitId \ 45 | --pr $pr_id \ 46 | --repository $repourl 47 | ``` 48 | -------------------------------------------------------------------------------- /src/commands/deployment/dashboard.decorator.json: -------------------------------------------------------------------------------- 1 | { 2 | "command": "dashboard", 3 | "alias": "d", 4 | "description": "Launch the service introspection dashboard", 5 | "options": [ 6 | { 7 | "arg": "-p, --port ", 8 | "description": "Port to launch the dashboard on", 9 | "defaultValue": "4040" 10 | }, 11 | { 12 | "arg": "-r, --remove-all", 13 | "description": "Removes previously launched instances of the dashboard", 14 | "defaultValue": false 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /src/commands/deployment/dashboard.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | This command launches the Service Introspection Dashboard for your current 4 | configuration. It requires `docker` to be installed on your machine in order to 5 | work. 6 | -------------------------------------------------------------------------------- /src/commands/deployment/get.decorator.json: -------------------------------------------------------------------------------- 1 | { 2 | "command": "get", 3 | "alias": "g", 4 | "description": "Get the list of deployments and filter with these options: service name, environment, build ID, commit ID, container image tag.", 5 | "options": [ 6 | { 7 | "arg": "-b, --build-id ", 8 | "description": "Filter by the build ID of the source repository", 9 | "defaultValue": "" 10 | }, 11 | { 12 | "arg": "-c, --commit-id ", 13 | "description": "Filter by a commit ID from the source repository", 14 | "defaultValue": "" 15 | }, 16 | { 17 | "arg": "-d, --deployment-id ", 18 | "description": "Filter by the deployment ID of the source repository", 19 | "defaultValue": "" 20 | }, 21 | { 22 | "arg": "-i, --image-tag ", 23 | "description": "Filter by a container image tag", 24 | "defaultValue": "" 25 | }, 26 | { 27 | "arg": "-r, --ring ", 28 | "description": "Filter by ring name", 29 | "defaultValue": "" 30 | }, 31 | { 32 | "arg": "-s, --service ", 33 | "description": "Filter by service name", 34 | "defaultValue": "" 35 | }, 36 | { 37 | "arg": "-t, --top ", 38 | "description": "Return only top N most recent deployments", 39 | "defaultValue": "50" 40 | }, 41 | { 42 | "arg": "-o, --output ", 43 | "description": "Output the information one of the following: normal, wide, JSON", 44 | "defaultValue": "normal" 45 | }, 46 | { 47 | "arg": "-w, --watch", 48 | "description": "Watch the deployments for a live view", 49 | "defaultValue": false 50 | }, 51 | { 52 | "arg": "-h, --hide-separators", 53 | "description": "Display the table without separators between columns", 54 | "defaultValue": false 55 | } 56 | ] 57 | } 58 | -------------------------------------------------------------------------------- /src/commands/deployment/get.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | This commands retrieves the list of deployments by service name, release 4 | environment, build ID, commit ID, or container image tag. 5 | -------------------------------------------------------------------------------- /src/commands/deployment/index.ts: -------------------------------------------------------------------------------- 1 | import { Command } from "../command"; 2 | 3 | const subfolders = ["create", "dashboard", "get", "onboard", "validate"]; 4 | 5 | export const commandDecorator = Command( 6 | "deployment", 7 | "Introspect your deployments", 8 | subfolders.map((m) => { 9 | // eslint-disable-next-line @typescript-eslint/no-var-requires 10 | const cmd = require(`./${m}`); 11 | return cmd.commandDecorator; 12 | }) 13 | ); 14 | -------------------------------------------------------------------------------- /src/commands/deployment/mocks/author.json: -------------------------------------------------------------------------------- 1 | { 2 | "imageUrl": "https://www.gravatar.com/avatar/3931c180c6eb379205f3fce88d7fa4e1?r=g&d=mm", 3 | "name": "Service Account", 4 | "url": "https://www.gravatar.com/avatar/3931c180c6eb379205f3fce88d7fa4e1?r=g&d=mm", 5 | "username": "me@microsoft.com" 6 | } 7 | -------------------------------------------------------------------------------- /src/commands/deployment/mocks/cluster-sync.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": [ 3 | { 4 | "commit": "efeeebe", 5 | "date": "2020-02-11T08:04:41.000Z", 6 | "name": "CANADA", 7 | "tagger": "Weave Flux" 8 | }, 9 | { 10 | "commit": "e9fb7d4", 11 | "date": "2020-01-28T20:50:51.000Z", 12 | "name": "CENTRAL-US", 13 | "tagger": "Samiya Akhtar" 14 | }, 15 | { 16 | "commit": "1fdd7c4", 17 | "date": "2020-01-28T20:49:36.000Z", 18 | "name": "EAST-US", 19 | "tagger": "Samiya Akhtar" 20 | }, 21 | { 22 | "commit": "b3a3345", 23 | "date": "2019-12-16T08:10:25.000Z", 24 | "name": "EUROPE", 25 | "tagger": "Weave Flux" 26 | }, 27 | { 28 | "commit": "0ede612", 29 | "date": "2020-01-28T20:50:05.000Z", 30 | "name": "WEST-US", 31 | "tagger": "Samiya Akhtar" 32 | } 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /src/commands/deployment/mocks/pr.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Updating samiya.frontend to master-20200318.1.\nPR created by: samiya2019 with buildId: 14751 and buildNumber: 20200318.1", 3 | "id": 1371, 4 | "mergedBy": { 5 | "imageUrl": "https://dev.azure.com/epicstuff/_api/_common/identityImage?id=e8900b94-217f-4a51-9d86-6bbf5d82b6fb", 6 | "name": "Samiya Akhtar", 7 | "url": "https://dev.azure.com/epicstuff/e7236bd9-a6f9-4554-8dce-ad81ae94faf6/_apis/git/repositories/a491cdad-443c-4419-9726-95e7619673ae/pullRequests/1371", 8 | "username": "saakhta@microsoft.com" 9 | }, 10 | "sourceBranch": "DEPLOY/samiya2019-samiya.frontend-master-20200318.1", 11 | "targetBranch": "master", 12 | "title": "Updating samiya.frontend image tag to master-20200318.1.", 13 | "url": "https://dev.azure.com/epicstuff/hellobedrockprivate/_git/samiya-hld/pullrequest/1371" 14 | } 15 | -------------------------------------------------------------------------------- /src/commands/deployment/mocks/unmerged-pr.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Updating samiya.frontend to master-20200318.1.\nPR created by: samiya2019 with buildId: 14751 and buildNumber: 20200318.1", 3 | "id": 1372, 4 | "sourceBranch": "DEPLOY/samiya2019-samiya.frontend-master-20200318.1", 5 | "targetBranch": "master", 6 | "title": "Updating samiya.frontend image tag to master-20200318.1.", 7 | "url": "https://dev.azure.com/epicstuff/hellobedrockprivate/_git/samiya-hld/pullrequest/1371" 8 | } 9 | -------------------------------------------------------------------------------- /src/commands/deployment/onboard.decorator.json: -------------------------------------------------------------------------------- 1 | { 2 | "command": "onboard", 3 | "alias": "o", 4 | "description": "Onboard to use the service introspection tool. This will create a storage account if it does not exist in your Azure subscription in the give resource group.", 5 | "options": [ 6 | { 7 | "arg": "-s, --storage-account-name ", 8 | "description": "Azure storage account name", 9 | "inherit": "introspection.azure.account_name", 10 | "required": true 11 | }, 12 | { 13 | "arg": "-t, --storage-table-name ", 14 | "description": "Azure storage table name", 15 | "inherit": "introspection.azure.table_name", 16 | "required": true 17 | }, 18 | { 19 | "arg": "-l, --storage-location ", 20 | "description": "Azure location to create new storage account when it does not exist" 21 | }, 22 | { 23 | "arg": "-r, --storage-resource-group-name ", 24 | "description": "Name of the resource group to create new storage account when it does not exist", 25 | "required": true 26 | }, 27 | { 28 | "arg": "--service-principal-id ", 29 | "description": "Azure service principal id with `contributor` role in Azure Resource Group", 30 | "inherit": "introspection.azure.service_principal_id", 31 | "required": true 32 | }, 33 | { 34 | "arg": "--service-principal-password ", 35 | "description": "The Azure service principal password", 36 | "inherit": "introspection.azure.service_principal_secret", 37 | "required": true 38 | }, 39 | { 40 | "arg": "--tenant-id ", 41 | "description": "The Azure AD tenant id of service principal", 42 | "inherit": "introspection.azure.tenant_id", 43 | "required": true 44 | }, 45 | { 46 | "arg": "--subscription-id ", 47 | "description": "The Azure subscription id", 48 | "inherit": "introspection.azure.subscription_id", 49 | "required": true 50 | } 51 | ] 52 | } 53 | -------------------------------------------------------------------------------- /src/commands/deployment/onboard.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | Prepare storage for the service introspection tool. This will create a storage 4 | account if it does not already exist in your subscription in the given 5 | `resource-group`. The storage table will also be created in a newly created or 6 | in an existing storage account if it does not exist already. When the Azure Key 7 | Vault argument is specified, a secret with Azure storage access key will be 8 | created. Otherwise, the storage access key will need to be specified in 9 | environment variables manually. 10 | 11 | See 12 | [Prerequisites](https://github.com/microsoft/bedrock-cli/blob/master/guides/service-introspection.md#prerequisites) 13 | -------------------------------------------------------------------------------- /src/commands/deployment/validate.decorator.json: -------------------------------------------------------------------------------- 1 | { 2 | "command": "validate", 3 | "alias": "v", 4 | "description": "Validate the configuration and storage account are correct.", 5 | "options": [ 6 | { 7 | "arg": "-s, --self-test", 8 | "description": "Run a test for the configured storage account. This will write test data and delete the test data. For more information on the behavior, please check the online documentation.", 9 | "defaultValue": false 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /src/commands/deployment/validate.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | This command validates the 4 | [requirements](https://github.com/microsoft/bedrock-cli/blob/master/guides/service-introspection.md#requirements) 5 | and the onboard 6 | [prerequisites](https://github.com/microsoft/bedrock-cli/blob/master/guides/service-introspection.md#prerequisites) 7 | 8 | ## Note 9 | 10 | The purpose of `--self-test` option is to make sure that `bedrock` is able to 11 | write data to the provided storage account. Once the test ends, it will remove 12 | the test data that was added. 13 | -------------------------------------------------------------------------------- /src/commands/hld/append-variable-group.decorator.json: -------------------------------------------------------------------------------- 1 | { 2 | "command": "append-variable-group ", 3 | "alias": "avg", 4 | "description": "Appends the name of an existing variable group to the current manifest-generation.yaml file." 5 | } 6 | -------------------------------------------------------------------------------- /src/commands/hld/append-variable-group.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | Append a variable group name to the current `manifest-generation.yaml` of an 4 | initialized hld repository. 5 | 6 | ## Example 7 | 8 | When an HLD repository is first initialized with `bedrock hld init`, the top 9 | portion of the `manifest-generation.yaml` looks like this: 10 | 11 | ```yaml 12 | trigger: 13 | branches: 14 | include: 15 | - master 16 | variables: [] 17 | pool: 18 | vmImage: ubuntu-latest 19 | steps: 20 | . 21 | . 22 | . 23 | ``` 24 | 25 | running `bedrock hld append-variable-group my-vg` with a variable group name, in 26 | this case `my-vg`, will add it under the `variables` section if it does not 27 | already exist: 28 | 29 | ```yaml 30 | trigger: 31 | branches: 32 | include: 33 | - master 34 | variables: 35 | - group: my-variable-group 36 | pool: 37 | vmImage: ubuntu-latest 38 | steps: 39 | . 40 | . 41 | . 42 | ``` 43 | -------------------------------------------------------------------------------- /src/commands/hld/append-variable-group.test.ts: -------------------------------------------------------------------------------- 1 | import { execute } from "./append-variable-group"; 2 | import * as fileutils from "../../lib/fileutils"; 3 | 4 | describe("Test execute function", () => { 5 | it("missing variable group name", async () => { 6 | const exitFn = jest.fn(); 7 | await execute("my-path", "", exitFn); 8 | expect(exitFn).toBeCalledTimes(1); 9 | expect(exitFn.mock.calls).toEqual([[1]]); 10 | }); 11 | it("appends variable group", async () => { 12 | const exitFn = jest.fn(); 13 | spyOn(fileutils, "appendVariableGroupToPipelineYaml"); 14 | await execute("my-path", "my-vg", exitFn); 15 | expect(exitFn).toBeCalledTimes(1); 16 | expect(exitFn.mock.calls).toEqual([[0]]); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /src/commands/hld/append-variable-group.ts: -------------------------------------------------------------------------------- 1 | import commander from "commander"; 2 | import { build as buildCmd, exit as exitCmd } from "../../lib/commandBuilder"; 3 | import { RENDER_HLD_PIPELINE_FILENAME } from "../../lib/constants"; 4 | import { appendVariableGroupToPipelineYaml } from "../../lib/fileutils"; 5 | import { logger } from "../../logger"; 6 | import { build as buildError, log as logError } from "../../lib/errorBuilder"; 7 | import { errorStatusCode } from "../../lib/errorStatusCode"; 8 | import { hasValue } from "../../lib/validator"; 9 | import decorator from "./append-variable-group.decorator.json"; 10 | 11 | /** 12 | * Executes the command, can call exit function with 0 or 1 13 | * when command completed successfully or failed respectively. 14 | * 15 | * @param hldRepoPath The hld repository path 16 | * @param variableGroupName The variable group name 17 | * @param exitFn exit function 18 | */ 19 | export const execute = async ( 20 | hldRepoPath: string, 21 | variableGroupName: string, 22 | exitFn: (status: number) => Promise 23 | ): Promise => { 24 | try { 25 | if (!hasValue(variableGroupName)) { 26 | throw buildError( 27 | errorStatusCode.VALIDATION_ERR, 28 | "hld-append-var-group-name-missing" 29 | ); 30 | } 31 | 32 | appendVariableGroupToPipelineYaml( 33 | hldRepoPath, 34 | RENDER_HLD_PIPELINE_FILENAME, 35 | variableGroupName 36 | ); 37 | await exitFn(0); 38 | } catch (err) { 39 | logError( 40 | buildError( 41 | errorStatusCode.CMD_EXE_ERR, 42 | "hld-append-var-group-cmd-failed", 43 | err 44 | ) 45 | ); 46 | await exitFn(1); 47 | } 48 | }; 49 | 50 | /** 51 | * Adds the init command to the commander command object 52 | * @param command Commander command object to decorate 53 | */ 54 | export const commandDecorator = (command: commander.Command): void => { 55 | buildCmd(command, decorator).action(async (variableGroupName: string) => { 56 | const hldRepoPath = process.cwd(); 57 | await execute(hldRepoPath, variableGroupName, async (status: number) => { 58 | await exitCmd(logger, process.exit, status); 59 | }); 60 | }); 61 | }; 62 | -------------------------------------------------------------------------------- /src/commands/hld/index.ts: -------------------------------------------------------------------------------- 1 | import { Command } from "../command"; 2 | 3 | const subfolders = ["init", "pipeline", "reconcile", "append-variable-group"]; 4 | 5 | export const commandDecorator = Command( 6 | "hld", 7 | "Commands for initalizing and managing a bedrock HLD repository.", 8 | subfolders.map((m) => { 9 | // eslint-disable-next-line @typescript-eslint/no-var-requires 10 | const cmd = require(`./${m}`); 11 | return cmd.commandDecorator; 12 | }) 13 | ); 14 | -------------------------------------------------------------------------------- /src/commands/hld/init.decorator.json: -------------------------------------------------------------------------------- 1 | { 2 | "command": "init", 3 | "alias": "i", 4 | "description": "Initialize High Level Definition repository. Add manifest-generation.yaml file to working directory/repository if it does not already exist.", 5 | "options": [ 6 | { 7 | "arg": "--git-push", 8 | "description": "Bedrock will try to commit and push these changes to a new origin/branch.", 9 | "required": false, 10 | "defaultValue": false 11 | }, 12 | { 13 | "arg": "--default-component-git ", 14 | "description": "The default hld repository's component's git repository url.", 15 | "required": false, 16 | "defaultValue": "https://github.com/microsoft/fabrikate-definitions.git" 17 | }, 18 | { 19 | "arg": "--default-component-name ", 20 | "description": "The default hld repository's component's name.", 21 | "required": false, 22 | "defaultValue": "traefik2" 23 | }, 24 | { 25 | "arg": "--default-component-path ", 26 | "description": "The default hld repository's component's path.", 27 | "required": false, 28 | "defaultValue": "definitions/traefik2" 29 | } 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /src/commands/hld/init.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | Initializes the HLD repository by creating the pipeline 4 | `manifest-generation.yaml` file, and the default `component.yaml` for 5 | [fabrikate](https://github.com/microsoft/fabrikate) to consume, if each does not 6 | already exist. 7 | 8 | The created `component.yaml` will be populated with a traefik2 definition by 9 | default: 10 | 11 | ``` 12 | name: default-component 13 | subcomponents: 14 | - name: traefik2 15 | method: git 16 | source: 'https://github.com/microsoft/fabrikate-definitions.git' 17 | path: definitions/traefik2 18 | ``` 19 | 20 | However, you can set a another fabrikate definition to be added instead via the 21 | `--default-component-*` flags. 22 | -------------------------------------------------------------------------------- /src/commands/hld/pipeline.decorator.json: -------------------------------------------------------------------------------- 1 | { 2 | "command": "install-manifest-pipeline", 3 | "alias": "p", 4 | "description": "Install the manifest generation pipeline to your Azure DevOps instance. Default values are set in bedrock-config.yaml and can be loaded via bedrock init or overriden via option flags.", 5 | "options": [ 6 | { 7 | "arg": "-n, --pipeline-name ", 8 | "description": "Name of the pipeline to be created", 9 | "defaultValue": "" 10 | }, 11 | { 12 | "arg": "-a, --personal-access-token ", 13 | "description": "Personal Access Token", 14 | "defaultValue": "", 15 | "inherit": "azure_devops.access_token", 16 | "required": true 17 | }, 18 | { 19 | "arg": "-o, --org-name ", 20 | "description": "Organization Name for Azure DevOps", 21 | "defaultValue": "", 22 | "inherit": "azure_devops.org", 23 | "required": true 24 | }, 25 | { 26 | "arg": "-u, --hld-url ", 27 | "description": "HLD Repository URL", 28 | "defaultValue": "", 29 | "inherit": "azure_devops.hld_repository", 30 | "required": true 31 | }, 32 | { 33 | "arg": "-m, --manifest-url ", 34 | "description": "Manifest Repository URL", 35 | "defaultValue": "", 36 | "inherit": "azure_devops.manifest_repository", 37 | "required": true 38 | }, 39 | { 40 | "arg": "-d, --devops-project ", 41 | "description": "Azure DevOps Project", 42 | "defaultValue": "", 43 | "inherit": "azure_devops.project", 44 | "required": true 45 | }, 46 | { 47 | "arg": "-b, --build-script-url ", 48 | "description": "Build Script URL. By default it is 'https://raw.githubusercontent.com/Microsoft/bedrock/master/gitops/azure-devops/build.sh'.", 49 | "defaultValue": "https://raw.githubusercontent.com/Microsoft/bedrock/master/gitops/azure-devops/build.sh" 50 | }, 51 | { 52 | "arg": "--yaml-file-branch ", 53 | "description": "The git branch where the pipeline definition yaml file is located.", 54 | "required": false, 55 | "defaultValue": "master" 56 | } 57 | ] 58 | } 59 | -------------------------------------------------------------------------------- /src/commands/hld/pipeline.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | After merging the azure-pipelines yaml file generated by the init step above 4 | into the `master` branch, run the following command to install the HLD to 5 | Manifest pipeline. This pipeline will be triggered on commits to master and 6 | invoke "manifest generation" 7 | [(via fabrikate)](https://github.com/microsoft/fabrikate), rendering helm charts 8 | and configuration into Kubernetes yaml. 9 | -------------------------------------------------------------------------------- /src/commands/hld/reconcile.decorator.json: -------------------------------------------------------------------------------- 1 | { 2 | "command": "reconcile ", 3 | "alias": "r", 4 | "description": "Reconcile a HLD with the services tracked in bedrock.yaml.", 5 | "options": [] 6 | } 7 | -------------------------------------------------------------------------------- /src/commands/infra/generate.decorator.json: -------------------------------------------------------------------------------- 1 | { 2 | "command": "generate", 3 | "alias": "g", 4 | "description": "Generate scaffold for terraform cluster deployment.", 5 | "options": [ 6 | { 7 | "arg": "-p, --project ", 8 | "description": "Location of the definition.yaml file that will be generated", 9 | "required": false 10 | }, 11 | { 12 | "arg": "-O, --output ", 13 | "description": "Location of the generated directory that will be generated", 14 | "required": false 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /src/commands/infra/generate.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | Creates a "generated" deployment folder with the completed Terraform files based 4 | on definitions provided from a scaffolded project. 5 | 6 | It will do the following: 7 | 8 | - Check if a provided project folder contains a `definition.yaml` 9 | - Verify the configuration of parent and leaf definitions. 10 | - Check if the terraform template `source` provided has a valid remote 11 | repository. 12 | - Clone and cache the master version of the provided `source` repository locally 13 | in `~/.bedrock/templates` 14 | > Cached repositories will be converted through regex for bedrock to hash. 15 | > (i.e. a `source` template of `https://github.com/microsoft/bedrock` will be 16 | > cached into a folder called `_microsoft_bedrock_git`) 17 | - Create a "generated" directory for Terrform deployments (alongside the 18 | scaffolded project directory) 19 | - Copy the appropriate Terraform templates to the "generated" directory 20 | - Check the Terraform module source values and convert them into a generic git 21 | url based on the `definition.yaml`'s `source`, `version` and `template` path. 22 | - Create a `bedrock.tfvars` in the generated directory based on the variables 23 | provided in `definition.yaml` files of the parent and leaf directories. 24 | 25 | ## Example 26 | 27 | Assuming you have the following setup: 28 | 29 | ``` 30 | fabrikam 31 | |- definition.yaml 32 | |- east/ 33 | |- definition.yaml 34 | |- central/ 35 | |- definition.yaml 36 | ``` 37 | 38 | When executing the following command **in the `fabrikam` directory**: 39 | 40 | ``` 41 | bedrock infra generate --project east 42 | ``` 43 | 44 | The following hiearchy of directories will be generated _alongside_ the targeted 45 | directory. In addition, the appropriate versioned Terraform templates will be 46 | copied over to the leaf directory with a `bedrock.tfvars`, which contains the 47 | variables accumulated from parent **and** leaf definition.yaml files, where if a 48 | variable exists in both parent and leaf definition, the **leaf definitions will 49 | take precedence**. 50 | 51 | ``` 52 | fabrikam 53 | |- definition.yaml 54 | |- east/ 55 | |- definition.yaml 56 | |- central/ 57 | |- definition.yaml 58 | fabrikam-generated 59 | |- east 60 | |- main.tf 61 | |- variables.tf 62 | |- bedrock.tfvars (concatenation of variables from fabrikam/definition.yaml (parent) and fabrikam/east/definition.yaml (leaf)) 63 | ``` 64 | 65 | You can also have a "single-tree" generation by executing 66 | `bedrock infra generate` inside a directory without specifying a project folder. 67 | For example, if you had the following tree structure: 68 | 69 | ``` 70 | fabrikam 71 | |- definition.yaml 72 | ``` 73 | 74 | and executed `bedrock infra generate` inside the `fabrikam` directory, this will 75 | generate the following: 76 | 77 | ``` 78 | fabrikam-generated 79 | |- main.tf 80 | |- variables.tf 81 | |- bedrock.tfvars 82 | ``` 83 | -------------------------------------------------------------------------------- /src/commands/infra/index.ts: -------------------------------------------------------------------------------- 1 | import { Command } from "../command"; 2 | 3 | const subfolders = ["generate", "scaffold"]; 4 | 5 | export const commandDecorator = Command( 6 | "infra", 7 | "Manage and modify your Bedrock infrastructure.", 8 | subfolders.map((m) => { 9 | // eslint-disable-next-line @typescript-eslint/no-var-requires 10 | const cmd = require(`./${m}`); 11 | return cmd.commandDecorator; 12 | }) 13 | ); 14 | -------------------------------------------------------------------------------- /src/commands/infra/infra_common.test.ts: -------------------------------------------------------------------------------- 1 | import { getSourceFolderNameFromURL } from "./infra_common"; 2 | 3 | describe("test getSourceFolderNameFromURL function", () => { 4 | it("positive test with http .com domain", () => { 5 | const result = getSourceFolderNameFromURL( 6 | "http://github.com/contoso/fabrikam" 7 | ); 8 | expect(result).toBe("_contoso_fabrikam"); 9 | }); 10 | it("positive test with http .net domain", () => { 11 | const result = getSourceFolderNameFromURL( 12 | "http://github.net/contoso/fabrikam" 13 | ); 14 | expect(result).toBe("_contoso_fabrikam"); 15 | }); 16 | it("positive test with ssh", () => { 17 | const result = getSourceFolderNameFromURL( 18 | "git@github.com:microsoft/contoso.git" 19 | ); 20 | expect(result).toBe("_microsoft_contoso_git"); 21 | }); 22 | it("positive test with any string", () => { 23 | const result = getSourceFolderNameFromURL("microsoft/contoso.git"); 24 | expect(result).toBe("microsoft_contoso_git"); 25 | }); 26 | it("positive test with empty string", () => { 27 | const result = getSourceFolderNameFromURL(""); // this will not happen in real world. 28 | expect(result).toBe(""); 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /src/commands/infra/infra_common.ts: -------------------------------------------------------------------------------- 1 | import * as os from "os"; 2 | import path from "path"; 3 | import url from "url"; 4 | 5 | export const bedrockTemplatesPath = path.join( 6 | os.homedir(), 7 | ".bedrock", 8 | "templates" 9 | ); 10 | 11 | export const DEFINITION_YAML = "definition.yaml"; 12 | export const VARIABLES_TF = "variables.tf"; 13 | export const BACKEND_TFVARS = "backend.tfvars"; 14 | export const TERRAFORM_TFVARS = "terraform.tfvars"; 15 | export const BEDROCK_TFVARS = "bedrock.tfvars"; 16 | export const DEFAULT_VAR_VALUE = ""; 17 | 18 | /** 19 | * Returns a source folder name for a given git URL. 20 | * 21 | * @param source git source URL 22 | */ 23 | export const getSourceFolderNameFromURL = (source: string): string => { 24 | const punctuationReg = /[^\w\s]/g; 25 | 26 | const oUrl = url.parse(source); // does not throw any exception. even when source is an empty string 27 | if (oUrl.hostname) { 28 | return (oUrl.pathname || "").replace(punctuationReg, "_").toLowerCase(); 29 | } 30 | // no hostname e.g. git@github.com:microsoft/bedrock.git 31 | const idx = source.indexOf(":"); 32 | if (idx === -1) { 33 | // do not have : 34 | return source.replace(punctuationReg, "_").toLowerCase(); 35 | } 36 | return source.substring(idx).replace(punctuationReg, "_").toLowerCase(); 37 | }; 38 | -------------------------------------------------------------------------------- /src/commands/infra/mocks/fabrikam/central/definition.yaml: -------------------------------------------------------------------------------- 1 | name: fabrikam-central 2 | backend: 3 | storage_account_name: storage-account-name 4 | access_key: storage-account-access-key 5 | container_name: storage-account-container 6 | key: tfstate-key 7 | variables: 8 | acr_enabled: "true" 9 | address_space: 10 | agent_vm_count: 11 | agent_vm_size: 12 | cluster_name: "fabrikam-central" 13 | dns_prefix: 14 | flux_recreate: 15 | kubeconfig_recreate: 16 | gc_enabled: "true" 17 | gitops_poll_interval: 5m 18 | gitops_ssh_url: 19 | gitops_url_branch: master 20 | gitops_ssh_key: 21 | gitops_path: 22 | keyvault_name: 23 | keyvault_resource_group: 24 | resource_group_name: 25 | ssh_public_key: 26 | service_principal_id: 27 | service_principal_secret: 28 | subnet_prefixes: 29 | vnet_name: 30 | subnet_name: 31 | network_plugin: azure 32 | network_policy: azure 33 | oms_agent_enabled: "false" 34 | enable_acr: "false" 35 | acr_name: 36 | -------------------------------------------------------------------------------- /src/commands/infra/mocks/fabrikam/definition.yaml: -------------------------------------------------------------------------------- 1 | name: fabrikam 2 | source: "https://github.com/fabrikam/bedrock" 3 | template: cluster/environments/azure-single-keyvault 4 | version: v0.0.1 5 | backend: 6 | storage_account_name: storage-account-name 7 | access_key: storage-account-access-key 8 | container_name: storage-account-container 9 | key: tfstate-key 10 | variables: 11 | acr_enabled: "true" 12 | address_space: 13 | agent_vm_count: 14 | agent_vm_size: 15 | cluster_name: 16 | dns_prefix: 17 | flux_recreate: 18 | kubeconfig_recreate: 19 | gc_enabled: "true" 20 | gitops_poll_interval: 5m 21 | gitops_ssh_url: 22 | gitops_url_branch: master 23 | gitops_ssh_key: 24 | gitops_path: 25 | keyvault_name: 26 | keyvault_resource_group: 27 | resource_group_name: 28 | ssh_public_key: 29 | service_principal_id: 30 | service_principal_secret: 31 | subnet_prefixes: 32 | vnet_name: 33 | subnet_name: 34 | network_plugin: azure 35 | network_policy: azure 36 | oms_agent_enabled: "false" 37 | enable_acr: "false" 38 | acr_name: 39 | -------------------------------------------------------------------------------- /src/commands/infra/mocks/fabrikam/west/definition.yaml: -------------------------------------------------------------------------------- 1 | name: fabrikam-west 2 | source: "https://github.com/fabrikam/bedrock" 3 | template: cluster/environments/azure-single-keyvault 4 | version: v0.0.2 5 | backend: 6 | storage_account_name: storage-account-name 7 | access_key: storage-account-access-key 8 | container_name: storage-account-container 9 | key: tfstate-key 10 | variables: 11 | acr_enabled: "true" 12 | address_space: 13 | agent_vm_count: 14 | agent_vm_size: 15 | cluster_name: "fabrikam-west" 16 | dns_prefix: 17 | flux_recreate: 18 | kubeconfig_recreate: 19 | gc_enabled: "true" 20 | gitops_poll_interval: 5m 21 | gitops_ssh_url: 22 | gitops_url_branch: master 23 | gitops_ssh_key: 24 | gitops_path: 25 | keyvault_name: 26 | keyvault_resource_group: 27 | resource_group_name: 28 | ssh_public_key: 29 | service_principal_id: 30 | service_principal_secret: 31 | subnet_prefixes: 32 | vnet_name: 33 | subnet_name: 34 | network_plugin: azure 35 | network_policy: azure 36 | oms_agent_enabled: "false" 37 | enable_acr: "false" 38 | acr_name: 39 | -------------------------------------------------------------------------------- /src/commands/infra/mocks/missing-parent-defn/definition.yaml: -------------------------------------------------------------------------------- 1 | name: fabrikam-west 2 | source: "https://github.com/fabrikam/bedrock" 3 | template: cluster/environments/azure-single-keyvault 4 | version: v0.0.2 5 | backend: 6 | storage_account_name: storage-account-name 7 | access_key: storage-account-access-key 8 | container_name: storage-account-container 9 | key: tfstate-key 10 | variables: 11 | acr_enabled: "true" 12 | address_space: 13 | agent_vm_count: 14 | agent_vm_size: 15 | cluster_name: "discovery-service-west" 16 | dns_prefix: 17 | flux_recreate: 18 | kubeconfig_recreate: 19 | gc_enabled: "true" 20 | gitops_poll_interval: 5m 21 | gitops_ssh_url: 22 | gitops_url_branch: master 23 | gitops_ssh_key: 24 | gitops_path: 25 | keyvault_name: 26 | keyvault_resource_group: 27 | resource_group_name: 28 | ssh_public_key: 29 | service_principal_id: 30 | service_principal_secret: 31 | subnet_prefixes: 32 | vnet_name: 33 | subnet_name: 34 | network_plugin: azure 35 | network_policy: azure 36 | oms_agent_enabled: "false" 37 | enable_acr: "false" 38 | acr_name: 39 | -------------------------------------------------------------------------------- /src/commands/infra/scaffold.decorator.json: -------------------------------------------------------------------------------- 1 | { 2 | "command": "scaffold", 3 | "alias": "s", 4 | "description": "Create initial scaffolding for cluster deployment.", 5 | "options": [ 6 | { 7 | "arg": "-n, --name ", 8 | "description": "Cluster name for scaffolding", 9 | "required": true, 10 | "defaultValue": "" 11 | }, 12 | { 13 | "arg": "-s, --source ", 14 | "description": "Source URL for the repository containing the terraform deployment", 15 | "required": false, 16 | "defaultValue": "" 17 | }, 18 | { 19 | "arg": "-r --version ", 20 | "description": "Version or tag for the repository so a fixed version is referenced", 21 | "required": true, 22 | "defaultValue": "" 23 | }, 24 | { 25 | "arg": "-t, --template ", 26 | "description": "Location of the variables.tf for the terraform deployment", 27 | "required": true, 28 | "defaultValue": "" 29 | } 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /src/commands/infra/scaffold.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | Builds a scaffold of an infrastructure deployment project containing a 4 | `definition.yaml` that enables a user to version, modify and organize terraform 5 | deployments. 6 | 7 | In detail, it will do the following: 8 | 9 | - Create a new folder with the `` you provided. 10 | - Clone and cache the source repo to `~.bedrock/templates`. 11 | - Provide an infrastructure deployment scaffold based on a `` git url 12 | for a repo that holds terraform template, a `` respective to the 13 | repository tag or branch to pull from, and a `