Users/jysin/pm feedback changes for master (#99)

* Changed dockerfile, Manifests, helmcharts links and README
This commit is contained in:
Jyotsna 2021-01-07 12:51:44 +05:30 коммит произвёл GitHub
Родитель 4bd69f56a9
Коммит 56e4abca5e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 244 добавлений и 236 удалений

Просмотреть файл

@ -316,8 +316,9 @@ jobs:
```
## Sample workflows for new traceability fields support
- Environment variable `HELM_CHART_PATHS` is a list of helmchart files used in k8s-bake and k8s-deploy
- Use script to build image and add `dockerfile-path` label to it. The value expected is the link to the dockerfile.
- Environment variable `HELM_CHART_PATHS` is a list of helmchart files expected by k8s-deploy - it will be populated automatically if you are using `k8s-bake` to generate the manifests.
- Use script to build image and add `dockerfile-path` label to it.
The value expected is the link to the dockerfile : `https://github.com/${{github.repo}}/blob/${{github.sha}}/Dockerfile`
If your dockerfile is in the same repo and branch where the workflow is run, it can be a relative path and it will be converted to a link for traceability.
- Run docker login action for each image registry - in case image build and image deploy are 2 distinct jobs in the same or separate workflows.
@ -389,7 +390,7 @@ jobs:
password: ${{ secrets.REGISTRY_PASSWORD }}
- run: |
docker build . -t contoso.azurecr.io/k8sdemo:${{ github.sha }} --label dockerfile-path=https://github.com/${{github.repo}}/blob/${GITHUB_REF##*/}/Dockerfile
docker build . -t contoso.azurecr.io/k8sdemo:${{ github.sha }} --label dockerfile-path=https://github.com/${{github.repo}}/blob/${{github.sha}}/Dockerfile
docker push contoso.azurecr.io/k8sdemo:${{ github.sha }}
```
@ -399,8 +400,6 @@ jobs:
on: [push]
env:
NAMESPACE: demo-ns2
HELM_CHART_PATHS: |
./helmCharts/file1
jobs:
deploy:
@ -432,7 +431,7 @@ jobs:
- uses: azure/k8s-bake@v1
with:
renderEngine: 'helm'
helmChart: ${{ env.HELM_CHART_PATHS }}
helmChart: './aks-helloworld/'
overrideFiles: './aks-helloworld/values-override.yaml'
overrides: |
replicas:2

Просмотреть файл

@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.isHttpUrl = exports.getCurrentTime = exports.getRandomInt = exports.sleep = exports.getDeploymentConfig = exports.annotateChildPods = exports.getWorkflowFilePath = exports.getLastSuccessfulRunSha = exports.checkForErrors = exports.isEqual = exports.getExecutableExtension = void 0;
exports.getNormalizedPath = exports.isHttpUrl = exports.getCurrentTime = exports.getRandomInt = exports.sleep = exports.getDeploymentConfig = exports.annotateChildPods = exports.getWorkflowFilePath = exports.getLastSuccessfulRunSha = exports.checkForErrors = exports.isEqual = exports.getExecutableExtension = void 0;
const os = require("os");
const core = require("@actions/core");
const githubClient_1 = require("../githubClient");
@ -143,8 +143,12 @@ function annotateChildPods(kubectl, resourceType, resourceName, annotationKeyVal
exports.annotateChildPods = annotateChildPods;
function getDeploymentConfig() {
return __awaiter(this, void 0, void 0, function* () {
const inputManifestFiles = inputParams.manifests || [];
const helmChartPaths = (process.env.HELM_CHART_PATHS && process.env.HELM_CHART_PATHS.split('\n').filter(path => path != "")) || [];
let helmChartPaths = (process.env.HELM_CHART_PATHS && process.env.HELM_CHART_PATHS.split(';').filter(path => path != "")) || [];
helmChartPaths = helmChartPaths.map(helmchart => getNormalizedPath(helmchart.trim()));
let inputManifestFiles = inputParams.manifests || [];
if (!helmChartPaths || helmChartPaths.length == 0) {
inputManifestFiles = inputManifestFiles.map(manifestFile => getNormalizedPath(manifestFile));
}
const imageNames = inputParams.containers || [];
let imageDockerfilePathMap = {};
//Fetching from image label if available
@ -194,18 +198,11 @@ function getDockerfilePath(image) {
imageInspectResult = dockerExec.inspect(image, [], true);
imageConfig = JSON.parse(imageInspectResult)[0];
const DOCKERFILE_PATH_LABEL_KEY = 'dockerfile-path';
const ref = process.env.GITHUB_REF && process.env.GITHUB_REF.replace('refs/heads/', '').replace('refs/tags/', '');
let pathValue = '';
if (imageConfig) {
if ((imageConfig.Config) && (imageConfig.Config.Labels) && (imageConfig.Config.Labels[DOCKERFILE_PATH_LABEL_KEY])) {
const pathLabel = imageConfig.Config.Labels[DOCKERFILE_PATH_LABEL_KEY];
if (!isHttpUrl(pathLabel)) { //if it is not an http url then convert to link from current repo and ref
let pathLink = `https://github.com/${process.env.GITHUB_REPOSITORY}/blob/${ref}/${pathLabel}`;
pathValue = pathLink;
}
else {
pathValue = pathLabel;
}
pathValue = getNormalizedPath(pathLabel);
}
}
return Promise.resolve(pathValue);
@ -216,3 +213,10 @@ function isHttpUrl(url) {
return HTTP_REGEX.test(url);
}
exports.isHttpUrl = isHttpUrl;
function getNormalizedPath(pathValue) {
if (!isHttpUrl(pathValue)) { //if it is not an http url then convert to link from current repo and commit
return `https://github.com/${process.env.GITHUB_REPOSITORY}/blob/${process.env.GITHUB_SHA}/${pathValue}`;
}
return pathValue;
}
exports.getNormalizedPath = getNormalizedPath;

