Skip to content

Commit

Permalink
Changed image tag naming (#78)
Browse files Browse the repository at this point in the history
* 3.5.1 changed image tag name:
- git tag is removed
- added environment
- added utc timestamp

* updated packages

* env is defined at this step
  • Loading branch information
skifahrer authored Aug 14, 2024
1 parent cd1210d commit 7f49ffd
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 62 deletions.
12 changes: 6 additions & 6 deletions dist/bratiska-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const tag_1 = require("./tag");
const label_1 = require("./label");
const common_1 = require("./common");
const helpers = __importStar(require("./helpers"));
const version = "3.5.0";
const version = "3.5.1";
const deploy = new deploy_1.Deploy();
const tag = new tag_1.Tag();
const common = new common_1.Common();
Expand All @@ -47,13 +47,13 @@ const build_kustomize = new build_kustomize_1.BuildKustomize();
const label = new label_1.Label();
try {
(0, clear_1.default)();
console.log(chalk_1.default.blue(figlet_1.default.textSync("Bratiska-cli", { horizontalLayout: "full" })));
console.log(chalk_1.default.blue(figlet_1.default.textSync("Bratiska-cli", { horizontalLayout: "full" })));
commander_1.program
.name("bratiska-cli")
.version(version)
.description("Simple Bratiska-cli utility for managing Bratislava Innovation apps")
.action(() => {
console.log(chalk_1.default.green("Please choose from selected commands based on yur needs. My favourite command is `deploy`."));
console.log(chalk_1.default.green("Please choose from selected commands based on yur needs. My favourite command is `deploy`."));
commander_1.program.help();
});
commander_1.program
Expand Down Expand Up @@ -232,7 +232,7 @@ try {
/* step 1 */
build_image.check_build_image_commands(options);
/* step 2 */
common.show_options("build_image", options);
common.show_options("build_image", options);
/* step 3 */
common.get_git_current_branch(options);
/* step 4 */
Expand Down Expand Up @@ -354,7 +354,7 @@ try {
/* step 1 */
label.check_label_commands(options);
/* step 2 */
common.show_options("", options);
common.show_options("", options);
/* step 3 */
label.show_label_info(label_value, options);
/* step 4 */
Expand All @@ -377,6 +377,6 @@ try {
// @ts-ignore
}
catch (e) {
helpers.log("\x1b[31m", `\nISSUE: ${e.message}`);
helpers.log("\x1b[31m", `\nISSUE: ${e.message}`);
process.exit(1);
}
1 change: 1 addition & 0 deletions dist/common/show_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const path = __importStar(require("path"));
const fs_1 = __importDefault(require("fs"));
const crypto_1 = __importDefault(require("crypto"));
function show_options(env, options) {
options.timestamp = Date.now();
if (typeof env !== "undefined" &&
env !== "" &&
typeof options.env === "undefined") {
Expand Down
16 changes: 12 additions & 4 deletions dist/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ function tag(options) {
let untracked = "";
let pipelines = "";
let commit = "";
let tag = "";
let timestamp = "";
let env = "";
let branch = "-" + options.branch;
if (options.untracked) {
untracked = "-untracked";
Expand All @@ -192,17 +193,20 @@ function tag(options) {
if (options.commit) {
commit = `-${options.commit}`;
}
if (options.timestamp) {
timestamp = `-${options.timestamp}`;
}
let force_rebuild = "";
if (options.force_rebuild) {
force_rebuild = "-force-rebuild-" + crypto_1.default.randomBytes(20).toString("hex");
}
if (options.pipelines) {
pipelines = "-pipelines";
}
if (options.gittag) {
tag = `-tag-${options.gittag}`;
if (options.env) {
env = `-${options.env}`;
}
let tag_value = `bratiska-cli-v${options.bratiska_cli_version}${pipelines}${untracked}${force_rebuild}${branch}${commit}${tag}-v${options.version}`;
let tag_value = `bratiska-cli-v${options.bratiska_cli_version}${pipelines}${untracked}${force_rebuild}${branch}${commit}${env}${timestamp}`;
tag_value = tag_value.replace(" ", "-");
tag_value = tag_value.replace("+", "-");
tag_value = tag_value.replace(/[#@/\\_]/g, "-");
Expand Down Expand Up @@ -431,6 +435,7 @@ function load_package(options) {
throw new Error("There was an issue getting the current working directory!");
}
options = {
timestamp: Date.now(),
app_port: "",
cluster: "",
commit: "",
Expand Down Expand Up @@ -529,6 +534,9 @@ function print_options(options) {
if (options.recursive) {
print_important_info_spacer(`--recursive`);
}
if (options.timestamp) {
print_important_info_spacer(`--timestamp=${options.timestamp}`);
}
if (options.env) {
print_important_info_spacer(`--env=${options.env}`);
}
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bratiska-cli",
"version": "3.5.0",
"version": "3.5.1",
"description": "Simple CLI for deploying Bratislava apps to kubernetes",
"preferGlobal": true,
"bin": "./dist/bratiska-cli.js",
Expand Down Expand Up @@ -29,7 +29,7 @@
"clear": "^0.1.0",
"commander": "^11.0.0",
"compare-versions": "^6.1.0",
"dotenv": "^16.0.1",
"dotenv": "^16.4.5",
"figlet": "^1.5.2",
"fs": "^0.0.1-security",
"sync-request": "^6.1.0"
Expand All @@ -46,12 +46,12 @@
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"install": "^0.13.0",
"node-fetch": "^3.3.1",
"node-fetch": "^3.3.2",
"npm": "^8.10.0",
"prettier": "^3.2.5",
"ts-node": "^10.7.0",
"ts-node": "^10.9.2",
"typedoc": "^0.24.8",
"typescript": "^4.6.4"
"typescript": "^5.1.6"
},
"engines": {
"node": ">=16.0.0"
Expand Down
2 changes: 1 addition & 1 deletion src/bratiska-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Label } from './label';
import { Common } from './common';
import * as helpers from './helpers';

const version = '3.5.0';
const version = '3.5.1';
const deploy = new Deploy();
const tag = new Tag();
const common = new Common();
Expand Down
2 changes: 2 additions & 0 deletions src/common/show_options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import crypto from 'crypto';
import { Options } from '../types';

export function show_options(env: string, options: Options) {
options.timestamp = Date.now();

if (
typeof env !== 'undefined' &&
env !== '' &&
Expand Down
18 changes: 13 additions & 5 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ export function tag(options: Options) {
let untracked = '';
let pipelines = '';
let commit = '';
let tag = '';
let timestamp = '';
let env = '';
let branch = '-' + options.branch;
if (options.untracked) {
untracked = '-untracked';
Expand All @@ -181,6 +182,10 @@ export function tag(options: Options) {
commit = `-${options.commit}`;
}

if (options.timestamp) {
timestamp = `-${options.timestamp}`;
}

let force_rebuild = '';
if (options.force_rebuild) {
force_rebuild = '-force-rebuild-' + crypto.randomBytes(20).toString('hex');
Expand All @@ -190,11 +195,9 @@ export function tag(options: Options) {
pipelines = '-pipelines';
}

if (options.gittag) {
tag = `-tag-${options.gittag}`;
}
env = `-${options.env}`;

let tag_value = `bratiska-cli-v${options.bratiska_cli_version}${pipelines}${untracked}${force_rebuild}${branch}${commit}${tag}-v${options.version}`;
let tag_value = `bratiska-cli-v${options.bratiska_cli_version}${pipelines}${untracked}${force_rebuild}${branch}${commit}${env}${timestamp}`;
tag_value = tag_value.replace(' ', '-');
tag_value = tag_value.replace('+', '-');
tag_value = tag_value.replace(/[#@/\\_]/g, '-');
Expand Down Expand Up @@ -474,6 +477,7 @@ export function load_package(options?: Options) {
);
}
options = {
timestamp: Date.now(),
app_port: '',
cluster: '',
commit: '',
Expand Down Expand Up @@ -595,6 +599,10 @@ export function print_options(options: Options) {
print_important_info_spacer(`--recursive`);
}

if (options.timestamp) {
print_important_info_spacer(`--timestamp=${options.timestamp}`);
}

if (options.env) {
print_important_info_spacer(`--env=${options.env}`);
}
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//type Options = Record<string, string | number | boolean>;
export interface Options
extends Record<string, string | number | boolean | string[]> {
timestamp: number;
cluster: string;
repository_uri: string;
deployment: string;
Expand Down
82 changes: 41 additions & 41 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -881,20 +881,20 @@ __metadata:
clear: ^0.1.0
commander: ^11.0.0
compare-versions: ^6.1.0
dotenv: ^16.0.1
dotenv: ^16.4.5
eslint: ^8.56.0
eslint-config-prettier: ^9.1.0
eslint-plugin-prettier: ^5.1.3
figlet: ^1.5.2
fs: ^0.0.1-security
install: ^0.13.0
node-fetch: ^3.3.1
node-fetch: ^3.3.2
npm: ^8.10.0
prettier: ^3.2.5
sync-request: ^6.1.0
ts-node: ^10.7.0
ts-node: ^10.9.2
typedoc: ^0.24.8
typescript: ^4.6.4
typescript: ^5.1.6
bin:
bratiska-cli: ./dist/bratiska-cli.js
languageName: unknown
Expand Down Expand Up @@ -1282,10 +1282,10 @@ __metadata:
languageName: node
linkType: hard

"dotenv@npm:^16.0.1":
version: 16.0.1
resolution: "dotenv@npm:16.0.1"
checksum: f459ffce07b977b7f15d8cc4ee69cdff77d4dd8c5dc8c85d2d485ee84655352c2415f9dd09d42b5b5985ced3be186130871b34e2f3e2569ebc72fbc2e8096792
"dotenv@npm:^16.4.5":
version: 16.4.5
resolution: "dotenv@npm:16.4.5"
checksum: 301a12c3d44fd49888b74eb9ccf9f07a1f5df43f489e7fcb89647a2edcd84c42d6bc349dc8df099cd18f07c35c7b04685c1a4f3e6a6a9e6b30f8d48c15b7f49c
languageName: node
linkType: hard

Expand Down Expand Up @@ -2587,14 +2587,14 @@ __metadata:
languageName: node
linkType: hard

"node-fetch@npm:^3.3.1":
version: 3.3.1
resolution: "node-fetch@npm:3.3.1"
"node-fetch@npm:^3.3.2":
version: 3.3.2
resolution: "node-fetch@npm:3.3.2"
dependencies:
data-uri-to-buffer: "npm:^4.0.0"
fetch-blob: "npm:^3.1.4"
formdata-polyfill: "npm:^4.0.10"
checksum: 62145fd3ba4770a76110bc31fdc0054ab2f5442b5ce96e9c4b39fc9e94a3d305560eec76e1165d9259eab866e02a8eecf9301062bb5dfc9f08a4d08b69d223dd
data-uri-to-buffer: ^4.0.0
fetch-blob: ^3.1.4
formdata-polyfill: ^4.0.10
checksum: 06a04095a2ddf05b0830a0d5302699704d59bda3102894ea64c7b9d4c865ecdff2d90fd042df7f5bc40337266961cb6183dcc808ea4f3000d024f422b462da92
languageName: node
linkType: hard

Expand Down Expand Up @@ -3585,23 +3585,23 @@ __metadata:
languageName: node
linkType: hard

"ts-node@npm:^10.7.0":
version: 10.9.1
resolution: "ts-node@npm:10.9.1"
dependencies:
"@cspotcode/source-map-support": "npm:^0.8.0"
"@tsconfig/node10": "npm:^1.0.7"
"@tsconfig/node12": "npm:^1.0.7"
"@tsconfig/node14": "npm:^1.0.0"
"@tsconfig/node16": "npm:^1.0.2"
acorn: "npm:^8.4.1"
acorn-walk: "npm:^8.1.1"
arg: "npm:^4.1.0"
create-require: "npm:^1.1.0"
diff: "npm:^4.0.1"
make-error: "npm:^1.1.1"
v8-compile-cache-lib: "npm:^3.0.1"
yn: "npm:3.1.1"
"ts-node@npm:^10.9.2":
version: 10.9.2
resolution: "ts-node@npm:10.9.2"
dependencies:
"@cspotcode/source-map-support": ^0.8.0
"@tsconfig/node10": ^1.0.7
"@tsconfig/node12": ^1.0.7
"@tsconfig/node14": ^1.0.0
"@tsconfig/node16": ^1.0.2
acorn: ^8.4.1
acorn-walk: ^8.1.1
arg: ^4.1.0
create-require: ^1.1.0
diff: ^4.0.1
make-error: ^1.1.1
v8-compile-cache-lib: ^3.0.1
yn: 3.1.1
peerDependencies:
"@swc/core": ">=1.2.50"
"@swc/wasm": ">=1.2.50"
Expand All @@ -3619,7 +3619,7 @@ __metadata:
ts-node-script: dist/bin-script.js
ts-node-transpile-only: dist/bin-transpile.js
ts-script: dist/bin-script-deprecated.js
checksum: 090adff1302ab20bd3486e6b4799e90f97726ed39e02b39e566f8ab674fd5bd5f727f43615debbfc580d33c6d9d1c6b1b3ce7d8e3cca3e20530a145ffa232c35
checksum: fde256c9073969e234526e2cfead42591b9a2aec5222bac154b0de2fa9e4ceb30efcd717ee8bc785a56f3a119bdd5aa27b333d9dbec94ed254bd26f8944c67ac
languageName: node
linkType: hard

Expand Down Expand Up @@ -3669,23 +3669,23 @@ __metadata:
languageName: node
linkType: hard

"typescript@npm:^4.6.4":
version: 4.7.4
resolution: "typescript@npm:4.7.4"
"typescript@npm:^5.1.6":
version: 5.5.4
resolution: "typescript@npm:5.5.4"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 5750181b1cd7e6482c4195825547e70f944114fb47e58e4aa7553e62f11b3f3173766aef9c281783edfd881f7b8299cf35e3ca8caebe73d8464528c907a164df
checksum: b309040f3a1cd91c68a5a58af6b9fdd4e849b8c42d837b2c2e73f9a4f96a98c4f1ed398a9aab576ee0a4748f5690cf594e6b99dbe61de7839da748c41e6d6ca8
languageName: node
linkType: hard

"typescript@patch:typescript@^4.6.4#~builtin<compat/typescript>":
version: 4.7.4
resolution: "typescript@patch:typescript@npm%3A4.7.4#~builtin<compat/typescript>::version=4.7.4&hash=65a307"
"typescript@patch:typescript@^5.1.6#~builtin<compat/typescript>":
version: 5.5.4
resolution: "typescript@patch:typescript@npm%3A5.5.4#~builtin<compat/typescript>::version=5.5.4&hash=ad5954"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 9096d8f6c16cb80ef3bf96fcbbd055bf1c4a43bd14f3b7be45a9fbe7ada46ec977f604d5feed3263b4f2aa7d4c7477ce5f9cd87de0d6feedec69a983f3a4f93e
checksum: fc52962f31a5bcb716d4213bef516885e4f01f30cea797a831205fc9ef12b405a40561c40eae3127ab85ba1548e7df49df2bcdee6b84a94bfbe3a0d7eff16b14
languageName: node
linkType: hard

Expand Down

0 comments on commit 7f49ffd

Please sign in to comment.