Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/commands/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,13 @@
{
"arg": "-s, --storage-account-name <storage-account-name>",
"description": "Azure storage account name",
"inherit": "introspection.azure.account_name",
"required": true
},
{
"arg": "-t, --storage-table-name <storage-table-name>",
"description": "Azure storage table name",
"inherit": "introspection.azure.table_name",
"required": true
},
{
Expand All @@ -194,21 +196,25 @@
{
"arg": "--service-principal-id <service-principal-id>",
"description": "Azure service principal id with `contributor` role in Azure Resource Group",
"inherit": "introspection.azure.service_principal_id",
"required": true
},
{
"arg": "--service-principal-password <service-principal-password>",
"description": "The Azure service principal password",
"inherit": "introspection.azure.service_principal_secret",
"required": true
},
{
"arg": "--tenant-id <tenant-id>",
"description": "The Azure AD tenant id of service principal",
"inherit": "introspection.azure.tenant_id",
"required": true
},
{
"arg": "--subscription-id <subscription-id>",
"description": "The Azure subscription id",
"inherit": "introspection.azure.subscription_id",
"required": true
}
],
Expand Down
64 changes: 38 additions & 26 deletions docs/commands/spk.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
var data = null;
var filter = "";
var converter = new showdown.Converter();
Expand All @@ -8,7 +9,9 @@ var sepVersion = "@";
var template =
'<p class="cmd-title">@@main-cmd@@</p><p class="cmd-description">@@cmd-description@@</p><p>&nbsp;</p><p>Options:</p>@@options@@<p>&nbsp;</p>';
var optionTemplate =
'<p>@@option@@</p><p class="cmd-description">@@description@@</p><div class="line-space"></div>';
'<p>@@option@@</p><p class="cmd-description">@@description@@</p>@@inherit@@<div class="line-space"></div>';
var inheritTemplate =
'<p class="cmd-inherit">inherit @@inherit@@ from spk config.yaml</p>';
var relTemplate =
'<li><a class="preserve-view button is-small has-border-none has-inner-focus has-flex-justify-content-start is-full-width has-text-wrap is-text-left">@@value@@</a></li>';

