Skip to content
This repository has been archived by the owner on Mar 30, 2023. It is now read-only.

Commit

Permalink
Patch marketplace tracking guid in gulp pipe transform
Browse files Browse the repository at this point in the history
This commit always changes the tracking guid in the gulp pipe
to use the Marketplace guid, so that this guid always ends up in the
release zip. This ensures that the guid always makes it into the zip
and can never be accidently checked into GitHub with this guid applied.
  • Loading branch information
russcam committed Jul 13, 2018
1 parent 83efebe commit 2e4abd7
Show file tree
Hide file tree
Showing 6 changed files with 499 additions and 601 deletions.
3 changes: 1 addition & 2 deletions build/allowedValues.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@
"Other"
],
"trackingGuids": {
"marketplace": "pid-53DEEEE7-A572-4F07-99DC-151B67BB6F1F",
"github": "pid-B2C934E3-29F3-4194-BFD2-4F1370B78E0C"
"marketplace": "pid-53DEEEE7-A572-4F07-99DC-151B67BB6F1F"
}
}
17 changes: 16 additions & 1 deletion build/tasks/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,24 @@ var jsonlint = require("gulp-jsonlint");
var zip = require("gulp-zip");
var addsrc = require('gulp-add-src');
var timestamp = require("./lib/timestamp");
var transform = require('gulp-transform');
var path = require("path");

gulp.task("default", ["sanity-checks", "patch"], function() {
var stream = gulp.src(["../src/**/*.json"])
.pipe(transform('utf8', function (content, file) {
return new Promise((resolve, reject) => {
if (path.basename(file.path) === "mainTemplate.json") {
var allowedValues = require("../allowedValues.json");
var mainTemplate = JSON.parse(content);
mainTemplate.parameters.elasticTags.defaultValue.tracking = allowedValues.trackingGuids.marketplace;

resolve(JSON.stringify(mainTemplate, null, 2) + "\n");
}

resolve(content);
});
}))
.pipe(jsonlint())
.pipe(jsonlint.reporter())
.pipe(eclint.check({
Expand All @@ -25,7 +40,7 @@ gulp.task("default", ["sanity-checks", "patch"], function() {
return stream;
});

gulp.task("release", ["default", "check-tracking", "deploy-all"], function() {
gulp.task("release", ["default", "deploy-all"], function() {
var stream = gulp.src(["../dist/test-runs/tmp/*.log"])
.pipe(zip("test-results" + timestamp +".zip"))
.pipe(gulp.dest("../dist/releases"))
Expand Down
2 changes: 0 additions & 2 deletions build/tasks/patch-values.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ gulp.task("patch", function(cb) {
main.parameters.vmSizeMasterNodes.allowedValues = vmSizes;
main.parameters.vmSizeClientNodes.allowedValues = vmSizes;
main.parameters.vmSizeKibana.allowedValues = kibanaVmSizes;
main.parameters.elasticTags.defaultValue.tracking = (argv.tracking && argv.tracking.toLowerCase() === "marketplace") ?
allowedValues.trackingGuids.marketplace : allowedValues.trackingGuids.github;

jsonfile.writeFile(mainTemplate, main, function (err) {
jsonfile.readFile(uiTemplate, function(err, ui) {
Expand Down
12 changes: 0 additions & 12 deletions build/tasks/sanity-checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,6 @@ var gulp = require("gulp");
var _ = require('lodash');
var filereader = require('./lib/filereader');

function checkTracking(cb) {
var mainTemplate = require("../../src/mainTemplate.json");
var allowedValues = require("../allowedValues.json");

if (mainTemplate.parameters.elasticTags.defaultValue.tracking !== allowedValues.trackingGuids.marketplace) {
throw new Error(`Tracking check failed:\nExpected tracking guid for release to be ${allowedValues.trackingGuids.marketplace}. Pass --tracking marketplace argument`);
}

cb();
}

function checks(cb) {
var errors = [];
var mainTemplate = require("../../src/mainTemplate.json");
Expand Down Expand Up @@ -103,4 +92,3 @@ function checks(cb) {
}

gulp.task("sanity-checks", checks);
gulp.task("check-tracking", checkTracking);
Loading

0 comments on commit 2e4abd7

Please sign in to comment.