Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

Commit

Permalink
Add example for ACR Build
Browse files Browse the repository at this point in the history
  • Loading branch information
radu-matei committed Jan 28, 2019
1 parent b81e520 commit 8553e6d
Show file tree
Hide file tree
Showing 7 changed files with 1,391 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
44 changes: 44 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "brigade-utils",
"version": "0.0.1",
"description": "Various utility classes and functions to use in brigade.js",
"main": "index.js",
"scripts": {
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"test": "mocha --compilers ts:ts-node/register --recursive ./test/**/*.ts"
},
"files": [
"out/*.js",
"out/*.ts"
],
"devDependencies": {
"@types/chai": "^4.0.1",
"@types/mocha": "^2.2.41",
"@types/node": "^10.3.0",
"chai": "^4.1.0",
"mocha": "^3.4.2",
"prettier": "^1.9.1",
"rimraf": "^2.6.2",
"ts-node": "^7.0.0",
"typedoc": "^0.11.0",
"typescript": "^3.0.1"
},
"dependencies": {
"@azure/brigadier": "^0.2.1",
"@kubernetes/client-node": "^0.7.2",
"child-process-promise": "^2.2.1",
"pretty-error": "^2.1.1",
"ulid": "^0.2.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/radu-matei/brigade-utils.git"
},
"author": "Radu M <root@radu-matei.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/radu-matei/brigade-utils/issues"
},
"homepage": "https://github.com/radu-matei/brigade-utils#readme"
}
29 changes: 29 additions & 0 deletions src/acr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as brigadier from "@azure/brigadier";

export class ACRBuildJob extends brigadier.Job {

/**
* The constructor returns a new Brigade Job configured to
*
* @param name - name of the job
* @param img - container image to be built
* @param tag - tag of the image
* @param dir - directory where the container build context cab be found. It requires the Dockerfile to be at the root
* @param registry - container registry to log in to, and where the image will be pushed
* @param username - username for the container registry
* @param token - Azure Service Principal token to log in for the registry. The Service Principal needs to have proper permissions
* @param tenant - the Azure tenant of the subscription
* @param azureCli - the Docker image to use for the Azure CLI. Defaults to "microsoft/azure-cli:latest"
*/
constructor(name: string, img: string, tag: string, dir: string, registry: string, username: string, token: string, tenant: string, azureCli = "microsoft/azure-cli:latest") {
super(name, azureCli);
let imgName = img + ":" + tag;
this.tasks = [
`az login --service-principal -u ${username} -p ${token} --tenant ${tenant}`,
`cd ${dir}`,
`echo '========> building ${img}...'`,
`az acr build -r ${registry} -t ${imgName} .`,
`echo '<======== finished building ${img}.'`
];
}
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./acr"
30 changes: 30 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"outDir": "out",
"lib": [
"es6"
],
"declaration": true,
"sourceMap": true,
"rootDir": "src",
/* Strict Type-Checking Option */
"strict": true, /* enable all strict type-checking options */
/* Additional Checks */
"noUnusedLocals": true, /* Report errors on unused locals. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
"typeRoots": [
"node_modules/@types"
]
},
"include": [
"./src/**/*"
],
"exclude": [
"node_modules/**/*"
//, "test"
]
}
15 changes: 15 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"rules": {
"no-string-throw": true,
"no-unused-expression": true,
"no-duplicate-variable": true,
"curly": true,
"class-name": true,
"semicolon": [
true,
"always"
],
"triple-equals": true
},
"defaultSeverity": "warning"
}
Loading

0 comments on commit 8553e6d

Please sign in to comment.