Skip to content

Commit fa80133

Browse files
committed
Iterate on docker entrypoint and init command
Signed-off-by: Jakub Dzikowski <[email protected]>
1 parent a4ff2cf commit fa80133

File tree

4 files changed

+27
-20
lines changed

4 files changed

+27
-20
lines changed

docker-entrypoint.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,18 @@ case "$oclif_command" in
5757
;;
5858
esac
5959

60+
# Build command with all arguments (mapped command + remaining args)
61+
# Replace first argument with mapped command, then pass all args
62+
if [ $# -gt 0 ]; then
63+
shift
64+
set -- "$oclif_command" "$@"
65+
else
66+
set -- "$oclif_command"
67+
fi
68+
command_with_args="$*"
69+
6070
# Execute the command
61-
executeOclifCommand "$oclif_command"
71+
executeOclifCommand "$command_with_args"
6272

6373
if echo "$oclif_command" | grep -q "setup-network"; then
6474
formatGeneratedFiles

e2e-network/docker/test-01-v3-simple.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export FABLO_HOME
1010

1111
networkUp() {
1212
"$FABLO_HOME/fablo-build.sh"
13-
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" init)
13+
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" init --node && cat "$TEST_TMP/fablo-config.json")
1414
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" up)
1515
}
1616

fablo.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ printHelp() {
190190
}
191191

192192
executeOnFabloDocker() {
193+
set -x
193194
local command_with_params="$1"
194195
local fablo_workspace="${2:-$FABLO_TEMP_DIR}"
195196
local fablo_config="$3"
@@ -218,7 +219,7 @@ executeOnFabloDocker() {
218219
"${fablo_workspace_params[@]}" \
219220
"${fablo_config_params[@]}" \
220221
-u "$(id -u):$(id -g)" \
221-
$FABLO_IMAGE sh -c "/fablo/docker-entrypoint.sh \"$command_with_params\"" \
222+
$FABLO_IMAGE sh -c "/fablo/docker-entrypoint.sh $command_with_params" \
222223
2>&1
223224
}
224225

@@ -237,7 +238,7 @@ useVersion() {
237238

238239
initConfig() {
239240
printSplash
240-
executeOnFabloDocker "init $1 $2"
241+
executeOnFabloDocker "init \"$1\" \"$2\" \"$3\" \"$4\" \"$5\""
241242
cp -R -i "$FABLO_TEMP_DIR/." "$COMMAND_CALL_ROOT/"
242243
}
243244

src/commands/init/index.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Args, Command } from '@oclif/core'
1+
import { Command, Flags } from '@oclif/core'
22
import * as chalk from "chalk";
33
import { GlobalJson, FabloConfigJson, ChaincodeJson } from "../../types/FabloConfigJson";
44
import * as path from 'path';
@@ -72,23 +72,19 @@ export default class Init extends Command {
7272
static override description =
7373
"Creates simple Fablo config in current directory with optional Node.js, chaincode, REST API and dev mode";
7474

75-
static args = {
76-
feat: Args.string({
77-
description: 'feature node,dev,ccass,gateway,rest',
78-
multiple: true
79-
})
80-
}
75+
static flags = {
76+
node: Flags.boolean({ description: 'Include Node.js chaincode sample' }),
77+
dev: Flags.boolean({ description: 'Enable dev mode (dev chaincodes)' }),
78+
ccaas: Flags.boolean({ description: 'Include CCAAS chaincode sample' }),
79+
gateway: Flags.boolean({ description: 'Include Gateway app sample' }),
80+
rest: Flags.boolean({ description: 'Include REST API sample' }),
81+
};
82+
8183
async copySampleConfig(): Promise<void> {
8284
let fabloConfigJson = getDefaultFabloConfig();
83-
const { args } = await this.parse(Init);
84-
85-
86-
const features: string[] = Array.isArray(args.feat) ? args.feat : args.feat ? [args.feat] : [];
85+
const { flags } = await this.parse(Init);
8786

88-
const flags: Record<string, true> = features.reduce<Record<string, true>>((acc, v) => {
89-
acc[v] = true;
90-
return acc;
91-
}, {});
87+
console.log("init flags: ", JSON.stringify(flags, null, 2));
9288

9389
if (flags.ccaas) {
9490
if (flags.dev || flags.node) {
@@ -167,7 +163,7 @@ export default class Init extends Command {
167163
fabloConfigJson = { ...fabloConfigJson, orgs };
168164
}
169165

170-
const engine = flags.kubernetes || flags.k8s ? "kubernetes" : "docker";
166+
const engine = "docker";
171167

172168
const global: GlobalJson = {
173169
...fabloConfigJson.global,

0 commit comments

Comments
 (0)