Skip to content

Commit

Permalink
Add DevContainer definition (#204)
Browse files Browse the repository at this point in the history
Provide a better experience for contributors by including a DevContainer
definition that includes all the required pre-requisites. See:

- https://containers.dev/
- https://code.visualstudio.com/docs/devcontainers/containers

Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
  • Loading branch information
bestbeforetoday authored Sep 19, 2024
1 parent 29e9edb commit b0d7acf
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 89 deletions.
15 changes: 15 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Ubuntu",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
"ghcr.io/devcontainers/features/go:1": {},
"ghcr.io/devcontainers/features/node:1": {}
},
"customizations": {
"vscode": {
"extensions": ["esbenp.prettier-vscode", "github.vscode-github-actions", "ms-vscode.makefile-tools"]
}
},
"postStartCommand": ["make", "generate"]
}
22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,50 +18,50 @@ unit-test-node:
cd '$(node_dir)/admin' && \
npm install

.PHONEY: lint
.PHONY: lint
lint: staticcheck golangci-lint

.PHONEY: staticcheck
.PHONY: staticcheck
staticcheck:
go install honnef.co/go/tools/cmd/staticcheck@latest
staticcheck -f stylish '$(base_dir)/...'

.PHONEY: install-golangci-lint
.PHONY: install-golangci-lint
install-golangci-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go_bin_dir)

$(go_bin_dir)/golangci-lint:
$(MAKE) install-golangci-lint

.PHONEY: golangci-lint
.PHONY: golangci-lint
golangci-lint: $(go_bin_dir)/golangci-lint
golangci-lint run

.PHONEY: scan
.PHONY: scan
scan: scan-go scan-node

.PHONEY: scan-go
.PHONY: scan-go
scan-go: scan-go-govulncheck

.PHONEY: scan-go-govulncheck
.PHONY: scan-go-govulncheck
scan-go-govulncheck:
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck '$(base_dir)/...'

.PHONEY: scan-node
.PHONY: scan-node
scan-node: scan-node-npm-audit

.PHONEY: scan-node-npm-audit
.PHONY: scan-node-npm-audit
scan-node-npm-audit:
cd "$(node_dir)/admin" && \
npm install --package-lock-only && \
npm audit --omit=dev

.PHONEY: escapes_detect
.PHONY: escapes_detect
escapes_detect:
@go build -gcflags="-m -l" ./... 2>&1 | grep "escapes to heap" || true

.PHONEY: generate
.PHONY: generate
generate:
go install go.uber.org/mock/mockgen@latest
go generate ./pkg/...
71 changes: 42 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,66 @@
# fabric-admin-sdk
Fabric SDK for Admin Capability services
# Fabric Admin SDK