Expand All @@ -19,18 +22,18 @@ function sanitize(str) {
function getExistingVersions() {
$.ajax({
url: "releases.txt",
success: function(result) {
result.split("\n").forEach(function(r) {
success: function (result) {
result.split("\n").forEach(function (r) {
var rTrim = r.trim();
if (rTrim && releases.indexOf(rTrim) === -1) {
releases.push(rTrim);
}
});
releases.sort(function(a, b) {
releases.sort(function (a, b) {
return a > b ? -1 : 1;
});
},
async: false
async: false,
});
}

Expand All @@ -56,8 +59,8 @@ function populateVersionList() {
return a + relTemplate.replace("@@value@@", c);
}, "")
);
oSelect.find("li").each(function(i, elm) {
$(elm).on("click", function(evt) {
oSelect.find("li").each(function (i, elm) {
$(elm).on("click", function (evt) {
evt.stopPropagation();
oSelect.css("display", "none");
var ver = $(this).text();
Expand Down Expand Up @@ -91,15 +94,27 @@ function showDetails(key) {
);
content = content.replace("@@cmd-description@@", cmd.description);

var options = (cmd.options || []).reduce(function(a, c) {
a += optionTemplate
var options = (cmd.options || []).reduce(function (a, c) {
var o = optionTemplate
.replace("@@option@@", sanitize(c.arg))
.replace("@@description@@", sanitize(c.description));

if (c.inherit) {
o = o.replace(
"@@inherit@@",
inheritTemplate.replace("@@inherit@@", c.inherit)
);
} else {
o = o.replace("@@inherit@@", "");
}

a += o;
return a;
}, "");
options += optionTemplate
.replace("@@option@@", "-h, --help")
.replace("@@description@@", "output usage information");
.replace("@@description@@", "output usage information")
.replace("@@inherit@@", "");

content = content.replace("@@options@@", options);

Expand All @@ -121,11 +136,11 @@ function showDetails(key) {
function populateListing() {
var cmdKeys = Object.keys(data);
if (filter) {
cmdKeys = cmdKeys.filter(function(k) {
cmdKeys = cmdKeys.filter(function (k) {
return k.indexOf(filter) !== -1;
});
}
var listing = cmdKeys.reduce(function(a, c) {
var listing = cmdKeys.reduce(function (a, c) {
a +=
"<li><a href=\"javascript:showDetails('" +
c +
Expand Down Expand Up @@ -159,32 +174,29 @@ function populateListing() {
}
}

var subheaderItems = function() {
$("#item_share").click(function(evt) {
var subheaderItems = function () {
$("#item_share").click(function (evt) {
evt.stopPropagation();
$("#sharing-menu").css("display", "block");
});
$("body").click(function() {
$("body").click(function () {
$("#sharing-menu").css("display", "none");
});
$("#item_contribute").click(function(evt) {
$("#item_contribute").click(function (evt) {
var win = window.open("https://github.com/CatalystCode/spk", "_blank");
win.focus();
});
};

function loadCommands() {
var url = version === "master" ? "./data.json" : "./data" + version + ".json";
$.getJSON(url, function(json) {
$.getJSON(url, function (json) {
data = json;
subheaderItems();
populateListing();

$("#commandfilter").on("input", function() {
filter = $(this)
.val()
.trim()
.toLowerCase();
$("#commandfilter").on("input", function () {
filter = $(this).val().trim().toLowerCase();
populateListing();
});
});
Expand All @@ -206,15 +218,15 @@ function showReleaseSelector(bShow) {
}
}

$(function() {
$("#btnSelectRelease").on("click", function(evt) {
$(function () {
$("#btnSelectRelease").on("click", function (evt) {
evt.stopPropagation();
showReleaseSelector();
});
$(document.body).on("click", function() {
$(document.body).on("click", function () {
showReleaseSelector(false);
});
$(document).keyup(function(evt) {
$(document).keyup(function (evt) {
if (evt.keyCode === 27) {
showReleaseSelector(false);
}
Expand Down
4 changes: 4 additions & 0 deletions docs/commands/styles/spk.css
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ a:visited {
.cmd-description {
margin-left: 16px;
}
.cmd-inherit {
margin-left: 16px;
color: #666;
}
.markdown {
padding: 20px;
margin-bottom: 20px;
Expand Down
6 changes: 6 additions & 0 deletions src/commands/deployment/onboard.decorator.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
{
"arg": "-s, --storage-account-name <storage-account-name>",
"description": "Azure storage account name",
"inherit": "introspection.azure.account_name",
"required": true
},
{
"arg": "-t, --storage-table-name <storage-table-name>",
"description": "Azure storage table name",
"inherit": "introspection.azure.table_name",
"required": true
},
{
Expand All @@ -25,21 +27,25 @@
{
"arg": "--service-principal-id <service-principal-id>",
"description": "Azure service principal id with `contributor` role in Azure Resource Group",
"inherit": "introspection.azure.service_principal_id",
"required": true
},
{
"arg": "--service-principal-password <service-principal-password>",
"description": "The Azure service principal password",
"inherit": "introspection.azure.service_principal_secret",
"required": true
},
{
"arg": "--tenant-id <tenant-id>",
"description": "The Azure AD tenant id of service principal",
"inherit": "introspection.azure.tenant_id",
"required": true
},
{
"arg": "--subscription-id <subscription-id>",
"description": "The Azure subscription id",
"inherit": "introspection.azure.subscription_id",
"required": true
}
]
Expand Down
31 changes: 3 additions & 28 deletions src/commands/deployment/onboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import {
build as buildCmd,
exit as exitCmd,
populateInheritValueFromConfig,
validateForRequiredValues,
} from "../../lib/commandBuilder";
import { logger } from "../../logger";
Expand Down Expand Up @@ -50,22 +51,7 @@ export interface OnBoardConfig {
* @param opts values from commander
*/
export const populateValues = (opts: CommandOptions): CommandOptions => {
const config = Config();
const azure = config.introspection ? config.introspection.azure : undefined;

opts.storageAccountName =
opts.storageAccountName || azure?.account_name || undefined;
opts.storageTableName =
opts.storageTableName || azure?.table_name || undefined;
opts.servicePrincipalId =
opts.servicePrincipalId || azure?.service_principal_id || undefined;
opts.servicePrincipalPassword =
opts.servicePrincipalPassword ||
azure?.service_principal_secret ||
undefined;
opts.tenantId = opts.tenantId || azure?.tenant_id || undefined;
opts.subscriptionId =
opts.subscriptionId || azure?.subscription_id || undefined;
populateInheritValueFromConfig(decorator, Config(), opts);
return opts;
};

Expand All @@ -75,18 +61,7 @@ export const populateValues = (opts: CommandOptions): CommandOptions => {
* @param opts values from commander (including populated values from spk config)
*/
export const validateValues = (opts: CommandOptions): OnBoardConfig => {
const errors = validateForRequiredValues(decorator, {
servicePrincipalId: opts.servicePrincipalId,
servicePrincipalPassword: opts.servicePrincipalPassword,
storageAccountName: opts.storageAccountName,
storageResourceGroupName: opts.storageResourceGroupName,
storageTableName: opts.storageTableName,
subscriptionId: opts.subscriptionId,
tenantId: opts.tenantId,
});
if (errors.length > 0) {
throw Error("Required values are missing");
}
validateForRequiredValues(decorator, opts, true);

// validateForRequiredValues already check
// opts.storageAccountName and opts.storageTableName are not empty string
Expand Down
Loading