Просмотреть файл

@ -140,8 +140,14 @@ export function annotateChildPods(kubectl: Kubectl, resourceType: string, resour
export async function getDeploymentConfig(): Promise<DeploymentConfig> {
const inputManifestFiles = inputParams.manifests || [];
const helmChartPaths = (process.env.HELM_CHART_PATHS && process.env.HELM_CHART_PATHS.split('\n').filter(path => path != "")) || [];
let helmChartPaths: string[] = (process.env.HELM_CHART_PATHS && process.env.HELM_CHART_PATHS.split(';').filter(path => path != "")) || [];
helmChartPaths = helmChartPaths.map(helmchart => getNormalizedPath(helmchart.trim()));
let inputManifestFiles: string[] = inputParams.manifests || [];
if (!helmChartPaths || helmChartPaths.length == 0) {
inputManifestFiles = inputManifestFiles.map(manifestFile => getNormalizedPath(manifestFile));
}
const imageNames = inputParams.containers || [];
let imageDockerfilePathMap: { [id: string]: string; } = {};
@ -160,7 +166,6 @@ export async function getDeploymentConfig(): Promise<DeploymentConfig> {
helmChartFilePaths: helmChartPaths,
dockerfilePaths: imageDockerfilePathMap
};
return Promise.resolve(deploymentConfig);
}
@ -191,18 +196,11 @@ async function getDockerfilePath(image: any): Promise<string> {
imageInspectResult = dockerExec.inspect(image, [], true);
imageConfig = JSON.parse(imageInspectResult)[0];
const DOCKERFILE_PATH_LABEL_KEY = 'dockerfile-path';
const ref: string = process.env.GITHUB_REF && process.env.GITHUB_REF.replace('refs/heads/', '').replace('refs/tags/', '');
let pathValue: string = '';
if (imageConfig) {
if ((imageConfig.Config) && (imageConfig.Config.Labels) && (imageConfig.Config.Labels[DOCKERFILE_PATH_LABEL_KEY])) {
const pathLabel = imageConfig.Config.Labels[DOCKERFILE_PATH_LABEL_KEY];
if (!isHttpUrl(pathLabel)) { //if it is not an http url then convert to link from current repo and ref
let pathLink: string = `https://github.com/${process.env.GITHUB_REPOSITORY}/blob/${ref}/${pathLabel}`;
pathValue = pathLink;
}
else {
pathValue = pathLabel;
}
pathValue = getNormalizedPath(pathLabel);
}
}
return Promise.resolve(pathValue);
@ -212,3 +210,10 @@ export function isHttpUrl(url: string) {
const HTTP_REGEX = /^https?:\/\/.*$/;
return HTTP_REGEX.test(url);
}
export function getNormalizedPath(pathValue: string) {
if (!isHttpUrl(pathValue)) { //if it is not an http url then convert to link from current repo and commit
return `https://github.com/${process.env.GITHUB_REPOSITORY}/blob/${process.env.GITHUB_SHA}/${pathValue}`;
}
return pathValue;
}