Skip to content

Commit

Permalink
Merge branch 'main' into 92-update-api-config-json
Browse files Browse the repository at this point in the history
  • Loading branch information
felipe.fuerback authored Mar 12, 2024
2 parents 6b5c94d + 1ae62f1 commit 0761abc
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 300 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/test-on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,10 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y jq
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
sudo chmod a+x /usr/local/bin/yq
git --version
node --version
npm --version
jq --version
yq --version
bash --version
docker version
docker-compose version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ FROM docker:dind
# Install bash, Node.js, jq, and Perl
RUN apk add --update nodejs npm bash jq perl

# Install yq
RUN wget https://github.com/mikefarah/yq/releases/download/v4.9.8/yq_linux_amd64 -O /usr/bin/yq && chmod +x /usr/bin/yq

# Install Gala Chain CLI globally
RUN npm install -g @gala-chain/cli

Expand Down
5 changes: 1 addition & 4 deletions chain-cli/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# Start with the Docker in Docker image
FROM docker:dind

# Install bash, Node.js, jq, yq, and Perl
# Install bash, Node.js, jq, and Perl
RUN apk add --update nodejs npm bash jq perl

# Install yq
RUN wget https://github.com/mikefarah/yq/releases/download/v4.9.8/yq_linux_amd64 -O /usr/bin/yq && chmod +x /usr/bin/yq

# Install Gala Chain CLI globally
RUN npm install -g @gala-chain/cli

Expand Down
230 changes: 0 additions & 230 deletions chain-cli/network/configtx-policies.yml

This file was deleted.

37 changes: 0 additions & 37 deletions chain-cli/network/fablo-post-generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,43 +41,6 @@ perl -i -pe 's/_CA_VERSION=1.5.0/_CA_VERSION=1.5.5/g' "$target_env"
# skip chaincode installation for UsersOrg1 (note the approval for UsersOrg1 is not skipped)
perl -i -pe 's/chaincodeInstall "cli.users1.local"/echo "Skipping..." # chaincodeInstall "cli.users1.local"/g' "./fablo-target/fabric-docker/commands-generated.sh"

#
# overwrite default policies
#
setFromPoliciesConfigtx() {
yaml_path="$1"
configtx_policies="./configtx-policies.yml"
echo " - $yaml_path"
yq eval-all --inplace "select(fileIndex == 0)$yaml_path = select(fileIndex == 1)$yaml_path | select(fileIndex == 0)" "$target_configtx" "$configtx_policies"
}

executeInConfigtx() {
expression="$1"
echo " - $expression"
yq eval --inplace "$expression" "$target_configtx"
}

echo "Overriding policies:"
setFromPoliciesConfigtx ".Organizations[0].Policies"
setFromPoliciesConfigtx ".Organizations[1].Policies"
setFromPoliciesConfigtx ".Organizations[2].Policies"
setFromPoliciesConfigtx ".Organizations[3].Policies"
setFromPoliciesConfigtx ".Application.ACLs"
setFromPoliciesConfigtx ".Application.Policies"
executeInConfigtx '.Application.Policies anchor = "ApplicationDefaultPolicies"'
setFromPoliciesConfigtx ".Orderer.Policies"
setFromPoliciesConfigtx ".Channel.Policies"
setFromPoliciesConfigtx '.Profiles.CuratorChannel'
executeInConfigtx '.Profiles.CuratorChannel anchor = "CuratorChannelDefaults"'
setFromPoliciesConfigtx '.Profiles.PartnerChannel'
executeInConfigtx '.Profiles.PartnerChannel anchor = "PartnerChannelDefaults"'

for channel_name in $(cat "$fablo_config" | jq -r '.channels[] | .name'); do
channel_name_pascal_case="$(perl -pe 's/(^|-)(\w)/\U$2/g' <<<"$channel_name")"
executeInConfigtx "del(.Profiles.$channel_name_pascal_case)"
setFromPoliciesConfigtx ".Profiles.$channel_name_pascal_case"
done

#
# Some sample commands that might be useful in experiments
#
Expand Down
18 changes: 0 additions & 18 deletions chain-cli/src/commands/network-up/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import { Flags } from "@oclif/core";

import { Fablo, FabloConfig } from "fablo";
import * as fs from "fs";
import { readFileSync, writeFileSync } from "fs";
import path from "path";

Expand Down Expand Up @@ -122,7 +121,6 @@ export default class NetworkUp extends BaseCommand<typeof NetworkUp> {
await Fablo.directory(fabloRoot)
.then(() => saveConnectionProfiles(fabloRoot, flags.watch, flags.channel ?? [], localhostName))
.config(fabloConfig, (cfg) => updatedFabloConfig(cfg, fabloRoot, singleArgs))
.then(() => updateConfigTxWithChannelProfile(fabloRoot, singleArgs))
.then(() =>
copyEnvFile(
fabloRoot,
Expand Down Expand Up @@ -168,22 +166,6 @@ function copyEnvFile(fabloRoot: string, envConfigPath: string | undefined, chain
});
}

function updateConfigTxWithChannelProfile(fabloRoot: string, args: SingleArg[]) {
const update = createConfigtxProfiles(args);
const configtxFilePath = path.resolve(fabloRoot, "configtx-policies.yml");
fs.appendFileSync(configtxFilePath, update);
}

export function createConfigtxProfiles(args: SingleArg[]): string {
const profiles = args.map(({ channel, channelType }) => {
const configtxProfileName = channel.replace(/(^\w|-\w)/g, (t) => t.replace(/-/, "").toUpperCase());
const configtxProfileDefaults =
channelType === "curator" ? "CuratorChannelDefaults" : "PartnerChannelDefaults";
return ` ${configtxProfileName}:\n <<: *${configtxProfileDefaults}`;
});
return `\n${profiles.join("\n")}`;
}

export function updatedFabloConfig(
initialCfg: FabloConfig,
fabloRoot: string,
Expand Down
5 changes: 1 addition & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# Start with the Docker in Docker image
FROM docker:dind

# Install bash, Node.js, jq, yq, and Perl
# Install bash, Node.js, jq, and Perl
RUN apk add --update nodejs npm bash jq perl

# Install yq
RUN wget https://github.com/mikefarah/yq/releases/download/v4.9.8/yq_linux_amd64 -O /usr/bin/yq && chmod +x /usr/bin/yq

# Install Gala Chain CLI globally
RUN npm install -g @gala-chain/cli

Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ If you are using Windows with WSL don't forget to enable integration with WSL on
You need to have the following tools installed on your machine:
- Node.js 16+
- Docker and Docker Compose
- [jq](https://jqlang.github.io/jq/) and [yq](https://github.com/mikefarah/yq)
- [jq](https://jqlang.github.io/jq/)

### 1. Install our CLI

Expand Down

0 comments on commit 0761abc

Please sign in to comment.