feat: add scripts

Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
pull/462/head
Xinwei Xiong(cubxxw-openim) 1 year ago
parent 74b849f4bc
commit ae2369c3a9

@ -89,7 +89,7 @@ To propose PR for the Open-IM-Server item, we assume you have registered a GitHu
1. Fork the repository(Open-IM-Server)
2. **CLONE** your own repository to master locally. Use `git clone https://github.com/<your-username>/Open-IM-Server.git` to clone repository to your local machine. Then you can create new branches to finish the change you wish to make.
2. **CLONE** your own repository to main locally. Use `git clone https://github.com/<your-username>/Open-IM-Server.git` to clone repository to your local machine. Then you can create new branches to finish the change you wish to make.
3. **Set Remote** upstream to be `https://github.com/OpenIMSDK/Open-IM-Server.git` using the following two commands:

@ -42,7 +42,7 @@ Options:
PLATFORMS Platform to build for. Default is linux_arm64 and linux_amd64.
This option is available when using: make {build}.multiarch
Example: make build.multiarch PLATFORMS="linux_s390x linux_mips64
Example: make multiarch PLATFORMS="linux_s390x linux_mips64
linux_mips64le darwin_amd64 windows_amd64 linux_amd64 linux_arm64".
V Set to 1 enable verbose build. Default is 0.

@ -0,0 +1,84 @@
docs/.generated_docs
docs/guide/en-US/cmd/iam-apiserver.md
docs/guide/en-US/cmd/iam-authz-server.md
docs/guide/en-US/cmd/iam-pump.md
docs/guide/en-US/cmd/iam-watcher.md
docs/guide/en-US/cmd/iamctl/iamctl.md
docs/guide/en-US/cmd/iamctl/iamctl_color.md
docs/guide/en-US/cmd/iamctl/iamctl_completion.md
docs/guide/en-US/cmd/iamctl/iamctl_info.md
docs/guide/en-US/cmd/iamctl/iamctl_jwt.md
docs/guide/en-US/cmd/iamctl/iamctl_jwt_show.md
docs/guide/en-US/cmd/iamctl/iamctl_jwt_sign.md
docs/guide/en-US/cmd/iamctl/iamctl_jwt_verify.md
docs/guide/en-US/cmd/iamctl/iamctl_new.md
docs/guide/en-US/cmd/iamctl/iamctl_options.md
docs/guide/en-US/cmd/iamctl/iamctl_policy.md
docs/guide/en-US/cmd/iamctl/iamctl_policy_create.md
docs/guide/en-US/cmd/iamctl/iamctl_policy_delete.md
docs/guide/en-US/cmd/iamctl/iamctl_policy_get.md
docs/guide/en-US/cmd/iamctl/iamctl_policy_list.md
docs/guide/en-US/cmd/iamctl/iamctl_policy_update.md
docs/guide/en-US/cmd/iamctl/iamctl_secret.md
docs/guide/en-US/cmd/iamctl/iamctl_secret_create.md
docs/guide/en-US/cmd/iamctl/iamctl_secret_delete.md
docs/guide/en-US/cmd/iamctl/iamctl_secret_get.md
docs/guide/en-US/cmd/iamctl/iamctl_secret_list.md
docs/guide/en-US/cmd/iamctl/iamctl_secret_update.md
docs/guide/en-US/cmd/iamctl/iamctl_set.md
docs/guide/en-US/cmd/iamctl/iamctl_user.md
docs/guide/en-US/cmd/iamctl/iamctl_user_create.md
docs/guide/en-US/cmd/iamctl/iamctl_user_delete.md
docs/guide/en-US/cmd/iamctl/iamctl_user_get.md
docs/guide/en-US/cmd/iamctl/iamctl_user_list.md
docs/guide/en-US/cmd/iamctl/iamctl_user_update.md
docs/guide/en-US/cmd/iamctl/iamctl_validate.md
docs/guide/en-US/cmd/iamctl/iamctl_version.md
docs/guide/en-US/yaml/iamctl/iamctl.yaml
docs/guide/en-US/yaml/iamctl/iamctl_color.yaml
docs/guide/en-US/yaml/iamctl/iamctl_completion.yaml
docs/guide/en-US/yaml/iamctl/iamctl_info.yaml
docs/guide/en-US/yaml/iamctl/iamctl_jwt.yaml
docs/guide/en-US/yaml/iamctl/iamctl_new.yaml
docs/guide/en-US/yaml/iamctl/iamctl_options.yaml
docs/guide/en-US/yaml/iamctl/iamctl_policy.yaml
docs/guide/en-US/yaml/iamctl/iamctl_secret.yaml
docs/guide/en-US/yaml/iamctl/iamctl_set.yaml
docs/guide/en-US/yaml/iamctl/iamctl_user.yaml
docs/guide/en-US/yaml/iamctl/iamctl_validate.yaml
docs/guide/en-US/yaml/iamctl/iamctl_version.yaml
docs/man/man1/iam-apiserver.1
docs/man/man1/iam-authz-server.1
docs/man/man1/iam-pump.1
docs/man/man1/iam-watcher.1
docs/man/man1/iamctl-color.1
docs/man/man1/iamctl-completion.1
docs/man/man1/iamctl-info.1
docs/man/man1/iamctl-jwt-show.1
docs/man/man1/iamctl-jwt-sign.1
docs/man/man1/iamctl-jwt-verify.1
docs/man/man1/iamctl-jwt.1
docs/man/man1/iamctl-new.1
docs/man/man1/iamctl-options.1
docs/man/man1/iamctl-policy-create.1
docs/man/man1/iamctl-policy-delete.1
docs/man/man1/iamctl-policy-get.1
docs/man/man1/iamctl-policy-list.1
docs/man/man1/iamctl-policy-update.1
docs/man/man1/iamctl-policy.1
docs/man/man1/iamctl-secret-create.1
docs/man/man1/iamctl-secret-delete.1
docs/man/man1/iamctl-secret-get.1
docs/man/man1/iamctl-secret-list.1
docs/man/man1/iamctl-secret-update.1
docs/man/man1/iamctl-secret.1
docs/man/man1/iamctl-set.1
docs/man/man1/iamctl-user-create.1
docs/man/man1/iamctl-user-delete.1
docs/man/man1/iamctl-user-get.1
docs/man/man1/iamctl-user-list.1
docs/man/man1/iamctl-user-update.1
docs/man/man1/iamctl-user.1
docs/man/man1/iamctl-validate.1
docs/man/man1/iamctl-version.1
docs/man/man1/iamctl.1

