mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-04-28 14:29:19 +08:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e33ce70d66 | |||
| 94ec6cd212 | |||
| 062aa5766e | |||
| 9cf3fcb1fc | |||
| 2e08746f3f | |||
| 08ccf7c318 | |||
| ca4bfde2aa | |||
| bc8702749f | |||
| 9e14c92933 | |||
| 0a6f10a7cc | |||
| bce5cdf746 | |||
| 18728fc993 | |||
| be6f189365 | |||
| da1316af2a | |||
| b759f8b5cc | |||
| c1f6fc4e63 |
+1
-1
@@ -15,7 +15,7 @@ CHANGELOG/
|
|||||||
# LICENSE
|
# LICENSE
|
||||||
|
|
||||||
# Ignore testing and linting configuration
|
# Ignore testing and linting configuration
|
||||||
.golangci.yml
|
scripts/golangci.yml
|
||||||
|
|
||||||
# Ignore deployment-related files
|
# Ignore deployment-related files
|
||||||
docker-compose.yaml
|
docker-compose.yaml
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ jobs:
|
|||||||
#
|
#
|
||||||
# Note: by default the `.golangci.yml` file should be at the root of the repository.
|
# Note: by default the `.golangci.yml` file should be at the root of the repository.
|
||||||
# The location of the configuration file can be changed by using `--config=`
|
# The location of the configuration file can be changed by using `--config=`
|
||||||
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0
|
args: --timeout=30m --config=/scripts/golangci.yml # --issues-exit-code=0
|
||||||
|
|
||||||
# Optional: show only new issues if it's a pull request. The default value is `false`.
|
# Optional: show only new issues if it's a pull request. The default value is `false`.
|
||||||
# only-new-issues: true
|
# only-new-issues: true
|
||||||
|
|||||||
@@ -43,9 +43,12 @@ jobs:
|
|||||||
# either 'goreleaser' (default) or 'goreleaser-pro':
|
# either 'goreleaser' (default) or 'goreleaser-pro':
|
||||||
distribution: goreleaser
|
distribution: goreleaser
|
||||||
version: latest
|
version: latest
|
||||||
args: release --clean
|
workdir: .
|
||||||
|
args: release -f ./build/goreleaser.yaml --rm-dist --clean --release-footer-tmpl=scripts/template/footer.md.tmpl --release-header-tmpl=scripts/template/head.md.tmpl
|
||||||
env:
|
env:
|
||||||
|
USERNAME: ${{ github.repository_owner }}
|
||||||
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
|
||||||
|
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
|
||||||
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro'
|
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro'
|
||||||
# distribution:
|
# distribution:
|
||||||
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
|
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
|
||||||
|
|||||||
+1
-1
@@ -26,6 +26,6 @@ WORKDIR ${SERVER_WORKDIR}
|
|||||||
# Copy scripts and binary files to the production image
|
# Copy scripts and binary files to the production image
|
||||||
COPY --from=builder ${OPENIM_SERVER_CMDDIR} /openim/openim-server/scripts
|
COPY --from=builder ${OPENIM_SERVER_CMDDIR} /openim/openim-server/scripts
|
||||||
COPY --from=builder ${SERVER_WORKDIR}/config /openim/openim-server/config
|
COPY --from=builder ${SERVER_WORKDIR}/config /openim/openim-server/config
|
||||||
COPY --from=builder ${SERVER_WORKDIR}/_output/bin/platforms /openim/openim-server/_output/bin/platforms
|
COPY --from=builder $OPENIM_SERVER_BINDIR/platforms /openim/openim-server/_output/bin/platforms
|
||||||
|
|
||||||
CMD ["bash","-c","${OPENIM_SERVER_CMDDIR}/docker_start_all.sh"]
|
CMD ["bash","-c","${OPENIM_SERVER_CMDDIR}/docker_start_all.sh"]
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ all: tidy gen add-copyright format lint cover build
|
|||||||
# Build set
|
# Build set
|
||||||
|
|
||||||
ROOT_PACKAGE=github.com/OpenIMSDK/Open-IM-Server
|
ROOT_PACKAGE=github.com/OpenIMSDK/Open-IM-Server
|
||||||
# TODO: This is version control for the future
|
# TODO: This is version control for the future https://github.com/OpenIMSDK/Open-IM-Server/issues/574
|
||||||
VERSION_PACKAGE=github.com/OpenIMSDK/Open-IM-Server/pkg/version
|
VERSION_PACKAGE=github.com/OpenIMSDK/Open-IM-Server/pkg/version
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
@@ -191,6 +191,11 @@ advertise:
|
|||||||
release: release.verify release.ensure-tag
|
release: release.verify release.ensure-tag
|
||||||
@scripts/release.sh
|
@scripts/release.sh
|
||||||
|
|
||||||
|
## demo: Run demo ✨
|
||||||
|
.PHONY: demo
|
||||||
|
demo:
|
||||||
|
@$(MAKE) go.demo
|
||||||
|
|
||||||
## help: Show this help info. ✨
|
## help: Show this help info. ✨
|
||||||
.PHONY: help
|
.PHONY: help
|
||||||
help: Makefile
|
help: Makefile
|
||||||
|
|||||||
@@ -34,13 +34,16 @@ COPY . .
|
|||||||
RUN make clean
|
RUN make clean
|
||||||
RUN make build BINS=openim-api
|
RUN make build BINS=openim-api
|
||||||
|
|
||||||
FROM ghcr.io/openim-sigs/openim-bash-image:latest
|
# FROM ghcr.io/openim-sigs/openim-bash-image:latest
|
||||||
|
FROM test:v1
|
||||||
|
|
||||||
WORKDIR /openim/openim-server
|
WORKDIR /openim/openim-server
|
||||||
|
|
||||||
COPY --from=builder /openim/openim-server/_output/bin/platforms /openim/openim-server/_output/bin/platforms
|
COPY --from=builder /openim/openim-server/_output/bin/platforms /openim/openim-server/_output/bin/platforms
|
||||||
COPY --from=builder /openim/openim-server/config /openim/openim-server/config
|
COPY --from=builder /openim/openim-server/config /openim/openim-server/config
|
||||||
|
|
||||||
EXPOSE ${10002}
|
ENV PORT 10002
|
||||||
|
|
||||||
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-api --port 10002 -c ${SERVER_WORKDIR}/config"]
|
EXPOSE ${PORT}
|
||||||
|
|
||||||
|
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-api --port ${PORT} -c ${SERVER_WORKDIR}/config"]
|
||||||
@@ -39,7 +39,7 @@ FROM ghcr.io/openim-sigs/openim-bash-image:latest
|
|||||||
|
|
||||||
WORKDIR /openim/openim-server
|
WORKDIR /openim/openim-server
|
||||||
|
|
||||||
COPY --from=builder ${SERVER_WORKDIR}/_output/bin/platforms /openim/openim-server/_output/bin/platforms
|
COPY --from=builder $OPENIM_SERVER_BINDIR/platforms /openim/openim-server/_output/bin/platforms
|
||||||
COPY --from=builder ${SERVER_WORKDIR}/config /openim/openim-server/config
|
COPY --from=builder ${SERVER_WORKDIR}/config /openim/openim-server/config
|
||||||
|
|
||||||
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-cmdutils"]
|
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-cmdutils"]
|
||||||
|
|||||||
@@ -41,4 +41,4 @@ WORKDIR /openim/openim-server
|
|||||||
COPY --from=builder /openim/openim-server/_output/bin/platforms /openim/openim-server/_output/bin/platforms
|
COPY --from=builder /openim/openim-server/_output/bin/platforms /openim/openim-server/_output/bin/platforms
|
||||||
COPY --from=builder /openim/openim-server/config /openim/openim-server/config
|
COPY --from=builder /openim/openim-server/config /openim/openim-server/config
|
||||||
|
|
||||||
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-crontask"]
|
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-crontask"]
|
||||||
|
|||||||
@@ -47,4 +47,4 @@ ENV ARCH ${ARCH}
|
|||||||
EXPOSE 10140
|
EXPOSE 10140
|
||||||
EXPOSE 10001
|
EXPOSE 10001
|
||||||
|
|
||||||
CMD ${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-msggateway --port 10140 --ws_port 10001
|
CMD ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-msggateway --port 10140 --ws_port 10001
|
||||||
@@ -44,4 +44,4 @@ WORKDIR /openim/openim-server
|
|||||||
COPY --from=builder /openim/openim-server/_output/bin/platforms /openim/openim-server/_output/bin/platforms
|
COPY --from=builder /openim/openim-server/_output/bin/platforms /openim/openim-server/_output/bin/platforms
|
||||||
COPY --from=builder /openim/openim-server/config /openim/openim-server/config
|
COPY --from=builder /openim/openim-server/config /openim/openim-server/config
|
||||||
|
|
||||||
CMD ${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-msgtransfer
|
CMD ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-msgtransfer
|
||||||
@@ -46,4 +46,4 @@ COPY --from=builder /openim/openim-server/config /openim/openim-server/config
|
|||||||
|
|
||||||
EXPOSE 10170
|
EXPOSE 10170
|
||||||
|
|
||||||
CMD ${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-push --port 10170
|
CMD ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-push --port 10170
|
||||||
@@ -49,4 +49,4 @@ COPY --from=builder /openim/openim-server/config /openim/openim-server/config
|
|||||||
|
|
||||||
EXPOSE 10160
|
EXPOSE 10160
|
||||||
|
|
||||||
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-auth --port 10160 -c ${SERVER_WORKDIR}/config"]
|
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-rpc-auth --port 10160 -c ${SERVER_WORKDIR}/config"]
|
||||||
@@ -56,4 +56,4 @@ COPY --from=builder /openim/openim-server/config /openim/openim-server/config
|
|||||||
EXPOSE 10230
|
EXPOSE 10230
|
||||||
EXPOSE 20230
|
EXPOSE 20230
|
||||||
|
|
||||||
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-conversation --port 10230 --prometheus_port 20230 -c ${SERVER_WORKDIR}/config"]
|
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-rpc-conversation --port 10230 --prometheus_port 20230 -c ${SERVER_WORKDIR}/config"]
|
||||||
@@ -56,4 +56,4 @@ COPY --from=builder /openim/openim-server/config /openim/openim-server/config
|
|||||||
EXPOSE 10120
|
EXPOSE 10120
|
||||||
EXPOSE 20120
|
EXPOSE 20120
|
||||||
|
|
||||||
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-friend --port 10120 --prometheus_port 20120 -c ${SERVER_WORKDIR}/config"]
|
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-rpc-friend --port 10120 --prometheus_port 20120 -c ${SERVER_WORKDIR}/config"]
|
||||||
@@ -56,4 +56,4 @@ COPY --from=builder /openim/openim-server/config /openim/openim-server/config
|
|||||||
EXPOSE 10150
|
EXPOSE 10150
|
||||||
EXPOSE 20150
|
EXPOSE 20150
|
||||||
|
|
||||||
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-group --port 10150 --prometheus_port 20150 -c ${SERVER_WORKDIR}/config"]
|
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-rpc-group --port 10150 --prometheus_port 20150 -c ${SERVER_WORKDIR}/config"]
|
||||||
@@ -56,4 +56,4 @@ COPY --from=builder /openim/openim-server/config /openim/openim-server/config
|
|||||||
EXPOSE 10130
|
EXPOSE 10130
|
||||||
EXPOSE 20130
|
EXPOSE 20130
|
||||||
|
|
||||||
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-msg --port 10130 --prometheus_port 20130 -c ${SERVER_WORKDIR}/config"]
|
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-rpc-msg --port 10130 --prometheus_port 20130 -c ${SERVER_WORKDIR}/config"]
|
||||||
@@ -55,4 +55,4 @@ COPY --from=builder /openim/openim-server/config /openim/openim-server/config
|
|||||||
|
|
||||||
EXPOSE 10200
|
EXPOSE 10200
|
||||||
|
|
||||||
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-third --port 10200 -c ${SERVER_WORKDIR}/config"]
|
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-rpc-third --port 10200 -c ${SERVER_WORKDIR}/config"]
|
||||||
@@ -55,4 +55,4 @@ COPY --from=builder /openim/openim-server/config /openim/openim-server/config
|
|||||||
|
|
||||||
EXPOSE 10110
|
EXPOSE 10110
|
||||||
|
|
||||||
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-user --port 10110 -c ${SERVER_WORKDIR}/config"]
|
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-rpc-user --port 10110 -c ${SERVER_WORKDIR}/config"]
|
||||||
@@ -479,53 +479,4 @@ checksum:
|
|||||||
algorithm: sha256
|
algorithm: sha256
|
||||||
|
|
||||||
release:
|
release:
|
||||||
|
prerelease: auto
|
||||||
prerelease: auto
|
|
||||||
|
|
||||||
footer: |
|
|
||||||
|
|
||||||
## Welcome to the {{ .Tag }} release of [chat](https://github.com/OpenIMSDK/chat)!🎉🎉!
|
|
||||||
|
|
||||||
**Full Changelog**: https://github.com/OpenIMSDK/Open-IM-Server/compare/{{ .PreviousTag }}...{{ .Tag }}
|
|
||||||
|
|
||||||
## Helping out
|
|
||||||
|
|
||||||
+ We release logs are recorded on [✨CHANGELOG](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/CHANGELOG/CHANGELOG.md)
|
|
||||||
|
|
||||||
+ For information on versions of OpenIM and how to maintain branches, read [📚this article](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/version.md)
|
|
||||||
|
|
||||||
+ If you wish to use mirroring, read OpenIM's [image management policy](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/images.md)
|
|
||||||
|
|
||||||
**Want to be one of them 😘?**
|
|
||||||
|
|
||||||
<p align="center">
|
|
||||||
<a href="https://github.com/kubbot" style="float: left; margin-right: 10px;">
|
|
||||||
<img src="https://github.com/openimbot/openimbot/blob/main/assets/icon/blue%E9%80%8F%E6%98%8E.png" width="50" height="50" />
|
|
||||||
</a>
|
|
||||||
<a href="https://www.openim.online">
|
|
||||||
<img src="https://github.com/OpenIMSDK/Open-IM-Server/blob/main/assets/logo/openim-logo.png" />
|
|
||||||
</a>
|
|
||||||
<a href="https://github.com/openimbot" style="float: right; margin-left: 10px;">
|
|
||||||
<img src="https://github.com/openimbot/openimbot/blob/main/assets/icon/red%E9%80%8F%E6%98%8E.png" width="50" height="50" />
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
> **Note**
|
|
||||||
> @openimbot and @kubbot have made great contributions to the community as community 🤖robots(@openimsdk/bot), respectively.
|
|
||||||
> Thanks to the @openimsdk/openim team for all their hard work on this release.
|
|
||||||
> Thank you to all the [💕developers and contributors](https://github.com/OpenIMSDK/Open-IM-Server/graphs/contributors), people from all over the world, OpenIM brings us together
|
|
||||||
> Contributions to this project are welcome! Please see [CONTRIBUTING.md](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/CONTRIBUTING.md) for details.
|
|
||||||
|
|
||||||
## Get Involved with OpenIM!
|
|
||||||
|
|
||||||
**Here are some ways to get involved with the OpenIM community:**
|
|
||||||
|
|
||||||
📢 **Slack Channel**: Join our Slack channels for discussions, communication, and support. Click [here](https://join.slack.com/t/openimsdk/shared_invite/zt-1tmoj26uf-_FDy3dowVHBiGvLk9e5Xkg) to join the Open-IM-Server Slack team channel.
|
|
||||||
|
|
||||||
📧 **Gmail Contact**: If you have any questions, suggestions, or feedback for our open-source projects, please feel free to [contact us via email](https://mail.google.com/mail/?view=cm&fs=1&tf=1&to=winxu81@gmail.com).
|
|
||||||
|
|
||||||
📖 **Blog**: Stay up-to-date with OpenIM-Server projects and trends by reading our [blog](https://doc.rentsoft.cn/). We share the latest developments, tech trends, and other interesting information related to OpenIM.
|
|
||||||
|
|
||||||
📱 **WeChat**: Add us on WeChat (QR Code) and indicate that you are a user or developer of Open-IM-Server. We'll process your request as soon as possible.
|
|
||||||
|
|
||||||
Remember, your contributions play a vital role in making OpenIM successful, and we look forward to your active participation in our community! 🙌
|
|
||||||
+1
-1
@@ -77,7 +77,7 @@ logs/* @skiffer-git @FGadvancer
|
|||||||
pkg/a2r @openimsdk/openim @skiffer-git @cubxxw @openimsdk/bot
|
pkg/a2r @openimsdk/openim @skiffer-git @cubxxw @openimsdk/bot
|
||||||
|
|
||||||
# scripts directory
|
# scripts directory
|
||||||
scripts/LICENSE/* @openimsdk/openim @cubxxw @skiffer-git @FGadvancer
|
scripts/template/* @openimsdk/openim @cubxxw @skiffer-git @FGadvancer
|
||||||
scripts/enterprise/* @openimsdk/openim @FGadvancer @cubxxw @skiffer-git @openimsdk/bot
|
scripts/enterprise/* @openimsdk/openim @FGadvancer @cubxxw @skiffer-git @openimsdk/bot
|
||||||
scripts/githooks/* @openimsdk/openim @cubxxw @skiffer-git @FGadvancer
|
scripts/githooks/* @openimsdk/openim @cubxxw @skiffer-git @FGadvancer
|
||||||
scripts/lib/* @openimsdk/openim @FGadvancer @cubxxw @skiffer-git @openimsdk/bot
|
scripts/lib/* @openimsdk/openim @FGadvancer @cubxxw @skiffer-git @openimsdk/bot
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
go 1.20
|
go 1.20
|
||||||
|
|
||||||
use (
|
use (
|
||||||
.
|
.
|
||||||
|
./tools/changelog
|
||||||
./tools/infra
|
./tools/infra
|
||||||
./tools/ncpu
|
./tools/ncpu
|
||||||
|
./tools/yamlfmt
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ func (u *UserApi) GetUsersOnlineStatus(c *gin.Context) {
|
|||||||
log.ZWarn(c, "GetUsersOnlineStatus rpc err", err)
|
log.ZWarn(c, "GetUsersOnlineStatus rpc err", err)
|
||||||
|
|
||||||
parseError := apiresp.ParseError(err)
|
parseError := apiresp.ParseError(err)
|
||||||
log.ZDebug(c, "errcode bantanger", "errcode", parseError.ErrCode)
|
|
||||||
if parseError.ErrCode == errs.NoPermissionError {
|
if parseError.ErrCode == errs.NoPermissionError {
|
||||||
apiresp.GinError(c, err)
|
apiresp.GinError(c, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package apistruct // import "github.com/OpenIMSDK/Open-IM-Server/pkg/apistruct"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package authverify // import "github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package callbackstruct // import "github.com/OpenIMSDK/Open-IM-Server/pkg/callbackstruct"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package cmd // import "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package config // import "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package convert // import "github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
|
||||||
Vendored
+15
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package cache // import "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package controller // import "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
|
||||||
@@ -52,7 +52,7 @@ type UserDatabase interface {
|
|||||||
CountTotal(ctx context.Context, before *time.Time) (int64, error)
|
CountTotal(ctx context.Context, before *time.Time) (int64, error)
|
||||||
// CountRangeEverydayTotal Get the user increment in the range
|
// CountRangeEverydayTotal Get the user increment in the range
|
||||||
CountRangeEverydayTotal(ctx context.Context, start time.Time, end time.Time) (map[string]int64, error)
|
CountRangeEverydayTotal(ctx context.Context, start time.Time, end time.Time) (map[string]int64, error)
|
||||||
//SubscribeUsersStatus Subscribe a user's presence status
|
// SubscribeUsersStatus Subscribe a user's presence status
|
||||||
SubscribeUsersStatus(ctx context.Context, userID string, userIDs []string) error
|
SubscribeUsersStatus(ctx context.Context, userID string, userIDs []string) error
|
||||||
// UnsubscribeUsersStatus unsubscribe a user's presence status
|
// UnsubscribeUsersStatus unsubscribe a user's presence status
|
||||||
UnsubscribeUsersStatus(ctx context.Context, userID string, userIDs []string) error
|
UnsubscribeUsersStatus(ctx context.Context, userID string, userIDs []string) error
|
||||||
@@ -179,13 +179,13 @@ func (u *userDatabase) CountRangeEverydayTotal(ctx context.Context, start time.T
|
|||||||
return u.userDB.CountRangeEverydayTotal(ctx, start, end)
|
return u.userDB.CountRangeEverydayTotal(ctx, start, end)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SubscribeUsersStatus Subscribe or unsubscribe a user's presence status
|
// SubscribeUsersStatus Subscribe or unsubscribe a user's presence status.
|
||||||
func (u *userDatabase) SubscribeUsersStatus(ctx context.Context, userID string, userIDs []string) error {
|
func (u *userDatabase) SubscribeUsersStatus(ctx context.Context, userID string, userIDs []string) error {
|
||||||
err := u.mongoDB.AddSubscriptionList(ctx, userID, userIDs)
|
err := u.mongoDB.AddSubscriptionList(ctx, userID, userIDs)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnsubscribeUsersStatus unsubscribe a user's presence status
|
// UnsubscribeUsersStatus unsubscribe a user's presence status.
|
||||||
func (u *userDatabase) UnsubscribeUsersStatus(ctx context.Context, userID string, userIDs []string) error {
|
func (u *userDatabase) UnsubscribeUsersStatus(ctx context.Context, userID string, userIDs []string) error {
|
||||||
err := u.mongoDB.UnsubscriptionList(ctx, userID, userIDs)
|
err := u.mongoDB.UnsubscriptionList(ctx, userID, userIDs)
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package localcache // import "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/localcache"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package relation // import "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package cont // import "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/cont"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package cos // import "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/cos"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package s3 // import "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package minio // import "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/minio"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package oss // import "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/oss"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package relation // import "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package unrelation // import "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package unrelation // import "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation"
|
||||||
@@ -16,6 +16,7 @@ package unrelation
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
||||||
"github.com/OpenIMSDK/tools/errs"
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
"github.com/OpenIMSDK/tools/utils"
|
"github.com/OpenIMSDK/tools/utils"
|
||||||
@@ -153,7 +154,7 @@ func (u *UserMongoDriver) RemoveSubscribedListFromUser(ctx context.Context, user
|
|||||||
return errs.Wrap(err)
|
return errs.Wrap(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAllSubscribeList Get all users subscribed by this user
|
// GetAllSubscribeList Get all users subscribed by this user.
|
||||||
func (u *UserMongoDriver) GetAllSubscribeList(ctx context.Context, userID string) (userIDList []string, err error) {
|
func (u *UserMongoDriver) GetAllSubscribeList(ctx context.Context, userID string) (userIDList []string, err error) {
|
||||||
var user unrelation.UserModel
|
var user unrelation.UserModel
|
||||||
cursor := u.userCollection.FindOne(
|
cursor := u.userCollection.FindOne(
|
||||||
@@ -166,7 +167,7 @@ func (u *UserMongoDriver) GetAllSubscribeList(ctx context.Context, userID string
|
|||||||
return user.UserIDList, nil
|
return user.UserIDList, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSubscribedList Get the user subscribed by those users
|
// GetSubscribedList Get the user subscribed by those users.
|
||||||
func (u *UserMongoDriver) GetSubscribedList(ctx context.Context, userID string) (userIDList []string, err error) {
|
func (u *UserMongoDriver) GetSubscribedList(ctx context.Context, userID string) (userIDList []string, err error) {
|
||||||
var user unrelation.UserModel
|
var user unrelation.UserModel
|
||||||
cursor := u.userCollection.FindOne(
|
cursor := u.userCollection.FindOne(
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package http // import "github.com/OpenIMSDK/Open-IM-Server/pkg/common/http"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package kafka // import "github.com/OpenIMSDK/Open-IM-Server/pkg/common/kafka"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package locker // import "github.com/OpenIMSDK/Open-IM-Server/pkg/common/locker"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package prome // import "github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package startrpc // import "github.com/OpenIMSDK/Open-IM-Server/pkg/common/startrpc"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package msgprocessor // import "github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package rpcclient // import "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package notification // import "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package statistics // import "github.com/OpenIMSDK/Open-IM-Server/pkg/statistics"
|
||||||
+31
-1
@@ -84,7 +84,37 @@ Each directory and script in the structure should be understood as a part of a l
|
|||||||
|
|
||||||
- Linux MIPS64LE (linux_mips64le) : Suitable for 64-bit Linux systems with little endian MIPS architecture.
|
- Linux MIPS64LE (linux_mips64le) : Suitable for 64-bit Linux systems with little endian MIPS architecture.
|
||||||
|
|
||||||
|
## Get started quickly - demo.sh
|
||||||
|
|
||||||
|
Is the `demo.sh` script teaching you how to quickly get started with OpenIM development and use
|
||||||
|
|
||||||
|
|
||||||
|
Steps to run demo:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
make demo
|
||||||
|
```
|
||||||
|
|
||||||
|
Instructions for producing the demo movie:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Create temporary directory
|
||||||
|
mkdir /tmp/kb-demo
|
||||||
|
cd /tmp/kb-demo
|
||||||
|
|
||||||
|
asciinema rec
|
||||||
|
<path-to-KB-repo>/scripts/demo/run.sh
|
||||||
|
|
||||||
|
<CTRL-C> to terminate the script
|
||||||
|
<CTRL-D> to terminate the asciinema recording
|
||||||
|
<CTRL-C> to save the recording locally
|
||||||
|
|
||||||
|
# Edit the recorded file by editing the controller-gen path
|
||||||
|
# Once you are happy with the recording, use svg-term program to generate the svg
|
||||||
|
|
||||||
|
svg-term --cast=<movie-id> --out _output/demo.svg --window
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## examples
|
## examples
|
||||||
Scripts to perform various build, install, analysis, etc operations.
|
Scripts to perform various build, install, analysis, etc operations.
|
||||||
|
|||||||
+3
-18
@@ -17,6 +17,8 @@
|
|||||||
set -e
|
set -e
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
|
. $(dirname ${BASH_SOURCE})/lib/init.sh
|
||||||
|
|
||||||
trap 'echo "Script interrupted."; exit 1' INT
|
trap 'echo "Script interrupted."; exit 1' INT
|
||||||
|
|
||||||
# Function for colored echo
|
# Function for colored echo
|
||||||
@@ -26,24 +28,6 @@ function color_echo() {
|
|||||||
echo -e "${COLOR}===> $* ${COLOR_SUFFIX}"
|
echo -e "${COLOR}===> $* ${COLOR_SUFFIX}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Color definitions
|
|
||||||
function openim_color() {
|
|
||||||
COLOR_SUFFIX="\033[0m" # End all colors and special effects
|
|
||||||
|
|
||||||
BLACK_PREFIX="\033[30m" # Black prefix
|
|
||||||
RED_PREFIX="\033[31m" # Red prefix
|
|
||||||
GREEN_PREFIX="\033[32m" # Green prefix
|
|
||||||
YELLOW_PREFIX="\033[33m" # Yellow prefix
|
|
||||||
BLUE_PREFIX="\033[34m" # Blue prefix
|
|
||||||
SKY_BLUE_PREFIX="\033[36m" # Sky blue prefix
|
|
||||||
WHITE_PREFIX="\033[37m" # White prefix
|
|
||||||
BOLD_PREFIX="\033[1m" # Bold prefix
|
|
||||||
UNDERLINE_PREFIX="\033[4m" # Underline prefix
|
|
||||||
ITALIC_PREFIX="\033[3m" # Italic prefix
|
|
||||||
|
|
||||||
CYAN_PREFIX="\033[0;36m" # Cyan prefix
|
|
||||||
}
|
|
||||||
|
|
||||||
function print_with_delay() {
|
function print_with_delay() {
|
||||||
text="$1"
|
text="$1"
|
||||||
delay="$2"
|
delay="$2"
|
||||||
@@ -68,6 +52,7 @@ function print_progress() {
|
|||||||
done
|
done
|
||||||
printf "]${COLOR_SUFFIX}\n"
|
printf "]${COLOR_SUFFIX}\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
function openim_logo() {
|
function openim_logo() {
|
||||||
# Set text color to cyan for header and URL
|
# Set text color to cyan for header and URL
|
||||||
echo -e "\033[0;36m"
|
echo -e "\033[0;36m"
|
||||||
|
|||||||
@@ -21,9 +21,8 @@ SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|||||||
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||||
|
|
||||||
#Include shell font styles and some basic information
|
#Include shell font styles and some basic information
|
||||||
source $SCRIPTS_ROOT/style_info.sh
|
source $SCRIPTS_ROOT/lib/init.sh
|
||||||
source $SCRIPTS_ROOT/path_info.sh
|
source $SCRIPTS_ROOT/path_info.sh
|
||||||
source $SCRIPTS_ROOT/function.sh
|
|
||||||
|
|
||||||
cd $SCRIPTS_ROOT
|
cd $SCRIPTS_ROOT
|
||||||
|
|
||||||
|
|||||||
@@ -19,21 +19,8 @@ SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|||||||
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||||
|
|
||||||
#Include shell font styles and some basic information
|
#Include shell font styles and some basic information
|
||||||
source $SCRIPTS_ROOT/style_info.sh
|
|
||||||
source $SCRIPTS_ROOT/path_info.sh
|
source $SCRIPTS_ROOT/path_info.sh
|
||||||
source $SCRIPTS_ROOT/function.sh
|
source $SCRIPTS_ROOT/lib/init.sh
|
||||||
|
|
||||||
echo -e "${YELLOW_PREFIX}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
|
|
||||||
echo -e "${YELLOW_PREFIX}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
|
|
||||||
echo -e "${YELLOW_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}"
|
|
||||||
|
|
||||||
echo -e ""
|
|
||||||
|
|
||||||
echo -e "${BACKGROUND_BLUE}===============> Building all using make build binary files ${COLOR_SUFFIX}"
|
|
||||||
|
|
||||||
echo -e ""
|
|
||||||
echo -e "${BOLD_PREFIX}____________________________________________________________ ${COLOR_SUFFIX}"
|
|
||||||
|
|
||||||
|
|
||||||
bin_dir="$BIN_DIR"
|
bin_dir="$BIN_DIR"
|
||||||
logs_dir="$OPENIM_ROOT/logs"
|
logs_dir="$OPENIM_ROOT/logs"
|
||||||
@@ -68,43 +55,7 @@ if [ $? -ne 0 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get the current operating system and architecture
|
openim::util::gen_os_arch
|
||||||
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
|
||||||
ARCH=$(uname -m)
|
|
||||||
|
|
||||||
# Select the repository home directory based on the operating system and architecture
|
|
||||||
if [[ "$OS" == "darwin" ]]; then
|
|
||||||
if [[ "$ARCH" == "x86_64" ]]; then
|
|
||||||
REPO_DIR="darwin/amd64"
|
|
||||||
else
|
|
||||||
REPO_DIR="darwin/386"
|
|
||||||
fi
|
|
||||||
elif [[ "$OS" == "linux" ]]; then
|
|
||||||
if [[ "$ARCH" == "x86_64" ]]; then
|
|
||||||
REPO_DIR="linux/amd64"
|
|
||||||
elif [[ "$ARCH" == "arm64" ]]; then
|
|
||||||
REPO_DIR="linux/arm64"
|
|
||||||
elif [[ "$ARCH" == "mips64" ]]; then
|
|
||||||
REPO_DIR="linux/mips64"
|
|
||||||
elif [[ "$ARCH" == "mips64le" ]]; then
|
|
||||||
REPO_DIR="linux/mips64le"
|
|
||||||
elif [[ "$ARCH" == "ppc64le" ]]; then
|
|
||||||
REPO_DIR="linux/ppc64le"
|
|
||||||
elif [[ "$ARCH" == "s390x" ]]; then
|
|
||||||
REPO_DIR="linux/s390x"
|
|
||||||
else
|
|
||||||
REPO_DIR="linux/386"
|
|
||||||
fi
|
|
||||||
elif [[ "$OS" == "windows" ]]; then
|
|
||||||
if [[ "$ARCH" == "x86_64" ]]; then
|
|
||||||
REPO_DIR="windows/amd64"
|
|
||||||
else
|
|
||||||
REPO_DIR="windows/386"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo -e "${RED_PREFIX}Unsupported OS: $OS${COLOR_SUFFIX}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Determine if all scripts were successfully built
|
# Determine if all scripts were successfully built
|
||||||
BUILD_SUCCESS=true
|
BUILD_SUCCESS=true
|
||||||
|
|||||||
@@ -18,9 +18,8 @@ SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|||||||
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||||
|
|
||||||
#Include shell font styles and some basic information
|
#Include shell font styles and some basic information
|
||||||
source $SCRIPTS_ROOT/style_info.sh
|
source $SCRIPTS_ROOT/lib/init.sh
|
||||||
source $SCRIPTS_ROOT/path_info.sh
|
source $SCRIPTS_ROOT/path_info.sh
|
||||||
source $SCRIPTS_ROOT/function.sh
|
|
||||||
|
|
||||||
cd $SCRIPTS_ROOT
|
cd $SCRIPTS_ROOT
|
||||||
|
|
||||||
@@ -43,7 +42,7 @@ service_port_name=(
|
|||||||
)
|
)
|
||||||
for i in ${service_port_name[*]}; do
|
for i in ${service_port_name[*]}; do
|
||||||
list=$(cat $config_path | grep -w ${i} | awk -F '[:]' '{print $NF}')
|
list=$(cat $config_path | grep -w ${i} | awk -F '[:]' '{print $NF}')
|
||||||
list_to_string $list
|
openim::util::list-to-string $list
|
||||||
for j in ${ports_array}; do
|
for j in ${ports_array}; do
|
||||||
port=$(ss -tunlp| grep openim | awk '{print $5}' | grep -w ${j} | awk -F '[:]' '{print $NF}')
|
port=$(ss -tunlp| grep openim | awk '{print $5}' | grep -w ${j} | awk -F '[:]' '{print $NF}')
|
||||||
if [[ ${port} -ne ${j} ]]; then
|
if [[ ${port} -ne ${j} ]]; then
|
||||||
|
|||||||
Executable
+83
@@ -0,0 +1,83 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
clear
|
||||||
|
. $(dirname ${BASH_SOURCE})/lib/util.sh
|
||||||
|
|
||||||
|
openim::util::desc "========> Welcome to the OpenIM Demo"
|
||||||
|
openim::util::desc "========> We'll help you get started with OpenIM quickly"
|
||||||
|
openim::util::desc "========> Press Enter to continue...."
|
||||||
|
openim::util::run "make advertise"
|
||||||
|
clear
|
||||||
|
|
||||||
|
openim::util::desc "You can learn a lot about automation using make help"
|
||||||
|
openim::util::run "make help"
|
||||||
|
clear
|
||||||
|
|
||||||
|
openim::util::desc "You can learn a lot about automation using make help-all"
|
||||||
|
openim::util::run "make help-all"
|
||||||
|
clear
|
||||||
|
|
||||||
|
openim::util::desc "How did we teach you how to build OpenIM"
|
||||||
|
openim::util::desc "A full build startup check"
|
||||||
|
openim::util::run "make all"
|
||||||
|
|
||||||
|
openim::util::desc "Build one OpenIM binary"
|
||||||
|
openim::util::desc "BINS: openim-api openim-cmdutils openim-crontask openim-msggateway openim-msgtransfer openim-push openim-rpc changelog infra ncpu yamlfmt"
|
||||||
|
openim::util::run "make build BINS=openim-api"
|
||||||
|
|
||||||
|
openim::util::desc "Build binaries for all platforms"
|
||||||
|
openim::util::run "make multiarch -j BINS=openim-api PLATFORMS='linux_arm64 linux_amd64' "
|
||||||
|
|
||||||
|
openim::util::desc "If you wish to use dlv for debugging, either binary or process"
|
||||||
|
openim::util::desc "You need to enable debug mode"
|
||||||
|
openim::util::run "make build BINS=openim-api DEBUG=1"
|
||||||
|
clear
|
||||||
|
|
||||||
|
openim::util::desc "Run tidy to format and fix imports"
|
||||||
|
openim::util::run "make tidy"
|
||||||
|
clear
|
||||||
|
|
||||||
|
openim::util::desc "Vendor go.mod dependencies"
|
||||||
|
openim::util::run "make vendor"
|
||||||
|
clear
|
||||||
|
|
||||||
|
openim::util::desc "Run unit tests"
|
||||||
|
openim::util::run "make test"
|
||||||
|
clear
|
||||||
|
|
||||||
|
openim::util::desc "Run unit tests and get test coverage"
|
||||||
|
openim::util::run "make cover"
|
||||||
|
clear
|
||||||
|
|
||||||
|
openim::util::desc "Check for updates to go.mod dependencies"
|
||||||
|
openim::util::run "make updates"
|
||||||
|
clear
|
||||||
|
|
||||||
|
openim::util::desc "Clean all generated files"
|
||||||
|
openim::util::run "make clean"
|
||||||
|
clear
|
||||||
|
|
||||||
|
openim::util::desc "Generate all necessary files"
|
||||||
|
openim::util::run "make gen"
|
||||||
|
clear
|
||||||
|
|
||||||
|
openim::util::desc "Verify the license headers for all files"
|
||||||
|
openim::util::run "make verify-copyright"
|
||||||
|
clear
|
||||||
|
|
||||||
|
openim::util::desc "Add copyright"
|
||||||
|
openim::util::run "make add-copyright"
|
||||||
|
clear
|
||||||
@@ -18,9 +18,8 @@ SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|||||||
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||||
|
|
||||||
#Include shell font styles and some basic information
|
#Include shell font styles and some basic information
|
||||||
source $SCRIPTS_ROOT/style_info.sh
|
source $SCRIPTS_ROOT/lib/init.sh
|
||||||
source $SCRIPTS_ROOT/path_info.sh
|
source $SCRIPTS_ROOT/path_info.sh
|
||||||
source $SCRIPTS_ROOT/function.sh
|
|
||||||
|
|
||||||
cd $SCRIPTS_ROOT
|
cd $SCRIPTS_ROOT
|
||||||
|
|
||||||
@@ -38,7 +37,7 @@ service_port_name=(
|
|||||||
|
|
||||||
for i in ${service_port_name[*]}; do
|
for i in ${service_port_name[*]}; do
|
||||||
list=$(cat $config_path | grep -w ${i} | awk -F '[:]' '{print $NF}')
|
list=$(cat $config_path | grep -w ${i} | awk -F '[:]' '{print $NF}')
|
||||||
list_to_string $list
|
openim::util::list-to-string $list
|
||||||
for j in ${ports_array}; do
|
for j in ${ports_array}; do
|
||||||
port=$(ss -tunlp| grep openim | awk '{print $5}' | grep -w ${j} | awk -F '[:]' '{print $NF}')
|
port=$(ss -tunlp| grep openim | awk '{print $5}' | grep -w ${j} | awk -F '[:]' '{print $NF}')
|
||||||
if [[ ${port} -ne ${j} ]]; then
|
if [[ ${port} -ne ${j} ]]; then
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#input:[10023,2323,3434]
|
#input:[10023,2323,3434]
|
||||||
#output:10023 2323 3434
|
#output:10023 2323 3434
|
||||||
list_to_string(){
|
openim::util::list-to-string(){
|
||||||
ports_list=$*
|
ports_list=$*
|
||||||
sub_s1=`echo $ports_list | sed 's/ //g'`
|
sub_s1=`echo $ports_list | sed 's/ //g'`
|
||||||
sub_s2=${sub_s1//,/ }
|
sub_s2=${sub_s1//,/ }
|
||||||
@@ -23,7 +23,7 @@ list_to_string(){
|
|||||||
sub_s4=${sub_s3%]*}
|
sub_s4=${sub_s3%]*}
|
||||||
ports_array=$sub_s4
|
ports_array=$sub_s4
|
||||||
}
|
}
|
||||||
remove_space(){
|
openim::util::remove_space(){
|
||||||
value=$*
|
value=$*
|
||||||
result=`echo $value | sed 's/ //g'`
|
result=`echo $value | sed 's/ //g'`
|
||||||
}
|
}
|
||||||
@@ -19,9 +19,8 @@ SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|||||||
OPENIM_ROOT=$(dirname "${SCRIPTS_ROOT}")/..
|
OPENIM_ROOT=$(dirname "${SCRIPTS_ROOT}")/..
|
||||||
|
|
||||||
#Include shell font styles and some basic information
|
#Include shell font styles and some basic information
|
||||||
source $SCRIPTS_ROOT/style_info.sh
|
|
||||||
source $SCRIPTS_ROOT/path_info.sh
|
source $SCRIPTS_ROOT/path_info.sh
|
||||||
source $SCRIPTS_ROOT/function.sh
|
source $SCRIPTS_ROOT/lib/init.sh
|
||||||
|
|
||||||
cd $SCRIPTS_ROOT
|
cd $SCRIPTS_ROOT
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Copyright © 2023 OpenIM. All rights reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
# input: [10023, 2323, 3434]
|
|
||||||
# output: 10023 2323 3434
|
|
||||||
|
|
||||||
# 函数功能:将列表转换为字符串,去除空格和括号
|
|
||||||
list_to_string() {
|
|
||||||
ports_list=$* # 获取传入的参数列表
|
|
||||||
sub_s1=$(echo $ports_list | sed 's/ //g') # 去除空格
|
|
||||||
sub_s2=${sub_s1//,/ } # 将逗号替换为空格
|
|
||||||
sub_s3=${sub_s2#*[} # 去除左括号及其之前的内容
|
|
||||||
sub_s4=${sub_s3%]*} # 去除右括号及其之后的内容
|
|
||||||
ports_array=$sub_s4 # 将处理后的字符串赋值给变量 ports_array
|
|
||||||
}
|
|
||||||
|
|
||||||
# 函数功能:去除字符串中的空格
|
|
||||||
remove_space() {
|
|
||||||
value=$* # 获取传入的参数
|
|
||||||
result=$(echo $value | sed 's/ //g') # 去除空格
|
|
||||||
}
|
|
||||||
Executable
+73
@@ -0,0 +1,73 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
# Script to generate docs from the latest swagger spec.
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
# The root of the build/dist directory
|
||||||
|
OPENIM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
|
||||||
|
source ${OPENIM_ROOT}/scripts/lib/util.sh
|
||||||
|
|
||||||
|
mkdir -p ${OPENIM_OUTPUT_TMP}
|
||||||
|
cd ${OPENIM_OUTPUT_TMP}
|
||||||
|
|
||||||
|
# gendocs takes "input.json" as the input swagger spec.
|
||||||
|
# $1 is expected to be <group>_<version>
|
||||||
|
cp ${OPENIM_OUTPUT_TMP}/swagger-source/"$1".json ${OPENIM_OUTPUT_TMP}/input.json
|
||||||
|
|
||||||
|
./gradle-2.5/bin/gradle gendocs --info
|
||||||
|
|
||||||
|
#insert a TOC for top level API objects
|
||||||
|
buf="== Top Level API Objects\n\n"
|
||||||
|
top_level_models=$(grep '&[A-Za-z]*{},' /register.go | sed 's/.*&//;s/{},//')
|
||||||
|
|
||||||
|
# check if the top level models exist in the definitions.adoc. If they exist,
|
||||||
|
# their name will be <version>.<model_name>
|
||||||
|
VERSION="${1#*_}"
|
||||||
|
for m in ${top_level_models}
|
||||||
|
do
|
||||||
|
if grep -xq "=== ${VERSION}.${m}" ./definitions.adoc
|
||||||
|
then
|
||||||
|
buf+="* <<${VERSION}.${m}>>\n"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
sed -i "1i ${buf}" ./definitions.adoc
|
||||||
|
|
||||||
|
# fix the links in .adoc, replace <<x.y>> with link:definitions.html#_x_y[x.y], and lowercase the _x_y part
|
||||||
|
sed -i -e 's|<<\(.*\)\.\(.*\)>>|link:#_\L\1_\2\E[\1.\2]|g' ./definitions.adoc
|
||||||
|
sed -i -e 's|<<\(.*\)\.\(.*\)>>|link:../definitions#_\L\1_\2\E[\1.\2]|g' ./paths.adoc
|
||||||
|
|
||||||
|
# fix the link to <<any>>
|
||||||
|
sed -i -e 's|<<any>>|link:#_any[any]|g' ./definitions.adoc
|
||||||
|
sed -i -e 's|<<any>>|link:../definitions#_any[any]|g' ./paths.adoc
|
||||||
|
|
||||||
|
# change the title of paths.adoc from "paths" to "operations"
|
||||||
|
sed -i 's|== Paths|== Operations|g' ./paths.adoc
|
||||||
|
|
||||||
|
# $$ has special meaning in asciidoc, we need to escape it
|
||||||
|
sed -i 's|\$\$|+++$$+++|g' ./definitions.adoc
|
||||||
|
|
||||||
|
echo -e "=== any\nRepresents an untyped JSON map - see the description of the field for more info about the structure of this object." >> ./definitions.adoc
|
||||||
|
|
||||||
|
asciidoctor definitions.adoc
|
||||||
|
asciidoctor paths.adoc
|
||||||
|
|
||||||
|
cp ${OPENIM_OUTPUT_TMP}/definitions.html ${OPENIM_OUTPUT_TMP}/_output/
|
||||||
|
cp ${OPENIM_OUTPUT_TMP}/paths.html ${OPENIM_OUTPUT_TMP}/_output/operations.html
|
||||||
|
|
||||||
|
success "SUCCESS"
|
||||||
@@ -5,17 +5,17 @@
|
|||||||
# license that can be found in the LICENSE file.
|
# license that can be found in the LICENSE file.
|
||||||
|
|
||||||
# 本脚本功能:根据 scripts/environment.sh 配置,生成 OPENIM 组件 YAML 配置文件。
|
# 本脚本功能:根据 scripts/environment.sh 配置,生成 OPENIM 组件 YAML 配置文件。
|
||||||
# 示例:genconfig.sh scripts/environment.sh configs/openim-apiserver.yaml
|
# 示例:genconfig.sh scripts/environment.sh configs/openim-api.yaml
|
||||||
|
|
||||||
|
# Path to the original script file
|
||||||
env_file="$1"
|
env_file="$1"
|
||||||
|
# Path to the generated config file
|
||||||
template_file="$2"
|
template_file="$2"
|
||||||
|
|
||||||
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
. $(dirname ${BASH_SOURCE})/lib/init.sh
|
||||||
|
|
||||||
source "${OPENIM_ROOT}/scripts/lib/init.sh"
|
|
||||||
|
|
||||||
if [ $# -ne 2 ];then
|
if [ $# -ne 2 ];then
|
||||||
openim::log::error "Usage: genconfig.sh scripts/environment.sh configs/openim-apiserver.yaml"
|
openim::log::error "Usage: genconfig.sh scripts/environment.sh configs/openim-api.yaml"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Executable
+37
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
# Iterates over two directories: 'pkg' and 'internal/pkg'.
|
||||||
|
for top in pkg internal/pkg tools
|
||||||
|
do
|
||||||
|
# Finds all subdirectories (including nested ones) under the current directory in the iteration ('pkg' or 'internal/pkg').
|
||||||
|
for d in $(find $top -type d)
|
||||||
|
do
|
||||||
|
# Checks if 'doc.go' doesn't exist in the current subdirectory.
|
||||||
|
if [ ! -f $d/doc.go ]; then
|
||||||
|
# Checks if there are any '.go' files in the current subdirectory.
|
||||||
|
if ls $d/*.go > /dev/null 2>&1; then
|
||||||
|
# Echoes the path of the 'doc.go' file to the terminal.
|
||||||
|
# This is likely for debugging or information purposes.
|
||||||
|
echo $d/doc.go
|
||||||
|
|
||||||
|
# Writes the package declaration and import comment to the 'doc.go' file in the current subdirectory.
|
||||||
|
# 'basename $d' retrieves the name of the current directory (last part of the path).
|
||||||
|
# The import comment is constructed based on a static base URL and the directory path.
|
||||||
|
echo "package $(basename $d) // import \"github.com/OpenIMSDK/Open-IM-Server/$d\"" > $d/doc.go
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
LC_ALL=C
|
LC_ALL=C
|
||||||
|
|
||||||
local_branch="$(git rev-parse --abbrev-ref HEAD)"
|
local_branch="$(git rev-parse --abbrev-ref HEAD)"
|
||||||
valid_branch_regex="^(main|master|develop|release(-[a-zA-Z0-9._-]+)?)$|(feature|feat|openim|hotfix|test|bug|bot|ci|cicd|style|)\/[a-z0-9._-]+$|^HEAD$"
|
valid_branch_regex="^(main|master|develop|release(-[a-zA-Z0-9._-]+)?)$|(feature|feat|openim|hotfix|test|bug|bot|refactor|revert|ci|cicd|style|)\/[a-z0-9._-]+$|^HEAD$"
|
||||||
|
|
||||||
YELLOW="\e[93m"
|
YELLOW="\e[93m"
|
||||||
GREEN="\e[32m"
|
GREEN="\e[32m"
|
||||||
|
|||||||
+1
-2
@@ -19,9 +19,8 @@ SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|||||||
OPENIM_ROOT=$(dirname "${SCRIPTS_ROOT}")/..
|
OPENIM_ROOT=$(dirname "${SCRIPTS_ROOT}")/..
|
||||||
|
|
||||||
#Include shell font styles and some basic information
|
#Include shell font styles and some basic information
|
||||||
source $SCRIPTS_ROOT/style_info.sh
|
source $SCRIPTS_ROOT/lib/init.sh
|
||||||
source $SCRIPTS_ROOT/path_info.sh
|
source $SCRIPTS_ROOT/path_info.sh
|
||||||
source $SCRIPTS_ROOT/function.sh
|
|
||||||
|
|
||||||
cd $SCRIPTS_ROOT
|
cd $SCRIPTS_ROOT
|
||||||
|
|
||||||
|
|||||||
Executable
+178
@@ -0,0 +1,178 @@
|
|||||||
|
# Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
# A set of helpers for starting/running chat for tests
|
||||||
|
|
||||||
|
CHAT_VERSION=${CHAT_VERSION:-1.1.0}
|
||||||
|
CHAT_HOST=${CHAT_HOST:-127.0.0.1}
|
||||||
|
CHAT_PORT=${CHAT_PORT:-2379}
|
||||||
|
# This is intentionally not called CHAT_LOG_LEVEL:
|
||||||
|
# chat checks that and compains when it is set in addition
|
||||||
|
# to the command line argument, even when both have the same value.
|
||||||
|
CHAT_LOGLEVEL=${CHAT_LOGLEVEL:-warn}
|
||||||
|
export OPENIM_INTEGRATION_CHAT_URL="http://${CHAT_HOST}:${CHAT_PORT}"
|
||||||
|
|
||||||
|
openim::chat::validate() {
|
||||||
|
# validate if in path
|
||||||
|
command -v chat >/dev/null || {
|
||||||
|
openim::log::usage "chat must be in your PATH"
|
||||||
|
openim::log::info "You can use 'hack/install-chat.sh' to install a copy in third_party/."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# validate chat port is free
|
||||||
|
local port_check_command
|
||||||
|
if command -v ss &> /dev/null && ss -Version | grep 'iproute2' &> /dev/null; then
|
||||||
|
port_check_command="ss"
|
||||||
|
elif command -v netstat &>/dev/null; then
|
||||||
|
port_check_command="netstat"
|
||||||
|
else
|
||||||
|
openim::log::usage "unable to identify if chat is bound to port ${CHAT_PORT}. unable to find ss or netstat utilities."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if ${port_check_command} -nat | grep "LISTEN" | grep "[\.:]${CHAT_PORT:?}" >/dev/null 2>&1; then
|
||||||
|
openim::log::usage "unable to start chat as port ${CHAT_PORT} is in use. please stop the process listening on this port and retry."
|
||||||
|
openim::log::usage "$(${port_check_command} -nat | grep "LISTEN" | grep "[\.:]${CHAT_PORT:?}")"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# need set the env of "CHAT_UNSUPPORTED_ARCH" on unstable arch.
|
||||||
|
arch=$(uname -m)
|
||||||
|
if [[ $arch =~ arm* ]]; then
|
||||||
|
export CHAT_UNSUPPORTED_ARCH=arm
|
||||||
|
fi
|
||||||
|
# validate installed version is at least equal to minimum
|
||||||
|
version=$(chat --version | grep Version | head -n 1 | cut -d " " -f 3)
|
||||||
|
if [[ $(openim::chat::version "${CHAT_VERSION}") -gt $(openim::chat::version "${version}") ]]; then
|
||||||
|
export PATH=${OPENIM_ROOT}/third_party/chat:${PATH}
|
||||||
|
hash chat
|
||||||
|
echo "${PATH}"
|
||||||
|
version=$(chat --version | grep Version | head -n 1 | cut -d " " -f 3)
|
||||||
|
if [[ $(openim::chat::version "${CHAT_VERSION}") -gt $(openim::chat::version "${version}") ]]; then
|
||||||
|
openim::log::usage "chat version ${CHAT_VERSION} or greater required."
|
||||||
|
openim::log::info "You can use 'hack/install-chat.sh' to install a copy in third_party/."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
openim::chat::version() {
|
||||||
|
printf '%s\n' "${@}" | awk -F . '{ printf("%d%03d%03d\n", $1, $2, $3) }'
|
||||||
|
}
|
||||||
|
|
||||||
|
openim::chat::start() {
|
||||||
|
# validate before running
|
||||||
|
openim::chat::validate
|
||||||
|
|
||||||
|
# Start chat
|
||||||
|
CHAT_DIR=${CHAT_DIR:-$(mktemp -d 2>/dev/null || mktemp -d -t test-chat.XXXXXX)}
|
||||||
|
if [[ -d "${ARTIFACTS:-}" ]]; then
|
||||||
|
CHAT_LOGFILE="${ARTIFACTS}/chat.$(uname -n).$(id -un).log.DEBUG.$(date +%Y%m%d-%H%M%S).$$"
|
||||||
|
else
|
||||||
|
CHAT_LOGFILE=${CHAT_LOGFILE:-"/dev/null"}
|
||||||
|
fi
|
||||||
|
openim::log::info "chat --advertise-client-urls ${OPENIM_INTEGRATION_CHAT_URL} --data-dir ${CHAT_DIR} --listen-client-urls http://${CHAT_HOST}:${CHAT_PORT} --log-level=${CHAT_LOGLEVEL} 2> \"${CHAT_LOGFILE}\" >/dev/null"
|
||||||
|
chat --advertise-client-urls "${OPENIM_INTEGRATION_CHAT_URL}" --data-dir "${CHAT_DIR}" --listen-client-urls "${OPENIM_INTEGRATION_CHAT_URL}" --log-level="${CHAT_LOGLEVEL}" 2> "${CHAT_LOGFILE}" >/dev/null &
|
||||||
|
CHAT_PID=$!
|
||||||
|
|
||||||
|
echo "Waiting for chat to come up."
|
||||||
|
openim::util::wait_for_url "${OPENIM_INTEGRATION_CHAT_URL}/health" "chat: " 0.25 80
|
||||||
|
curl -fs -X POST "${OPENIM_INTEGRATION_CHAT_URL}/v3/kv/put" -d '{"key": "X3Rlc3Q=", "value": ""}'
|
||||||
|
}
|
||||||
|
|
||||||
|
openim::chat::start_scraping() {
|
||||||
|
if [[ -d "${ARTIFACTS:-}" ]]; then
|
||||||
|
CHAT_SCRAPE_DIR="${ARTIFACTS}/chat-scrapes"
|
||||||
|
else
|
||||||
|
CHAT_SCRAPE_DIR=$(mktemp -d -t test.XXXXXX)/chat-scrapes
|
||||||
|
fi
|
||||||
|
openim::log::info "Periodically scraping chat to ${CHAT_SCRAPE_DIR} ."
|
||||||
|
mkdir -p "${CHAT_SCRAPE_DIR}"
|
||||||
|
(
|
||||||
|
while sleep 30; do
|
||||||
|
openim::chat::scrape
|
||||||
|
done
|
||||||
|
) &
|
||||||
|
CHAT_SCRAPE_PID=$!
|
||||||
|
}
|
||||||
|
|
||||||
|
openim::chat::scrape() {
|
||||||
|
curl -s -S "${OPENIM_INTEGRATION_CHAT_URL}/metrics" > "${CHAT_SCRAPE_DIR}/next" && mv "${CHAT_SCRAPE_DIR}/next" "${CHAT_SCRAPE_DIR}/$(date +%s).scrape"
|
||||||
|
}
|
||||||
|
|
||||||
|
openim::chat::stop() {
|
||||||
|
if [[ -n "${CHAT_SCRAPE_PID:-}" ]] && [[ -n "${CHAT_SCRAPE_DIR:-}" ]] ; then
|
||||||
|
kill "${CHAT_SCRAPE_PID}" &>/dev/null || :
|
||||||
|
wait "${CHAT_SCRAPE_PID}" &>/dev/null || :
|
||||||
|
openim::chat::scrape || :
|
||||||
|
(
|
||||||
|
# shellcheck disable=SC2015
|
||||||
|
cd "${CHAT_SCRAPE_DIR}"/.. && \
|
||||||
|
tar czf chat-scrapes.tgz chat-scrapes && \
|
||||||
|
rm -rf chat-scrapes || :
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
if [[ -n "${CHAT_PID-}" ]]; then
|
||||||
|
kill "${CHAT_PID}" &>/dev/null || :
|
||||||
|
wait "${CHAT_PID}" &>/dev/null || :
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
openim::chat::clean_chat_dir() {
|
||||||
|
if [[ -n "${CHAT_DIR-}" ]]; then
|
||||||
|
rm -rf "${CHAT_DIR}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
openim::chat::cleanup() {
|
||||||
|
openim::chat::stop
|
||||||
|
openim::chat::clean_chat_dir
|
||||||
|
}
|
||||||
|
|
||||||
|
openim::chat::install() {
|
||||||
|
(
|
||||||
|
local os
|
||||||
|
local arch
|
||||||
|
|
||||||
|
os=$(openim::util::host_os)
|
||||||
|
arch=$(openim::util::host_arch)
|
||||||
|
|
||||||
|
cd "${OPENIM_ROOT}/third_party" || return 1
|
||||||
|
if [[ $(readlink chat) == chat-v${CHAT_VERSION}-${os}-* ]]; then
|
||||||
|
openim::log::info "chat v${CHAT_VERSION} already installed. To use:"
|
||||||
|
openim::log::info "export PATH=\"$(pwd)/chat:\${PATH}\""
|
||||||
|
return #already installed
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ${os} == "darwin" ]]; then
|
||||||
|
download_file="chat-v${CHAT_VERSION}-${os}-${arch}.zip"
|
||||||
|
url="https://github.com/chat-io/chat/releases/download/v${CHAT_VERSION}/${download_file}"
|
||||||
|
openim::util::download_file "${url}" "${download_file}"
|
||||||
|
unzip -o "${download_file}"
|
||||||
|
ln -fns "chat-v${CHAT_VERSION}-${os}-${arch}" chat
|
||||||
|
rm "${download_file}"
|
||||||
|
elif [[ ${os} == "linux" ]]; then
|
||||||
|
url="https://github.com/coreos/chat/releases/download/v${CHAT_VERSION}/chat-v${CHAT_VERSION}-${os}-${arch}.tar.gz"
|
||||||
|
download_file="chat-v${CHAT_VERSION}-${os}-${arch}.tar.gz"
|
||||||
|
openim::util::download_file "${url}" "${download_file}"
|
||||||
|
tar xzf "${download_file}"
|
||||||
|
ln -fns "chat-v${CHAT_VERSION}-${os}-${arch}" chat
|
||||||
|
rm "${download_file}"
|
||||||
|
else
|
||||||
|
openim::log::info "${os} is NOT supported."
|
||||||
|
fi
|
||||||
|
openim::log::info "chat v${CHAT_VERSION} installed. To use:"
|
||||||
|
openim::log::info "export PATH=\"$(pwd)/chat:\${PATH}\""
|
||||||
|
)
|
||||||
|
}
|
||||||
+43
-21
@@ -14,58 +14,80 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# this script is used to install the dependencies of the project
|
||||||
|
#
|
||||||
|
# Usage: `scripts/color.sh`.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
# Define color variables
|
# Define color variables
|
||||||
# Feature
|
# --- Feature ---
|
||||||
COLOR_NORMAL='\033[0m';COLOR_BOLD='\033[1m';COLOR_DIM='\033[2m';COLOR_UNDER='\033[4m';
|
COLOR_NORMAL='\033[0m';COLOR_BOLD='\033[1m';COLOR_DIM='\033[2m';COLOR_UNDER='\033[4m';
|
||||||
COLOR_ITALIC='\033[3m';COLOR_NOITALIC='\033[23m';COLOR_BLINK='\033[5m';
|
COLOR_ITALIC='\033[3m';COLOR_NOITALIC='\033[23m';COLOR_BLINK='\033[5m';
|
||||||
COLOR_REVERSE='\033[7m';COLOR_CONCEAL='\033[8m';COLOR_NOBOLD='\033[22m';
|
COLOR_REVERSE='\033[7m';COLOR_CONCEAL='\033[8m';COLOR_NOBOLD='\033[22m';
|
||||||
COLOR_NOUNDER='\033[24m';COLOR_NOBLINK='\033[25m';
|
COLOR_NOUNDER='\033[24m';COLOR_NOBLINK='\033[25m';
|
||||||
|
|
||||||
# Front color
|
# --- Front color ---
|
||||||
COLOR_BLACK='\033[30m';COLOR_RED='\033[31m';COLOR_GREEN='\033[32m';COLOR_YELLOW='\033[33m';
|
COLOR_BLACK='\033[30m';COLOR_RED='\033[31m';COLOR_GREEN='\033[32m';COLOR_YELLOW='\033[33m';
|
||||||
COLOR_BLUE='\033[34m';COLOR_MAGENTA='\033[35m';COLOR_CYAN='\033[36m';COLOR_WHITE='\033[37m';
|
COLOR_BLUE='\033[34m';COLOR_MAGENTA='\033[35m';COLOR_CYAN='\033[36m';COLOR_WHITE='\033[37m';
|
||||||
|
|
||||||
# background color
|
# --- background color ---
|
||||||
COLOR_BBLACK='\033[40m';COLOR_BRED='\033[41m';
|
COLOR_BBLACK='\033[40m';COLOR_BRED='\033[41m';
|
||||||
COLOR_BGREEN='\033[42m';COLOR_BYELLOW='\033[43m';
|
COLOR_BGREEN='\033[42m';COLOR_BYELLOW='\033[43m';
|
||||||
COLOR_BBLUE='\033[44m';COLOR_BMAGENTA='\033[45m';
|
COLOR_BBLUE='\033[44m';COLOR_BMAGENTA='\033[45m';
|
||||||
COLOR_BCYAN='\033[46m';COLOR_BWHITE='\033[47m';
|
COLOR_BCYAN='\033[46m';COLOR_BWHITE='\033[47m';
|
||||||
|
|
||||||
|
# --- make demo (run demo) ---
|
||||||
|
reset=$(tput sgr0)
|
||||||
|
bold=$(tput bold)
|
||||||
|
black=$(tput setaf 0)
|
||||||
|
red=$(tput setaf 1)
|
||||||
|
green=$(tput bold; tput setaf 2)
|
||||||
|
yellow=$(tput bold; tput setaf 3)
|
||||||
|
blue=$(tput bold; tput setaf 6)
|
||||||
|
timeout=$(if [ "$(uname)" == "Darwin" ]; then echo "1"; else echo "0.1"; fi)
|
||||||
|
|
||||||
|
# --- Color definitions ---
|
||||||
# Color definitions
|
# Color definitions
|
||||||
COLOR_SUFFIX="\033[0m" # End all colors and special effects
|
function openim_color() {
|
||||||
BLACK_PREFIX="\033[30m" # Black prefix
|
COLOR_SUFFIX="\033[0m" # End all colors and special effects
|
||||||
RED_PREFIX="\033[31m" # Red prefix
|
|
||||||
GREEN_PREFIX="\033[32m" # Green prefix
|
BLACK_PREFIX="\033[30m" # Black prefix
|
||||||
YELLOW_PREFIX="\033[33m" # Yellow prefix
|
RED_PREFIX="\033[31m" # Red prefix
|
||||||
BLUE_PREFIX="\033[34m" # Blue prefix
|
GREEN_PREFIX="\033[32m" # Green prefix
|
||||||
SKY_BLUE_PREFIX="\033[36m" # Sky blue prefix
|
YELLOW_PREFIX="\033[33m" # Yellow prefix
|
||||||
WHITE_PREFIX="\033[37m" # White prefix
|
BLUE_PREFIX="\033[34m" # Blue prefix
|
||||||
BOLD_PREFIX="\033[1m" # Bold prefix
|
SKY_BLUE_PREFIX="\033[36m" # Sky blue prefix
|
||||||
UNDERLINE_PREFIX="\033[4m" # Underline prefix
|
WHITE_PREFIX="\033[37m" # White prefix
|
||||||
ITALIC_PREFIX="\033[3m" # Italic prefix
|
BOLD_PREFIX="\033[1m" # Bold prefix
|
||||||
BRIGHT_GREEN_PREFIX='\033[1;32m' # Bright green prefix
|
UNDERLINE_PREFIX="\033[4m" # Underline prefix
|
||||||
CYAN_PREFIX="\033[0;36m" # Cyan prefix
|
ITALIC_PREFIX="\033[3m" # Italic prefix
|
||||||
|
|
||||||
|
CYAN_PREFIX="\033[0;36m" # Cyan prefix
|
||||||
|
}
|
||||||
|
|
||||||
# --- helper functions for logs ---
|
# --- helper functions for logs ---
|
||||||
info()
|
function info()
|
||||||
{
|
{
|
||||||
echo -e "[${GREEN_PREFIX}INFO${COLOR_SUFFIX}] " "$@"
|
echo -e "[${GREEN_PREFIX}INFO${COLOR_SUFFIX}] " "$@"
|
||||||
}
|
}
|
||||||
warn()
|
|
||||||
|
function warn()
|
||||||
{
|
{
|
||||||
echo -e "[${YELLOW_PREFIX}WARN${COLOR_SUFFIX}] " "$@" >&2
|
echo -e "[${YELLOW_PREFIX}WARN${COLOR_SUFFIX}] " "$@" >&2
|
||||||
}
|
}
|
||||||
fatal()
|
|
||||||
|
function fatal()
|
||||||
{
|
{
|
||||||
echo -e "[${RED_PREFIX}ERROR${COLOR_SUFFIX}] " "$@" >&2
|
echo -e "[${RED_PREFIX}ERROR${COLOR_SUFFIX}] " "$@" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
debug()
|
|
||||||
|
function debug()
|
||||||
{
|
{
|
||||||
echo -e "[${BLUE_PREFIX}DEBUG${COLOR_SUFFIX}]===> " "$@"
|
echo -e "[${BLUE_PREFIX}DEBUG${COLOR_SUFFIX}]===> " "$@"
|
||||||
}
|
}
|
||||||
success()
|
|
||||||
|
function success()
|
||||||
{
|
{
|
||||||
echo -e "${BRIGHT_GREEN_PREFIX}===> [SUCCESS] <===${COLOR_SUFFIX}\n=> " "$@"
|
echo -e "${BRIGHT_GREEN_PREFIX}===> [SUCCESS] <===${COLOR_SUFFIX}\n=> " "$@"
|
||||||
}
|
}
|
||||||
|
|||||||
+171
-7
@@ -13,25 +13,189 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
set -o errexit
|
set -o errexit
|
||||||
set +o nounset
|
set +o nounset
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
|
# Short-circuit if init.sh has already been sourced
|
||||||
|
[[ $(type -t openim::init::loaded) == function ]] && return 0
|
||||||
|
|
||||||
# Unset CDPATH so that path interpolation can work correctly
|
# Unset CDPATH so that path interpolation can work correctly
|
||||||
unset CDPATH
|
unset CDPATH
|
||||||
|
|
||||||
# Default use go modules
|
# Until all GOPATH references are removed from all build scripts as well,
|
||||||
|
# explicitly disable module mode to avoid picking up user-set GO111MODULE preferences.
|
||||||
|
# As individual scripts (like hack/update-vendor.sh) make use of go modules,
|
||||||
|
# they can explicitly set GO111MODULE=on
|
||||||
export GO111MODULE=on
|
export GO111MODULE=on
|
||||||
|
|
||||||
# The root of the build/dist directory
|
# The root of the build/dist directory
|
||||||
OPENIM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
|
OPENIM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
|
||||||
|
|
||||||
source "${OPENIM_ROOT}/scripts/lib/util.sh"
|
OPENIM_OUTPUT_SUBPATH="${OPENIM_OUTPUT_SUBPATH:-_output}"
|
||||||
source "${OPENIM_ROOT}/scripts/lib/logging.sh"
|
OPENIM_OUTPUT="${OPENIM_ROOT}/${OPENIM_OUTPUT_SUBPATH}"
|
||||||
source "${OPENIM_ROOT}/scripts/lib/color.sh"
|
OPENIM_OUTPUT_BINPATH="${OPENIM_OUTPUT}/bin/platforms"
|
||||||
|
OPENIM_OUTPUT_BINTOOLPATH="${OPENIM_OUTPUT}/bin-tools"
|
||||||
|
OPENIM_OUTPUT_TOOLS="${OPENIM_OUTPUT}/tools"
|
||||||
|
OPENIM_OUTPUT_TMP="${OPENIM_OUTPUT}/tmp"
|
||||||
|
|
||||||
|
# This controls rsync compression. Set to a value > 0 to enable rsync
|
||||||
|
# compression for build container
|
||||||
|
OPENIM_RSYNC_COMPRESS="${KUBE_RSYNC_COMPRESS:-0}"
|
||||||
|
|
||||||
|
# Set no_proxy for localhost if behind a proxy, otherwise,
|
||||||
|
# the connections to localhost in scripts will time out
|
||||||
|
export no_proxy="127.0.0.1,localhost${no_proxy:+,${no_proxy}}"
|
||||||
|
|
||||||
|
# This is a symlink to binaries for "this platform", e.g. build tools.
|
||||||
|
export THIS_PLATFORM_BIN="${OPENIM_ROOT}/_output/bin/platforms"
|
||||||
|
|
||||||
|
. $(dirname ${BASH_SOURCE})/color.sh
|
||||||
|
. $(dirname ${BASH_SOURCE})/util.sh
|
||||||
|
. $(dirname ${BASH_SOURCE})/logging.sh
|
||||||
|
|
||||||
openim::log::install_errexit
|
openim::log::install_errexit
|
||||||
|
openim::util::ensure-bash-version
|
||||||
|
|
||||||
source "${OPENIM_ROOT}/scripts/lib/version.sh"
|
. $(dirname ${BASH_SOURCE})/version.sh
|
||||||
source "${OPENIM_ROOT}/scripts/lib/golang.sh"
|
. $(dirname ${BASH_SOURCE})/golang.sh
|
||||||
|
. $(dirname ${BASH_SOURCE})/test.sh
|
||||||
|
. $(dirname ${BASH_SOURCE})/release.sh
|
||||||
|
. $(dirname ${BASH_SOURCE})/chat.sh
|
||||||
|
|
||||||
|
OPENIM_OUTPUT_HOSTBIN="${OPENIM_OUTPUT_BINPATH}/$(openim::util::host_platform)"
|
||||||
|
export OPENIM_OUTPUT_HOSTBIN
|
||||||
|
|
||||||
|
export OPENIM_NONSERVER_GROUP_VERSIONS
|
||||||
|
|
||||||
|
# This emulates "readlink -f" which is not available on MacOS X.
|
||||||
|
# Test:
|
||||||
|
# T=/tmp/$$.$RANDOM
|
||||||
|
# mkdir $T
|
||||||
|
# touch $T/file
|
||||||
|
# mkdir $T/dir
|
||||||
|
# ln -s $T/file $T/linkfile
|
||||||
|
# ln -s $T/dir $T/linkdir
|
||||||
|
# function testone() {
|
||||||
|
# X=$(readlink -f $1 2>&1)
|
||||||
|
# Y=$(kube::readlinkdashf $1 2>&1)
|
||||||
|
# if [ "$X" != "$Y" ]; then
|
||||||
|
# echo readlinkdashf $1: expected "$X", got "$Y"
|
||||||
|
# fi
|
||||||
|
# }
|
||||||
|
# testone /
|
||||||
|
# testone /tmp
|
||||||
|
# testone $T
|
||||||
|
# testone $T/file
|
||||||
|
# testone $T/dir
|
||||||
|
# testone $T/linkfile
|
||||||
|
# testone $T/linkdir
|
||||||
|
# testone $T/nonexistant
|
||||||
|
# testone $T/linkdir/file
|
||||||
|
# testone $T/linkdir/dir
|
||||||
|
# testone $T/linkdir/linkfile
|
||||||
|
# testone $T/linkdir/linkdir
|
||||||
|
function openim::readlinkdashf {
|
||||||
|
# run in a subshell for simpler 'cd'
|
||||||
|
(
|
||||||
|
if [[ -d "${1}" ]]; then # This also catch symlinks to dirs.
|
||||||
|
cd "${1}"
|
||||||
|
pwd -P
|
||||||
|
else
|
||||||
|
cd "$(dirname "${1}")"
|
||||||
|
local f
|
||||||
|
f=$(basename "${1}")
|
||||||
|
if [[ -L "${f}" ]]; then
|
||||||
|
readlink "${f}"
|
||||||
|
else
|
||||||
|
echo "$(pwd -P)/${f}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
# This emulates "readlink -f" which is not available on MacOS X.
|
||||||
|
# Test:
|
||||||
|
# T=/tmp/$$.$RANDOM
|
||||||
|
# mkdir $T
|
||||||
|
# touch $T/file
|
||||||
|
# mkdir $T/dir
|
||||||
|
# ln -s $T/file $T/linkfile
|
||||||
|
# ln -s $T/dir $T/linkdir
|
||||||
|
# function testone() {
|
||||||
|
# X=$(readlink -f $1 2>&1)
|
||||||
|
# Y=$(kube::readlinkdashf $1 2>&1)
|
||||||
|
# if [ "$X" != "$Y" ]; then
|
||||||
|
# echo readlinkdashf $1: expected "$X", got "$Y"
|
||||||
|
# fi
|
||||||
|
# }
|
||||||
|
# testone /
|
||||||
|
# testone /tmp
|
||||||
|
# testone $T
|
||||||
|
# testone $T/file
|
||||||
|
# testone $T/dir
|
||||||
|
# testone $T/linkfile
|
||||||
|
# testone $T/linkdir
|
||||||
|
# testone $T/nonexistant
|
||||||
|
# testone $T/linkdir/file
|
||||||
|
# testone $T/linkdir/dir
|
||||||
|
# testone $T/linkdir/linkfile
|
||||||
|
# testone $T/linkdir/linkdir
|
||||||
|
function openim::readlinkdashf {
|
||||||
|
# run in a subshell for simpler 'cd'
|
||||||
|
(
|
||||||
|
if [[ -d "${1}" ]]; then # This also catch symlinks to dirs.
|
||||||
|
cd "${1}"
|
||||||
|
pwd -P
|
||||||
|
else
|
||||||
|
cd "$(dirname "${1}")"
|
||||||
|
local f
|
||||||
|
f=$(basename "${1}")
|
||||||
|
if [[ -L "${f}" ]]; then
|
||||||
|
readlink "${f}"
|
||||||
|
else
|
||||||
|
echo "$(pwd -P)/${f}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
# This emulates "realpath" which is not available on MacOS X
|
||||||
|
# Test:
|
||||||
|
# T=/tmp/$$.$RANDOM
|
||||||
|
# mkdir $T
|
||||||
|
# touch $T/file
|
||||||
|
# mkdir $T/dir
|
||||||
|
# ln -s $T/file $T/linkfile
|
||||||
|
# ln -s $T/dir $T/linkdir
|
||||||
|
# function testone() {
|
||||||
|
# X=$(realpath $1 2>&1)
|
||||||
|
# Y=$(kube::realpath $1 2>&1)
|
||||||
|
# if [ "$X" != "$Y" ]; then
|
||||||
|
# echo realpath $1: expected "$X", got "$Y"
|
||||||
|
# fi
|
||||||
|
# }
|
||||||
|
# testone /
|
||||||
|
# testone /tmp
|
||||||
|
# testone $T
|
||||||
|
# testone $T/file
|
||||||
|
# testone $T/dir
|
||||||
|
# testone $T/linkfile
|
||||||
|
# testone $T/linkdir
|
||||||
|
# testone $T/nonexistant
|
||||||
|
# testone $T/linkdir/file
|
||||||
|
# testone $T/linkdir/dir
|
||||||
|
# testone $T/linkdir/linkfile
|
||||||
|
# testone $T/linkdir/linkdir
|
||||||
|
openim::realpath() {
|
||||||
|
if [[ ! -e "${1}" ]]; then
|
||||||
|
echo "${1}: No such file or directory" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
openim::readlinkdashf "${1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Marker function to indicate init.sh has been fully sourced
|
||||||
|
openim::init::loaded() {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
@@ -38,6 +38,7 @@ readonly RELEASE_IMAGES="${LOCAL_OUTPUT_ROOT}/release-images"
|
|||||||
# OpenIM github account info
|
# OpenIM github account info
|
||||||
readonly OPENIM_GITHUB_ORG=OpenIMSDK
|
readonly OPENIM_GITHUB_ORG=OpenIMSDK
|
||||||
readonly OPENIM_GITHUB_REPO=Open-IM-Server
|
readonly OPENIM_GITHUB_REPO=Open-IM-Server
|
||||||
|
readonly CHAT_GITHUB_REPO=chat
|
||||||
|
|
||||||
readonly ARTIFACT=openim.tar.gz
|
readonly ARTIFACT=openim.tar.gz
|
||||||
readonly CHECKSUM=${ARTIFACT}.sha1sum
|
readonly CHECKSUM=${ARTIFACT}.sha1sum
|
||||||
@@ -143,8 +144,8 @@ function openim::release::package_src_tarball() {
|
|||||||
-path "${OPENIM_ROOT}"/.config\* -o \
|
-path "${OPENIM_ROOT}"/.config\* -o \
|
||||||
-path "${OPENIM_ROOT}"/.chglog\* -o \
|
-path "${OPENIM_ROOT}"/.chglog\* -o \
|
||||||
-path "${OPENIM_ROOT}"/.gitlint -o \
|
-path "${OPENIM_ROOT}"/.gitlint -o \
|
||||||
-path "${OPENIM_ROOT}"/.golangci.yml -o \
|
-path "${OPENIM_ROOT}"/scripts/golangci.yml -o \
|
||||||
-path "${OPENIM_ROOT}"/.goreleaser.yml -o \
|
-path "${OPENIM_ROOT}"/build/goreleaser.yaml -o \
|
||||||
-path "${OPENIM_ROOT}"/.note.md -o \
|
-path "${OPENIM_ROOT}"/.note.md -o \
|
||||||
-path "${OPENIM_ROOT}"/.todo.md \
|
-path "${OPENIM_ROOT}"/.todo.md \
|
||||||
\) -prune \
|
\) -prune \
|
||||||
|
|||||||
Executable
+561
@@ -0,0 +1,561 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
# A set of helpers for tests
|
||||||
|
|
||||||
|
openim::test::clear_all() {
|
||||||
|
if openim::test::if_supports_resource "rc" ; then
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
# Disabling because "kube_flags" is set in a parent script
|
||||||
|
kubectl delete "${kube_flags[@]}" rc --all --grace-period=0 --force
|
||||||
|
fi
|
||||||
|
if openim::test::if_supports_resource "pods" ; then
|
||||||
|
kubectl delete "${kube_flags[@]}" pods --all --grace-period=0 --force
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Prints the calling file and line number $1 levels deep
|
||||||
|
# Defaults to 2 levels so you can call this to find your own caller
|
||||||
|
openim::test::get_caller() {
|
||||||
|
local levels=${1:-2}
|
||||||
|
local caller_file="${BASH_SOURCE[${levels}]}"
|
||||||
|
local caller_line="${BASH_LINENO[${levels}-1]}"
|
||||||
|
echo "$(basename "${caller_file}"):${caller_line}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Force exact match of a returned result for a object query. Wrap this with || to support multiple
|
||||||
|
# valid return types.
|
||||||
|
# This runs `kubectl get` once and asserts that the result is as expected.
|
||||||
|
# $1: Object on which get should be run
|
||||||
|
# $2: The go-template to run on the result
|
||||||
|
# $3: The expected output
|
||||||
|
# $4: Additional args to be passed to kubectl
|
||||||
|
openim::test::get_object_assert() {
|
||||||
|
openim::test::object_assert 1 "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Asserts that the output of a given get query is as expected.
|
||||||
|
# Runs the query multiple times before failing it.
|
||||||
|
# $1: Object on which get should be run
|
||||||
|
# $2: The go-template to run on the result
|
||||||
|
# $3: The expected output
|
||||||
|
# $4: Additional args to be passed to kubectl
|
||||||
|
openim::test::wait_object_assert() {
|
||||||
|
openim::test::object_assert 10 "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Asserts that the output of a given get query is as expected.
|
||||||
|
# Can run the query multiple times before failing it.
|
||||||
|
# $1: Number of times the query should be run before failing it.
|
||||||
|
# $2: Object on which get should be run
|
||||||
|
# $3: The go-template to run on the result
|
||||||
|
# $4: The expected output
|
||||||
|
# $5: Additional args to be passed to kubectl
|
||||||
|
openim::test::object_assert() {
|
||||||
|
local tries=$1
|
||||||
|
local object=$2
|
||||||
|
local request=$3
|
||||||
|
local expected=$4
|
||||||
|
local args=${5:-}
|
||||||
|
|
||||||
|
for j in $(seq 1 "${tries}"); do
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
# Disabling because to allow for expansion here
|
||||||
|
res=$(kubectl get "${kube_flags[@]}" ${args} ${object} -o go-template="${request}")
|
||||||
|
if [[ "${res}" =~ ^$expected$ ]]; then
|
||||||
|
echo -n "${green}"
|
||||||
|
echo "$(openim::test::get_caller 3): Successful get ${object} ${request}: ${res}"
|
||||||
|
echo -n "${reset}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
echo "Waiting for Get ${object} ${request} ${args}: expected: ${expected}, got: ${res}"
|
||||||
|
sleep $((j-1))
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "${bold}${red}"
|
||||||
|
echo "$(openim::test::get_caller 3): FAIL!"
|
||||||
|
echo "Get ${object} ${request}"
|
||||||
|
echo " Expected: ${expected}"
|
||||||
|
echo " Got: ${res}"
|
||||||
|
echo "${reset}${red}"
|
||||||
|
caller
|
||||||
|
echo "${reset}"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
openim::test::get_object_jsonpath_assert() {
|
||||||
|
local object=$1
|
||||||
|
local request=$2
|
||||||
|
local expected=$3
|
||||||
|
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
# Disabling to allow for expansion here
|
||||||
|
res=$(kubectl get "${kube_flags[@]}" ${object} -o jsonpath=${request})
|
||||||
|
|
||||||
|
if [[ "${res}" =~ ^$expected$ ]]; then
|
||||||
|
echo -n "${green}"
|
||||||
|
echo "$(openim::test::get_caller): Successful get ${object} ${request}: ${res}"
|
||||||
|
echo -n "${reset}"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo "${bold}${red}"
|
||||||
|
echo "$(openim::test::get_caller): FAIL!"
|
||||||
|
echo "Get ${object} ${request}"
|
||||||
|
echo " Expected: ${expected}"
|
||||||
|
echo " Got: ${res}"
|
||||||
|
echo "${reset}${red}"
|
||||||
|
caller
|
||||||
|
echo "${reset}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
openim::test::describe_object_assert() {
|
||||||
|
local resource=$1
|
||||||
|
local object=$2
|
||||||
|
local matches=( "${@:3}" )
|
||||||
|
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
# Disabling to allow for expansion here
|
||||||
|
result=$(kubectl describe "${kube_flags[@]}" ${resource} ${object})
|
||||||
|
|
||||||
|
for match in "${matches[@]}"; do
|
||||||
|
if grep -q "${match}" <<< "${result}"; then
|
||||||
|
echo "matched ${match}"
|
||||||
|
else
|
||||||
|
echo "${bold}${red}"
|
||||||
|
echo "$(openim::test::get_caller): FAIL!"
|
||||||
|
echo "Describe ${resource} ${object}"
|
||||||
|
echo " Expected Match: ${match}"
|
||||||
|
echo " Not found in:"
|
||||||
|
echo "${result}"
|
||||||
|
echo "${reset}${red}"
|
||||||
|
caller
|
||||||
|
echo "${reset}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo -n "${green}"
|
||||||
|
echo "$(openim::test::get_caller): Successful describe ${resource} ${object}:"
|
||||||
|
echo "${result}"
|
||||||
|
echo -n "${reset}"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
openim::test::describe_object_events_assert() {
|
||||||
|
local resource=$1
|
||||||
|
local object=$2
|
||||||
|
local showevents=${3:-"true"}
|
||||||
|
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
# Disabling to allow for expansion here
|
||||||
|
if [[ -z "${3:-}" ]]; then
|
||||||
|
result=$(kubectl describe "${kube_flags[@]}" ${resource} ${object})
|
||||||
|
else
|
||||||
|
result=$(kubectl describe "${kube_flags[@]}" "--show-events=${showevents}" ${resource} ${object})
|
||||||
|
fi
|
||||||
|
|
||||||
|
if grep -q "No events.\|Events:" <<< "${result}"; then
|
||||||
|
local has_events="true"
|
||||||
|
else
|
||||||
|
local has_events="false"
|
||||||
|
fi
|
||||||
|
if [[ "${showevents}" == "${has_events}" ]]; then
|
||||||
|
echo -n "${green}"
|
||||||
|
echo "$(openim::test::get_caller): Successful describe"
|
||||||
|
echo "${result}"
|
||||||
|
echo "${reset}"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo "${bold}${red}"
|
||||||
|
echo "$(openim::test::get_caller): FAIL"
|
||||||
|
if [[ "${showevents}" == "false" ]]; then
|
||||||
|
echo " Events information should not be described in:"
|
||||||
|
else
|
||||||
|
echo " Events information not found in:"
|
||||||
|
fi
|
||||||
|
echo "${result}"
|
||||||
|
echo "${reset}${red}"
|
||||||
|
caller
|
||||||
|
echo "${reset}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
openim::test::describe_resource_assert() {
|
||||||
|
local resource=$1
|
||||||
|
local matches=( "${@:2}" )
|
||||||
|
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
# Disabling to allow for expansion here
|
||||||
|
result=$(kubectl describe "${kube_flags[@]}" ${resource})
|
||||||
|
|
||||||
|
for match in "${matches[@]}"; do
|
||||||
|
if grep -q "${match}" <<< "${result}"; then
|
||||||
|
echo "matched ${match}"
|
||||||
|
else
|
||||||
|
echo "${bold}${red}"
|
||||||
|
echo "FAIL!"
|
||||||
|
echo "Describe ${resource}"
|
||||||
|
echo " Expected Match: ${match}"
|
||||||
|
echo " Not found in:"
|
||||||
|
echo "${result}"
|
||||||
|
echo "${reset}${red}"
|
||||||
|
caller
|
||||||
|
echo "${reset}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo -n "${green}"
|
||||||
|
echo "Successful describe ${resource}:"
|
||||||
|
echo "${result}"
|
||||||
|
echo -n "${reset}"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
openim::test::describe_resource_events_assert() {
|
||||||
|
local resource=$1
|
||||||
|
local showevents=${2:-"true"}
|
||||||
|
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
# Disabling to allow for expansion here
|
||||||
|
result=$(kubectl describe "${kube_flags[@]}" "--show-events=${showevents}" ${resource})
|
||||||
|
|
||||||
|
if grep -q "No events.\|Events:" <<< "${result}"; then
|
||||||
|
local has_events="true"
|
||||||
|
else
|
||||||
|
local has_events="false"
|
||||||
|
fi
|
||||||
|
if [[ "${showevents}" == "${has_events}" ]]; then
|
||||||
|
echo -n "${green}"
|
||||||
|
echo "Successful describe"
|
||||||
|
echo "${result}"
|
||||||
|
echo -n "${reset}"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo "${bold}${red}"
|
||||||
|
echo "FAIL"
|
||||||
|
if [[ "${showevents}" == "false" ]]; then
|
||||||
|
echo " Events information should not be described in:"
|
||||||
|
else
|
||||||
|
echo " Events information not found in:"
|
||||||
|
fi
|
||||||
|
echo "${result}"
|
||||||
|
caller
|
||||||
|
echo "${reset}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
openim::test::describe_resource_chunk_size_assert() {
|
||||||
|
# $1: the target resource
|
||||||
|
local resource=$1
|
||||||
|
# $2: comma-separated list of additional resources that will be listed
|
||||||
|
local additionalResources=${2:-}
|
||||||
|
# Remaining args are flags to pass to kubectl
|
||||||
|
local args=${3:-}
|
||||||
|
|
||||||
|
# Expect list requests for the target resource and the additional resources
|
||||||
|
local expectLists
|
||||||
|
IFS="," read -r -a expectLists <<< "${resource},${additionalResources}"
|
||||||
|
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
# Disabling to allow for expansion here
|
||||||
|
defaultResult=$(kubectl describe ${resource} --show-events=true -v=6 ${args} "${kube_flags[@]}" 2>&1 >/dev/null)
|
||||||
|
for r in "${expectLists[@]}"; do
|
||||||
|
if grep -q "${r}?.*limit=500" <<< "${defaultResult}"; then
|
||||||
|
echo "query for ${r} had limit param"
|
||||||
|
else
|
||||||
|
echo "${bold}${red}"
|
||||||
|
echo "FAIL!"
|
||||||
|
echo "Describe ${resource}"
|
||||||
|
echo " Expected limit param on request for: ${r}"
|
||||||
|
echo " Not found in:"
|
||||||
|
echo "${defaultResult}"
|
||||||
|
echo "${reset}${red}"
|
||||||
|
caller
|
||||||
|
echo "${reset}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
# Disabling to allow for expansion here
|
||||||
|
# Try a non-default chunk size
|
||||||
|
customResult=$(kubectl describe ${resource} --show-events=false --chunk-size=10 -v=6 ${args} "${kube_flags[@]}" 2>&1 >/dev/null)
|
||||||
|
if grep -q "${resource}?limit=10" <<< "${customResult}"; then
|
||||||
|
echo "query for ${resource} had user-specified limit param"
|
||||||
|
else
|
||||||
|
echo "${bold}${red}"
|
||||||
|
echo "FAIL!"
|
||||||
|
echo "Describe ${resource}"
|
||||||
|
echo " Expected limit param on request for: ${r}"
|
||||||
|
echo " Not found in:"
|
||||||
|
echo "${customResult}"
|
||||||
|
echo "${reset}${red}"
|
||||||
|
caller
|
||||||
|
echo "${reset}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -n "${green}"
|
||||||
|
echo "Successful describe ${resource} verbose logs:"
|
||||||
|
echo "${defaultResult}"
|
||||||
|
echo -n "${reset}"
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# Compare sort-by resource name output (first column, skipping first line) with expected order specify in the last parameter
|
||||||
|
openim::test::if_sort_by_has_correct_order() {
|
||||||
|
local var
|
||||||
|
var="$(echo "$1" | awk '{if(NR!=1) print $1}' | tr '\n' ':')"
|
||||||
|
openim::test::if_has_string "${var}" "${@:$#}"
|
||||||
|
}
|
||||||
|
|
||||||
|
openim::test::if_has_string() {
|
||||||
|
local message=$1
|
||||||
|
local match=$2
|
||||||
|
|
||||||
|
if grep -q "${match}" <<< "${message}"; then
|
||||||
|
echo -n "${green}"
|
||||||
|
echo "Successful"
|
||||||
|
echo -n "${reset}"
|
||||||
|
echo "message:${message}"
|
||||||
|
echo "has:${match}"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo -n "${bold}${red}"
|
||||||
|
echo "FAIL!"
|
||||||
|
echo -n "${reset}"
|
||||||
|
echo "message:${message}"
|
||||||
|
echo "has not:${match}"
|
||||||
|
caller
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
openim::test::if_has_not_string() {
|
||||||
|
local message=$1
|
||||||
|
local match=$2
|
||||||
|
|
||||||
|
if grep -q "${match}" <<< "${message}"; then
|
||||||
|
echo -n "${bold}${red}"
|
||||||
|
echo "FAIL!"
|
||||||
|
echo -n "${reset}"
|
||||||
|
echo "message:${message}"
|
||||||
|
echo "has:${match}"
|
||||||
|
caller
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
echo -n "${green}"
|
||||||
|
echo "Successful"
|
||||||
|
echo -n "${reset}"
|
||||||
|
echo "message:${message}"
|
||||||
|
echo "has not:${match}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
openim::test::if_empty_string() {
|
||||||
|
local match=$1
|
||||||
|
if [ -n "${match}" ]; then
|
||||||
|
echo -n "${bold}${red}"
|
||||||
|
echo "FAIL!"
|
||||||
|
echo "${match} is not empty"
|
||||||
|
echo -n "${reset}"
|
||||||
|
caller
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
echo -n "${green}"
|
||||||
|
echo "Successful"
|
||||||
|
echo -n "${reset}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Returns true if the required resource is part of supported resources.
|
||||||
|
# Expects env vars:
|
||||||
|
# SUPPORTED_RESOURCES: Array of all resources supported by the apiserver. "*"
|
||||||
|
# means it supports all resources. For ex: ("*") or ("rc" "*") both mean that
|
||||||
|
# all resources are supported.
|
||||||
|
# $1: Name of the resource to be tested.
|
||||||
|
openim::test::if_supports_resource() {
|
||||||
|
SUPPORTED_RESOURCES=${SUPPORTED_RESOURCES:-""}
|
||||||
|
REQUIRED_RESOURCE=${1:-""}
|
||||||
|
|
||||||
|
for r in "${SUPPORTED_RESOURCES[@]}"; do
|
||||||
|
if [[ "${r}" == "*" || "${r}" == "${REQUIRED_RESOURCE}" ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
openim::test::version::object_to_file() {
|
||||||
|
name=$1
|
||||||
|
flags=${2:-""}
|
||||||
|
file=$3
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
# Disabling because "flags" needs to allow for expansion here
|
||||||
|
kubectl version ${flags} | grep "${name} Version:" | sed -e s/"${name} Version: "/""/g > "${file}"
|
||||||
|
}
|
||||||
|
|
||||||
|
openim::test::version::json_object_to_file() {
|
||||||
|
flags=$1
|
||||||
|
file=$2
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
# Disabling because "flags" needs to allow for expansion here
|
||||||
|
kubectl version ${flags} --output json | sed -e s/' '/''/g -e s/'\"'/''/g -e s/'}'/''/g -e s/'{'/''/g -e s/'clientVersion:'/'clientVersion:,'/ -e s/'serverVersion:'/'serverVersion:,'/ | tr , '\n' > "${file}"
|
||||||
|
}
|
||||||
|
|
||||||
|
openim::test::version::json_client_server_object_to_file() {
|
||||||
|
flags=$1
|
||||||
|
name=$2
|
||||||
|
file=$3
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
# Disabling because "flags" needs to allow for expansion here
|
||||||
|
kubectl version ${flags} --output json | jq -r ".${name}" | sed -e s/'\"'/''/g -e s/'}'/''/g -e s/'{'/''/g -e /^$/d -e s/','/''/g -e s/':'/'='/g > "${file}"
|
||||||
|
}
|
||||||
|
|
||||||
|
openim::test::version::yaml_object_to_file() {
|
||||||
|
flags=$1
|
||||||
|
file=$2
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
# Disabling because "flags" needs to allow for expansion here
|
||||||
|
kubectl version ${flags} --output yaml | sed -e s/' '/''/g -e s/'\"'/''/g -e /^$/d > "${file}"
|
||||||
|
}
|
||||||
|
|
||||||
|
openim::test::version::diff_assert() {
|
||||||
|
local original=$1
|
||||||
|
local comparator=${2:-"eq"}
|
||||||
|
local latest=$3
|
||||||
|
local diff_msg=${4:-""}
|
||||||
|
local res=""
|
||||||
|
|
||||||
|
if [ ! -f "${original}" ]; then
|
||||||
|
echo "${bold}${red}"
|
||||||
|
echo "FAIL! ${diff_msg}"
|
||||||
|
echo "the file '${original}' does not exit"
|
||||||
|
echo "${reset}${red}"
|
||||||
|
caller
|
||||||
|
echo "${reset}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "${latest}" ]; then
|
||||||
|
echo "${bold}${red}"
|
||||||
|
echo "FAIL! ${diff_msg}"
|
||||||
|
echo "the file '${latest}' does not exit"
|
||||||
|
echo "${reset}${red}"
|
||||||
|
caller
|
||||||
|
echo "${reset}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${comparator}" == "exact" ]; then
|
||||||
|
# Skip sorting of file content for exact comparison.
|
||||||
|
cp "${original}" "${original}.sorted"
|
||||||
|
cp "${latest}" "${latest}.sorted"
|
||||||
|
else
|
||||||
|
sort "${original}" > "${original}.sorted"
|
||||||
|
sort "${latest}" > "${latest}.sorted"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${comparator}" == "eq" ] || [ "${comparator}" == "exact" ]; then
|
||||||
|
if [ "$(diff -iwB "${original}".sorted "${latest}".sorted)" == "" ] ; then
|
||||||
|
echo -n "${green}"
|
||||||
|
echo "Successful: ${diff_msg}"
|
||||||
|
echo -n "${reset}"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo "${bold}${red}"
|
||||||
|
echo "FAIL! ${diff_msg}"
|
||||||
|
echo " Expected: "
|
||||||
|
cat "${original}"
|
||||||
|
echo " Got: "
|
||||||
|
cat "${latest}"
|
||||||
|
echo "${reset}${red}"
|
||||||
|
caller
|
||||||
|
echo "${reset}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ -n "$(diff -iwB "${original}".sorted "${latest}".sorted)" ] ; then
|
||||||
|
echo -n "${green}"
|
||||||
|
echo "Successful: ${diff_msg}"
|
||||||
|
echo -n "${reset}"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo "${bold}${red}"
|
||||||
|
echo "FAIL! ${diff_msg}"
|
||||||
|
echo " Expected: "
|
||||||
|
cat "${original}"
|
||||||
|
echo " Got: "
|
||||||
|
cat "${latest}"
|
||||||
|
echo "${reset}${red}"
|
||||||
|
caller
|
||||||
|
echo "${reset}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Force exact match of kubectl stdout, stderr, and return code.
|
||||||
|
# $1: file with actual stdout
|
||||||
|
# $2: file with actual stderr
|
||||||
|
# $3: the actual return code
|
||||||
|
# $4: file with expected stdout
|
||||||
|
# $5: file with expected stderr
|
||||||
|
# $6: expected return code
|
||||||
|
# $7: additional message describing the invocation
|
||||||
|
openim::test::results::diff() {
|
||||||
|
local actualstdout=$1
|
||||||
|
local actualstderr=$2
|
||||||
|
local actualcode=$3
|
||||||
|
local expectedstdout=$4
|
||||||
|
local expectedstderr=$5
|
||||||
|
local expectedcode=$6
|
||||||
|
local message=$7
|
||||||
|
local result=0
|
||||||
|
|
||||||
|
if ! openim::test::version::diff_assert "${expectedstdout}" "exact" "${actualstdout}" "stdout for ${message}"; then
|
||||||
|
result=1
|
||||||
|
fi
|
||||||
|
if ! openim::test::version::diff_assert "${expectedstderr}" "exact" "${actualstderr}" "stderr for ${message}"; then
|
||||||
|
result=1
|
||||||
|
fi
|
||||||
|
if [ "${actualcode}" -ne "${expectedcode}" ]; then
|
||||||
|
echo "${bold}${red}"
|
||||||
|
echo "$(openim::test::get_caller): FAIL!"
|
||||||
|
echo "Return code for ${message}"
|
||||||
|
echo " Expected: ${expectedcode}"
|
||||||
|
echo " Got: ${actualcode}"
|
||||||
|
echo "${reset}${red}"
|
||||||
|
caller
|
||||||
|
echo "${reset}"
|
||||||
|
result=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${result}" -eq 0 ]; then
|
||||||
|
echo -n "${green}"
|
||||||
|
echo "$(openim::test::get_caller): Successful: ${message}"
|
||||||
|
echo -n "${reset}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
return "$result"
|
||||||
|
}
|
||||||
+228
-3
@@ -13,6 +13,70 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# this script is used to check whether the code is formatted by gofmt or not
|
||||||
|
#
|
||||||
|
# Usage: source scripts/lib/util.sh
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
#1、将IP写在一个文件里,比如文件名为hosts_file,一行一个IP地址。
|
||||||
|
#2、修改ssh-mutual-trust.sh里面的用户名及密码,默认为root用户及密码123。
|
||||||
|
# hosts_file_path="path/to/your/hosts/file"
|
||||||
|
# openim:util::setup_ssh_key_copy "$hosts_file_path" "root" "123"
|
||||||
|
function openim:util::setup_ssh_key_copy() {
|
||||||
|
local hosts_file="$1"
|
||||||
|
local username="${2:-root}"
|
||||||
|
local password="${3:-123}"
|
||||||
|
|
||||||
|
local sshkey_file=~/.ssh/id_rsa.pub
|
||||||
|
|
||||||
|
# check sshkey file
|
||||||
|
if [[ ! -e $sshkey_file ]]; then
|
||||||
|
expect -c "
|
||||||
|
spawn ssh-keygen -t rsa
|
||||||
|
expect \"Enter*\" { send \"\n\"; exp_continue; }
|
||||||
|
"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# get hosts list
|
||||||
|
local hosts=$(awk '/^[^#]/ {print $1}' "${hosts_file}")
|
||||||
|
|
||||||
|
ssh_key_copy() {
|
||||||
|
local target=$1
|
||||||
|
|
||||||
|
# delete history
|
||||||
|
sed -i "/$target/d" ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
# copy key
|
||||||
|
expect -c "
|
||||||
|
set timeout 100
|
||||||
|
spawn ssh-copy-id $username@$target
|
||||||
|
expect {
|
||||||
|
\"yes/no\" { send \"yes\n\"; exp_continue; }
|
||||||
|
\"*assword\" { send \"$password\n\"; }
|
||||||
|
\"already exist on the remote system\" { exit 1; }
|
||||||
|
}
|
||||||
|
expect eof
|
||||||
|
"
|
||||||
|
}
|
||||||
|
|
||||||
|
# auto sshkey pair
|
||||||
|
for host in $hosts; do
|
||||||
|
if ! ping -i 0.2 -c 3 -W 1 "$host" > /dev/null 2>&1; then
|
||||||
|
echo "[ERROR]: Can't connect $host"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
local host_entry=$(awk "/$host/"'{print $1, $2}' /etc/hosts)
|
||||||
|
if [[ $host_entry ]]; then
|
||||||
|
local hostaddr=$(echo "$host_entry" | awk '{print $1}')
|
||||||
|
local hostname=$(echo "$host_entry" | awk '{print $2}')
|
||||||
|
ssh_key_copy "$hostaddr"
|
||||||
|
ssh_key_copy "$hostname"
|
||||||
|
else
|
||||||
|
ssh_key_copy "$host"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
function openim::util::sourced_variable {
|
function openim::util::sourced_variable {
|
||||||
# Call this function to tell shellcheck that a variable is supposed to
|
# Call this function to tell shellcheck that a variable is supposed to
|
||||||
@@ -616,6 +680,50 @@ function openim::util::ensure-cfssl {
|
|||||||
popd > /dev/null || return 1
|
popd > /dev/null || return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# openim::util::ensure-docker-buildx
|
||||||
|
# Check if we have "docker buildx" commands available
|
||||||
|
#
|
||||||
|
function openim::util::ensure-docker-buildx {
|
||||||
|
# podman returns 0 on `docker buildx version`, docker on `docker buildx`. One of them must succeed.
|
||||||
|
if docker buildx version >/dev/null 2>&1 || docker buildx >/dev/null 2>&1; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo "ERROR: docker buildx not available. Docker 19.03 or higher is required with experimental features enabled"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# openim::util::ensure-bash-version
|
||||||
|
# Check if we are using a supported bash version
|
||||||
|
#
|
||||||
|
function openim::util::ensure-bash-version {
|
||||||
|
# shellcheck disable=SC2004
|
||||||
|
if ((${BASH_VERSINFO[0]}<4)) || ( ((${BASH_VERSINFO[0]}==4)) && ((${BASH_VERSINFO[1]}<2)) ); then
|
||||||
|
echo "ERROR: This script requires a minimum bash version of 4.2, but got version of ${BASH_VERSINFO[0]}.${BASH_VERSINFO[1]}"
|
||||||
|
if [ "$(uname)" = 'Darwin' ]; then
|
||||||
|
echo "On macOS with homebrew 'brew install bash' is sufficient."
|
||||||
|
fi
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# openim::util::ensure-install-nginx
|
||||||
|
# Check if nginx is installed
|
||||||
|
#
|
||||||
|
function openim::util::ensure-install-nginx {
|
||||||
|
if ! command -v nginx &>/dev/null; then
|
||||||
|
echo "ERROR: nginx not found. Please install nginx."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
for port in 80
|
||||||
|
do
|
||||||
|
if echo |telnet 127.0.0.1 $port 2>&1|grep refused &>/dev/null;then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# openim::util::ensure-gnu-sed
|
# openim::util::ensure-gnu-sed
|
||||||
# Determines which sed binary is gnu-sed on linux/darwin
|
# Determines which sed binary is gnu-sed on linux/darwin
|
||||||
#
|
#
|
||||||
@@ -637,6 +745,26 @@ function openim::util::ensure-gnu-sed {
|
|||||||
openim::util::sourced_variable "${SED}"
|
openim::util::sourced_variable "${SED}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# openim::util::ensure-gnu-date
|
||||||
|
# Determines which date binary is gnu-date on linux/darwin
|
||||||
|
#
|
||||||
|
# Sets:
|
||||||
|
# DATE: The name of the gnu-date binary
|
||||||
|
#
|
||||||
|
function openim::util::ensure-gnu-date {
|
||||||
|
# NOTE: the echo below is a workaround to ensure date is executed before the grep.
|
||||||
|
date_help="$(LANG=C date --help 2>&1 || true)"
|
||||||
|
if echo "${date_help}" | grep -q "GNU\|BusyBox"; then
|
||||||
|
DATE="date"
|
||||||
|
elif command -v gdate &>/dev/null; then
|
||||||
|
DATE="gdate"
|
||||||
|
else
|
||||||
|
openim::log::error "Failed to find GNU date as date or gdate. If you are on Mac: brew install coreutils." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
openim::util::sourced_variable "${DATE}"
|
||||||
|
}
|
||||||
|
|
||||||
# openim::util::check-file-in-alphabetical-order <file>
|
# openim::util::check-file-in-alphabetical-order <file>
|
||||||
# Check that the file is in alphabetical order
|
# Check that the file is in alphabetical order
|
||||||
#
|
#
|
||||||
@@ -710,12 +838,69 @@ fi
|
|||||||
|
|
||||||
# ex: ts=2 sw=2 et filetype=sh
|
# ex: ts=2 sw=2 et filetype=sh
|
||||||
|
|
||||||
|
function openim::util::desc() {
|
||||||
|
openim::util:run::maybe_first_prompt
|
||||||
|
rate=25
|
||||||
|
if [ -n "$DEMO_RUN_FAST" ]; then
|
||||||
|
rate=1000
|
||||||
|
fi
|
||||||
|
echo "$blue# $@$reset" | pv -qL $rate
|
||||||
|
openim::util:run::prompt
|
||||||
|
}
|
||||||
|
|
||||||
|
function openim::util:run::prompt() {
|
||||||
|
echo -n "$yellow\$ $reset"
|
||||||
|
}
|
||||||
|
|
||||||
|
started=""
|
||||||
|
function openim::util:run::maybe_first_prompt() {
|
||||||
|
if [ -z "$started" ]; then
|
||||||
|
openim::util:run::prompt
|
||||||
|
started=true
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# After a `run` this variable will hold the stdout of the command that was run.
|
||||||
|
# If the command was interactive, this will likely be garbage.
|
||||||
|
DEMO_RUN_STDOUT=""
|
||||||
|
|
||||||
|
function openim::util::run() {
|
||||||
|
openim::util:run::maybe_first_prompt
|
||||||
|
rate=25
|
||||||
|
if [ -n "$DEMO_RUN_FAST" ]; then
|
||||||
|
rate=1000
|
||||||
|
fi
|
||||||
|
echo "$green$1$reset" | pv -qL $rate
|
||||||
|
if [ -n "$DEMO_RUN_FAST" ]; then
|
||||||
|
sleep 0.5
|
||||||
|
fi
|
||||||
|
OFILE="$(mktemp -t $(basename $0).XXXXXX)"
|
||||||
|
if [ "$(uname)" == "Darwin" ]; then
|
||||||
|
script -q "$OFILE" $1
|
||||||
|
else
|
||||||
|
script -eq -c "$1" -f "$OFILE"
|
||||||
|
fi
|
||||||
|
r=$?
|
||||||
|
read -d '' -t "${timeout}" -n 10000 # clear stdin
|
||||||
|
openim::util:run::prompt
|
||||||
|
if [ -z "$DEMO_AUTO_RUN" ]; then
|
||||||
|
read -s
|
||||||
|
fi
|
||||||
|
DEMO_RUN_STDOUT="$(tail -n +2 $OFILE | sed 's/\r//g')"
|
||||||
|
return $r
|
||||||
|
}
|
||||||
|
|
||||||
|
function openim::util::run::relative() {
|
||||||
|
for arg; do
|
||||||
|
echo "$(realpath $(dirname $(which $0)))/$arg" | sed "s|$(realpath $(pwd))|.|"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# input: [10023, 2323, 3434]
|
# input: [10023, 2323, 3434]
|
||||||
# output: 10023 2323 3434
|
# output: 10023 2323 3434
|
||||||
|
|
||||||
# Function function: Converts a list to a string, removing Spaces and parentheses
|
# Function function: Converts a list to a string, removing Spaces and parentheses
|
||||||
function list_to_string() {
|
function openim::util::list-to-string() {
|
||||||
ports_list=$* # 获取传入的参数列表
|
ports_list=$* # 获取传入的参数列表
|
||||||
sub_s1=$(echo $ports_list | sed 's/ //g') # 去除空格
|
sub_s1=$(echo $ports_list | sed 's/ //g') # 去除空格
|
||||||
sub_s2=${sub_s1//,/ } # 将逗号替换为空格
|
sub_s2=${sub_s1//,/ } # 将逗号替换为空格
|
||||||
@@ -725,7 +910,47 @@ function list_to_string() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Function Function: Remove Spaces in the string
|
# Function Function: Remove Spaces in the string
|
||||||
function remove_space() {
|
function openim::util::remove_space() {
|
||||||
value=$* # 获取传入的参数
|
value=$* # 获取传入的参数
|
||||||
result=$(echo $value | sed 's/ //g') # 去除空格
|
result=$(echo $value | sed 's/ //g') # 去除空格
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openim::util::gen_os_arch() {
|
||||||
|
# Get the current operating system and architecture
|
||||||
|
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||||
|
ARCH=$(uname -m)
|
||||||
|
|
||||||
|
# Select the repository home directory based on the operating system and architecture
|
||||||
|
if [[ "$OS" == "darwin" ]]; then
|
||||||
|
if [[ "$ARCH" == "x86_64" ]]; then
|
||||||
|
REPO_DIR="darwin/amd64"
|
||||||
|
else
|
||||||
|
REPO_DIR="darwin/386"
|
||||||
|
fi
|
||||||
|
elif [[ "$OS" == "linux" ]]; then
|
||||||
|
if [[ "$ARCH" == "x86_64" ]]; then
|
||||||
|
REPO_DIR="linux/amd64"
|
||||||
|
elif [[ "$ARCH" == "arm64" ]]; then
|
||||||
|
REPO_DIR="linux/arm64"
|
||||||
|
elif [[ "$ARCH" == "mips64" ]]; then
|
||||||
|
REPO_DIR="linux/mips64"
|
||||||
|
elif [[ "$ARCH" == "mips64le" ]]; then
|
||||||
|
REPO_DIR="linux/mips64le"
|
||||||
|
elif [[ "$ARCH" == "ppc64le" ]]; then
|
||||||
|
REPO_DIR="linux/ppc64le"
|
||||||
|
elif [[ "$ARCH" == "s390x" ]]; then
|
||||||
|
REPO_DIR="linux/s390x"
|
||||||
|
else
|
||||||
|
REPO_DIR="linux/386"
|
||||||
|
fi
|
||||||
|
elif [[ "$OS" == "windows" ]]; then
|
||||||
|
if [[ "$ARCH" == "x86_64" ]]; then
|
||||||
|
REPO_DIR="windows/amd64"
|
||||||
|
else
|
||||||
|
REPO_DIR="windows/386"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo -e "${RED_PREFIX}Unsupported OS: $OS${COLOR_SUFFIX}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
@@ -12,7 +12,6 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Version management helpers. These functions help to set, save and load the
|
# Version management helpers. These functions help to set, save and load the
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ FIND := find . ! -path './utils/*' ! -path './vendor/*' ! -path './third_party/*
|
|||||||
XARGS := xargs -r --no-run-if-empty
|
XARGS := xargs -r --no-run-if-empty
|
||||||
|
|
||||||
# Linux command settings-CODE DIRS Copyright
|
# Linux command settings-CODE DIRS Copyright
|
||||||
CODE_DIRS := $(ROOT_DIR)/pkg $(ROOT_DIR)/cmd $(ROOT_DIR)/config $(ROOT_DIR)/db $(ROOT_DIR)/.docker-compose_cfg $(ROOT_DIR)/internal $(ROOT_DIR)/scripts $(ROOT_DIR)/test $(ROOT_DIR)/.github $(ROOT_DIR)/build $(ROOT_DIR)/build $(ROOT_DIR)/deployments
|
CODE_DIRS := $(ROOT_DIR)/pkg $(ROOT_DIR)/cmd $(ROOT_DIR)/config $(ROOT_DIR)/db $(ROOT_DIR)/.docker-compose_cfg $(ROOT_DIR)/internal $(ROOT_DIR)/scripts $(ROOT_DIR)/test $(ROOT_DIR)/.github $(ROOT_DIR)/build $(ROOT_DIR)/tools $(ROOT_DIR)/deployments
|
||||||
FINDS := find $(CODE_DIRS)
|
FINDS := find $(CODE_DIRS)
|
||||||
|
|
||||||
# Makefile settings: Select different behaviors by determining whether V option is set
|
# Makefile settings: Select different behaviors by determining whether V option is set
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
# Makefile helper functions for copyright
|
# Makefile helper functions for copyright
|
||||||
#
|
#
|
||||||
|
|
||||||
LICENSE_TEMPLATE ?= $(ROOT_DIR)/scripts/LICENSE/LICENSE_TEMPLATES
|
LICENSE_TEMPLATE ?= $(ROOT_DIR)/scripts/template/LICENSE_TEMPLATES
|
||||||
|
|
||||||
## copyright.verify: Validate boilerplate headers for assign files
|
## copyright.verify: Validate boilerplate headers for assign files
|
||||||
.PHONY: copyright.verify
|
.PHONY: copyright.verify
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
GO := go
|
GO := go
|
||||||
GO_SUPPORTED_VERSIONS ?= 1.18|1.19|1.20
|
GO_SUPPORTED_VERSIONS ?= 1.18|1.19|1.20|1.21
|
||||||
|
|
||||||
GO_LDFLAGS += -X $(VERSION_PACKAGE).gitVersion=$(GIT_TAG) \
|
GO_LDFLAGS += -X $(VERSION_PACKAGE).gitVersion=$(GIT_TAG) \
|
||||||
-X $(VERSION_PACKAGE).gitCommit=$(GIT_COMMIT) \
|
-X $(VERSION_PACKAGE).gitCommit=$(GIT_COMMIT) \
|
||||||
@@ -130,9 +130,10 @@ go.build.%:
|
|||||||
if [ -f $(ROOT_DIR)/cmd/$(COMMAND)/main.go ]; then \
|
if [ -f $(ROOT_DIR)/cmd/$(COMMAND)/main.go ]; then \
|
||||||
CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o \
|
CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o \
|
||||||
$(BIN_DIR)/platforms/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT) $(ROOT_DIR)/cmd/$(COMMAND)/main.go; \
|
$(BIN_DIR)/platforms/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT) $(ROOT_DIR)/cmd/$(COMMAND)/main.go; \
|
||||||
elif [ -f $(ROOT_DIR)/tools/$(COMMAND)/main.go ]; then \
|
elif [ -f $(ROOT_DIR)/tools/$(COMMAND)/$(COMMAND).go ]; then \
|
||||||
CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o \
|
CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o \
|
||||||
$(BIN_TOOLS_DIR)/platforms/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT) $(ROOT_DIR)/tools/$(COMMAND)/main.go; \
|
$(BIN_TOOLS_DIR)/platforms/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT) $(ROOT_DIR)/tools/$(COMMAND)/$(COMMAND).go; \
|
||||||
|
chmod +x $(BIN_TOOLS_DIR)/platforms/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT); \
|
||||||
fi \
|
fi \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -156,13 +157,19 @@ go.build.multiarch: go.build.verify $(foreach p,$(PLATFORMS),$(addprefix go.buil
|
|||||||
.PHONY: go.lint
|
.PHONY: go.lint
|
||||||
go.lint: tools.verify.golangci-lint
|
go.lint: tools.verify.golangci-lint
|
||||||
@echo "===========> Run golangci to lint source codes"
|
@echo "===========> Run golangci to lint source codes"
|
||||||
@$(TOOLS_DIR)/golangci-lint run --color always -c $(ROOT_DIR)/.golangci.yml $(ROOT_DIR)/...
|
@$(TOOLS_DIR)/golangci-lint run --color always -c $(ROOT_DIR)/scripts/golangci.yml $(ROOT_DIR)/...
|
||||||
|
|
||||||
## go.test: Run unit test
|
## go.test: Run unit test
|
||||||
.PHONY: go.test
|
.PHONY: go.test
|
||||||
go.test:
|
go.test:
|
||||||
@$(GO) test ./...
|
@$(GO) test ./...
|
||||||
|
|
||||||
|
## go.demo: Run demo
|
||||||
|
.PHONY: go.demo
|
||||||
|
go.demo:
|
||||||
|
@echo "===========> Run demo"
|
||||||
|
@$(ROOT_DIR)/scripts/demo.sh
|
||||||
|
|
||||||
## go.test.junit-report: Run unit test
|
## go.test.junit-report: Run unit test
|
||||||
.PHONY: go.test.junit-report
|
.PHONY: go.test.junit-report
|
||||||
go.test.junit-report: tools.verify.go-junit-report
|
go.test.junit-report: tools.verify.go-junit-report
|
||||||
|
|||||||
@@ -18,9 +18,8 @@ SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|||||||
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||||
|
|
||||||
#Include shell font styles and some basic information
|
#Include shell font styles and some basic information
|
||||||
source $SCRIPTS_ROOT/style_info.sh
|
source $SCRIPTS_ROOT/lib/init.sh
|
||||||
source $SCRIPTS_ROOT/path_info.sh
|
source $SCRIPTS_ROOT/path_info.sh
|
||||||
source $SCRIPTS_ROOT/function.sh
|
|
||||||
|
|
||||||
cd $SCRIPTS_ROOT
|
cd $SCRIPTS_ROOT
|
||||||
|
|
||||||
@@ -36,11 +35,11 @@ ulimit -n 200000
|
|||||||
list1=$(cat $config_path | grep openImMessageGatewayPort | awk -F '[:]' '{print $NF}')
|
list1=$(cat $config_path | grep openImMessageGatewayPort | awk -F '[:]' '{print $NF}')
|
||||||
list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}')
|
list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}')
|
||||||
list3=$(cat $config_path | grep messageGatewayPrometheusPort | awk -F '[:]' '{print $NF}')
|
list3=$(cat $config_path | grep messageGatewayPrometheusPort | awk -F '[:]' '{print $NF}')
|
||||||
list_to_string $list1
|
openim::util::list-to-string $list1
|
||||||
rpc_ports=($ports_array)
|
rpc_ports=($ports_array)
|
||||||
list_to_string $list2
|
openim::util::list-to-string $list2
|
||||||
ws_ports=($ports_array)
|
ws_ports=($ports_array)
|
||||||
list_to_string $list3
|
openim::util::list-to-string $list3
|
||||||
prome_ports=($ports_array)
|
prome_ports=($ports_array)
|
||||||
if [ ${#rpc_ports[@]} -ne ${#ws_ports[@]} ]; then
|
if [ ${#rpc_ports[@]} -ne ${#ws_ports[@]} ]; then
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,8 @@ SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|||||||
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||||
|
|
||||||
#Include shell font styles and some basic information
|
#Include shell font styles and some basic information
|
||||||
source $SCRIPTS_ROOT/style_info.sh
|
source $SCRIPTS_ROOT/lib/init.sh
|
||||||
source $SCRIPTS_ROOT/path_info.sh
|
source $SCRIPTS_ROOT/path_info.sh
|
||||||
source $SCRIPTS_ROOT/function.sh
|
|
||||||
|
|
||||||
echo -e "${YELLOW_PREFIX}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
|
echo -e "${YELLOW_PREFIX}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
|
||||||
echo -e "${YELLOW_PREFIX}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
|
echo -e "${YELLOW_PREFIX}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
|
||||||
@@ -32,7 +31,7 @@ logs_dir="$OPENIM_ROOT/logs"
|
|||||||
cd $OPENIM_ROOT
|
cd $OPENIM_ROOT
|
||||||
|
|
||||||
list1=$(cat $config_path | grep messageTransferPrometheusPort | awk -F '[:]' '{print $NF}')
|
list1=$(cat $config_path | grep messageTransferPrometheusPort | awk -F '[:]' '{print $NF}')
|
||||||
list_to_string $list1
|
openim::util::list-to-string $list1
|
||||||
prome_ports=($ports_array)
|
prome_ports=($ports_array)
|
||||||
|
|
||||||
#Check if the service exists
|
#Check if the service exists
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|||||||
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||||
|
|
||||||
#Include shell font styles and some basic information
|
#Include shell font styles and some basic information
|
||||||
source $SCRIPTS_ROOT/style_info.sh
|
source $SCRIPTS_ROOT/lib/color.sh
|
||||||
|
|
||||||
cd $SCRIPTS_ROOT
|
cd $SCRIPTS_ROOT
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,8 @@ SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|||||||
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||||
|
|
||||||
#Include shell font styles and some basic information
|
#Include shell font styles and some basic information
|
||||||
source $SCRIPTS_ROOT/style_info.sh
|
source $SCRIPTS_ROOT/lib/init.sh
|
||||||
source $SCRIPTS_ROOT/path_info.sh
|
source $SCRIPTS_ROOT/path_info.sh
|
||||||
source $SCRIPTS_ROOT/function.sh
|
|
||||||
|
|
||||||
cd $SCRIPTS_ROOT
|
cd $SCRIPTS_ROOT
|
||||||
|
|
||||||
@@ -37,9 +36,9 @@ cd "$OPENIM_ROOT/scripts/"
|
|||||||
|
|
||||||
list1=$(cat $config_path | grep openImPushPort | awk -F '[:]' '{print $NF}')
|
list1=$(cat $config_path | grep openImPushPort | awk -F '[:]' '{print $NF}')
|
||||||
list2=$(cat $config_path | grep pushPrometheusPort | awk -F '[:]' '{print $NF}')
|
list2=$(cat $config_path | grep pushPrometheusPort | awk -F '[:]' '{print $NF}')
|
||||||
list_to_string $list1
|
openim::util::list-to-string $list1
|
||||||
rpc_ports=($ports_array)
|
rpc_ports=($ports_array)
|
||||||
list_to_string $list2
|
openim::util::list-to-string $list2
|
||||||
prome_ports=($ports_array)
|
prome_ports=($ports_array)
|
||||||
|
|
||||||
#Check if the service exists
|
#Check if the service exists
|
||||||
|
|||||||
@@ -21,9 +21,8 @@ SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|||||||
OPENIM_ROOT=$(dirname "${SCRIPTS_ROOT}")/..
|
OPENIM_ROOT=$(dirname "${SCRIPTS_ROOT}")/..
|
||||||
|
|
||||||
#Include shell font styles and some basic information
|
#Include shell font styles and some basic information
|
||||||
source $SCRIPTS_ROOT/style_info.sh
|
source $SCRIPTS_ROOT/lib/init.sh
|
||||||
source $SCRIPTS_ROOT/path_info.sh
|
source $SCRIPTS_ROOT/path_info.sh
|
||||||
source $SCRIPTS_ROOT/function.sh
|
|
||||||
|
|
||||||
cd $SCRIPTS_ROOT
|
cd $SCRIPTS_ROOT
|
||||||
|
|
||||||
|
|||||||
@@ -19,9 +19,8 @@ SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|||||||
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||||
|
|
||||||
#Include shell font styles and some basic information
|
#Include shell font styles and some basic information
|
||||||
source $SCRIPTS_ROOT/style_info.sh
|
source $SCRIPTS_ROOT/lib/init.sh
|
||||||
source $SCRIPTS_ROOT/path_info.sh
|
source $SCRIPTS_ROOT/path_info.sh
|
||||||
source $SCRIPTS_ROOT/function.sh
|
|
||||||
|
|
||||||
cd $SCRIPTS_ROOT
|
cd $SCRIPTS_ROOT
|
||||||
|
|
||||||
|
|||||||
@@ -19,9 +19,8 @@ SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|||||||
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||||
|
|
||||||
#Include shell font styles and some basic information
|
#Include shell font styles and some basic information
|
||||||
source $SCRIPTS_ROOT/style_info.sh
|
source $SCRIPTS_ROOT/lib/init.sh
|
||||||
source $SCRIPTS_ROOT/path_info.sh
|
source $SCRIPTS_ROOT/path_info.sh
|
||||||
source $SCRIPTS_ROOT/function.sh
|
|
||||||
|
|
||||||
cd $SCRIPTS_ROOT
|
cd $SCRIPTS_ROOT
|
||||||
|
|
||||||
@@ -90,11 +89,11 @@ for ((i = 0; i < ${#service_filename[*]}; i++)); do
|
|||||||
cd $BIN_DIR
|
cd $BIN_DIR
|
||||||
# Get the rpc port in the configuration file
|
# Get the rpc port in the configuration file
|
||||||
portList=$(cat $config_path | grep ${service_port_name[$i]} | awk -F '[:]' '{print $NF}')
|
portList=$(cat $config_path | grep ${service_port_name[$i]} | awk -F '[:]' '{print $NF}')
|
||||||
list_to_string ${portList}
|
openim::util::list-to-string ${portList}
|
||||||
service_ports=($ports_array)
|
service_ports=($ports_array)
|
||||||
|
|
||||||
portList2=$(cat $config_path | grep ${service_prometheus_port_name[$i]} | awk -F '[:]' '{print $NF}')
|
portList2=$(cat $config_path | grep ${service_prometheus_port_name[$i]} | awk -F '[:]' '{print $NF}')
|
||||||
list_to_string $portList2
|
openim::util::list-to-string $portList2
|
||||||
prome_ports=($ports_array)
|
prome_ports=($ports_array)
|
||||||
#Start related rpc services based on the number of ports
|
#Start related rpc services based on the number of ports
|
||||||
for ((j = 0; j < ${#service_ports[*]}; j++)); do
|
for ((j = 0; j < ${#service_ports[*]}; j++)); do
|
||||||
|
|||||||
+3
-3
@@ -19,7 +19,7 @@ SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|||||||
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||||
|
|
||||||
#Include shell font styles and some basic information
|
#Include shell font styles and some basic information
|
||||||
source $OPENIM_ROOT/scripts/style_info.sh
|
source $OPENIM_ROOT/scripts/lib/init.sh
|
||||||
source $OPENIM_ROOT/scripts/path_info.sh
|
source $OPENIM_ROOT/scripts/path_info.sh
|
||||||
|
|
||||||
bin_dir="$BIN_DIR"
|
bin_dir="$BIN_DIR"
|
||||||
@@ -29,7 +29,7 @@ cd "$SCRIPTS_ROOT"
|
|||||||
|
|
||||||
for i in ${service_names[*]}; do
|
for i in ${service_names[*]}; do
|
||||||
#Check whether the service exists
|
#Check whether the service exists
|
||||||
name="ps |grep -w $i |grep -v grep"
|
name="ps -aux |grep -w $i |grep -v grep"
|
||||||
count="${name}| wc -l"
|
count="${name}| wc -l"
|
||||||
if [ $(eval ${count}) -gt 0 ]; then
|
if [ $(eval ${count}) -gt 0 ]; then
|
||||||
pid="${name}| awk '{print \$2}'"
|
pid="${name}| awk '{print \$2}'"
|
||||||
@@ -38,4 +38,4 @@ for i in ${service_names[*]}; do
|
|||||||
kill -9 $(eval $pid)
|
kill -9 $(eval $pid)
|
||||||
echo -e "${SKY_BLUE_PREFIX}service:$i was killed ${COLOR_SUFFIX}"
|
echo -e "${SKY_BLUE_PREFIX}service:$i was killed ${COLOR_SUFFIX}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Copyright © 2023 OpenIM. All rights reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
function style-info() {
|
|
||||||
COLOR_SUFFIX="\033[0m" # End all colors and special effects
|
|
||||||
|
|
||||||
BLACK_PREFIX="\033[30m" # Black prefix
|
|
||||||
RED_PREFIX="\033[31m" # Red prefix
|
|
||||||
GREEN_PREFIX="\033[32m" # Green prefix
|
|
||||||
YELLOW_PREFIX="\033[33m" # Yellow prefix
|
|
||||||
BLUE_PREFIX="\033[34m" # Blue prefix
|
|
||||||
PURPLE_PREFIX="\033[35m" # Purple prefix
|
|
||||||
SKY_BLUE_PREFIX="\033[36m" # Sky blue prefix
|
|
||||||
WHITE_PREFIX="\033[37m" # White prefix
|
|
||||||
BOLD_PREFIX="\033[1m" # Bold prefix
|
|
||||||
UNDERLINE_PREFIX="\033[4m" # Underline prefix
|
|
||||||
ITALIC_PREFIX="\033[3m" # Italic prefix
|
|
||||||
|
|
||||||
CYAN_PREFIX="033[0;36m" # Cyan prefix
|
|
||||||
|
|
||||||
BACKGROUND_BLACK="\033[40m" # Black background
|
|
||||||
BACKGROUND_RED="\033[41m" # Red background
|
|
||||||
BACKGROUND_GREEN="\033[42m" # Green background
|
|
||||||
BACKGROUND_YELLOW="\033[43m" # Yellow background
|
|
||||||
BACKGROUND_BLUE="\033[44m" # Blue background
|
|
||||||
BACKGROUND_PURPLE="\033[45m" # Purple background
|
|
||||||
BACKGROUND_SKY_BLUE="\033[46m" # Sky blue background
|
|
||||||
BACKGROUND_WHITE="\033[47m" # White background
|
|
||||||
|
|
||||||
BLINK="\033[5m" # Blinking effect
|
|
||||||
INVERT="\033[7m" # Invert color
|
|
||||||
HIDE="\033[8m" # Hide text
|
|
||||||
|
|
||||||
GRAY_PREFIX="\033[90m" # Gray prefix
|
|
||||||
LIGHT_RED_PREFIX="\033[91m" # Light red prefix
|
|
||||||
LIGHT_GREEN_PREFIX="\033[92m" # Light green prefix
|
|
||||||
LIGHT_YELLOW_PREFIX="\033[93m" # Light yellow prefix
|
|
||||||
LIGHT_BLUE_PREFIX="\033[94m" # Light blue prefix
|
|
||||||
LIGHT_PURPLE_PREFIX="\033[95m" # Light purple prefix
|
|
||||||
LIGHT_SKY_BLUE_PREFIX="\033[96m" # Light sky blue prefix
|
|
||||||
LIGHT_WHITE_PREFIX="\033[97m" # Light white prefix
|
|
||||||
|
|
||||||
BACKGROUND_GRAY="\033[100m" # Gray background
|
|
||||||
BACKGROUND_LIGHT_RED="\033[101m" # Light red background
|
|
||||||
BACKGROUND_LIGHT_GREEN="\033[102m" # Light green background
|
|
||||||
BACKGROUND_LIGHT_YELLOW="\033[103m" # Light yellow background
|
|
||||||
BACKGROUND_LIGHT_BLUE="\033[104m" # Light blue background
|
|
||||||
BACKGROUND_LIGHT_PURPLE="\033[105m" # Light purple background
|
|
||||||
BACKGROUND_LIGHT_SKY_BLUE="\033[106m" # Light sky blue background
|
|
||||||
BACKGROUND_LIGHT_WHITE="\033[107m" # Light white background
|
|
||||||
}
|
|
||||||
|
|
||||||
style-info
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
Copyright © {{.Year}} {{.Holder}} All rights reserved.
|
||||||
|
Use of this source code is governed by a MIT style
|
||||||
|
license that can be found in the LICENSE file.
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
**Full Changelog**: https://github.com/{{ .Env.USERNAME }}/{{ .ProjectName }}/compare/{{ .PreviousTag }}...{{ .Tag }}
|
||||||
|
|
||||||
|
## Get Involved with OpenIM!
|
||||||
|
|
||||||
|
Your patronage towards OpenIM is greatly appreciated 🎉🎉.
|
||||||
|
|
||||||
|
If you encounter any problems during its usage, please create an issue in the [GitHub repository](https://github.com/{{ .Env.USERNAME }}/{{ .ProjectName }}/), we're committed to resolving your problem as soon as possible.
|
||||||
|
|
||||||
|
**Here are some ways to get involved with the OpenIM community:**
|
||||||
|
|
||||||
|
📢 **Slack Channel**: Join our Slack channels for discussions, communication, and support. Click [here](https://join.slack.com/t/openimsdk/shared_invite/zt-1tmoj26uf-_FDy3dowVHBiGvLk9e5Xkg) to join the Open-IM-Server Slack team channel.
|
||||||
|
|
||||||
|
📧 **Gmail Contact**: If you have any questions, suggestions, or feedback for our open-source projects, please feel free to [contact us via email](https://mail.google.com/mail/?view=cm&fs=1&tf=1&to=winxu81@gmail.com).
|
||||||
|
|
||||||
|
📖 **Blog**: Stay up-to-date with OpenIM-Server projects and trends by reading our [blog](https://doc.rentsoft.cn/). We share the latest developments, tech trends, and other interesting information related to OpenIM.
|
||||||
|
|
||||||
|
📱 **WeChat**: Add us on WeChat (QR Code) and indicate that you are a user or developer of Open-IM-Server. We'll process your request as soon as possible.
|
||||||
|
|
||||||
|
Remember, your contributions play a vital role in making OpenIM successful, and we look forward to your active participation in our community! 🙌
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
|
||||||
|
**Full Changelog**: https://github.com/OpenIMSDK/Open-IM-Server/compare/{{ .PreviousTag }}...{{ .Tag }}
|
||||||
|
|
||||||
|
## Helping out
|
||||||
|
|
||||||
|
+ We release logs are recorded on [✨CHANGELOG](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/CHANGELOG/CHANGELOG.md)
|
||||||
|
|
||||||
|
+ For information on versions of OpenIM and how to maintain branches, read [📚this article](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/version.md)
|
||||||
|
|
||||||
|
+ If you wish to use mirroring, read OpenIM's [image management policy](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/images.md)
|
||||||
|
|
||||||
|
**Want to be one of them 😘?**
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://github.com/kubbot" style="float: left; margin-right: 10px;">
|
||||||
|
<img src="https://github.com/openimbot/openimbot/blob/main/assets/icon/blue%E9%80%8F%E6%98%8E.png" width="50" height="50" />
|
||||||
|
</a>
|
||||||
|
<a href="https://www.openim.online">
|
||||||
|
<img src="https://github.com/OpenIMSDK/Open-IM-Server/blob/main/assets/logo/openim-logo.png" />
|
||||||
|
</a>
|
||||||
|
<a href="https://github.com/openimbot" style="float: right; margin-left: 10px;">
|
||||||
|
<img src="https://github.com/openimbot/openimbot/blob/main/assets/icon/red%E9%80%8F%E6%98%8E.png" width="50" height="50" />
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
> **Note**
|
||||||
|
> @openimbot and @kubbot have made great contributions to the community as community 🤖robots(@openimsdk/bot), respectively.
|
||||||
|
> Thanks to the @openimsdk/openim team for all their hard work on this release.
|
||||||
|
> Thank you to all the [💕developers and contributors](https://github.com/OpenIMSDK/Open-IM-Server/graphs/contributors), people from all over the world, OpenIM brings us together
|
||||||
|
> Contributions to this project are welcome! Please see [CONTRIBUTING.md](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/CONTRIBUTING.md) for details.
|
||||||
|
|
||||||
|
## Get Involved with OpenIM!
|
||||||
|
|
||||||
|
**Here are some ways to get involved with the OpenIM community:**
|
||||||
|
|
||||||
|
📢 **Slack Channel**: Join our Slack channels for discussions, communication, and support. Click [here](https://join.slack.com/t/openimsdk/shared_invite/zt-1tmoj26uf-_FDy3dowVHBiGvLk9e5Xkg) to join the Open-IM-Server Slack team channel.
|
||||||
|
|
||||||
|
📧 **Gmail Contact**: If you have any questions, suggestions, or feedback for our open-source projects, please feel free to [contact us via email](https://mail.google.com/mail/?view=cm&fs=1&tf=1&to=winxu81@gmail.com).
|
||||||
|
|
||||||
|
📖 **Blog**: Stay up-to-date with OpenIM-Server projects and trends by reading our [blog](https://doc.rentsoft.cn/). We share the latest developments, tech trends, and other interesting information related to OpenIM.
|
||||||
|
|
||||||
|
📱 **WeChat**: Add us on WeChat (QR Code) and indicate that you are a user or developer of Open-IM-Server. We'll process your request as soon as possible.
|
||||||
|
|
||||||
|
Remember, your contributions play a vital role in making OpenIM successful, and we look forward to your active participation in our community! 🙌
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
## Welcome to the {{ .Tag }} release of [OpenIM](https://github.com/{{ .Env.USERNAME }}/{{ .ProjectName }})!🎉🎉!
|
||||||
|
|
||||||
|
We are excited to release {{.Tag}}, Branch: https://github.com/{{ .Env.USERNAME }}/{{ .ProjectName }}/tree/{{ .Tag }} , Git hash [{{ .ShortCommit }}], Install Address: [{{ .ReleaseURL }}]({{ .ReleaseURL }})
|
||||||
|
|
||||||
|
Learn more about versions of OpenIM:
|
||||||
|
|
||||||
|
+ We release logs are recorded on [✨CHANGELOG](https://github.com/{{ .Env.USERNAME }}/{{ .ProjectName }}/blob/main/CHANGELOG/CHANGELOG.md)
|
||||||
|
|
||||||
|
+ For information on versions of OpenIM and how to maintain branches, read [📚this article](https://github.com/{{ .Env.USERNAME }}/{{ .ProjectName }}/blob/main/docs/conversions/version.md)
|
||||||
|
|
||||||
|
+ If you wish to use mirroring, read OpenIM's [🤲image management policy](https://github.com/{{ .Env.USERNAME }}/{{ .ProjectName }}/blob/main/docs/conversions/images.md)
|
||||||
|
|
||||||
|
**Want to be one of them 😘?**
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://github.com/kubbot" style="float: left; margin-right: 10px;">
|
||||||
|
<img src="https://github.com/openimbot/openimbot/blob/main/assets/icon/blue%E9%80%8F%E6%98%8E.png" width="50" height="50" />
|
||||||
|
</a>
|
||||||
|
<a href="https://www.openim.online">
|
||||||
|
<img src="https://github.com/OpenIMSDK/Open-IM-Server/blob/main/assets/logo/openim-logo.png" />
|
||||||
|
</a>
|
||||||
|
<a href="https://github.com/openimbot" style="float: right; margin-left: 10px;">
|
||||||
|
<img src="https://github.com/openimbot/openimbot/blob/main/assets/icon/red%E9%80%8F%E6%98%8E.png" width="50" height="50" />
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
> **Note**
|
||||||
|
> @openimbot and @kubbot have made great contributions to the community as community 🤖robots(@openimsdk/bot), respectively.
|
||||||
|
> Thanks to the @openimsdk/openim team for all their hard work on this release.
|
||||||
|
> Thank you to all the [💕developers and contributors](https://github.com/OpenIMSDK/Open-IM-Server/graphs/contributors), people from all over the world, OpenIM brings us together
|
||||||
|
> Contributions to this project are welcome! Please see [CONTRIBUTING.md](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/CONTRIBUTING.md) for details.
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
# Project myproject
|
||||||
|
|
||||||
|
<!-- Write one paragraph of this project description here -->
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
<!-- Tell others the features of this project -->
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
### Prerequisites
|
||||||
|
|
||||||
|
<!-- Describe packages, tools and everything we needed here -->
|
||||||
|
|
||||||
|
### Building
|
||||||
|
|
||||||
|
<!-- Describe how to build this project -->
|
||||||
|
|
||||||
|
### Running
|
||||||
|
|
||||||
|
<!-- Describe how to run this project -->
|
||||||
|
|
||||||
|
## Using
|
||||||
|
|
||||||
|
<!-- Place user documents here -->
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
<!-- Tell others how to contribute this project -->
|
||||||
|
|
||||||
|
## Community(optional)
|
||||||
|
|
||||||
|
<!-- Tell something about the community if needed -->
|
||||||
|
|
||||||
|
## Authors
|
||||||
|
|
||||||
|
<!-- Put authors here -->
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
<!-- A link to license file -->
|
||||||
Executable
+43
@@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||||
|
source "${OPENIM_ROOT}/hack/lib/init.sh"
|
||||||
|
|
||||||
|
kube::golang::setup_env
|
||||||
|
|
||||||
|
cd "${OPENIM_ROOT}"
|
||||||
|
|
||||||
|
find_files() {
|
||||||
|
find . -not \( \
|
||||||
|
\( \
|
||||||
|
-wholename './output' \
|
||||||
|
-o -wholename './.git' \
|
||||||
|
-o -wholename './_output' \
|
||||||
|
-o -wholename './_gopath' \
|
||||||
|
-o -wholename './release' \
|
||||||
|
-o -wholename './target' \
|
||||||
|
-o -wholename '*/vendor/*' \
|
||||||
|
\) -prune \
|
||||||
|
\) -name 'OWNERS*'
|
||||||
|
}
|
||||||
|
|
||||||
|
export GO111MODULE=on
|
||||||
|
find_files | xargs go run tools/yamlfmt/main.go
|
||||||
Executable
+48
@@ -0,0 +1,48 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
|
# This script checks whether the OWNERS files need to be formatted or not by
|
||||||
|
# `yamlfmt`. Run `scripts/update-yamlfmt.sh` to actually format sources.
|
||||||
|
#
|
||||||
|
# Usage: `scripts/verify-yamlfmt.sh`.
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||||
|
source "${OPENIM_ROOT}/scripts/lib/init.sh"
|
||||||
|
|
||||||
|
openim::util::ensure_clean_working_dir
|
||||||
|
# This sets up the environment, like GOCACHE, which keeps the worktree cleaner.
|
||||||
|
openim::golang::setup_env
|
||||||
|
|
||||||
|
_tmpdir="$(openim::realpath "$(mktemp -d -t "$(basename "$0").XXXXXX")")"
|
||||||
|
git worktree add -f -q "${_tmpdir}" HEAD
|
||||||
|
openim::util::trap_add "git worktree remove -f ${_tmpdir}" EXIT
|
||||||
|
cd "${_tmpdir}"
|
||||||
|
|
||||||
|
# Format YAML files
|
||||||
|
hack/update-yamlfmt.sh
|
||||||
|
|
||||||
|
# Test for diffs
|
||||||
|
diffs=$(git status --porcelain | wc -l)
|
||||||
|
if [[ ${diffs} -gt 0 ]]; then
|
||||||
|
echo "YAML files need to be formatted" >&2
|
||||||
|
git diff
|
||||||
|
echo "Please run 'hack/update-yamlfmt.sh'" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
+14
-8
@@ -1,15 +1,21 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
# Copyright © 2023 OpenIM. All rights reserved.
|
||||||
# Copyright 2020 Lingfei Kong <colin404@foxmail.com>. All rights reserved.
|
#
|
||||||
# Use of this source code is governed by a MIT style
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# license that can be found in the LICENSE file.
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
# Use this script to test if a given TCP host/port are available
|
# Use this script to test if a given TCP host/port are available
|
||||||
|
|
||||||
WAITFORIT_cmdname=${0##*/}
|
WAITFORIT_cmdname=${0##*/}
|
||||||
|
. $(dirname ${BASH_SOURCE})/lib/init.sh
|
||||||
openim_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
|
|
||||||
source "${openim_root}/scripts/lib/color.sh"
|
|
||||||
|
|
||||||
echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then info "$@" 1>&2; fi }
|
echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then info "$@" 1>&2; fi }
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
## Run the Tests
|
||||||
|
|
||||||
|
To run a single test or set of tests, you'll need the [Ginkgo](https://github.com/onsi/ginkgo) tool installed on your
|
||||||
|
machine:
|
||||||
|
|
||||||
|
```console
|
||||||
|
go install github.com/onsi/ginkgo/ginkgo@latest
|
||||||
|
```
|
||||||
|
|
||||||
|
```shell
|
||||||
|
ginkgo --help
|
||||||
|
--focus value
|
||||||
|
If set, ginkgo will only run specs that match this regular expression. Can be specified multiple times, values are ORed.
|
||||||
|
|
||||||
|
```
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
// Copyright 2020 Lingfei Kong <colin404@foxmail.com>. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/golang-jwt/jwt/v4"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
rawJWT := `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJpYW0uYXV0aHoubWFybW90ZWR1LmNvbSIsImV4cCI6MTYwNDEyODQwMywiaWF0IjoxNjA0MTI4NDAyLCJpc3MiOiJpYW1jdGwiLCJraWQiOiJpZDEifQ.Itr5u4C-nTeA01qbjjl7RzuPD-aSQazsJZY_Z25aGnI`
|
||||||
|
|
||||||
|
// Verify the token
|
||||||
|
claims := &jwt.MapClaims{}
|
||||||
|
parsedT, err := jwt.ParseWithClaims(rawJWT, claims, func(token *jwt.Token) (interface{}, error) {
|
||||||
|
// Validate the alg is HMAC signature
|
||||||
|
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"])
|
||||||
|
}
|
||||||
|
|
||||||
|
if kid, ok := token.Header["kid"].(string); ok {
|
||||||
|
fmt.Println("kid", kid)
|
||||||
|
}
|
||||||
|
|
||||||
|
return []byte("key1"), nil
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil || !parsedT.Valid {
|
||||||
|
fmt.Println("token valid failed", err)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("ok")
|
||||||
|
}
|
||||||
Vendored
+64
@@ -0,0 +1,64 @@
|
|||||||
|
|
||||||
|
# Test Data for OpenIM Server
|
||||||
|
|
||||||
|
This directory (`testdata`) contains various JSON formatted data files that are used for testing the OpenIM Server.
|
||||||
|
|
||||||
|
## Structure
|
||||||
|
|
||||||
|
```bash
|
||||||
|
testdata/
|
||||||
|
│
|
||||||
|
├── README.md # 描述该目录下各子目录和文件的作用
|
||||||
|
│
|
||||||
|
├── db/ # 存储模拟的数据库数据
|
||||||
|
│ ├── users.json # 用户的模拟数据
|
||||||
|
│ └── messages.json # 消息的模拟数据
|
||||||
|
│
|
||||||
|
├── requests/ # 存储模拟的请求数据
|
||||||
|
│ ├── login.json # 模拟登陆请求
|
||||||
|
│ ├── register.json # 模拟注册请求
|
||||||
|
│ └── sendMessage.json # 模拟发送消息请求
|
||||||
|
│
|
||||||
|
└── responses/ # 存储模拟的响应数据
|
||||||
|
├── login.json # 模拟登陆响应
|
||||||
|
├── register.json # 模拟注册响应
|
||||||
|
└── sendMessage.json # 模拟发送消息响应
|
||||||
|
```
|
||||||
|
|
||||||
|
Here is an overview of what each subdirectory or file represents:
|
||||||
|
|
||||||
|
- `db/` - This directory contains mock data mimicking the actual database contents.
|
||||||
|
- `users.json` - Represents a list of users in the system. Each entry contains user-specific information such as user ID, username, password hash, etc.
|
||||||
|
- `messages.json` - Contains a list of messages exchanged between users. Each message entry includes the sender's and receiver's user IDs, message content, timestamp, etc.
|
||||||
|
- `requests/` - This directory contains mock requests that a client might send to the server.
|
||||||
|
- `login.json` - Represents a user login request. It includes fields such as username and password.
|
||||||
|
- `register.json` - Mimics a user registration request. Contains details such as username, password, email, etc.
|
||||||
|
- `sendMessage.json` - Simulates a message sending request from a user to another user.
|
||||||
|
- `responses/` - This directory holds the expected server responses for the respective requests.
|
||||||
|
- `login.json` - Represents a successful login response from the server. It typically includes a session token and user-specific information.
|
||||||
|
- `register.json` - Simulates a successful registration response from the server, usually containing the new user's ID, username, etc.
|
||||||
|
- `sendMessage.json` - Depicts a successful message sending response from the server, confirming the delivery of the message.
|
||||||
|
|
||||||
|
## JSON Format
|
||||||
|
|
||||||
|
All the data files in this directory are in JSON format. JSON (JavaScript Object Notation) is a lightweight data-interchange format that is easy for humans to read and write and easy for machines to parse and generate.
|
||||||
|
|
||||||
|
Here is a simple example of what a JSON file might look like:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
"users": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"username": "user1",
|
||||||
|
"password": "password1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"username": "user2",
|
||||||
|
"password": "password2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
In this example, "users" is an array of user objects. Each user object has an "id", "username", and "password".
|
||||||
Vendored
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user