## [motivation](https://github.com/hyperledger/fabric-rfcs/pull/55)
As gateway sdk will drop off admin capacity, we plan to recover admin capacity related things with this project proposal.
The fabric-admin-sdk provides administrative APIs for creating and configuring [Hyperledger Fabric](https://hyperledger-fabric.readthedocs.io/) networks, and for deploying smart contracts (chaincode) to those networks.

## identified [features](https://github.com/Hyperledger-TWGC/fabric-admin-sdk/issues/15)
For information on using the fabric-admin-sdk, please visit the [Go API documentation](https://pkg.go.dev/github.com/hyperledger/fabric-admin-sdk/pkg). The API documentation includes some usage examples. Additionally, the [scenario tests](./test/e2e_test.go) can be used as an example of an end-to-end flow, covering channel creation and smart contract deployment.

### channel
- new channel
- channel update(new org join into specific channel)
- peer join channel
- peer exit channel
- list channel
- inspect channel config
## Overview

### chaincode
- chain code lifecycle
- system chain code(as list all chain code)
The current API for client application to transact with Fabric networks (the [Fabric Gateway client API](https://hyperledger.github.io/fabric-gateway/)) does not provide the administrative capabilities of the legcacy client application SDKs. The fabric-admin-sdk aims to provide this programmatic administrative capability for use-cases where the [Fabric CLI commands](https://hyperledger-fabric.readthedocs.io/en/latest/command_ref.html) are not the best fit. A specific objective is to support the development of Kubernetes operators.

### tools
- gate policy?(common/policydsl/policyparser.go, tool for operator)
- peer discovery(optional, as ping test among peer networks when gateway disabled or fabric version below 2.5)
- base on peer discovery result, generate connection profile for sdk if possible?(optional)
More detailed information on the motivation and objectives of the fabric-admin-sdk can be found in the associated [Fabric Admin SDK RFC](https://hyperledger.github.io/fabric-rfcs/text/0000-admin_sdk.html).

## languages: go, java, nodejs, typescript
### [golang Documentation](https://pkg.go.dev/github.com/hyperledger/fabric-admin-sdk)
## Building and testing

### Install pre-reqs

This repository contains APIs written in Go and JavaScript. In order to build these components, the following need to be installed and available in the PATH:

- [Go 1.21+](https://go.dev/)
- [Node 18+](https://nodejs.org/)
- [Make](https://www.gnu.org/software/make/)

In order to run scenario test, [Docker](https://www.docker.com/) is also required.

#### Dev Container

This project includes a [Dev Container](https://containers.dev/) configuration that includes all of the pre-requisite software described above in a Docker container, avoiding the need to install them locally. The only requirement is that [Docker](https://www.docker.com/) is installed and available.

Opening the project folder in an IDE such as [VS Code](https://code.visualstudio.com/docs/devcontainers/containers) (with the [Dev Containers extention](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)) should offer the option of opening in the Dev Container. Alternatively, VS Code allows the remote repository to [opened directly in an isolated Dev Container](https://code.visualstudio.com/docs/devcontainers/containers#_quick-start-open-a-git-repository-or-github-pr-in-an-isolated-container-volume).

### Build using make

> **Note:** When the repository is first cloned, some mock implementations used for testing will not be present and the Go code will show compile errors. These can be generated explicitly by running `make generate`.
The following Makefile targets are available:

- `make generate` - generate mock implementations used by unit tests
- `make lint` - run linting checks for the Go code
- `make unit-test-go` - run unit tests for the Go API
- `make unit-test-node` - run unit tests for the Node API
- `make unit-test` - run unit tests for all language implementations

## History

The initial submission and implementation of fabric-admin-sdk was driven by members of the [Technical Working Group China](https://github.com/Hyperledger-TWGC) / 超级账本中国技术工作组 (TWGC):

## init by
- [davidkhala](https://github.com/davidkhala)
- [SamYuan1990](https://github.com/SamYuan1990)
- [xiaohui249](https://github.com/xiaohui249)
- [Peng-Du](https://github.com/Peng-Du)

## Contributors
<a href="https://github.com/Hyperledger/fabric-admin-sdk/graphs/contributors">
<img src="https://contributors-img.web.app/image?repo=Hyperledger/fabric-admin-sdk" />
</a>
## Contribute

### [Scenario tests and example](./test/e2e_test.go)
Here is steps in short for any contribution.

## Contribute
Here is steps in short for any contribution.
1. check license and code of conduct
1. fork this project
1. make your own feature branch
1. change and commit your changes, please use `git commit -s` to commit as we enabled [DCO](https://probot.github.io/apps/dco/)
1. raise PR

## Code of Conduct guidelines

Please review the Hyperledger [Code of
Conduct](https://wiki.hyperledger.org/community/hyperledger-project-code-of-conduct)
before participating. It is important that we keep things civil.
41 changes: 0 additions & 41 deletions scripts/gofmt.sh

This file was deleted.

8 changes: 0 additions & 8 deletions scripts/golinter.sh

This file was deleted.

0 comments on commit b0d7acf

Please sign in to comment.