@ -0,0 +1,30 @@
# `/scripts`
## Supported platforms
- Linux x86_64 (linux_amd64) : 64-bit Linux for most desktop and server systems.
- Windows x86_64 (windows_amd64) : 64-bit version for most Windows operating systems.
- macOS x86_64 (darwin_amd64) : 64-bit version for Apple Macintosh computers.
- Linux ARM64 (linux_arm64) : For ARM-based 64-bit Linux systems such as Raspberry Pi 4 and Jetson Nano.
- Linux s390x (linux_s390x) : 64-bit Linux for IBM System z hosts.
- Linux MIPS64 (linux_mips64) : 64-bit Linux for MIPS architecture.
- Linux MIPS64LE (linux_mips64le) : Suitable for 64-bit Linux systems with little endian MIPS architecture.
## examples
Scripts to perform various build, install, analysis, etc operations.
These scripts keep the root level Makefile small and simple.
Examples:
* https://github.com/kubernetes/helm/tree/master/scripts
* https://github.com/cockroachdb/cockroach/tree/master/scripts
* https://github.com/hashicorp/terraform/tree/master/scripts

@ -89,11 +89,22 @@ openim::build::get_docker_wrapped_binaries() {
local debian_iptables_version=v12.1.0
### If you change any of these lists, please also update DOCKERIZED_BINARIES
### in build/BUILD. And openim::golang::server_image_targets
local targets=(
"openim-apiserver,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
"openim-controller-manager,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
"openim-scheduler,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
"openim-proxy,${OPENIM_BASE_IMAGE_REGISTRY}/debian-iptables-${arch}:${debian_iptables_version}"
"openim-api,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
"openim-cmdutils,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
"openim-crontask,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
"openim-msggateway,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
"openim-msgtransfer,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
"openim-push,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
"openim-rpc-auth,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
"openim-rpc-conversation,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
"openim-rpc-friend,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
"openim-rpc-group,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
"openim-rpc-msg,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
"openim-rpc-third,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
"openim-rpc-user,${OPENIM_BASE_IMAGE_REGISTRY}/debian-base-${arch}:${debian_base_version}"
)
echo "${targets[@]}"
@ -189,7 +200,7 @@ function openim::build::prepare_docker_machine() {
local virtualbox_memory_mb=$(( available_memory_bytes / (bytes_in_mb * memory_divisor) ))
docker-machine inspect "${DOCKER_MACHINE_NAME}" &> /dev/null || {
openim::log::status "Creating a machine to build IAM"
openim::log::status "Creating a machine to build OPENIM"
docker-machine create --driver "${DOCKER_MACHINE_DRIVER}" \
--virtualbox-memory "${virtualbox_memory_mb}" \
--engine-env HTTP_PROXY="${IAMRNETES_HTTP_PROXY:-}" \
@ -503,5 +514,5 @@ function openim::build::ensure_data_container() {
# Build all openim commands.
function openim::build::build_command() {
openim::log::status "Running build command..."
make -C "${OPENIM_ROOT}" build.multiarch BINS="openimctl openim-apiserver openim-authz-server openim-pump openim-watcher"
make -C "${OPENIM_ROOT}" multiarch
}

@ -26,7 +26,7 @@
LC_ALL=C
local_branch="$(git rev-parse --abbrev-ref HEAD)"
valid_branch_regex="^(main|master|develop)$|(feature|feat|release|hotfix|test|bug|ci|style|)\/[a-z0-9._-]+$|^HEAD$"
valid_branch_regex="^(main|master|develop)$|(feature|feat|openim|release|hotfix|test|bug|ci|cicd|style|)\/[a-z0-9._-]+$|^HEAD$"
YELLOW="\e[93m"
GREEN="\e[32m"

@ -33,10 +33,20 @@ readonly OPENIM_SUPPORTED_CLIENT_PLATFORMS=(
# If you update this list, please also update build/BUILD.
openim::golang::server_targets() {
local targets=(
openim-apiserver
openim-authz-server
openim-pump
openim-watcher
openim_api
openim_cmdutils
openim_cmdutils
openim_crontask
openim_msggateway
openim_msgtransfer
openim_push
openim_rpc_auth
openim_rpc_conversation
openim_rpc_friend
openim_rpc_group
openim_rpc_msg
openim_rpc_third
openim_rpc_user
)
echo "${targets[@]}"
}
@ -137,7 +147,7 @@ openim::golang::setup_platforms
# The set of client targets that we are building for all platforms
# If you update this list, please also update build/BUILD.
readonly OPENIM_CLIENT_TARGETS=(
iamctl
imctl
)
readonly OPENIM_CLIENT_BINARIES=("${OPENIM_CLIENT_TARGETS[@]##*/}")

@ -137,12 +137,13 @@ function openim::release::package_src_tarball() {
! \( \
\( -path "${OPENIM_ROOT}"/_\* -o \
-path "${OPENIM_ROOT}"/.git\* -o \
-path "${OPENIM_ROOT}"/.github\* -o \
-path "${OPENIM_ROOT}"/.gitignore\* -o \
-path "${OPENIM_ROOT}"/.gsemver.yaml\* -o \
-path "${OPENIM_ROOT}"/.gsemver.yml\* -o \
-path "${OPENIM_ROOT}"/.config\* -o \
-path "${OPENIM_ROOT}"/.chglog\* -o \
-path "${OPENIM_ROOT}"/.gitlint -o \
-path "${OPENIM_ROOT}"/.golangci.yaml -o \
-path "${OPENIM_ROOT}"/.golangci.yml -o \
-path "${OPENIM_ROOT}"/.goreleaser.yml -o \
-path "${OPENIM_ROOT}"/.note.md -o \
-path "${OPENIM_ROOT}"/.todo.md \
@ -274,6 +275,15 @@ function openim::release::sha1() {
fi
}
function openim::release::sha256() {
if which sha256sum >/dev/null 2>&1; then
sha256sum "$1" | awk '{ print $1 }'
else
shasum -a256 "$1" | awk '{ print $1 }'
fi
}
function openim::release::build_conformance_image() {
local -r arch="$1"
local -r registry="$2"
@ -396,10 +406,19 @@ function openim::release::package_iam_manifests_tarball() {
local dst_dir="${release_stage}"
mkdir -p "${dst_dir}"
cp -r ${src_dir}/* "${dst_dir}"
#cp "${src_dir}/openim-apiserver.yaml" "${dst_dir}"
#cp "${src_dir}/openim-authz-server.yaml" "${dst_dir}"
#cp "${src_dir}/openim-pump.yaml" "${dst_dir}"
#cp "${src_dir}/openim-watcher.yaml" "${dst_dir}"
#cp "${src_dir}/openim-api.yaml" "${dst_dir}"
#cp "${src_dir}/openim_cmdutils.yaml" "${dst_dir}"
#cp "${src_dir}/openim_crontask.yaml" "${dst_dir}"
#cp "${src_dir}/openim_msggateway.yaml" "${dst_dir}"
#cp "${src_dir}/openim_msgtransfer.yaml" "${dst_dir}"
#cp "${src_dir}/openim_push.yaml" "${dst_dir}"
#cp "${src_dir}/openim_rpc_auth.yaml" "${dst_dir}"
#cp "${src_dir}/openim_rpc_conversation.yaml" "${dst_dir}"
#cp "${src_dir}/openim_rpc_friend.yaml" "${dst_dir}"
#cp "${src_dir}/openim_rpc_group.yaml" "${dst_dir}"
#cp "${src_dir}/openim_rpc_msg.yaml" "${dst_dir}"
#cp "${src_dir}/openim_rpc_third.yaml" "${dst_dir}"
#cp "${src_dir}/openim_rpc_user.yaml" "${dst_dir}"
#cp "${OPENIM_ROOT}/cluster/gce/gci/health-monitor.sh" "${dst_dir}/health-monitor.sh"
openim::release::clean_cruft
@ -603,5 +622,5 @@ function openim::release::generate_changelog() {
set +o errexit
git add ${OPENIM_ROOT}/CHANGELOG/CHANGELOG-${OPENIM_GIT_VERSION#v}.md
git commit -a -m "docs(changelog): add CHANGELOG-${OPENIM_GIT_VERSION#v}.md"
git push -f origin master # 最后将 CHANGELOG 也 push 上去
git push -f origin main # 最后将 CHANGELOG 也 push 上去
}

@ -64,7 +64,7 @@ openim::util::wait_for_url() {
return 1
}
# Example: openim::util::wait_for_success 120 5 "iamctl get nodes|grep localhost"
# Example: openim::util::wait_for_success 120 5 "imctl get nodes|grep localhost"
# arguments: wait time, sleep time, shell command
# returns 0 if the shell command get output, 1 otherwise.
openim::util::wait_for_success(){
@ -212,7 +212,7 @@ openim::util::find-binary() {
openim::util::find-binary-for-platform "$1" "$(openim::util::host_platform)"
}
# Run all known doc generators (today gendocs and genman for iamctl)
# Run all known doc generators (today gendocs and genman for imctl)
# $1 is the directory to put those generated documents
openim::util::gen-docs() {
local dest="$1"
@ -228,25 +228,42 @@ openim::util::gen-docs() {
# least from k/k tree), remove it completely.
openim::util::sourced_variable "${genfeddocs}"
mkdir -p "${dest}/docs/guide/en-US/cmd/iamctl/"
"${gendocs}" "${dest}/docs/guide/en-US/cmd/iamctl/"
mkdir -p "${dest}/docs/guide/en-US/cmd/imctl/"
"${gendocs}" "${dest}/docs/guide/en-US/cmd/imctl/"
mkdir -p "${dest}/docs/guide/en-US/cmd/"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-apiserver"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-authz-server"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-pump"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-watcher"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/iamctl" "iamctl"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_api"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_cmdutils"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_crontask"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_msggateway"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_msgtransfer"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_push"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_rpc_auth"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_rpc_conversation"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_rpc_friend"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_rpc_group"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_rpc_msg"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_rpc_third"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim_rpc_user"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/imctl" "imctl"
mkdir -p "${dest}/docs/man/man1/"
"${genman}" "${dest}/docs/man/man1/" "openim-apiserver"
"${genman}" "${dest}/docs/man/man1/" "openim-authz-server"
"${genman}" "${dest}/docs/man/man1/" "openim-pump"
"${genman}" "${dest}/docs/man/man1/" "openim-watcher"
"${genman}" "${dest}/docs/man/man1/" "iamctl"
mkdir -p "${dest}/docs/guide/en-US/yaml/iamctl/"
"${genyaml}" "${dest}/docs/guide/en-US/yaml/iamctl/"
"${genman}" "${dest}/docs/man/man1/" "openim_api"
"${genman}" "${dest}/docs/man/man1/" "openim_cmdutils"
"${genman}" "${dest}/docs/man/man1/" "openim_crontask"
"${genman}" "${dest}/docs/man/man1/" "openim_msggateway"
"${genman}" "${dest}/docs/man/man1/" "openim_msgtransfer"
"${genman}" "${dest}/docs/man/man1/" "openim_push"
"${genman}" "${dest}/docs/man/man1/" "openim_rpc_auth"
"${genman}" "${dest}/docs/man/man1/" "openim_rpc_conversation"
"${genman}" "${dest}/docs/man/man1/" "openim_rpc_friend"
"${genman}" "${dest}/docs/man/man1/" "openim_rpc_group"
"${genman}" "${dest}/docs/man/man1/" "openim_rpc_msg"
"${genman}" "${dest}/docs/man/man1/" "openim_rpc_third"
"${genman}" "${dest}/docs/man/man1/" "openim_rpc_user"
mkdir -p "${dest}/docs/guide/en-US/yaml/imctl/"
"${genyaml}" "${dest}/docs/guide/en-US/yaml/imct/"
# create the list of generated files
pushd "${dest}" > /dev/null || return 1
@ -471,7 +488,7 @@ EOF
# flatten the iamconfig files to make them self contained
username=$(whoami)
${sudo} /usr/bin/env bash -e <<EOF
$(openim::util::find-binary iamctl) --iamconfig="${dest_dir}/${client_id}.iamconfig" config view --minify --flatten > "/tmp/${client_id}.iamconfig"
$(openim::util::find-binary imct) --iamconfig="${dest_dir}/${client_id}.iamconfig" config view --minify --flatten > "/tmp/${client_id}.iamconfig"
mv -f "/tmp/${client_id}.iamconfig" "${dest_dir}/${client_id}.iamconfig"
chown ${username} "${dest_dir}/${client_id}.iamconfig"
EOF

@ -147,18 +147,18 @@ endef
# Here are some examples of builds
define MAKEFILE_EXAMPLE
# make build BINS=imctl Only a single imctl binary is built.
# make build BINS=openim_api Only a single openim_api binary is built.
# make -j (nproc) all Run tidy gen add-copyright format lint cover build concurrently.
# make gen Generate all necessary files.
# make linux.arm64 imctl is compiled on arm64 platform.
# make release Build release binaries for all platforms.
# make verify-copyright Verify the license headers for all files.
# make install-deepcopy-gen Install deepcopy-gen tools if the license is missing.
# make build BINS=imctl V=1 DEBUG=1 Build debug binaries for only imctl.
# make multiarch PLATFORMS="linux_arm64 linux_amd64" V=1 Build binaries for both platforms.
# make build BINS=openim_api V=1 DEBUG=1 Build debug binaries for only openim_api.
# make multiarch -j PLATFORMS="linux_arm64 linux_amd64" V=1 Build binaries for both platforms.
endef
export MAKEFILE_EXAMPLE
# Define all help functions @printf "\n\033[1mCurrent imctl version information: $(shell imctl version):\033[0m\n\n"
# Define all help functions @printf "\n\033[1mCurrent openim_api version information: $(shell openim_api version):\033[0m\n\n"
define makeallhelp
@printf "\n\033[1mMake example:\033[0m\n\n"
$(call MAKEFILE_EXAMPLE)

Loading…
Cancel
Save