Commit 2ac58cb4 authored by John Northrup's avatar John Northrup

Merge branch 'data-driven-gcp-project-color-coder' into 'master'

Add gemnaisium to GCP greasemonkey script; make it data driven for future additions

See merge request gitlab-com/gl-infra/infrastructure!120
parents b293bcfd a3e458cf
// ==UserScript==
// @name GCP Console - Project Color Coder
// @namespace gitlab.com/gitlab-com/gl-infra
// @version 0.1
// @version 0.2
// @description Color code projects in GCP console to distinguish between production, staging, DR...etc
// @author aamarsanaa@
// @match https://console.cloud.google.com/*
......@@ -12,29 +12,22 @@
const PROJECT_FIELD = 'project';
const URL_DELIMETER = '&';
const PROJECT_DELIMETER = '=';
const PROJECT_PRODUCTION = 'gitlab-production';
const PROJECT_PRODUCTION_COLOR = 'red';
const PROJECT_STAGING = 'gitlab-staging-1';
const PROJECT_STAGING_COLOR = 'blue';
const PROJECT_INTERNAL = 'gitlab-internal-153318';
const PROJECT_INTERNAL_COLOR = 'green';
const CONTAINER_ID = '.cfc-platform-bar-container';
//TODO Add DR and other projects
const PROJECT_MAPPINGS = new Map([
['gitlab-production', 'red'],
['gitlab-staging-1', 'blue'],
['gitlab-internal-153318', 'green'],
['gemnasium-production', 'red'],
['gemnasium-staging', 'blue'],
]);
var $ = window.jQuery;
var colorCode = function(project_id) {
if (project_id == PROJECT_PRODUCTION){
$('.pcc-platform-bar-container').css('background-color', PROJECT_PRODUCTION_COLOR);
}
else if (project_id == PROJECT_STAGING){
$('.pcc-platform-bar-container').css('background-color', PROJECT_STAGING_COLOR);
}
else if (project_id == PROJECT_INTERNAL){
$('.pcc-platform-bar-container').css('background-color', PROJECT_INTERNAL_COLOR);
if (PROJECT_MAPPINGS.has(project_id)) {
$(CONTAINER_ID).css('background-color', PROJECT_MAPPINGS.get(project_id));
}
};
......@@ -51,7 +44,6 @@ $(document).ready(function() {
break;
}
}
if(project_id != ''){
colorCode(project_id);
}
......@@ -65,4 +57,4 @@ $(document).on("click", ".cfc-purview-picker-list-name-link", function() {
if(project_id != ''){
colorCode(project_id);
}
});
\ No newline at end of file
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment