Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.

Commit def8e96

Browse files
authored
Merge branch 'master' into lifecycle-variables
2 parents 3f9617c + 20d6d5f commit def8e96

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/commands/infra/generate.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import mkdirp from "mkdirp";
44
import * as os from "os";
55
import path from "path";
66
import simpleGit from "simple-git/promise";
7+
import {
8+
getCurrentBranch,
9+
getOriginUrl,
10+
safeGitUrlForLogging
11+
} from "../../lib/gitutils";
712
import { logger } from "../../logger";
813
import * as infraCommon from "./infra_common";
914
import { copyTfTemplate } from "./scaffold";
@@ -87,15 +92,16 @@ export const validateTemplateSource = async (
8792
): Promise<string[]> => {
8893
try {
8994
const definitionJSON = await readDefinitionJson(projectPath);
95+
const safeLoggingUrl = safeGitUrlForLogging(definitionJSON.source);
9096
// TO DO : Check for malformed JSON
9197
if (!(definitionJSON.template && definitionJSON.source)) {
9298
logger.info(
93-
`The definition.json file is invalid. There is a missing field for the definition file's sources. Template: ${definitionJSON.template} source: ${definitionJSON.source} version: ${definitionJSON.version}`
99+
`The definition.json file is invalid. There is a missing field for the definition file's sources. Template: ${definitionJSON.template} source: ${safeLoggingUrl} version: ${definitionJSON.version}`
94100
);
95101
return [];
96102
}
97103
logger.info(
98-
`Checking for locally stored template: ${definitionJSON.template} from remote repository: ${definitionJSON.source} at version: ${definitionJSON.version}`
104+
`Checking for locally stored template: ${definitionJSON.template} from remote repository: ${safeLoggingUrl} at version: ${definitionJSON.version}`
99105
);
100106
const sources = [
101107
definitionJSON.source,
@@ -123,6 +129,7 @@ export const validateRemoteSource = async (
123129
// Converting source name to storable folder name
124130
const sourceFolder = await infraCommon.repoCloneRegex(source);
125131
const sourcePath = path.join(infraCommon.spkTemplatesPath, sourceFolder);
132+
const safeLoggingUrl = safeGitUrlForLogging(source);
126133
logger.warn(`Converted to: ${sourceFolder}`);
127134
logger.info(`Checking if source: ${sourcePath} is stored locally.`);
128135
try {
@@ -144,20 +151,22 @@ export const validateRemoteSource = async (
144151
);
145152
return false;
146153
} else {
147-
logger.info(`Remote source repo: ${source} exists.`);
154+
logger.info(`Remote source repo: ${safeLoggingUrl} exists.`);
148155
logger.info(
149-
`Checking if source repo: ${source} has been already cloned to: ${sourcePath}.`
156+
`Checking if source repo: ${safeLoggingUrl} has been already cloned to: ${sourcePath}.`
150157
);
151158
// Check if .git folder exists in ${sourcePath}, if not, then clone
152159
// if already cloned, 'git pull'
153160
if (fs.existsSync(path.join(sourcePath, ".git"))) {
154161
// Make sure we have the latest version of all releases cached locally
155162
await simpleGit(sourcePath).fetch("all");
156163
await simpleGit(sourcePath).pull("origin", "master");
157-
logger.info(`${source} already cloned. Performing 'git pull'...`);
164+
logger.info(
165+
`${safeLoggingUrl} already cloned. Performing 'git pull'...`
166+
);
158167
} else {
159168
await git.clone(source, `${sourcePath}`);
160-
logger.info(`Cloning ${source} was successful.`);
169+
logger.info(`Cloning ${safeLoggingUrl} was successful.`);
161170
}
162171
// Checkout tagged version
163172
logger.info(`Checking out template version: ${version}`);

src/commands/infra/scaffold.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const scaffoldCommandDecorator = (command: commander.Command): void => {
6060
"@" +
6161
config.azure_devops.infra_repository;
6262
logger.info(
63-
`Infrastructure repository detected from initialized spk-config.yaml : ${opts.source}`
63+
`Infrastructure repository detected from initialized spk-config.yaml.`
6464
);
6565
}
6666
}

0 commit comments

Comments
 (0)