Compare commits
1 Commits
d75e519d8f
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7a5e83383 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -6,7 +6,7 @@ test/docker/vendor
|
||||
test/kubernetes/vendor
|
||||
build
|
||||
coverage
|
||||
#downloads
|
||||
downloads
|
||||
incubating/mqipt/ms81*
|
||||
vendor/github.com/prometheus/client_model/bin/
|
||||
vendor/github.com/prometheus/client_model/.classpath
|
||||
|
||||
16
.travis.yml
16
.travis.yml
@@ -18,7 +18,7 @@ sudo: required
|
||||
language: go
|
||||
|
||||
go:
|
||||
- "1.19.9"
|
||||
- "1.18.9"
|
||||
|
||||
services:
|
||||
- docker
|
||||
@@ -42,7 +42,7 @@ jobs:
|
||||
name: "Basic AMD64 build"
|
||||
os: linux
|
||||
env:
|
||||
- MQ_ARCHIVE_REPOSITORY_DEV=$MQ_933_ARCHIVE_REPOSITORY_DEV_AMD64
|
||||
- MQ_ARCHIVE_REPOSITORY_DEV=$MQ_932_ARCHIVE_REPOSITORY_DEV_AMD64
|
||||
script: bash -e travis-build-scripts/run.sh
|
||||
|
||||
# CD Build
|
||||
@@ -58,8 +58,8 @@ jobs:
|
||||
os: linux
|
||||
env:
|
||||
- BUILD_ALL=true
|
||||
- MQ_ARCHIVE_REPOSITORY=$MQ_933_ARCHIVE_REPOSITORY_AMD64
|
||||
- MQ_ARCHIVE_REPOSITORY_DEV=$MQ_933_ARCHIVE_REPOSITORY_DEV_AMD64
|
||||
- MQ_ARCHIVE_REPOSITORY=$MQ_932_ARCHIVE_REPOSITORY_AMD64
|
||||
- MQ_ARCHIVE_REPOSITORY_DEV=$MQ_932_ARCHIVE_REPOSITORY_DEV_AMD64
|
||||
script: bash -e travis-build-scripts/run.sh
|
||||
- stage: build
|
||||
if: branch = private-master OR tag =~ ^release-candidate*
|
||||
@@ -68,8 +68,8 @@ jobs:
|
||||
env:
|
||||
- BUILD_ALL=true
|
||||
- TEST_OPTS_DOCKER="-run TestGoldenPathWithMetrics"
|
||||
- MQ_ARCHIVE_REPOSITORY=$MQ_933_ARCHIVE_REPOSITORY_S390X
|
||||
- MQ_ARCHIVE_REPOSITORY_DEV=$MQ_933_ARCHIVE_REPOSITORY_DEV_S390X
|
||||
- MQ_ARCHIVE_REPOSITORY=$MQ_932_ARCHIVE_REPOSITORY_S390X
|
||||
- MQ_ARCHIVE_REPOSITORY_DEV=$MQ_932_ARCHIVE_REPOSITORY_DEV_S390X
|
||||
script: bash -e travis-build-scripts/run.sh
|
||||
- stage: build
|
||||
if: branch = private-master OR tag =~ ^release-candidate*
|
||||
@@ -78,8 +78,8 @@ jobs:
|
||||
env:
|
||||
- BUILD_ALL=true
|
||||
- TEST_OPTS_DOCKER="-run TestGoldenPathWithMetrics"
|
||||
- MQ_ARCHIVE_REPOSITORY=$MQ_933_ARCHIVE_REPOSITORY_PPC64LE
|
||||
- MQ_ARCHIVE_REPOSITORY_DEV=$MQ_933_ARCHIVE_REPOSITORY_DEV_PPC64LE
|
||||
- MQ_ARCHIVE_REPOSITORY=$MQ_932_ARCHIVE_REPOSITORY_PPC64LE
|
||||
- MQ_ARCHIVE_REPOSITORY_DEV=$MQ_932_ARCHIVE_REPOSITORY_DEV_PPC64LE
|
||||
script: bash -e travis-build-scripts/run.sh
|
||||
- stage: push-manifest
|
||||
if: branch = private-master AND type != pull_request OR tag =~ ^release-candidate*
|
||||
|
||||
39
CBO.md
39
CBO.md
@@ -1,39 +0,0 @@
|
||||
# MQ in Docker
|
||||
|
||||
## Download new version
|
||||
Download IBM MQ Advanced for Developers here: https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/
|
||||
Place the file in the downloads folder of this repo.
|
||||
|
||||
```bash
|
||||
mkdir -p downloads
|
||||
wget -P downloads https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/9.3.3.1-IBM-MQ-Advanced-for-Developers-Non-Install-LinuxX64.tar.gz
|
||||
wget -P downloads https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/9.3.3.1-IBM-MQ-Advanced-for-Developers-Non-Install-LinuxARM64.tar.gz
|
||||
```
|
||||
|
||||
# Build Docker image
|
||||
Update ```MQ_ARCHIVE``` with the new filename in the two Dockerfiles
|
||||
```bash
|
||||
nano Dockerfile-server-arm
|
||||
nano Dockerfile-server-x64
|
||||
```
|
||||
|
||||
Build the new images
|
||||
```bash
|
||||
docker buildx build -t <tag> -f <dockerfile> .
|
||||
|
||||
# Build for various architechtures
|
||||
docker buildx build --platform linux/amd64 -t git.cbo.dk/academy/mq:9.3.3.1-amd64 -f Dockerfile-server-x64 .
|
||||
docker buildx build --platform linux/arm64 -t git.cbo.dk/academy/mq:9.3.3.1-arm64 -f Dockerfile-server-arm .
|
||||
docker image tag git.cbo.dk/academy/mq:9.3.3.1-amd64 git.cbo.dk/academy/mq:latest
|
||||
|
||||
# Push to registry (Optional)
|
||||
docker login git.cbo.dk
|
||||
docker push --all-tags git.cbo.dk/academy/mq
|
||||
```
|
||||
|
||||
# Deploy MQ
|
||||
```bash
|
||||
docker stop ibmmq
|
||||
docker rm ibmmq
|
||||
docker run --name "ibmmq" -d -p 1414:1414 -p 9157:9157 -p 9443:9443 -e LICENSE=accept -e MQ_ADMIN_PASSWORD=passw0rd -e MQ_QMGR_NAME=MQDOCKER -e MQ_ENABLE_METRICS=true --name ibmmq git.cbo.dk/academy/mq:latest
|
||||
```
|
||||
@@ -1,9 +1,5 @@
|
||||
# Change log
|
||||
|
||||
## 9.3.3.0 (2023-06)
|
||||
|
||||
* Updated to MQ version 9.3.3.0
|
||||
|
||||
## 9.3.2.0 (2023-02)
|
||||
|
||||
* Updated to MQ version 9.3.2.0
|
||||
|
||||
@@ -12,19 +12,12 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Download IBM MQ Advanced for Developers here: https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/
|
||||
# mkdir downloads
|
||||
# Kopier 9.3.3.0-IBM-MQ-Advanced-for-Developers-Non-Install-LinuxX64.tar.gz ind i downloads.
|
||||
# Opdater .dockerignore
|
||||
# docker build -t mqserver -f Dockerfile-server-x64 .
|
||||
# docker run -d -p 1414:1414 -p 9157:9157 -p 9443:9443 -e LICENSE=accept --name mqserver mqserver
|
||||
|
||||
ARG BASE_IMAGE=registry.access.redhat.com/ubi8/ubi-minimal
|
||||
ARG BASE_TAG=8.8-860
|
||||
ARG BASE_TAG=8.7-1049.1675784874
|
||||
ARG BUILDER_IMAGE=registry.access.redhat.com/ubi8/go-toolset
|
||||
ARG BUILDER_TAG=1.19.9-2
|
||||
ARG BUILDER_TAG=1.18.9-8.1675807488
|
||||
ARG GO_WORKDIR=/opt/app-root/src/go/src/github.com/ibm-messaging/mq-container
|
||||
ARG MQ_ARCHIVE="downloads/9.3.3.0-IBM-MQ-Advanced-for-Developers-Non-Install-LinuxX64.tar.gz"
|
||||
ARG MQ_ARCHIVE="downloads/9.3.2.0-IBM-MQ-Advanced-for-Developers-Non-Install-LinuxX64.tar.gz"
|
||||
|
||||
###############################################################################
|
||||
# Build stage to build Go code
|
||||
@@ -1,210 +0,0 @@
|
||||
# © Copyright IBM Corporation 2015, 2023
|
||||
#
|
||||
# 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.
|
||||
|
||||
# Download IBM MQ Advanced for Developers here: https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/
|
||||
# mkdir downloads
|
||||
# Kopier 9.3.3.0-IBM-MQ-Advanced-for-Developers-Non-Install-LinuxARM64.tar.gz ind i downloads.
|
||||
# Opdater .dockerignore
|
||||
# docker build -t mqserver -f Dockerfile-server-arm .
|
||||
# docker run -d -p 1414:1414 -p 9157:9157 -p 9443:9443 -e LICENSE=accept --name mqserver mqserver
|
||||
|
||||
ARG BASE_IMAGE=registry.access.redhat.com/ubi8/ubi-minimal
|
||||
ARG BASE_TAG=8.8-860
|
||||
ARG BUILDER_IMAGE=registry.access.redhat.com/ubi8/go-toolset
|
||||
ARG BUILDER_TAG=1.19.9-2
|
||||
ARG GO_WORKDIR=/opt/app-root/src/go/src/github.com/ibm-messaging/mq-container
|
||||
ARG MQ_ARCHIVE="downloads/9.3.3.1-IBM-MQ-Advanced-for-Developers-Non-Install-LinuxARM64.tar.gz"
|
||||
|
||||
###############################################################################
|
||||
# Build stage to build Go code
|
||||
###############################################################################
|
||||
FROM $BUILDER_IMAGE:$BUILDER_TAG as builder
|
||||
ARG IMAGE_REVISION="Not specified"
|
||||
ARG IMAGE_SOURCE="Not specified"
|
||||
ARG IMAGE_TAG="Not specified"
|
||||
ARG GO_WORKDIR
|
||||
ARG MQ_ARCHIVE
|
||||
USER 0
|
||||
WORKDIR $GO_WORKDIR/
|
||||
ADD $MQ_ARCHIVE /opt/mqm
|
||||
ENV CGO_CFLAGS="-I/opt/mqm/inc/" \
|
||||
CGO_LDFLAGS_ALLOW="-Wl,-rpath.*" \
|
||||
PATH="${PATH}:/opt/mqm/bin"
|
||||
COPY go.mod go.sum ./
|
||||
COPY cmd/ ./cmd
|
||||
COPY internal/ ./internal
|
||||
COPY pkg/ ./pkg
|
||||
COPY vendor/ ./vendor
|
||||
RUN go build -ldflags "-X \"main.ImageCreated=$(date --iso-8601=seconds)\" -X \"main.ImageRevision=$IMAGE_REVISION\" -X \"main.ImageSource=$IMAGE_SOURCE\" -X \"main.ImageTag=$IMAGE_TAG\"" ./cmd/runmqserver/ \
|
||||
&& go build ./cmd/chkmqready/ \
|
||||
&& go build ./cmd/chkmqhealthy/ \
|
||||
&& go build ./cmd/chkmqstarted/ \
|
||||
&& go build ./cmd/runmqdevserver/ \
|
||||
&& go test -v ./cmd/runmqdevserver/... \
|
||||
&& go test -v ./cmd/runmqserver/ \
|
||||
&& go test -v ./cmd/chkmqready/ \
|
||||
&& go test -v ./cmd/chkmqhealthy/ \
|
||||
&& go test -v ./cmd/chkmqstarted/ \
|
||||
&& go test -v ./pkg/... \
|
||||
&& go test -v ./internal/... \
|
||||
&& go vet ./cmd/... ./internal/...
|
||||
|
||||
###############################################################################
|
||||
# Build stage to reduce MQ packages included using genmqpkg
|
||||
###############################################################################
|
||||
FROM $BASE_IMAGE:$BASE_TAG AS mq-redux
|
||||
ARG BASE_IMAGE
|
||||
ARG BASE_TAG
|
||||
ARG MQ_ARCHIVE
|
||||
WORKDIR /tmp/mq
|
||||
ENV genmqpkg_inc32=0 \
|
||||
genmqpkg_incadm=1 \
|
||||
genmqpkg_incamqp=0 \
|
||||
genmqpkg_incams=1 \
|
||||
genmqpkg_inccbl=0 \
|
||||
genmqpkg_inccics=0 \
|
||||
genmqpkg_inccpp=0 \
|
||||
genmqpkg_incdnet=0 \
|
||||
genmqpkg_incjava=1 \
|
||||
genmqpkg_incjre=1 \
|
||||
genmqpkg_incman=0 \
|
||||
genmqpkg_incmqbc=0 \
|
||||
genmqpkg_incmqft=0 \
|
||||
genmqpkg_incmqsf=0 \
|
||||
genmqpkg_incmqxr=0 \
|
||||
genmqpkg_incnls=1 \
|
||||
genmqpkg_incras=1 \
|
||||
genmqpkg_incsamp=1 \
|
||||
genmqpkg_incsdk=0 \
|
||||
genmqpkg_inctls=1 \
|
||||
genmqpkg_incunthrd=0 \
|
||||
genmqpkg_incweb=1
|
||||
ADD $MQ_ARCHIVE /opt/mqm-noinstall
|
||||
# Run genmqpkg to reduce the MQ packages included
|
||||
RUN /opt/mqm-noinstall/bin/genmqpkg.sh -b /opt/mqm-redux
|
||||
|
||||
###############################################################################
|
||||
# Main build stage, to build MQ image
|
||||
###############################################################################
|
||||
FROM $BASE_IMAGE:$BASE_TAG AS mq-server
|
||||
ARG MQ_URL
|
||||
ARG BASE_IMAGE
|
||||
ARG BASE_TAG
|
||||
ARG GO_WORKDIR
|
||||
LABEL summary="IBM MQ Advanced Server" \
|
||||
description="Simplify, accelerate and facilitate the reliable exchange of data with a security-rich messaging solution — trusted by the world’s most successful enterprises" \
|
||||
vendor="IBM" \
|
||||
maintainer="IBM" \
|
||||
distribution-scope="private" \
|
||||
authoritative-source-url="https://www.ibm.com/software/passportadvantage/" \
|
||||
url="https://www.ibm.com/products/mq/advanced" \
|
||||
io.openshift.tags="mq messaging" \
|
||||
io.k8s.display-name="IBM MQ Advanced Server" \
|
||||
io.k8s.description="Simplify, accelerate and facilitate the reliable exchange of data with a security-rich messaging solution — trusted by the world’s most successful enterprises" \
|
||||
base-image=$BASE_IMAGE \
|
||||
base-image-release=$BASE_TAG
|
||||
COPY --from=mq-redux /opt/mqm-redux/ /opt/mqm/
|
||||
COPY setup-image.sh /usr/local/bin/
|
||||
COPY install-mq-server-prereqs.sh /usr/local/bin/
|
||||
RUN env \
|
||||
&& chmod u+x /usr/local/bin/install-*.sh \
|
||||
&& chmod u+x /usr/local/bin/setup-image.sh \
|
||||
&& install-mq-server-prereqs.sh \
|
||||
&& setup-image.sh \
|
||||
&& /opt/mqm/bin/security/amqpamcf \
|
||||
&& chown -R 1001:root /opt/mqm/*
|
||||
COPY --from=builder $GO_WORKDIR/runmqserver /usr/local/bin/
|
||||
COPY --from=builder $GO_WORKDIR/chkmq* /usr/local/bin/
|
||||
COPY NOTICES.txt /opt/mqm/licenses/notices-container.txt
|
||||
COPY ha/native-ha.ini.tpl /etc/mqm/native-ha.ini.tpl
|
||||
# Copy web XML files
|
||||
COPY web /etc/mqm/web
|
||||
COPY etc/mqm/*.tpl /etc/mqm/
|
||||
RUN chmod ug+x /usr/local/bin/runmqserver \
|
||||
&& chown 1001:root /usr/local/bin/*mq* \
|
||||
&& chmod ug+x /usr/local/bin/chkmq* \
|
||||
&& chown -R 1001:root /etc/mqm/* \
|
||||
&& install --directory --mode 2775 --owner 1001 --group root /run/runmqserver \
|
||||
&& touch /run/termination-log \
|
||||
&& chown 1001:root /run/termination-log \
|
||||
&& chmod 0660 /run/termination-log \
|
||||
&& chmod -R g+w /etc/mqm/web
|
||||
# Always use port 1414 for MQ & 9157 for the metrics
|
||||
EXPOSE 1414 9157 9443
|
||||
ENV MQ_OVERRIDE_DATA_PATH=/mnt/mqm/data MQ_OVERRIDE_INSTALLATION_NAME=Installation1 MQ_USER_NAME="mqm" PATH="${PATH}:/opt/mqm/bin"
|
||||
ENV MQ_GRACE_PERIOD=30
|
||||
ENV LANG=en_US.UTF-8 AMQ_DIAGNOSTIC_MSG_SEVERITY=1 AMQ_ADDITIONAL_JSON_LOG=1
|
||||
ENV MQ_LOGGING_CONSOLE_EXCLUDE_ID=AMQ5041I,AMQ5052I,AMQ5051I,AMQ5037I,AMQ5975I
|
||||
ENV WLP_LOGGING_MESSAGE_FORMAT=json
|
||||
# We can run as any UID
|
||||
USER 1001
|
||||
ENV MQ_CONNAUTH_USE_HTP=false
|
||||
ENTRYPOINT ["runmqserver"]
|
||||
|
||||
###############################################################################
|
||||
# Build stage to build C code for custom authorization service (developer-only)
|
||||
###############################################################################
|
||||
# Use the Go toolset image, which already includes gcc and the MQ SDK
|
||||
FROM builder as cbuilder
|
||||
USER 0
|
||||
# Install the Apache Portable Runtime code (used for htpasswd hash checking)
|
||||
RUN yum --assumeyes --disableplugin=subscription-manager install apr-devel apr-util-openssl apr-util-devel
|
||||
COPY authservice/ /opt/app-root/src/authservice/
|
||||
WORKDIR /opt/app-root/src/authservice/mqhtpass
|
||||
RUN make all
|
||||
|
||||
###############################################################################
|
||||
# Add default developer config
|
||||
###############################################################################
|
||||
FROM mq-server AS mq-dev-server
|
||||
ARG BASE_IMAGE
|
||||
ARG BASE_TAG
|
||||
ARG GO_WORKDIR
|
||||
LABEL summary="IBM MQ Advanced for Developers Server" \
|
||||
description="Simplify, accelerate and facilitate the reliable exchange of data with a security-rich messaging solution — trusted by the world’s most successful enterprises" \
|
||||
vendor="IBM" \
|
||||
distribution-scope="private" \
|
||||
authoritative-source-url="https://www.ibm.com/software/passportadvantage/" \
|
||||
url="https://www.ibm.com/products/mq/advanced" \
|
||||
io.openshift.tags="mq messaging" \
|
||||
io.k8s.display-name="IBM MQ Advanced for Developers Server" \
|
||||
io.k8s.description="Simplify, accelerate and facilitate the reliable exchange of data with a security-rich messaging solution — trusted by the world’s most successful enterprises" \
|
||||
base-image=$BASE_IMAGE \
|
||||
base-image-release=$BASE_TAG
|
||||
USER 0
|
||||
COPY --from=cbuilder /opt/app-root/src/authservice/mqhtpass/build/mqhtpass.so /opt/mqm/lib64/
|
||||
COPY etc/mqm/*.ini /etc/mqm/
|
||||
COPY etc/mqm/mq.htpasswd /etc/mqm/
|
||||
COPY incubating/mqadvanced-server-dev/install-extra-packages.sh /usr/local/bin/
|
||||
RUN chmod u+x /usr/local/bin/install-extra-packages.sh \
|
||||
&& sleep 1 \
|
||||
&& install-extra-packages.sh
|
||||
COPY --from=builder $GO_WORKDIR/runmqdevserver /usr/local/bin/
|
||||
# Copy template files
|
||||
COPY incubating/mqadvanced-server-dev/*.tpl /etc/mqm/
|
||||
# Copy web XML files for default developer configuration
|
||||
COPY incubating/mqadvanced-server-dev/web /etc/mqm/web
|
||||
RUN chown -R 1001:root /etc/mqm/* \
|
||||
&& chmod -R g+w /etc/mqm/web \
|
||||
&& chmod +x /usr/local/bin/runmq* \
|
||||
&& chmod 0660 /etc/mqm/mq.htpasswd \
|
||||
&& install --directory --mode 2775 --owner 1001 --group root /run/runmqdevserver
|
||||
ENV MQ_DEV=true \
|
||||
MQ_ENABLE_EMBEDDED_WEB_SERVER=1 \
|
||||
MQ_GENERATE_CERTIFICATE_HOSTNAME=localhost \
|
||||
LD_LIBRARY_PATH=/opt/mqm/lib64 \
|
||||
MQ_CONNAUTH_USE_HTP=true \
|
||||
MQS_PERMIT_UNKNOWN_ID=true
|
||||
USER 1001
|
||||
ENTRYPOINT ["runmqdevserver"]
|
||||
@@ -15,7 +15,7 @@
|
||||
ARG BASE_IMAGE
|
||||
|
||||
# Build stage to build Go code
|
||||
FROM golang:1.22 as builder
|
||||
FROM golang:1.10 as builder
|
||||
WORKDIR /go/src/github.com/ibm-messaging/mq-container/
|
||||
COPY cmd/ ./cmd
|
||||
COPY internal/ ./internal
|
||||
|
||||
44
Makefile
44
Makefile
@@ -45,10 +45,10 @@ MQ_ARCHIVE ?= IBM_MQ_$(MQ_VERSION_VRM)_$(MQ_ARCHIVE_TYPE)_$(MQ_ARCHIVE_ARCH)_NOI
|
||||
MQ_ARCHIVE_DEV ?= $(MQ_VERSION)-IBM-MQ-Advanced-for-Developers-Non-Install-$(MQ_ARCHIVE_DEV_TYPE)$(MQ_ARCHIVE_DEV_ARCH).tar.gz
|
||||
# MQ_SDK_ARCHIVE specifies the archive to use for building the golang programs. Defaults vary on developer or advanced.
|
||||
MQ_SDK_ARCHIVE ?= $(MQ_ARCHIVE_DEV_$(MQ_VERSION))
|
||||
# Options to `go test` for the Container tests
|
||||
TEST_OPTS_CONTAINER ?=
|
||||
# Timeout for the tests
|
||||
TEST_TIMEOUT_CONTAINER ?= 45m
|
||||
# Options to `go test` for the Docker tests
|
||||
TEST_OPTS_DOCKER ?=
|
||||
# Timeout for the Docker tests
|
||||
TEST_TIMEOUT_DOCKER ?= 45m
|
||||
# MQ_IMAGE_ADVANCEDSERVER is the name of the built MQ Advanced image
|
||||
MQ_IMAGE_ADVANCEDSERVER ?=ibm-mqadvanced-server
|
||||
# MQ_IMAGE_DEVSERVER is the name of the built MQ Advanced for Developers image
|
||||
@@ -278,9 +278,9 @@ cache-mq-tag:
|
||||
# Test targets
|
||||
###############################################################################
|
||||
|
||||
# Vendor Go dependencies for the Container tests
|
||||
test/container/vendor:
|
||||
cd test/container && go mod vendor
|
||||
# Vendor Go dependencies for the Docker tests
|
||||
test/docker/vendor:
|
||||
cd test/docker && go mod vendor
|
||||
|
||||
# Shortcut to just run the unit tests
|
||||
.PHONY: test-unit
|
||||
@@ -288,28 +288,28 @@ test-unit:
|
||||
$(COMMAND) build --target builder --file Dockerfile-server .
|
||||
|
||||
.PHONY: test-advancedserver
|
||||
test-advancedserver: test/container/vendor
|
||||
test-advancedserver: test/docker/vendor
|
||||
$(info $(SPACER)$(shell printf $(TITLE)"Test $(MQ_IMAGE_ADVANCEDSERVER):$(MQ_TAG) on $(shell $(COMMAND) --version)"$(END)))
|
||||
$(COMMAND) inspect $(MQ_IMAGE_ADVANCEDSERVER):$(MQ_TAG)
|
||||
cd test/container && TEST_IMAGE=$(MQ_IMAGE_ADVANCEDSERVER):$(MQ_TAG) EXPECTED_LICENSE=Production DOCKER_API_VERSION=$(DOCKER_API_VERSION) COMMAND=$(COMMAND) go test -parallel $(NUM_CPU) -timeout $(TEST_TIMEOUT_CONTAINER) $(TEST_OPTS_CONTAINER)
|
||||
cd test/docker && TEST_IMAGE=$(MQ_IMAGE_ADVANCEDSERVER):$(MQ_TAG) EXPECTED_LICENSE=Production DOCKER_API_VERSION=$(DOCKER_API_VERSION) go test -parallel $(NUM_CPU) -timeout $(TEST_TIMEOUT_DOCKER) $(TEST_OPTS_DOCKER)
|
||||
|
||||
.PHONY: build-devjmstest
|
||||
build-devjmstest:
|
||||
$(info $(SPACER)$(shell printf $(TITLE)"Build JMS tests for developer config"$(END)))
|
||||
cd test/messaging && $(COMMAND) build --tag $(DEV_JMS_IMAGE) .
|
||||
cd test/messaging && docker build --tag $(DEV_JMS_IMAGE) .
|
||||
|
||||
.PHONY: test-devserver
|
||||
test-devserver: test/container/vendor
|
||||
test-devserver: test/docker/vendor
|
||||
$(info $(SPACER)$(shell printf $(TITLE)"Test $(MQ_IMAGE_DEVSERVER):$(MQ_TAG) on $(shell $(COMMAND) --version)"$(END)))
|
||||
$(COMMAND) inspect $(MQ_IMAGE_DEVSERVER):$(MQ_TAG)
|
||||
cd test/container && TEST_IMAGE=$(MQ_IMAGE_DEVSERVER):$(MQ_TAG) EXPECTED_LICENSE=Developer DEV_JMS_IMAGE=$(DEV_JMS_IMAGE) IBMJRE=false DOCKER_API_VERSION=$(DOCKER_API_VERSION) COMMAND=$(COMMAND) go test -parallel $(NUM_CPU) -timeout $(TEST_TIMEOUT_CONTAINER) -tags mqdev $(TEST_OPTS_CONTAINER)
|
||||
cd test/docker && TEST_IMAGE=$(MQ_IMAGE_DEVSERVER):$(MQ_TAG) EXPECTED_LICENSE=Developer DEV_JMS_IMAGE=$(DEV_JMS_IMAGE) IBMJRE=false DOCKER_API_VERSION=$(DOCKER_API_VERSION) go test -parallel $(NUM_CPU) -timeout $(TEST_TIMEOUT_DOCKER) -tags mqdev $(TEST_OPTS_DOCKER)
|
||||
|
||||
.PHONY: coverage
|
||||
coverage:
|
||||
mkdir coverage
|
||||
|
||||
.PHONY: test-advancedserver-cover
|
||||
test-advancedserver-cover: test/container/vendor coverage
|
||||
test-advancedserver-cover: test/docker/vendor coverage
|
||||
$(info $(SPACER)$(shell printf $(TITLE)"Test $(MQ_IMAGE_ADVANCEDSERVER):$(MQ_TAG) with code coverage on $(shell $(COMMAND) --version)"$(END)))
|
||||
rm -f ./coverage/unit*.cov
|
||||
# Run unit tests with coverage, for each package under 'internal'
|
||||
@@ -319,16 +319,16 @@ test-advancedserver-cover: test/container/vendor coverage
|
||||
tail -q -n +2 ./coverage/unit-*.cov >> ./coverage/unit.cov
|
||||
go tool cover -html=./coverage/unit.cov -o ./coverage/unit.html
|
||||
|
||||
rm -f ./test/container/coverage/*.cov
|
||||
rm -f ./coverage/container.*
|
||||
mkdir -p ./test/container/coverage/
|
||||
cd test/container && TEST_IMAGE=$(MQ_IMAGE_ADVANCEDSERVER):$(MQ_TAG)-cover TEST_COVER=true DOCKER_API_VERSION=$(DOCKER_API_VERSION) go test $(TEST_OPTS_CONTAINER)
|
||||
echo 'mode: count' > ./coverage/container.cov
|
||||
tail -q -n +2 ./test/container/coverage/*.cov >> ./coverage/container.cov
|
||||
go tool cover -html=./coverage/container.cov -o ./coverage/container.html
|
||||
rm -f ./test/docker/coverage/*.cov
|
||||
rm -f ./coverage/docker.*
|
||||
mkdir -p ./test/docker/coverage/
|
||||
cd test/docker && TEST_IMAGE=$(MQ_IMAGE_ADVANCEDSERVER):$(MQ_TAG)-cover TEST_COVER=true DOCKER_API_VERSION=$(DOCKER_API_VERSION) go test $(TEST_OPTS_DOCKER)
|
||||
echo 'mode: count' > ./coverage/docker.cov
|
||||
tail -q -n +2 ./test/docker/coverage/*.cov >> ./coverage/docker.cov
|
||||
go tool cover -html=./coverage/docker.cov -o ./coverage/docker.html
|
||||
|
||||
echo 'mode: count' > ./coverage/combined.cov
|
||||
tail -q -n +2 ./coverage/unit.cov ./coverage/container.cov >> ./coverage/combined.cov
|
||||
tail -q -n +2 ./coverage/unit.cov ./coverage/docker.cov >> ./coverage/combined.cov
|
||||
go tool cover -html=./coverage/combined.cov -o ./coverage/combined.html
|
||||
|
||||
###############################################################################
|
||||
@@ -569,4 +569,4 @@ ifneq (,$(findstring docker,$(COMMAND)))
|
||||
endif
|
||||
ifneq (,$(findstring podman,$(COMMAND)))
|
||||
@test "$(word 1,$(subst ., ,$(PODMAN_VERSION)))" -ge "1" || (echo "Error: Podman version 1.0 or greater is required" && exit 1)
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -48,8 +48,8 @@ For issues relating specifically to the container image or Helm chart, please us
|
||||
The Dockerfiles and associated code and scripts are licensed under the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0.html).
|
||||
Licenses for the products installed within the images are as follows:
|
||||
|
||||
- [IBM MQ Advanced for Developers](http://www14.software.ibm.com/cgi-bin/weblap/lap.pl?la_formnum=Z125-3301-14&li_formnum=L-AXAF-JLZ53A) (International License Agreement for Non-Warranted Programs). This license may be viewed from an image using the `LICENSE=view` environment variable as described above or by following the link above.
|
||||
- [IBM MQ Advanced](http://www14.software.ibm.com/cgi-bin/weblap/lap.pl?la_formnum=Z125-3301-14&li_formnum=L-AMRD-XH6P3Q) (International Program License Agreement). This license may be viewed from an image using the `LICENSE=view` environment variable as described above or by following the link above.
|
||||
- [IBM MQ Advanced for Developers](http://www14.software.ibm.com/cgi-bin/weblap/lap.pl?la_formnum=Z125-3301-14&li_formnum=L-APIG-CAUEQC) (International License Agreement for Non-Warranted Programs). This license may be viewed from an image using the `LICENSE=view` environment variable as described above or by following the link above.
|
||||
- [IBM MQ Advanced](http://www14.software.ibm.com/cgi-bin/weblap/lap.pl?la_formnum=Z125-3301-14&li_formnum=L-UPFX-8MW49T) (International Program License Agreement). This license may be viewed from an image using the `LICENSE=view` environment variable as described above or by following the link above.
|
||||
|
||||
Note: The IBM MQ Advanced for Developers license does not permit further distribution and the terms restrict usage to a developer machine.
|
||||
|
||||
|
||||
@@ -211,7 +211,7 @@ func mirrorHTPasswdLogs(ctx context.Context, wg *sync.WaitGroup, name string, fr
|
||||
|
||||
// mirrorWebServerLogs starts a goroutine to mirror the contents of the Liberty web server messages.log
|
||||
func mirrorWebServerLogs(ctx context.Context, wg *sync.WaitGroup, name string, fromStart bool, mf mirrorFunc) (chan error, error) {
|
||||
return mirrorLog(ctx, wg, "/var/mqm/web/installations/Installation1/servers/mqweb/logs/messages.log", fromStart, mf, true)
|
||||
return mirrorLog(ctx, wg, "/var/mqm/web/installations/Installation1/servers/mqweb/logs/messages.log", false, mf, true)
|
||||
}
|
||||
|
||||
func getDebug() bool {
|
||||
|
||||
@@ -165,27 +165,6 @@ func doMain() error {
|
||||
log.Println("One or more invalid value is provided for MQ_LOGGING_CONSOLE_SOURCE. Allowed values are 'qmgr' & 'web' in csv format")
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
defer func() {
|
||||
log.Debug("Waiting for log mirroring to complete")
|
||||
wg.Wait()
|
||||
}()
|
||||
ctx, cancelMirror := context.WithCancel(context.Background())
|
||||
defer func() {
|
||||
log.Debug("Cancel log mirroring")
|
||||
cancelMirror()
|
||||
}()
|
||||
|
||||
//For mirroring web server logs if source variable is set
|
||||
if checkLogSourceForMirroring("web") {
|
||||
// Always log from the end of the web server messages.log, because the log rotation should happen as soon as the web server starts
|
||||
_, err = mirrorWebServerLogs(ctx, &wg, name, false, mf)
|
||||
if err != nil {
|
||||
logTermination(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
err = postInit(name, keyLabel, defaultP12Truststore)
|
||||
if err != nil {
|
||||
logTermination(err)
|
||||
@@ -226,6 +205,17 @@ func doMain() error {
|
||||
}
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
defer func() {
|
||||
log.Debug("Waiting for log mirroring to complete")
|
||||
wg.Wait()
|
||||
}()
|
||||
ctx, cancelMirror := context.WithCancel(context.Background())
|
||||
defer func() {
|
||||
log.Debug("Cancel log mirroring")
|
||||
cancelMirror()
|
||||
}()
|
||||
|
||||
//For mirroring mq system logs and qm logs, if environment variable is set
|
||||
if checkLogSourceForMirroring("qmgr") {
|
||||
//Mirror MQ system logs
|
||||
@@ -251,6 +241,17 @@ func doMain() error {
|
||||
}
|
||||
}
|
||||
|
||||
//For mirroring web server logs if source variable is set
|
||||
if checkLogSourceForMirroring("web") {
|
||||
// Always log from the start of the web server messages.log, as
|
||||
// Liberty resets it.
|
||||
_, err = mirrorWebServerLogs(ctx, &wg, name, true, mf)
|
||||
if err != nil {
|
||||
logTermination(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
err = updateCommandLevel()
|
||||
if err != nil {
|
||||
logTermination(err)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
###########################################################################################################################################################
|
||||
|
||||
# MQ_VERSION is the fully qualified MQ version number to build
|
||||
MQ_VERSION ?= 9.3.3.0
|
||||
MQ_VERSION ?= 9.3.2.0
|
||||
|
||||
###########################################################################################################################################################
|
||||
|
||||
@@ -38,7 +38,7 @@ However, if you wish to build the previous MQ LTS, use the [instructions](https:
|
||||
|
||||
## Building a developer image
|
||||
|
||||
Run `make build-devserver`, which will download the latest version of MQ Advanced for Developers. This is available on the `amd64` and `arm64` (Apple Silicon) architectures.
|
||||
Run `make build-devserver`, which will download the latest version of MQ Advanced for Developers from IBM developerWorks. This is currently only available on the `amd64` architecture.
|
||||
|
||||
You can use the environment variable `MQ_ARCHIVE_DEV` to specify an alternative local file to install from (which must be in the `downloads` directory).
|
||||
|
||||
|
||||
@@ -16,5 +16,5 @@ docker run \
|
||||
--env LICENSE=accept \
|
||||
--env MQ_QMGR_NAME=QM1 \
|
||||
--detach \
|
||||
ibm-mqadvanced-server:9.3.3.0-amd64
|
||||
ibm-mqadvanced-server:9.3.2.0-amd64
|
||||
```
|
||||
|
||||
@@ -24,7 +24,7 @@ make test-advancedserver
|
||||
You can specify the image to use directly by using the `MQ_IMAGE_ADVANCEDSERVER` or `MQ_IMAGE_DEVSERVER` variables, for example:
|
||||
|
||||
```
|
||||
MQ_IMAGE_ADVANCEDSERVER=ibm-mqadvanced-server:9.3.3.0-amd64 make test-advancedserver
|
||||
MQ_IMAGE_ADVANCEDSERVER=ibm-mqadvanced-server:9.3.2.0-amd64 make test-advancedserver
|
||||
```
|
||||
|
||||
You can pass parameters to `go test` with an environment variable. For example, to run the "TestGoldenPath" test, run the following command:
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8
go.mod
8
go.mod
@@ -1,12 +1,12 @@
|
||||
module github.com/ibm-messaging/mq-container
|
||||
|
||||
go 1.19
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/genuinetools/amicontained v0.4.3
|
||||
github.com/ibm-messaging/mq-golang v2.0.0+incompatible
|
||||
github.com/prometheus/client_golang v1.11.1
|
||||
github.com/prometheus/client_model v0.6.1
|
||||
github.com/prometheus/client_model v0.2.0
|
||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1
|
||||
software.sslmate.com/src/go-pkcs12 v0.0.0-20200830195227-52f69702a001
|
||||
@@ -15,10 +15,10 @@ require (
|
||||
require (
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.1 // indirect
|
||||
github.com/golang/protobuf v1.5.0 // indirect
|
||||
github.com/golang/protobuf v1.4.3 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||
github.com/prometheus/common v0.26.0 // indirect
|
||||
github.com/prometheus/procfs v0.6.0 // indirect
|
||||
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect
|
||||
google.golang.org/protobuf v1.33.0 // indirect
|
||||
google.golang.org/protobuf v1.26.0-rc.1 // indirect
|
||||
)
|
||||
|
||||
6
go.sum
6
go.sum
@@ -33,8 +33,6 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=
|
||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.0 h1:LUVKkCeviFUMKqHa4tXIIij/lbhnMbP7Fn5wKdKkRh4=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
@@ -77,8 +75,6 @@ github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
|
||||
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
|
||||
github.com/prometheus/common v0.26.0 h1:iMAkS2TDoNWnKM+Kopnx/8tnEStIfpYA0ur0xQzzhMQ=
|
||||
@@ -141,8 +137,6 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.26.0-rc.1 h1:7QnIQpGRHE5RnLKnESfDoxm2dTapTZua5a0kS0A+VXQ=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
|
||||
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
# -*- mode: sh -*-
|
||||
# © Copyright IBM Corporation 2015, 2023
|
||||
# © Copyright IBM Corporation 2015, 2022
|
||||
#
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -42,12 +42,21 @@ if ($UBUNTU); then
|
||||
echo "deb ${APT_URL} ${UBUNTU_CODENAME}-security main restricted" >> /etc/apt/sources.list
|
||||
# Install additional packages required by MQ, this install process and the runtime scripts
|
||||
EXTRA_DEBS="bash bc ca-certificates coreutils curl debianutils file findutils gawk grep libc-bin mount passwd procps sed tar util-linux"
|
||||
# On ARM CPUs, there is no IBM JRE, so install another one
|
||||
if [ "${CPU_ARCH}" == "aarch64" ]; then
|
||||
EXTRA_DEBS="${EXTRA_DEBS} openjdk-8-jre"
|
||||
fi
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends ${EXTRA_DEBS}
|
||||
fi
|
||||
|
||||
if ($RPM); then
|
||||
EXTRA_RPMS="bash bc ca-certificates file findutils gawk glibc-common grep ncurses-compat-libs passwd procps-ng sed shadow-utils tar util-linux which"
|
||||
# On ARM CPUs, there is no IBM JRE, so install another one
|
||||
if [ "${CPU_ARCH}" == "aarch64" ]; then
|
||||
EXTRA_RPMS="${EXTRA_RPMS} java-1.8.0-openjdk-headless"
|
||||
fi
|
||||
|
||||
# Install additional packages required by MQ, this install process and the runtime scripts
|
||||
$YUM && yum -y install --setopt install_weak_deps=false ${EXTRA_RPMS}
|
||||
$MICRODNF && microdnf --disableplugin=subscription-manager install ${EXTRA_RPMS}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
|
||||
}
|
||||
@@ -1,669 +0,0 @@
|
||||
/*
|
||||
© Copyright IBM Corporation 2017, 2023
|
||||
|
||||
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 containerengine
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ContainerInterface interface {
|
||||
ContainerCreate(config *ContainerConfig, hostConfig *ContainerHostConfig, networkingConfig *ContainerNetworkSettings, containerName string) (string, error)
|
||||
ContainerStop(container string, timeout *time.Duration) error
|
||||
ContainerKill(container string, signal string) error
|
||||
ContainerRemove(container string, options ContainerRemoveOptions) error
|
||||
ContainerStart(container string, options ContainerStartOptions) error
|
||||
ContainerWait(ctx context.Context, container string, condition string) (<-chan int64, <-chan error)
|
||||
GetContainerLogs(ctx context.Context, container string, options ContainerLogsOptions) (string, error)
|
||||
CopyFromContainer(container, srcPath string) ([]byte, error)
|
||||
|
||||
GetContainerPort(ID string, hostPort int) (string, error)
|
||||
GetContainerIPAddress(ID string) (string, error)
|
||||
ContainerInspectWithFormat(format string, ID string) (string, error)
|
||||
ExecContainer(ID string, user string, cmd []string) (int, string)
|
||||
GetMQVersion(image string) (string, error)
|
||||
ContainerInspect(containerID string) (ContainerDetails, error)
|
||||
|
||||
NetworkCreate(name string, options NetworkCreateOptions) (string, error)
|
||||
NetworkRemove(network string) error
|
||||
|
||||
VolumeCreate(options VolumeCreateOptions) (string, error)
|
||||
VolumeRemove(volumeID string, force bool) error
|
||||
|
||||
ImageBuild(context io.Reader, tag string, dockerfilename string) (string, error)
|
||||
ImageRemove(image string, options ImageRemoveOptions) (bool, error)
|
||||
ImageInspectWithFormat(format string, ID string) (string, error)
|
||||
}
|
||||
|
||||
type ContainerClient struct {
|
||||
ContainerTool string
|
||||
Version string
|
||||
}
|
||||
|
||||
// objects
|
||||
var objVolume = "volume"
|
||||
var objImage = "image"
|
||||
var objPort = "port"
|
||||
var objNetwork = "network"
|
||||
|
||||
// verbs
|
||||
var listContainers = "ps"
|
||||
var listImages = "images"
|
||||
var create = "create"
|
||||
var startContainer = "start"
|
||||
var waitContainer = "wait"
|
||||
var execContainer = "exec"
|
||||
var getLogs = "logs"
|
||||
var stopContainer = "stop"
|
||||
var remove = "rm"
|
||||
var inspect = "inspect"
|
||||
var copyFile = "cp"
|
||||
var build = "build"
|
||||
var killContainer = "kill"
|
||||
|
||||
// args
|
||||
var argEntrypoint = "--entrypoint"
|
||||
var argUser = "--user"
|
||||
var argExpose = "--expose"
|
||||
var argVolume = "--volume"
|
||||
var argPublish = "--publish"
|
||||
var argPrivileged = "--privileged"
|
||||
var argAddCapability = "--cap-add"
|
||||
var argDropCapability = "--cap-drop"
|
||||
var argName = "--name"
|
||||
var argCondition = "--condition"
|
||||
var argEnvironmentVariable = "--env"
|
||||
var argTail = "--tail"
|
||||
var argForce = "--force"
|
||||
var argVolumes = "--volumes"
|
||||
var argHostname = "--hostname"
|
||||
var argDriver = "--driver"
|
||||
var argFile = "--file"
|
||||
var argQuiet = "--quiet"
|
||||
var argTag = "--tag"
|
||||
var argFormat = "--format"
|
||||
var argNetwork = "--network"
|
||||
var argSecurityOptions = "--security-opt"
|
||||
var argSignal = "--signal"
|
||||
|
||||
// generic
|
||||
var toolVersion = "version"
|
||||
var ContainerStateNotRunning = "not-running"
|
||||
var ContainerStateStopped = "stopped"
|
||||
|
||||
type ContainerConfig struct {
|
||||
Image string
|
||||
Hostname string
|
||||
User string
|
||||
Entrypoint []string
|
||||
Env []string
|
||||
ExposedPorts []string
|
||||
}
|
||||
|
||||
type ContainerDetails struct {
|
||||
ID string
|
||||
Name string
|
||||
Image string
|
||||
Path string
|
||||
Args []string
|
||||
Config ContainerConfig
|
||||
HostConfig ContainerHostConfig
|
||||
}
|
||||
|
||||
type ContainerDetailsLogging struct {
|
||||
ID string
|
||||
Name string
|
||||
Image string
|
||||
Path string
|
||||
Args []string
|
||||
CapAdd []string
|
||||
CapDrop []string
|
||||
User string
|
||||
Env []string
|
||||
}
|
||||
|
||||
type ContainerHostConfig struct {
|
||||
Binds []string // Bindings onto a volume
|
||||
PortBindings []PortBinding //Bindings from a container port to a port on the host
|
||||
Privileged bool // Give extended privileges to container
|
||||
CapAdd []string // Linux capabilities to add to the container
|
||||
CapDrop []string // Linux capabilities to drop from the container
|
||||
SecurityOpt []string
|
||||
}
|
||||
|
||||
type ContainerNetworkSettings struct {
|
||||
Networks []string // A list of networks to connect the container to
|
||||
}
|
||||
|
||||
type ContainerRemoveOptions struct {
|
||||
Force bool
|
||||
RemoveVolumes bool
|
||||
}
|
||||
|
||||
type ContainerStartOptions struct {
|
||||
}
|
||||
|
||||
type NetworkCreateOptions struct {
|
||||
}
|
||||
|
||||
type ContainerLogsOptions struct {
|
||||
}
|
||||
|
||||
type ImageRemoveOptions struct {
|
||||
Force bool
|
||||
}
|
||||
|
||||
type VolumeCreateOptions struct {
|
||||
Name string
|
||||
Driver string
|
||||
}
|
||||
|
||||
// Binding from a container port to a port on the host
|
||||
type PortBinding struct {
|
||||
HostIP string
|
||||
HostPort string //Port to map to on the host
|
||||
ContainerPort string //Exposed port on the container
|
||||
}
|
||||
|
||||
// NewContainerClient returns a new container client
|
||||
// Defaults to using podman
|
||||
func NewContainerClient() ContainerClient {
|
||||
tool, set := os.LookupEnv("COMMAND")
|
||||
if !set {
|
||||
tool = "podman"
|
||||
}
|
||||
return ContainerClient{
|
||||
ContainerTool: tool,
|
||||
Version: GetContainerToolVersion(tool),
|
||||
}
|
||||
}
|
||||
|
||||
// GetContainerToolVersion returns the version of the container tool being used
|
||||
func GetContainerToolVersion(containerTool string) string {
|
||||
if containerTool == "docker" {
|
||||
args := []string{"version", "--format", "'{{.Client.Version}}'"}
|
||||
v, err := exec.Command("docker", args...).Output()
|
||||
if err != nil {
|
||||
return "0.0.0"
|
||||
}
|
||||
return string(v)
|
||||
} else if containerTool == "podman" {
|
||||
//Default to checking the version of podman
|
||||
args := []string{"version", "--format", "'{{.Version}}'"}
|
||||
v, err := exec.Command("podman", args...).Output()
|
||||
if err != nil {
|
||||
return "0.0.0"
|
||||
}
|
||||
return string(v)
|
||||
}
|
||||
return "0.0.0"
|
||||
}
|
||||
|
||||
// GetMQVersion returns the MQ version of a given container image
|
||||
func (cli ContainerClient) GetMQVersion(image string) (string, error) {
|
||||
v, err := cli.ImageInspectWithFormat("{{.Config.Labels.version}}", image)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// ImageInspectWithFormat inspects an image with a given formatting string
|
||||
func (cli ContainerClient) ImageInspectWithFormat(format string, ID string) (string, error) {
|
||||
args := []string{
|
||||
objImage,
|
||||
inspect,
|
||||
ID,
|
||||
}
|
||||
if format != "" {
|
||||
args = append(args, []string{argFormat, format}...)
|
||||
}
|
||||
output, err := exec.Command(cli.ContainerTool, args...).Output()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(output), nil
|
||||
}
|
||||
|
||||
// ContainerInspectWithFormat inspects a container with a given formatting string
|
||||
func (cli ContainerClient) ContainerInspectWithFormat(format string, ID string) (string, error) {
|
||||
args := []string{
|
||||
inspect,
|
||||
ID,
|
||||
}
|
||||
if format != "" {
|
||||
args = append(args, []string{argFormat, format}...)
|
||||
}
|
||||
output, err := exec.Command(cli.ContainerTool, args...).Output()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(output), nil
|
||||
}
|
||||
|
||||
// GetContainerPort gets the ports on a container
|
||||
func (cli ContainerClient) GetContainerPort(ID string, hostPort int) (string, error) {
|
||||
args := []string{
|
||||
objPort,
|
||||
ID,
|
||||
strconv.Itoa(hostPort),
|
||||
}
|
||||
output, err := exec.Command(cli.ContainerTool, args...).Output()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
o := SanitizeString(string(output))
|
||||
return strings.Split((o), ":")[1], nil
|
||||
}
|
||||
|
||||
// GetContainerIPAddress gets the IP address of a container
|
||||
func (cli ContainerClient) GetContainerIPAddress(ID string) (string, error) {
|
||||
v, err := cli.ContainerInspectWithFormat("{{.NetworkSettings.IPAddress}}", ID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// CopyFromContainer copies a file from a container and returns its contents
|
||||
func (cli ContainerClient) CopyFromContainer(container, srcPath string) ([]byte, error) {
|
||||
tmpDir, err := os.MkdirTemp("", "tmp")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer os.RemoveAll(tmpDir)
|
||||
args := []string{
|
||||
copyFile,
|
||||
container + ":" + srcPath,
|
||||
tmpDir + "/.",
|
||||
}
|
||||
_, err = exec.Command(cli.ContainerTool, args...).CombinedOutput()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//Get file name
|
||||
fname := filepath.Base(srcPath)
|
||||
data, err := os.ReadFile(filepath.Join(tmpDir, fname))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
//Remove the file
|
||||
err = os.Remove(filepath.Join(tmpDir, fname))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (cli ContainerClient) ContainerInspect(containerID string) (ContainerDetails, error) {
|
||||
args := []string{
|
||||
inspect,
|
||||
containerID,
|
||||
}
|
||||
output, err := exec.Command(cli.ContainerTool, args...).Output()
|
||||
if err != nil {
|
||||
return ContainerDetails{}, err
|
||||
}
|
||||
|
||||
var container ContainerDetails
|
||||
err = json.Unmarshal(output, &container)
|
||||
if err != nil {
|
||||
return ContainerDetails{}, err
|
||||
}
|
||||
return container, err
|
||||
}
|
||||
|
||||
func (cli ContainerClient) ContainerStop(container string, timeout *time.Duration) error {
|
||||
args := []string{
|
||||
stopContainer,
|
||||
container,
|
||||
}
|
||||
_, err := exec.Command(cli.ContainerTool, args...).Output()
|
||||
return err
|
||||
}
|
||||
|
||||
func (cli ContainerClient) ContainerKill(container string, signal string) error {
|
||||
args := []string{
|
||||
killContainer,
|
||||
container,
|
||||
}
|
||||
if signal != "" {
|
||||
args = append(args, []string{argSignal, signal}...)
|
||||
}
|
||||
_, err := exec.Command(cli.ContainerTool, args...).Output()
|
||||
return err
|
||||
}
|
||||
|
||||
func (cli ContainerClient) ContainerRemove(container string, options ContainerRemoveOptions) error {
|
||||
args := []string{
|
||||
remove,
|
||||
container,
|
||||
}
|
||||
if options.Force {
|
||||
args = append(args, argForce)
|
||||
}
|
||||
if options.RemoveVolumes {
|
||||
args = append(args, argVolumes)
|
||||
}
|
||||
_, err := exec.Command(cli.ContainerTool, args...).Output()
|
||||
if err != nil {
|
||||
//Silently error as the exit code 125 is present on sucessful deletion
|
||||
if strings.Contains(err.Error(), "125") {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cli ContainerClient) ExecContainer(ID string, user string, cmd []string) (int, string) {
|
||||
args := []string{
|
||||
execContainer,
|
||||
}
|
||||
if user != "" {
|
||||
args = append(args, []string{argUser, user}...)
|
||||
}
|
||||
args = append(args, ID)
|
||||
args = append(args, cmd...)
|
||||
ctx := context.Background()
|
||||
output, err := exec.CommandContext(ctx, cli.ContainerTool, args...).CombinedOutput()
|
||||
if err != nil {
|
||||
if err.(*exec.ExitError) != nil {
|
||||
return err.(*exec.ExitError).ExitCode(), string(output)
|
||||
} else {
|
||||
return 9897, string(output)
|
||||
}
|
||||
}
|
||||
return 0, string(output)
|
||||
}
|
||||
|
||||
func (cli ContainerClient) ContainerStart(container string, options ContainerStartOptions) error {
|
||||
args := []string{
|
||||
startContainer,
|
||||
container,
|
||||
}
|
||||
_, err := exec.Command(cli.ContainerTool, args...).Output()
|
||||
return err
|
||||
}
|
||||
|
||||
// ContainerWait starts waiting for a container. It returns an int64 channel for receiving an exit code and an error channel for receiving errors.
|
||||
// The channels returned from this function should be used to receive the results from the wait command.
|
||||
func (cli ContainerClient) ContainerWait(ctx context.Context, container string, condition string) (<-chan int64, <-chan error) {
|
||||
args := []string{
|
||||
waitContainer,
|
||||
container,
|
||||
}
|
||||
if cli.ContainerTool == "podman" {
|
||||
if condition == ContainerStateNotRunning {
|
||||
condition = ContainerStateStopped
|
||||
}
|
||||
args = append(args, []string{argCondition, string(condition)}...)
|
||||
}
|
||||
|
||||
resultC := make(chan int64)
|
||||
errC := make(chan error, 1)
|
||||
|
||||
output, err := exec.CommandContext(ctx, cli.ContainerTool, args...).Output()
|
||||
if err != nil {
|
||||
errC <- err
|
||||
return resultC, errC
|
||||
}
|
||||
|
||||
go func() {
|
||||
out := strings.TrimSuffix(string(output), "\n")
|
||||
exitCode, err := strconv.Atoi(out)
|
||||
if err != nil {
|
||||
errC <- err
|
||||
return
|
||||
}
|
||||
resultC <- int64(exitCode)
|
||||
}()
|
||||
|
||||
return resultC, errC
|
||||
}
|
||||
|
||||
func (cli ContainerClient) GetContainerLogs(ctx context.Context, container string, options ContainerLogsOptions) (string, error) {
|
||||
args := []string{
|
||||
getLogs,
|
||||
container,
|
||||
}
|
||||
output, err := exec.Command(cli.ContainerTool, args...).CombinedOutput()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(output), nil
|
||||
}
|
||||
|
||||
func (cli ContainerClient) NetworkCreate(name string, options NetworkCreateOptions) (string, error) {
|
||||
args := []string{
|
||||
objNetwork,
|
||||
create,
|
||||
}
|
||||
netID, err := exec.Command(cli.ContainerTool, args...).CombinedOutput()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
networkID := SanitizeString(string(netID))
|
||||
|
||||
return networkID, nil
|
||||
}
|
||||
|
||||
func (cli ContainerClient) NetworkRemove(network string) error {
|
||||
args := []string{
|
||||
objNetwork,
|
||||
remove,
|
||||
}
|
||||
_, err := exec.Command(cli.ContainerTool, args...).CombinedOutput()
|
||||
return err
|
||||
}
|
||||
|
||||
func (cli ContainerClient) VolumeCreate(options VolumeCreateOptions) (string, error) {
|
||||
args := []string{
|
||||
objVolume,
|
||||
create,
|
||||
options.Name,
|
||||
}
|
||||
if options.Driver != "" {
|
||||
args = append(args, []string{argDriver, options.Driver}...)
|
||||
}
|
||||
output, err := exec.Command(cli.ContainerTool, args...).Output()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
name := SanitizeString(string(output))
|
||||
return name, nil
|
||||
}
|
||||
|
||||
func (cli ContainerClient) VolumeRemove(volumeID string, force bool) error {
|
||||
args := []string{
|
||||
objVolume,
|
||||
remove,
|
||||
volumeID,
|
||||
}
|
||||
if force {
|
||||
args = append(args, argForce)
|
||||
}
|
||||
_, err := exec.Command(cli.ContainerTool, args...).Output()
|
||||
return err
|
||||
}
|
||||
|
||||
func (cli ContainerClient) ImageBuild(context io.Reader, tag string, dockerfilename string) (string, error) {
|
||||
args := []string{
|
||||
objImage,
|
||||
build,
|
||||
}
|
||||
//dockerfilename includes the path to the dockerfile
|
||||
//When using podman use the full path including the name of the Dockerfile
|
||||
if cli.ContainerTool == "podman" {
|
||||
args = append(args, []string{argFile, dockerfilename}...)
|
||||
}
|
||||
if tag != "" {
|
||||
args = append(args, []string{argTag, tag}...)
|
||||
}
|
||||
args = append(args, argQuiet)
|
||||
//When using docker remove the name 'DockerFile' from the string
|
||||
if cli.ContainerTool == "docker" {
|
||||
dfn := strings.ReplaceAll(dockerfilename, "Dockerfile", "")
|
||||
args = append(args, dfn)
|
||||
}
|
||||
output, err := exec.Command(cli.ContainerTool, args...).Output()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
sha := SanitizeString(string(output))
|
||||
return sha, nil
|
||||
}
|
||||
|
||||
func (cli ContainerClient) ImageRemove(image string, options ImageRemoveOptions) (bool, error) {
|
||||
args := []string{
|
||||
objImage,
|
||||
remove,
|
||||
image,
|
||||
}
|
||||
if options.Force {
|
||||
args = append(args, argForce)
|
||||
}
|
||||
_, err := exec.Command(cli.ContainerTool, args...).Output()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (cli ContainerClient) ContainerCreate(config *ContainerConfig, hostConfig *ContainerHostConfig, networkingConfig *ContainerNetworkSettings, containerName string) (string, error) {
|
||||
args := []string{
|
||||
create,
|
||||
argName,
|
||||
containerName,
|
||||
}
|
||||
args = getHostConfigArgs(args, hostConfig)
|
||||
args = getNetworkConfigArgs(args, networkingConfig)
|
||||
args = getContainerConfigArgs(args, config, cli.ContainerTool)
|
||||
output, err := exec.Command(cli.ContainerTool, args...).Output()
|
||||
lines := strings.Split(strings.ReplaceAll(string(output), "\r\n", "\n"), "\n")
|
||||
if err != nil {
|
||||
return lines[0], err
|
||||
}
|
||||
return lines[0], nil
|
||||
}
|
||||
|
||||
// getContainerConfigArgs converts a ContainerConfig into a set of cli arguments
|
||||
func getContainerConfigArgs(args []string, config *ContainerConfig, toolName string) []string {
|
||||
argList := []string{}
|
||||
if config.Entrypoint != nil && toolName == "podman" {
|
||||
entrypoint := "[\""
|
||||
for i, commandPart := range config.Entrypoint {
|
||||
if i != len(config.Entrypoint)-1 {
|
||||
entrypoint += commandPart + "\",\""
|
||||
} else {
|
||||
//terminate list
|
||||
entrypoint += commandPart + "\"]"
|
||||
}
|
||||
}
|
||||
args = append(args, []string{argEntrypoint, entrypoint}...)
|
||||
}
|
||||
if config.Entrypoint != nil && toolName == "docker" {
|
||||
ep1 := ""
|
||||
for i, commandPart := range config.Entrypoint {
|
||||
if i == 0 {
|
||||
ep1 = commandPart
|
||||
} else {
|
||||
argList = append(argList, commandPart)
|
||||
}
|
||||
}
|
||||
args = append(args, []string{argEntrypoint, ep1}...)
|
||||
}
|
||||
if config.User != "" {
|
||||
args = append(args, []string{argUser, config.User}...)
|
||||
}
|
||||
if config.ExposedPorts != nil {
|
||||
for _, port := range config.ExposedPorts {
|
||||
args = append(args, []string{argExpose, port}...)
|
||||
}
|
||||
}
|
||||
if config.Hostname != "" {
|
||||
args = append(args, []string{argHostname, config.Hostname}...)
|
||||
}
|
||||
for _, env := range config.Env {
|
||||
args = append(args, []string{argEnvironmentVariable, env}...)
|
||||
}
|
||||
if config.Image != "" {
|
||||
args = append(args, config.Image)
|
||||
}
|
||||
if config.Entrypoint != nil && toolName == "docker" {
|
||||
args = append(args, argList...)
|
||||
}
|
||||
return args
|
||||
}
|
||||
|
||||
// getHostConfigArgs converts a ContainerHostConfig into a set of cli arguments
|
||||
func getHostConfigArgs(args []string, hostConfig *ContainerHostConfig) []string {
|
||||
if hostConfig.Binds != nil {
|
||||
for _, volume := range hostConfig.Binds {
|
||||
args = append(args, []string{argVolume, volume}...)
|
||||
}
|
||||
}
|
||||
if hostConfig.PortBindings != nil {
|
||||
for _, binding := range hostConfig.PortBindings {
|
||||
pub := binding.HostIP + ":" + binding.HostPort + ":" + binding.ContainerPort
|
||||
args = append(args, []string{argPublish, pub}...)
|
||||
}
|
||||
}
|
||||
if hostConfig.Privileged {
|
||||
args = append(args, []string{argPrivileged}...)
|
||||
}
|
||||
if hostConfig.CapAdd != nil {
|
||||
for _, capability := range hostConfig.CapAdd {
|
||||
args = append(args, []string{argAddCapability, string(capability)}...)
|
||||
}
|
||||
}
|
||||
if hostConfig.CapDrop != nil {
|
||||
for _, capability := range hostConfig.CapDrop {
|
||||
args = append(args, []string{argDropCapability, string(capability)}...)
|
||||
}
|
||||
}
|
||||
if hostConfig.SecurityOpt != nil {
|
||||
for _, securityOption := range hostConfig.SecurityOpt {
|
||||
args = append(args, []string{argSecurityOptions, string(securityOption)}...)
|
||||
}
|
||||
}
|
||||
return args
|
||||
}
|
||||
|
||||
// getNetworkConfigArgs converts a set of ContainerNetworkSettings into a set of cli arguments
|
||||
func getNetworkConfigArgs(args []string, networkingConfig *ContainerNetworkSettings) []string {
|
||||
if networkingConfig.Networks != nil {
|
||||
for _, netID := range networkingConfig.Networks {
|
||||
args = append(args, []string{argNetwork, netID}...)
|
||||
}
|
||||
}
|
||||
return args
|
||||
}
|
||||
|
||||
func SanitizeString(s string) string {
|
||||
s = strings.Replace(s, " ", "", -1)
|
||||
s = strings.Replace(s, "\t", "", -1)
|
||||
s = strings.Replace(s, "\n", "", -1)
|
||||
return s
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
module github.com/ibm-messaging/mq-container/test/container
|
||||
|
||||
go 1.19
|
||||
@@ -2,7 +2,7 @@
|
||||
// +build mqdev
|
||||
|
||||
/*
|
||||
© Copyright IBM Corporation 2018, 2023
|
||||
© Copyright IBM Corporation 2018, 2022
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -19,30 +19,37 @@ limitations under the License.
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"context"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
"crypto/tls"
|
||||
|
||||
ce "github.com/ibm-messaging/mq-container/test/container/containerengine"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/docker/go-connections/nat"
|
||||
)
|
||||
|
||||
// TestDevGoldenPath tests using the default values for the default developer config.
|
||||
// Note: This test requires a separate container image to be available for the JMS tests.
|
||||
func TestDevGoldenPath(t *testing.T) {
|
||||
t.Parallel()
|
||||
cli := ce.NewContainerClient()
|
||||
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
qm := "qm1"
|
||||
containerConfig := ce.ContainerConfig{
|
||||
containerConfig := container.Config{
|
||||
Env: []string{
|
||||
"LICENSE=accept",
|
||||
"MQ_QMGR_NAME=" + qm,
|
||||
"DEBUG=true",
|
||||
},
|
||||
}
|
||||
id := runContainerWithPorts(t, cli, &containerConfig, []int{9443, 1414})
|
||||
id := runContainerWithPorts(t, cli, &containerConfig, []int{9443})
|
||||
defer cleanContainer(t, cli, id)
|
||||
waitForReady(t, cli, id)
|
||||
waitForWebReady(t, cli, id, insecureTLSConfig)
|
||||
@@ -67,12 +74,15 @@ func TestDevGoldenPath(t *testing.T) {
|
||||
func TestDevSecure(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cli := ce.NewContainerClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
const tlsPassPhrase string = "passw0rd"
|
||||
qm := "qm1"
|
||||
appPassword := "differentPassw0rd"
|
||||
containerConfig := ce.ContainerConfig{
|
||||
containerConfig := container.Config{
|
||||
Env: []string{
|
||||
"LICENSE=accept",
|
||||
"MQ_QMGR_NAME=" + qm,
|
||||
@@ -83,67 +93,67 @@ func TestDevSecure(t *testing.T) {
|
||||
},
|
||||
Image: imageName(),
|
||||
}
|
||||
hostConfig := ce.ContainerHostConfig{
|
||||
hostConfig := container.HostConfig{
|
||||
Binds: []string{
|
||||
coverageBind(t),
|
||||
tlsDir(t, false) + ":/etc/mqm/pki/keys/default",
|
||||
},
|
||||
// Assign a random port for the web server on the host
|
||||
// TODO: Don't do this for all tests
|
||||
PortBindings: nat.PortMap{
|
||||
"9443/tcp": []nat.PortBinding{
|
||||
{
|
||||
HostIP: "0.0.0.0",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
// Assign a random port for the web server on the host
|
||||
// TODO: Don't do this for all tests
|
||||
var binding ce.PortBinding
|
||||
ports := []int{9443, 1414}
|
||||
for _, p := range ports {
|
||||
port := fmt.Sprintf("%v/tcp", p)
|
||||
binding = ce.PortBinding{
|
||||
ContainerPort: port,
|
||||
HostIP: "0.0.0.0",
|
||||
}
|
||||
hostConfig.PortBindings = append(hostConfig.PortBindings, binding)
|
||||
}
|
||||
networkingConfig := ce.ContainerNetworkSettings{}
|
||||
ID, err := cli.ContainerCreate(&containerConfig, &hostConfig, &networkingConfig, t.Name())
|
||||
networkingConfig := network.NetworkingConfig{}
|
||||
ctr, err := cli.ContainerCreate(context.Background(), &containerConfig, &hostConfig, &networkingConfig, t.Name())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer cleanContainer(t, cli, ID)
|
||||
startContainer(t, cli, ID)
|
||||
waitForReady(t, cli, ID)
|
||||
defer cleanContainer(t, cli, ctr.ID)
|
||||
startContainer(t, cli, ctr.ID)
|
||||
waitForReady(t, cli, ctr.ID)
|
||||
cert := filepath.Join(tlsDir(t, true), "server.crt")
|
||||
waitForWebReady(t, cli, ID, createTLSConfig(t, cert, tlsPassPhrase))
|
||||
waitForWebReady(t, cli, ctr.ID, createTLSConfig(t, cert, tlsPassPhrase))
|
||||
|
||||
t.Run("JMS", func(t *testing.T) {
|
||||
// OpenJDK is used for running tests, hence pass "false" for 7th parameter.
|
||||
// Cipher name specified is compliant with non-IBM JRE naming.
|
||||
runJMSTests(t, cli, ID, true, "app", appPassword, "false", "TLS_RSA_WITH_AES_256_CBC_SHA256")
|
||||
runJMSTests(t, cli, ctr.ID, true, "app", appPassword, "false", "TLS_RSA_WITH_AES_256_CBC_SHA256")
|
||||
})
|
||||
t.Run("REST admin", func(t *testing.T) {
|
||||
testRESTAdmin(t, cli, ID, insecureTLSConfig, "")
|
||||
testRESTAdmin(t, cli, ctr.ID, insecureTLSConfig, "")
|
||||
})
|
||||
t.Run("REST messaging", func(t *testing.T) {
|
||||
testRESTMessaging(t, cli, ID, insecureTLSConfig, qm, "app", appPassword, "")
|
||||
testRESTMessaging(t, cli, ctr.ID, insecureTLSConfig, qm, "app", appPassword, "")
|
||||
})
|
||||
|
||||
// Stop the container cleanly
|
||||
stopContainer(t, cli, ID)
|
||||
stopContainer(t, cli, ctr.ID)
|
||||
}
|
||||
|
||||
func TestDevWebDisabled(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cli := ce.NewContainerClient()
|
||||
containerConfig := ce.ContainerConfig{
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
containerConfig := container.Config{
|
||||
Env: []string{
|
||||
"LICENSE=accept",
|
||||
"MQ_QMGR_NAME=qm1",
|
||||
"MQ_ENABLE_EMBEDDED_WEB_SERVER=false",
|
||||
},
|
||||
}
|
||||
id := runContainerWithPorts(t, cli, &containerConfig, []int{1414})
|
||||
id := runContainer(t, cli, &containerConfig)
|
||||
defer cleanContainer(t, cli, id)
|
||||
waitForReady(t, cli, id)
|
||||
t.Run("Web", func(t *testing.T) {
|
||||
_, dspmqweb := cli.ExecContainer(id, "", []string{"dspmqweb"})
|
||||
_, dspmqweb := execContainer(t, cli, id, "", []string{"dspmqweb"})
|
||||
if !strings.Contains(dspmqweb, "Server mqweb is not running.") && !strings.Contains(dspmqweb, "MQWB1125I") {
|
||||
t.Errorf("Expected dspmqweb to say 'Server is not running' or 'MQWB1125I'; got \"%v\"", dspmqweb)
|
||||
}
|
||||
@@ -161,8 +171,11 @@ func TestDevWebDisabled(t *testing.T) {
|
||||
func TestDevConfigDisabled(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cli := ce.NewContainerClient()
|
||||
containerConfig := ce.ContainerConfig{
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
containerConfig := container.Config{
|
||||
Env: []string{
|
||||
"LICENSE=accept",
|
||||
"MQ_QMGR_NAME=qm1",
|
||||
@@ -186,8 +199,11 @@ func TestDevConfigDisabled(t *testing.T) {
|
||||
func TestSSLKEYRBlank(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cli := ce.NewContainerClient()
|
||||
containerConfig := ce.ContainerConfig{
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
containerConfig := container.Config{
|
||||
Env: []string{
|
||||
"LICENSE=accept",
|
||||
"MQ_QMGR_NAME=QM1",
|
||||
@@ -230,9 +246,12 @@ func TestSSLKEYRBlank(t *testing.T) {
|
||||
func TestSSLKEYRWithSuppliedKeyAndCert(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cli := ce.NewContainerClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
containerConfig := ce.ContainerConfig{
|
||||
containerConfig := container.Config{
|
||||
Env: []string{
|
||||
"LICENSE=accept",
|
||||
"MQ_QMGR_NAME=QM1",
|
||||
@@ -240,24 +259,24 @@ func TestSSLKEYRWithSuppliedKeyAndCert(t *testing.T) {
|
||||
},
|
||||
Image: imageName(),
|
||||
}
|
||||
hostConfig := ce.ContainerHostConfig{
|
||||
hostConfig := container.HostConfig{
|
||||
Binds: []string{
|
||||
coverageBind(t),
|
||||
tlsDir(t, false) + ":/etc/mqm/pki/keys/default",
|
||||
},
|
||||
}
|
||||
networkingConfig := ce.ContainerNetworkSettings{}
|
||||
ID, err := cli.ContainerCreate(&containerConfig, &hostConfig, &networkingConfig, t.Name())
|
||||
networkingConfig := network.NetworkingConfig{}
|
||||
ctr, err := cli.ContainerCreate(context.Background(), &containerConfig, &hostConfig, &networkingConfig, t.Name())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer cleanContainer(t, cli, ID)
|
||||
startContainer(t, cli, ID)
|
||||
waitForReady(t, cli, ID)
|
||||
defer cleanContainer(t, cli, ctr.ID)
|
||||
startContainer(t, cli, ctr.ID)
|
||||
waitForReady(t, cli, ctr.ID)
|
||||
|
||||
// execute runmqsc to display qmgr SSLKEYR and CERTLABL attibutes.
|
||||
// Search the console output for exepcted values
|
||||
_, sslkeyROutput := execContainer(t, cli, ID, "", []string{"bash", "-c", "echo 'DISPLAY QMGR SSLKEYR CERTLABL' | runmqsc"})
|
||||
_, sslkeyROutput := execContainer(t, cli, ctr.ID, "", []string{"bash", "-c", "echo 'DISPLAY QMGR SSLKEYR CERTLABL' | runmqsc"})
|
||||
if !strings.Contains(sslkeyROutput, "SSLKEYR(/run/runmqserver/tls/key)") || !strings.Contains(sslkeyROutput, "CERTLABL(default)") {
|
||||
// Although queue manager is ready, it may be that MQSC scripts have not been applied yet.
|
||||
// Hence wait for a second and retry few times before giving up.
|
||||
@@ -265,30 +284,33 @@ func TestSSLKEYRWithSuppliedKeyAndCert(t *testing.T) {
|
||||
var i int
|
||||
for i = 0; i < waitCount; i++ {
|
||||
time.Sleep(1 * time.Second)
|
||||
_, sslkeyROutput = execContainer(t, cli, ID, "", []string{"bash", "-c", "echo 'DISPLAY QMGR SSLKEYR CERTLABL' | runmqsc"})
|
||||
_, sslkeyROutput = execContainer(t, cli, ctr.ID, "", []string{"bash", "-c", "echo 'DISPLAY QMGR SSLKEYR CERTLABL' | runmqsc"})
|
||||
if strings.Contains(sslkeyROutput, "SSLKEYR(/run/runmqserver/tls/key)") && strings.Contains(sslkeyROutput, "CERTLABL(default)") {
|
||||
break
|
||||
}
|
||||
}
|
||||
// Failed to get expected output? dump the contents of mqsc files.
|
||||
if i == waitCount {
|
||||
_, tls15mqsc := execContainer(t, cli, ID, "", []string{"cat", "/etc/mqm/15-tls.mqsc"})
|
||||
_, autoMQSC := execContainer(t, cli, ID, "", []string{"cat", "/mnt/mqm/data/qmgrs/QM1/autocfg/cached.mqsc"})
|
||||
_, tls15mqsc := execContainer(t, cli, ctr.ID, "", []string{"cat", "/etc/mqm/15-tls.mqsc"})
|
||||
_, autoMQSC := execContainer(t, cli, ctr.ID, "", []string{"cat", "/mnt/mqm/data/qmgrs/QM1/autocfg/cached.mqsc"})
|
||||
t.Errorf("Expected SSLKEYR to be '/run/runmqserver/tls/key' but it is not; got \"%v\" \n AutoConfig MQSC file contents %v\n 15-tls: %v", sslkeyROutput, autoMQSC, tls15mqsc)
|
||||
}
|
||||
}
|
||||
|
||||
// Stop the container cleanly
|
||||
stopContainer(t, cli, ID)
|
||||
stopContainer(t, cli, ctr.ID)
|
||||
}
|
||||
|
||||
// Test with CA cert
|
||||
func TestSSLKEYRWithCACert(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cli := ce.NewContainerClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
containerConfig := ce.ContainerConfig{
|
||||
containerConfig := container.Config{
|
||||
Env: []string{
|
||||
"LICENSE=accept",
|
||||
"MQ_QMGR_NAME=QM1",
|
||||
@@ -296,35 +318,32 @@ func TestSSLKEYRWithCACert(t *testing.T) {
|
||||
},
|
||||
Image: imageName(),
|
||||
}
|
||||
hostConfig := ce.ContainerHostConfig{
|
||||
hostConfig := container.HostConfig{
|
||||
Binds: []string{
|
||||
coverageBind(t),
|
||||
tlsDirWithCA(t, false) + ":/etc/mqm/pki/keys/QM1CA",
|
||||
},
|
||||
// Assign a random port for the web server on the host
|
||||
PortBindings: nat.PortMap{
|
||||
"9443/tcp": []nat.PortBinding{
|
||||
{
|
||||
HostIP: "0.0.0.0",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
// Assign a random port for the web server on the host
|
||||
var binding ce.PortBinding
|
||||
ports := []int{9443}
|
||||
for _, p := range ports {
|
||||
port := fmt.Sprintf("%v/tcp", p)
|
||||
binding = ce.PortBinding{
|
||||
ContainerPort: port,
|
||||
HostIP: "0.0.0.0",
|
||||
}
|
||||
hostConfig.PortBindings = append(hostConfig.PortBindings, binding)
|
||||
}
|
||||
networkingConfig := ce.ContainerNetworkSettings{}
|
||||
ID, err := cli.ContainerCreate(&containerConfig, &hostConfig, &networkingConfig, t.Name())
|
||||
networkingConfig := network.NetworkingConfig{}
|
||||
ctr, err := cli.ContainerCreate(context.Background(), &containerConfig, &hostConfig, &networkingConfig, t.Name())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer cleanContainer(t, cli, ID)
|
||||
startContainer(t, cli, ID)
|
||||
waitForReady(t, cli, ID)
|
||||
defer cleanContainer(t, cli, ctr.ID)
|
||||
startContainer(t, cli, ctr.ID)
|
||||
waitForReady(t, cli, ctr.ID)
|
||||
|
||||
// execute runmqsc to display qmgr SSLKEYR and CERTLABL attibutes.
|
||||
// Search the console output for exepcted values
|
||||
_, sslkeyROutput := execContainer(t, cli, ID, "", []string{"bash", "-c", "echo 'DISPLAY QMGR SSLKEYR CERTLABL' | runmqsc"})
|
||||
_, sslkeyROutput := execContainer(t, cli, ctr.ID, "", []string{"bash", "-c", "echo 'DISPLAY QMGR SSLKEYR CERTLABL' | runmqsc"})
|
||||
|
||||
if !strings.Contains(sslkeyROutput, "SSLKEYR(/run/runmqserver/tls/key)") {
|
||||
// Although queue manager is ready, it may be that MQSC scripts have not been applied yet.
|
||||
@@ -333,35 +352,38 @@ func TestSSLKEYRWithCACert(t *testing.T) {
|
||||
var i int
|
||||
for i = 0; i < waitCount; i++ {
|
||||
time.Sleep(1 * time.Second)
|
||||
_, sslkeyROutput = execContainer(t, cli, ID, "", []string{"bash", "-c", "echo 'DISPLAY QMGR SSLKEYR CERTLABL' | runmqsc"})
|
||||
_, sslkeyROutput = execContainer(t, cli, ctr.ID, "", []string{"bash", "-c", "echo 'DISPLAY QMGR SSLKEYR CERTLABL' | runmqsc"})
|
||||
if strings.Contains(sslkeyROutput, "SSLKEYR(/run/runmqserver/tls/key)") {
|
||||
break
|
||||
}
|
||||
}
|
||||
// Failed to get expected output? dump the contents of mqsc files.
|
||||
if i == waitCount {
|
||||
_, tls15mqsc := execContainer(t, cli, ID, "", []string{"cat", "/etc/mqm/15-tls.mqsc"})
|
||||
_, autoMQSC := execContainer(t, cli, ID, "", []string{"cat", "/mnt/mqm/data/qmgrs/QM1/autocfg/cached.mqsc"})
|
||||
_, tls15mqsc := execContainer(t, cli, ctr.ID, "", []string{"cat", "/etc/mqm/15-tls.mqsc"})
|
||||
_, autoMQSC := execContainer(t, cli, ctr.ID, "", []string{"cat", "/mnt/mqm/data/qmgrs/QM1/autocfg/cached.mqsc"})
|
||||
t.Errorf("Expected SSLKEYR to be '/run/runmqserver/tls/key' but it is not; got \"%v\"\n AutoConfig MQSC file contents %v\n 15-tls: %v", sslkeyROutput, autoMQSC, tls15mqsc)
|
||||
}
|
||||
}
|
||||
|
||||
if !strings.Contains(sslkeyROutput, "CERTLABL(QM1CA)") {
|
||||
_, autoMQSC := execContainer(t, cli, ID, "", []string{"cat", "/etc/mqm/15-tls.mqsc"})
|
||||
_, autoMQSC := execContainer(t, cli, ctr.ID, "", []string{"cat", "/etc/mqm/15-tls.mqsc"})
|
||||
t.Errorf("Expected CERTLABL to be 'QM1CA' but it is not; got \"%v\" \n MQSC File contents %v", sslkeyROutput, autoMQSC)
|
||||
}
|
||||
|
||||
// Stop the container cleanly
|
||||
stopContainer(t, cli, ID)
|
||||
stopContainer(t, cli, ctr.ID)
|
||||
}
|
||||
|
||||
// Verifies SSLFIPS is set to NO if MQ_ENABLE_FIPS=false
|
||||
func TestSSLFIPSNO(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cli := ce.NewContainerClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
containerConfig := ce.ContainerConfig{
|
||||
containerConfig := container.Config{
|
||||
Env: []string{
|
||||
"LICENSE=accept",
|
||||
"MQ_QMGR_NAME=QM1",
|
||||
@@ -370,24 +392,24 @@ func TestSSLFIPSNO(t *testing.T) {
|
||||
},
|
||||
Image: imageName(),
|
||||
}
|
||||
hostConfig := ce.ContainerHostConfig{
|
||||
hostConfig := container.HostConfig{
|
||||
Binds: []string{
|
||||
coverageBind(t),
|
||||
tlsDir(t, false) + ":/etc/mqm/pki/keys/default",
|
||||
},
|
||||
}
|
||||
networkingConfig := ce.ContainerNetworkSettings{}
|
||||
ID, err := cli.ContainerCreate(&containerConfig, &hostConfig, &networkingConfig, t.Name())
|
||||
networkingConfig := network.NetworkingConfig{}
|
||||
ctr, err := cli.ContainerCreate(context.Background(), &containerConfig, &hostConfig, &networkingConfig, t.Name())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer cleanContainer(t, cli, ID)
|
||||
startContainer(t, cli, ID)
|
||||
waitForReady(t, cli, ID)
|
||||
defer cleanContainer(t, cli, ctr.ID)
|
||||
startContainer(t, cli, ctr.ID)
|
||||
waitForReady(t, cli, ctr.ID)
|
||||
|
||||
// execute runmqsc to display qmgr SSLKEYR, SSLFIPS and CERTLABL attibutes.
|
||||
// Search the console output for exepcted values
|
||||
_, sslFIPSOutput := execContainer(t, cli, ID, "", []string{"bash", "-c", "echo 'DISPLAY QMGR SSLKEYR CERTLABL SSLFIPS' | runmqsc"})
|
||||
_, sslFIPSOutput := execContainer(t, cli, ctr.ID, "", []string{"bash", "-c", "echo 'DISPLAY QMGR SSLKEYR CERTLABL SSLFIPS' | runmqsc"})
|
||||
if !strings.Contains(sslFIPSOutput, "SSLKEYR(/run/runmqserver/tls/key)") {
|
||||
t.Errorf("Expected SSLKEYR to be '/run/runmqserver/tls/key' but it is not; got \"%v\"", sslFIPSOutput)
|
||||
}
|
||||
@@ -400,7 +422,7 @@ func TestSSLFIPSNO(t *testing.T) {
|
||||
}
|
||||
|
||||
// Stop the container cleanly
|
||||
stopContainer(t, cli, ID)
|
||||
stopContainer(t, cli, ctr.ID)
|
||||
}
|
||||
|
||||
// Verifies SSLFIPS is set to YES if certificates for queue manager
|
||||
@@ -408,10 +430,13 @@ func TestSSLFIPSNO(t *testing.T) {
|
||||
func TestSSLFIPSYES(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cli := ce.NewContainerClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
appPassword := "differentPassw0rd"
|
||||
containerConfig := ce.ContainerConfig{
|
||||
containerConfig := container.Config{
|
||||
Env: []string{
|
||||
"LICENSE=accept",
|
||||
"MQ_APP_PASSWORD=" + appPassword,
|
||||
@@ -421,40 +446,30 @@ func TestSSLFIPSYES(t *testing.T) {
|
||||
},
|
||||
Image: imageName(),
|
||||
}
|
||||
hostConfig := ce.ContainerHostConfig{
|
||||
hostConfig := container.HostConfig{
|
||||
Binds: []string{
|
||||
coverageBind(t),
|
||||
tlsDir(t, false) + ":/etc/mqm/pki/keys/default",
|
||||
},
|
||||
}
|
||||
var binding ce.PortBinding
|
||||
ports := []int{1414}
|
||||
for _, p := range ports {
|
||||
port := fmt.Sprintf("%v/tcp", p)
|
||||
binding = ce.PortBinding{
|
||||
ContainerPort: port,
|
||||
HostIP: "0.0.0.0",
|
||||
}
|
||||
hostConfig.PortBindings = append(hostConfig.PortBindings, binding)
|
||||
}
|
||||
networkingConfig := ce.ContainerNetworkSettings{}
|
||||
ID, err := cli.ContainerCreate(&containerConfig, &hostConfig, &networkingConfig, t.Name())
|
||||
networkingConfig := network.NetworkingConfig{}
|
||||
ctr, err := cli.ContainerCreate(context.Background(), &containerConfig, &hostConfig, &networkingConfig, t.Name())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer cleanContainer(t, cli, ID)
|
||||
startContainer(t, cli, ID)
|
||||
waitForReady(t, cli, ID)
|
||||
defer cleanContainer(t, cli, ctr.ID)
|
||||
startContainer(t, cli, ctr.ID)
|
||||
waitForReady(t, cli, ctr.ID)
|
||||
|
||||
// Check for expected message on container log
|
||||
logs := inspectLogs(t, cli, ID)
|
||||
logs := inspectLogs(t, cli, ctr.ID)
|
||||
if !strings.Contains(logs, "FIPS cryptography is enabled.") {
|
||||
t.Errorf("Expected 'FIPS cryptography is enabled.' but got %v\n", logs)
|
||||
}
|
||||
|
||||
// execute runmqsc to display qmgr SSLKEYR, SSLFIPS and CERTLABL attibutes.
|
||||
// Search the console output for exepcted values
|
||||
_, sslFIPSOutput := execContainer(t, cli, ID, "", []string{"bash", "-c", "echo 'DISPLAY QMGR SSLKEYR CERTLABL SSLFIPS' | runmqsc"})
|
||||
_, sslFIPSOutput := execContainer(t, cli, ctr.ID, "", []string{"bash", "-c", "echo 'DISPLAY QMGR SSLKEYR CERTLABL SSLFIPS' | runmqsc"})
|
||||
if !strings.Contains(sslFIPSOutput, "SSLKEYR(/run/runmqserver/tls/key)") {
|
||||
t.Errorf("Expected SSLKEYR to be '/run/runmqserver/tls/key' but it is not; got \"%v\"", sslFIPSOutput)
|
||||
}
|
||||
@@ -468,23 +483,26 @@ func TestSSLFIPSYES(t *testing.T) {
|
||||
|
||||
t.Run("JMS", func(t *testing.T) {
|
||||
// Run the JMS tests, with no password specified
|
||||
runJMSTests(t, cli, ID, true, "app", appPassword, "false", "TLS_RSA_WITH_AES_256_CBC_SHA256")
|
||||
runJMSTests(t, cli, ctr.ID, true, "app", appPassword, "false", "TLS_RSA_WITH_AES_256_CBC_SHA256")
|
||||
})
|
||||
|
||||
// Stop the container cleanly
|
||||
stopContainer(t, cli, ID)
|
||||
stopContainer(t, cli, ctr.ID)
|
||||
}
|
||||
|
||||
// TestDevSecureFIPSYESWeb verifies if the MQ Web Server is running in FIPS mode
|
||||
func TestDevSecureFIPSTrueWeb(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cli := ce.NewContainerClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
const tlsPassPhrase string = "passw0rd"
|
||||
qm := "qm1"
|
||||
appPassword := "differentPassw0rd"
|
||||
containerConfig := ce.ContainerConfig{
|
||||
containerConfig := container.Config{
|
||||
Env: []string{
|
||||
"LICENSE=accept",
|
||||
"MQ_QMGR_NAME=" + qm,
|
||||
@@ -496,65 +514,65 @@ func TestDevSecureFIPSTrueWeb(t *testing.T) {
|
||||
},
|
||||
Image: imageName(),
|
||||
}
|
||||
hostConfig := ce.ContainerHostConfig{
|
||||
hostConfig := container.HostConfig{
|
||||
Binds: []string{
|
||||
coverageBind(t),
|
||||
tlsDir(t, false) + ":/etc/mqm/pki/keys/default",
|
||||
tlsDir(t, false) + ":/etc/mqm/pki/trust/default",
|
||||
},
|
||||
// Assign a random port for the web server on the host
|
||||
// TODO: Don't do this for all tests
|
||||
PortBindings: nat.PortMap{
|
||||
"9443/tcp": []nat.PortBinding{
|
||||
{
|
||||
HostIP: "0.0.0.0",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
// Assign a random port for the web server on the host
|
||||
// TODO: Don't do this for all tests
|
||||
var binding ce.PortBinding
|
||||
ports := []int{9443}
|
||||
for _, p := range ports {
|
||||
port := fmt.Sprintf("%v/tcp", p)
|
||||
binding = ce.PortBinding{
|
||||
ContainerPort: port,
|
||||
HostIP: "0.0.0.0",
|
||||
}
|
||||
hostConfig.PortBindings = append(hostConfig.PortBindings, binding)
|
||||
}
|
||||
networkingConfig := ce.ContainerNetworkSettings{}
|
||||
ID, err := cli.ContainerCreate(&containerConfig, &hostConfig, &networkingConfig, t.Name())
|
||||
networkingConfig := network.NetworkingConfig{}
|
||||
ctr, err := cli.ContainerCreate(context.Background(), &containerConfig, &hostConfig, &networkingConfig, t.Name())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer cleanContainer(t, cli, ID)
|
||||
defer cleanContainer(t, cli, ctr.ID)
|
||||
|
||||
startContainer(t, cli, ID)
|
||||
waitForReady(t, cli, ID)
|
||||
startContainer(t, cli, ctr.ID)
|
||||
waitForReady(t, cli, ctr.ID)
|
||||
cert := filepath.Join(tlsDir(t, true), "server.crt")
|
||||
waitForWebReady(t, cli, ID, createTLSConfig(t, cert, tlsPassPhrase))
|
||||
waitForWebReady(t, cli, ctr.ID, createTLSConfig(t, cert, tlsPassPhrase))
|
||||
|
||||
// Create a TLS Config with a cipher to use when connecting over HTTPS
|
||||
var secureTLSConfig *tls.Config = createTLSConfigWithCipher(t, cert, tlsPassPhrase, []uint16{tls.TLS_RSA_WITH_AES_256_GCM_SHA384})
|
||||
// Put a message to queue
|
||||
t.Run("REST messaging", func(t *testing.T) {
|
||||
testRESTMessaging(t, cli, ID, secureTLSConfig, qm, "app", appPassword, "")
|
||||
testRESTMessaging(t, cli, ctr.ID, secureTLSConfig, qm, "app", appPassword, "")
|
||||
})
|
||||
|
||||
// Create a TLS Config with a non-FIPS cipher to use when connecting over HTTPS
|
||||
var secureNonFIPSCipherConfig *tls.Config = createTLSConfigWithCipher(t, cert, tlsPassPhrase, []uint16{tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA})
|
||||
// Put a message to queue - the attempt to put message will fail with a EOF return message.
|
||||
t.Run("REST messaging", func(t *testing.T) {
|
||||
testRESTMessaging(t, cli, ID, secureNonFIPSCipherConfig, qm, "app", appPassword, "EOF")
|
||||
testRESTMessaging(t, cli, ctr.ID, secureNonFIPSCipherConfig, qm, "app", appPassword, "EOF")
|
||||
})
|
||||
|
||||
// Stop the container cleanly
|
||||
stopContainer(t, cli, ID)
|
||||
stopContainer(t, cli, ctr.ID)
|
||||
}
|
||||
|
||||
// TestDevSecureNOFIPSWeb verifies if the MQ Web Server is not running in FIPS mode
|
||||
func TestDevSecureFalseFIPSWeb(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cli := ce.NewContainerClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
const tlsPassPhrase string = "passw0rd"
|
||||
qm := "qm1"
|
||||
appPassword := "differentPassw0rd"
|
||||
containerConfig := ce.ContainerConfig{
|
||||
containerConfig := container.Config{
|
||||
Env: []string{
|
||||
"LICENSE=accept",
|
||||
"MQ_QMGR_NAME=" + qm,
|
||||
@@ -566,41 +584,38 @@ func TestDevSecureFalseFIPSWeb(t *testing.T) {
|
||||
},
|
||||
Image: imageName(),
|
||||
}
|
||||
hostConfig := ce.ContainerHostConfig{
|
||||
hostConfig := container.HostConfig{
|
||||
Binds: []string{
|
||||
coverageBind(t),
|
||||
tlsDir(t, false) + ":/etc/mqm/pki/keys/default",
|
||||
tlsDir(t, false) + ":/etc/mqm/pki/trust/default",
|
||||
},
|
||||
// Assign a random port for the web server on the host
|
||||
PortBindings: nat.PortMap{
|
||||
"9443/tcp": []nat.PortBinding{
|
||||
{
|
||||
HostIP: "0.0.0.0",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
// Assign a random port for the web server on the host
|
||||
var binding ce.PortBinding
|
||||
ports := []int{9443}
|
||||
for _, p := range ports {
|
||||
port := fmt.Sprintf("%v/tcp", p)
|
||||
binding = ce.PortBinding{
|
||||
ContainerPort: port,
|
||||
HostIP: "0.0.0.0",
|
||||
}
|
||||
hostConfig.PortBindings = append(hostConfig.PortBindings, binding)
|
||||
}
|
||||
networkingConfig := ce.ContainerNetworkSettings{}
|
||||
ID, err := cli.ContainerCreate(&containerConfig, &hostConfig, &networkingConfig, t.Name())
|
||||
networkingConfig := network.NetworkingConfig{}
|
||||
ctr, err := cli.ContainerCreate(context.Background(), &containerConfig, &hostConfig, &networkingConfig, t.Name())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer cleanContainer(t, cli, ID)
|
||||
startContainer(t, cli, ID)
|
||||
waitForReady(t, cli, ID)
|
||||
defer cleanContainer(t, cli, ctr.ID)
|
||||
startContainer(t, cli, ctr.ID)
|
||||
waitForReady(t, cli, ctr.ID)
|
||||
|
||||
cert := filepath.Join(tlsDir(t, true), "server.crt")
|
||||
waitForWebReady(t, cli, ID, createTLSConfig(t, cert, tlsPassPhrase))
|
||||
waitForWebReady(t, cli, ctr.ID, createTLSConfig(t, cert, tlsPassPhrase))
|
||||
|
||||
// As FIPS is not enabled, the MQ WebServer (actually Java) will choose a JSSE provider from the list
|
||||
// specified in java.security file. We will need to enable java.net.debug and then parse the web server
|
||||
// logs to check what JJSE provider is being used. Hence just check the jvm.options file does not contain
|
||||
// -Dcom.ibm.jsse2.usefipsprovider line.
|
||||
_, jvmOptionsOutput := execContainer(t, cli, ID, "", []string{"bash", "-c", "cat /var/mqm/web/installations/Installation1/servers/mqweb/configDropins/defaults/jvm.options"})
|
||||
_, jvmOptionsOutput := execContainer(t, cli, ctr.ID, "", []string{"bash", "-c", "cat /var/mqm/web/installations/Installation1/servers/mqweb/configDropins/defaults/jvm.options"})
|
||||
if strings.Contains(jvmOptionsOutput, "-Dcom.ibm.jsse2.usefipsprovider") {
|
||||
t.Errorf("Did not expect -Dcom.ibm.jsse2.usefipsprovider but it is not; got \"%v\"", jvmOptionsOutput)
|
||||
}
|
||||
@@ -608,21 +623,24 @@ func TestDevSecureFalseFIPSWeb(t *testing.T) {
|
||||
// Just do a HTTPS GET as well to query installation details.
|
||||
var secureTLSConfig *tls.Config = createTLSConfigWithCipher(t, cert, tlsPassPhrase, []uint16{tls.TLS_RSA_WITH_AES_256_GCM_SHA384})
|
||||
t.Run("REST admin", func(t *testing.T) {
|
||||
testRESTAdmin(t, cli, ID, secureTLSConfig, "")
|
||||
testRESTAdmin(t, cli, ctr.ID, secureTLSConfig, "")
|
||||
})
|
||||
|
||||
// Stop the container cleanly
|
||||
stopContainer(t, cli, ID)
|
||||
stopContainer(t, cli, ctr.ID)
|
||||
}
|
||||
|
||||
// Verify SSLFIPS is set to NO if no certificates were supplied
|
||||
func TestSSLFIPSTrueNoCerts(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cli := ce.NewContainerClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
appPassword := "differentPassw0rd"
|
||||
containerConfig := ce.ContainerConfig{
|
||||
containerConfig := container.Config{
|
||||
Env: []string{
|
||||
"LICENSE=accept",
|
||||
"MQ_APP_PASSWORD=" + appPassword,
|
||||
@@ -632,23 +650,23 @@ func TestSSLFIPSTrueNoCerts(t *testing.T) {
|
||||
},
|
||||
Image: imageName(),
|
||||
}
|
||||
hostConfig := ce.ContainerHostConfig{
|
||||
hostConfig := container.HostConfig{
|
||||
Binds: []string{
|
||||
coverageBind(t),
|
||||
},
|
||||
}
|
||||
networkingConfig := ce.ContainerNetworkSettings{}
|
||||
ID, err := cli.ContainerCreate(&containerConfig, &hostConfig, &networkingConfig, t.Name())
|
||||
networkingConfig := network.NetworkingConfig{}
|
||||
ctr, err := cli.ContainerCreate(context.Background(), &containerConfig, &hostConfig, &networkingConfig, t.Name())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer cleanContainer(t, cli, ID)
|
||||
startContainer(t, cli, ID)
|
||||
waitForReady(t, cli, ID)
|
||||
defer cleanContainer(t, cli, ctr.ID)
|
||||
startContainer(t, cli, ctr.ID)
|
||||
waitForReady(t, cli, ctr.ID)
|
||||
|
||||
// execute runmqsc to display qmgr SSLKEYR, SSLFIPS and CERTLABL attibutes.
|
||||
// Search the console output for exepcted values
|
||||
_, sslFIPSOutput := execContainer(t, cli, ID, "", []string{"bash", "-c", "echo 'DISPLAY QMGR SSLKEYR CERTLABL SSLFIPS' | runmqsc"})
|
||||
_, sslFIPSOutput := execContainer(t, cli, ctr.ID, "", []string{"bash", "-c", "echo 'DISPLAY QMGR SSLKEYR CERTLABL SSLFIPS' | runmqsc"})
|
||||
if !strings.Contains(sslFIPSOutput, "SSLKEYR( )") {
|
||||
t.Errorf("Expected SSLKEYR to be ' ' but it is not; got \"%v\"", sslFIPSOutput)
|
||||
}
|
||||
@@ -661,16 +679,19 @@ func TestSSLFIPSTrueNoCerts(t *testing.T) {
|
||||
}
|
||||
|
||||
// Stop the container cleanly
|
||||
stopContainer(t, cli, ID)
|
||||
stopContainer(t, cli, ctr.ID)
|
||||
}
|
||||
|
||||
// Verifies SSLFIPS is set to NO if MQ_ENABLE_FIPS=tru (invalid value)
|
||||
func TestSSLFIPSInvalidValue(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cli := ce.NewContainerClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
containerConfig := ce.ContainerConfig{
|
||||
containerConfig := container.Config{
|
||||
Env: []string{
|
||||
"LICENSE=accept",
|
||||
"MQ_QMGR_NAME=QM1",
|
||||
@@ -679,24 +700,24 @@ func TestSSLFIPSInvalidValue(t *testing.T) {
|
||||
},
|
||||
Image: imageName(),
|
||||
}
|
||||
hostConfig := ce.ContainerHostConfig{
|
||||
hostConfig := container.HostConfig{
|
||||
Binds: []string{
|
||||
coverageBind(t),
|
||||
tlsDir(t, false) + ":/etc/mqm/pki/keys/default",
|
||||
},
|
||||
}
|
||||
networkingConfig := ce.ContainerNetworkSettings{}
|
||||
ID, err := cli.ContainerCreate(&containerConfig, &hostConfig, &networkingConfig, t.Name())
|
||||
networkingConfig := network.NetworkingConfig{}
|
||||
ctr, err := cli.ContainerCreate(context.Background(), &containerConfig, &hostConfig, &networkingConfig, t.Name())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer cleanContainer(t, cli, ID)
|
||||
startContainer(t, cli, ID)
|
||||
waitForReady(t, cli, ID)
|
||||
defer cleanContainer(t, cli, ctr.ID)
|
||||
startContainer(t, cli, ctr.ID)
|
||||
waitForReady(t, cli, ctr.ID)
|
||||
|
||||
// execute runmqsc to display qmgr SSLKEYR, SSLFIPS and CERTLABL attibutes.
|
||||
// Search the console output for exepcted values
|
||||
_, sslFIPSOutput := execContainer(t, cli, ID, "", []string{"bash", "-c", "echo 'DISPLAY QMGR SSLKEYR CERTLABL SSLFIPS' | runmqsc"})
|
||||
_, sslFIPSOutput := execContainer(t, cli, ctr.ID, "", []string{"bash", "-c", "echo 'DISPLAY QMGR SSLKEYR CERTLABL SSLFIPS' | runmqsc"})
|
||||
if !strings.Contains(sslFIPSOutput, "SSLKEYR(/run/runmqserver/tls/key)") {
|
||||
t.Errorf("Expected SSLKEYR to be '/run/runmqserver/tls/key' but it is not; got \"%v\"", sslFIPSOutput)
|
||||
}
|
||||
@@ -710,16 +731,19 @@ func TestSSLFIPSInvalidValue(t *testing.T) {
|
||||
}
|
||||
|
||||
// Stop the container cleanly
|
||||
stopContainer(t, cli, ID)
|
||||
stopContainer(t, cli, ctr.ID)
|
||||
}
|
||||
|
||||
// Container creation fails when invalid certs are passed and MQ_ENABLE_FIPS set true
|
||||
func TestSSLFIPSBadCerts(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cli := ce.NewContainerClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
containerConfig := ce.ContainerConfig{
|
||||
containerConfig := container.Config{
|
||||
Env: []string{
|
||||
"LICENSE=accept",
|
||||
"MQ_QMGR_NAME=QM1",
|
||||
@@ -728,25 +752,25 @@ func TestSSLFIPSBadCerts(t *testing.T) {
|
||||
},
|
||||
Image: imageName(),
|
||||
}
|
||||
hostConfig := ce.ContainerHostConfig{
|
||||
hostConfig := container.HostConfig{
|
||||
Binds: []string{
|
||||
coverageBind(t),
|
||||
tlsDirInvalid(t, false) + ":/etc/mqm/pki/keys/default",
|
||||
},
|
||||
}
|
||||
networkingConfig := ce.ContainerNetworkSettings{}
|
||||
ID, err := cli.ContainerCreate(&containerConfig, &hostConfig, &networkingConfig, t.Name())
|
||||
networkingConfig := network.NetworkingConfig{}
|
||||
ctr, err := cli.ContainerCreate(context.Background(), &containerConfig, &hostConfig, &networkingConfig, t.Name())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer cleanContainer(t, cli, ID)
|
||||
startContainer(t, cli, ID)
|
||||
defer cleanContainer(t, cli, ctr.ID)
|
||||
startContainer(t, cli, ctr.ID)
|
||||
|
||||
rc := waitForContainer(t, cli, ID, 20*time.Second)
|
||||
rc := waitForContainer(t, cli, ctr.ID, 20*time.Second)
|
||||
// Expect return code 1 if container failed to create.
|
||||
if rc == 1 {
|
||||
// Get container logs and search for specific message.
|
||||
logs := inspectLogs(t, cli, ID)
|
||||
logs := inspectLogs(t, cli, ctr.ID)
|
||||
if strings.Contains(logs, "Failed to parse private key") {
|
||||
t.Logf("Container creating failed because of invalid certifates")
|
||||
}
|
||||
@@ -756,5 +780,5 @@ func TestSSLFIPSBadCerts(t *testing.T) {
|
||||
}
|
||||
|
||||
// Stop the container cleanly
|
||||
stopContainer(t, cli, ID)
|
||||
stopContainer(t, cli, ctr.ID)
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
// +build mqdev
|
||||
|
||||
/*
|
||||
© Copyright IBM Corporation 2018, 2023
|
||||
© Copyright IBM Corporation 2018, 2022
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -34,7 +34,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
ce "github.com/ibm-messaging/mq-container/test/container/containerengine"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
"github.com/docker/docker/client"
|
||||
)
|
||||
|
||||
const defaultAdminPassword string = "passw0rd"
|
||||
@@ -47,7 +49,7 @@ var insecureTLSConfig *tls.Config = &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
}
|
||||
|
||||
func waitForWebReady(t *testing.T, cli ce.ContainerInterface, ID string, tlsConfig *tls.Config) {
|
||||
func waitForWebReady(t *testing.T, cli *client.Client, ID string, tlsConfig *tls.Config) {
|
||||
t.Logf("%s Waiting for web server to be ready", time.Now().Format(time.RFC3339))
|
||||
httpClient := http.Client{
|
||||
Timeout: time.Duration(10 * time.Second),
|
||||
@@ -55,11 +57,7 @@ func waitForWebReady(t *testing.T, cli ce.ContainerInterface, ID string, tlsConf
|
||||
TLSClientConfig: tlsConfig,
|
||||
},
|
||||
}
|
||||
port, err := cli.GetContainerPort(ID, 9443)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
url := fmt.Sprintf("https://localhost:%s/ibmmq/rest/v1/admin/installation", port)
|
||||
url := fmt.Sprintf("https://localhost:%s/ibmmq/rest/v1/admin/installation", getPort(t, cli, ID, 9443))
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||
defer cancel()
|
||||
|
||||
@@ -93,16 +91,11 @@ func tlsDirInvalid(t *testing.T, unixPath bool) string {
|
||||
}
|
||||
|
||||
// runJMSTests runs a container with a JMS client, which connects to the queue manager container with the specified ID
|
||||
func runJMSTests(t *testing.T, cli ce.ContainerInterface, ID string, tls bool, user, password string, ibmjre string, cipherName string) {
|
||||
port, err := cli.GetContainerPort(ID, 1414)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
containerConfig := ce.ContainerConfig{
|
||||
func runJMSTests(t *testing.T, cli *client.Client, ID string, tls bool, user, password string, ibmjre string, cipherName string) {
|
||||
containerConfig := container.Config{
|
||||
// -e MQ_PORT_1414_TCP_ADDR=9.145.14.173 -e MQ_USERNAME=app -e MQ_PASSWORD=passw0rd -e MQ_CHANNEL=DEV.APP.SVRCONN -e MQ_TLS_TRUSTSTORE=/tls/test.p12 -e MQ_TLS_PASSPHRASE=passw0rd -v /Users/arthurbarr/go/src/github.com/ibm-messaging/mq-container/test/tls:/tls msgtest
|
||||
Env: []string{
|
||||
"MQ_PORT_1414_TCP_ADDR=127.0.0.1",
|
||||
"MQ_PORT_1414_OVERRIDE=" + port,
|
||||
"MQ_PORT_1414_TCP_ADDR=" + getIPAddress(t, cli, ID),
|
||||
"MQ_USERNAME=" + user,
|
||||
"MQ_CHANNEL=DEV.APP.SVRCONN",
|
||||
"IBMJRE=" + ibmjre,
|
||||
@@ -121,28 +114,26 @@ func runJMSTests(t *testing.T, cli ce.ContainerInterface, ID string, tls bool, u
|
||||
"MQ_TLS_CIPHER=" + cipherName,
|
||||
}...)
|
||||
}
|
||||
hostConfig := ce.ContainerHostConfig{
|
||||
hostConfig := container.HostConfig{
|
||||
Binds: []string{
|
||||
coverageBind(t),
|
||||
tlsDir(t, false) + ":/var/tls",
|
||||
},
|
||||
}
|
||||
networkingConfig := ce.ContainerNetworkSettings{
|
||||
Networks: []string{"host"},
|
||||
}
|
||||
jmsID, err := cli.ContainerCreate(&containerConfig, &hostConfig, &networkingConfig, strings.Replace(t.Name()+"JMS", "/", "", -1))
|
||||
networkingConfig := network.NetworkingConfig{}
|
||||
ctr, err := cli.ContainerCreate(context.Background(), &containerConfig, &hostConfig, &networkingConfig, strings.Replace(t.Name()+"JMS", "/", "", -1))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
startContainer(t, cli, jmsID)
|
||||
rc := waitForContainer(t, cli, jmsID, 2*time.Minute)
|
||||
startContainer(t, cli, ctr.ID)
|
||||
rc := waitForContainer(t, cli, ctr.ID, 2*time.Minute)
|
||||
if rc != 0 {
|
||||
t.Errorf("JUnit container failed with rc=%v", rc)
|
||||
}
|
||||
|
||||
// Get console output of the container and process the lines
|
||||
// to see if we have any failures
|
||||
scanner := bufio.NewScanner(strings.NewReader(inspectLogs(t, cli, jmsID)))
|
||||
scanner := bufio.NewScanner(strings.NewReader(inspectLogs(t, cli, ctr.ID)))
|
||||
for scanner.Scan() {
|
||||
s := scanner.Text()
|
||||
if processJunitLogLine(s) {
|
||||
@@ -150,7 +141,7 @@ func runJMSTests(t *testing.T, cli ce.ContainerInterface, ID string, tls bool, u
|
||||
}
|
||||
}
|
||||
|
||||
defer cleanContainer(t, cli, jmsID)
|
||||
defer cleanContainer(t, cli, ctr.ID)
|
||||
}
|
||||
|
||||
// Parse JUnit log line and return true if line contains failed or aborted tests
|
||||
@@ -214,18 +205,14 @@ func createTLSConfig(t *testing.T, certFile, password string) *tls.Config {
|
||||
}
|
||||
}
|
||||
|
||||
func testRESTAdmin(t *testing.T, cli ce.ContainerInterface, ID string, tlsConfig *tls.Config, errorExpected string) {
|
||||
func testRESTAdmin(t *testing.T, cli *client.Client, ID string, tlsConfig *tls.Config, errorExpected string) {
|
||||
httpClient := http.Client{
|
||||
Timeout: time.Duration(30 * time.Second),
|
||||
Transport: &http.Transport{
|
||||
TLSClientConfig: tlsConfig,
|
||||
},
|
||||
}
|
||||
port, err := cli.GetContainerPort(ID, 9443)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
url := fmt.Sprintf("https://localhost:%s/ibmmq/rest/v1/admin/installation", port)
|
||||
url := fmt.Sprintf("https://localhost:%s/ibmmq/rest/v1/admin/installation", getPort(t, cli, ID, 9443))
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
req.SetBasicAuth("admin", defaultAdminPassword)
|
||||
resp, err := httpClient.Do(req)
|
||||
@@ -261,7 +248,7 @@ func logHTTPResponse(t *testing.T, resp *http.Response) {
|
||||
t.Logf("HTTP response: %v", string(d))
|
||||
}
|
||||
|
||||
func testRESTMessaging(t *testing.T, cli ce.ContainerInterface, ID string, tlsConfig *tls.Config, qmName string, user string, password string, errorExpected string) {
|
||||
func testRESTMessaging(t *testing.T, cli *client.Client, ID string, tlsConfig *tls.Config, qmName string, user string, password string, errorExpected string) {
|
||||
httpClient := http.Client{
|
||||
Timeout: time.Duration(30 * time.Second),
|
||||
Transport: &http.Transport{
|
||||
@@ -269,11 +256,7 @@ func testRESTMessaging(t *testing.T, cli ce.ContainerInterface, ID string, tlsCo
|
||||
},
|
||||
}
|
||||
q := "DEV.QUEUE.1"
|
||||
port, err := cli.GetContainerPort(ID, 9443)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
url := fmt.Sprintf("https://localhost:%s/ibmmq/rest/v1/messaging/qmgr/%s/queue/%s/message", port, qmName, q)
|
||||
url := fmt.Sprintf("https://localhost:%s/ibmmq/rest/v1/messaging/qmgr/%s/queue/%s/message", getPort(t, cli, ID, 9443), qmName, q)
|
||||
putMessage := []byte("Hello")
|
||||
req, err := http.NewRequest("POST", url, bytes.NewBuffer(putMessage))
|
||||
req.SetBasicAuth(user, password)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -34,9 +34,28 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
ce "github.com/ibm-messaging/mq-container/test/container/containerengine"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
"github.com/docker/docker/api/types/volume"
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/docker/docker/pkg/jsonmessage"
|
||||
"github.com/docker/docker/pkg/stdcopy"
|
||||
"github.com/docker/go-connections/nat"
|
||||
)
|
||||
|
||||
type containerDetails struct {
|
||||
ID string
|
||||
Name string
|
||||
Image string
|
||||
Path string
|
||||
Args []string
|
||||
CapAdd []string
|
||||
CapDrop []string
|
||||
User string
|
||||
Env []string
|
||||
}
|
||||
|
||||
func imageName() string {
|
||||
image, ok := os.LookupEnv("TEST_IMAGE")
|
||||
if !ok {
|
||||
@@ -54,7 +73,7 @@ func imageNameDevJMS() string {
|
||||
}
|
||||
|
||||
// baseImage returns the ID of the underlying base image (e.g. "ubuntu" or "rhel")
|
||||
func baseImage(t *testing.T, cli ce.ContainerInterface) string {
|
||||
func baseImage(t *testing.T, cli *client.Client) string {
|
||||
rc, out := runContainerOneShot(t, cli, "grep", "^ID=", "/etc/os-release")
|
||||
if rc != 0 {
|
||||
t.Fatal("Couldn't determine base image")
|
||||
@@ -68,7 +87,7 @@ func baseImage(t *testing.T, cli ce.ContainerInterface) string {
|
||||
|
||||
// devImage returns true if the image under test is a developer image,
|
||||
// determined by use of the MQ_ADMIN_PASSWORD environment variable
|
||||
func devImage(t *testing.T, cli ce.ContainerInterface) bool {
|
||||
func devImage(t *testing.T, cli *client.Client) bool {
|
||||
rc, _ := runContainerOneShot(t, cli, "printenv", "MQ_ADMIN_PASSWORD")
|
||||
if rc == 0 {
|
||||
return true
|
||||
@@ -88,11 +107,6 @@ func isWSL(t *testing.T) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// isARM returns whether we are running an arm64 MacOS machine
|
||||
func isARM(t *testing.T) bool {
|
||||
return runtime.GOARCH == "arm64"
|
||||
}
|
||||
|
||||
// getCwd returns the working directory, in an os-specific or UNIX form
|
||||
func getCwd(t *testing.T, unixPath bool) string {
|
||||
dir, err := os.Getwd()
|
||||
@@ -147,17 +161,29 @@ func getTempDir(t *testing.T, unixStylePath bool) string {
|
||||
}
|
||||
|
||||
// terminationMessage return the termination message, or an empty string if not set
|
||||
func terminationMessage(t *testing.T, cli ce.ContainerInterface, ID string) string {
|
||||
r, err := cli.CopyFromContainer(ID, "/run/termination-log")
|
||||
func terminationMessage(t *testing.T, cli *client.Client, ID string) string {
|
||||
r, _, err := cli.CopyFromContainer(context.Background(), ID, "/run/termination-log")
|
||||
if err != nil {
|
||||
t.Log(err)
|
||||
t.Log(string(r))
|
||||
return ""
|
||||
}
|
||||
return string(r)
|
||||
b, err := ioutil.ReadAll(r)
|
||||
tr := tar.NewReader(bytes.NewReader(b))
|
||||
_, err = tr.Next()
|
||||
if err != nil {
|
||||
t.Log(err)
|
||||
return ""
|
||||
}
|
||||
// read the complete content of the file h.Name into the bs []byte
|
||||
content, err := ioutil.ReadAll(tr)
|
||||
if err != nil {
|
||||
t.Log(err)
|
||||
return ""
|
||||
}
|
||||
return string(content)
|
||||
}
|
||||
|
||||
func expectTerminationMessage(t *testing.T, cli ce.ContainerInterface, ID string) {
|
||||
func expectTerminationMessage(t *testing.T, cli *client.Client, ID string) {
|
||||
m := terminationMessage(t, cli, ID)
|
||||
if m == "" {
|
||||
t.Error("Expected termination message to be set")
|
||||
@@ -165,10 +191,10 @@ func expectTerminationMessage(t *testing.T, cli ce.ContainerInterface, ID string
|
||||
}
|
||||
|
||||
// logContainerDetails logs selected details about the container
|
||||
func logContainerDetails(t *testing.T, cli ce.ContainerInterface, ID string) {
|
||||
i, err := cli.ContainerInspect(ID)
|
||||
func logContainerDetails(t *testing.T, cli *client.Client, ID string) {
|
||||
i, err := cli.ContainerInspect(context.Background(), ID)
|
||||
if err == nil {
|
||||
d := ce.ContainerDetailsLogging{
|
||||
d := containerDetails{
|
||||
ID: ID,
|
||||
Name: i.Name,
|
||||
Image: i.Image,
|
||||
@@ -184,29 +210,29 @@ func logContainerDetails(t *testing.T, cli ce.ContainerInterface, ID string) {
|
||||
}
|
||||
}
|
||||
|
||||
func cleanContainerQuiet(t *testing.T, cli ce.ContainerInterface, ID string) {
|
||||
func cleanContainerQuiet(t *testing.T, cli *client.Client, ID string) {
|
||||
timeout := 10 * time.Second
|
||||
err := cli.ContainerStop(ID, &timeout)
|
||||
err := cli.ContainerStop(context.Background(), ID, &timeout)
|
||||
if err != nil {
|
||||
// Just log the error and continue
|
||||
t.Log(err)
|
||||
}
|
||||
opts := ce.ContainerRemoveOptions{
|
||||
opts := types.ContainerRemoveOptions{
|
||||
RemoveVolumes: true,
|
||||
Force: true,
|
||||
}
|
||||
err = cli.ContainerRemove(ID, opts)
|
||||
err = cli.ContainerRemove(context.Background(), ID, opts)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func cleanContainer(t *testing.T, cli ce.ContainerInterface, ID string) {
|
||||
func cleanContainer(t *testing.T, cli *client.Client, ID string) {
|
||||
logContainerDetails(t, cli, ID)
|
||||
t.Logf("Stopping container: %v", ID)
|
||||
timeout := 10 * time.Second
|
||||
// Stop the container. This allows the coverage output to be generated.
|
||||
err := cli.ContainerStop(ID, &timeout)
|
||||
err := cli.ContainerStop(context.Background(), ID, &timeout)
|
||||
if err != nil {
|
||||
// Just log the error and continue
|
||||
t.Log(err)
|
||||
@@ -224,11 +250,11 @@ func cleanContainer(t *testing.T, cli ce.ContainerInterface, ID string) {
|
||||
}
|
||||
|
||||
t.Logf("Removing container: %s", ID)
|
||||
opts := ce.ContainerRemoveOptions{
|
||||
opts := types.ContainerRemoveOptions{
|
||||
RemoveVolumes: true,
|
||||
Force: true,
|
||||
}
|
||||
err = cli.ContainerRemove(ID, opts)
|
||||
err = cli.ContainerRemove(context.Background(), ID, opts)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -242,17 +268,17 @@ func generateRandomUID() string {
|
||||
}
|
||||
|
||||
// getDefaultHostConfig creates a HostConfig and populates it with the defaults used in testing
|
||||
func getDefaultHostConfig(t *testing.T, cli ce.ContainerInterface) *ce.ContainerHostConfig {
|
||||
hostConfig := ce.ContainerHostConfig{
|
||||
PortBindings: []ce.PortBinding{},
|
||||
func getDefaultHostConfig(t *testing.T, cli *client.Client) *container.HostConfig {
|
||||
hostConfig := container.HostConfig{
|
||||
Binds: []string{
|
||||
coverageBind(t),
|
||||
},
|
||||
PortBindings: nat.PortMap{},
|
||||
CapDrop: []string{
|
||||
"ALL",
|
||||
},
|
||||
Privileged: false,
|
||||
}
|
||||
if coverage() {
|
||||
hostConfig.Binds = append(hostConfig.Binds, coverageBind(t))
|
||||
}
|
||||
if devImage(t, cli) {
|
||||
// Only needed for a RHEL-based image
|
||||
if baseImage(t, cli) != "ubuntu" {
|
||||
@@ -266,7 +292,7 @@ func getDefaultHostConfig(t *testing.T, cli ce.ContainerInterface) *ce.Container
|
||||
|
||||
// runContainerWithHostConfig creates and starts a container, using the supplied HostConfig.
|
||||
// Note that a default HostConfig can be created using getDefaultHostConfig.
|
||||
func runContainerWithHostConfig(t *testing.T, cli ce.ContainerInterface, containerConfig *ce.ContainerConfig, hostConfig *ce.ContainerHostConfig) string {
|
||||
func runContainerWithHostConfig(t *testing.T, cli *client.Client, containerConfig *container.Config, hostConfig *container.HostConfig) string {
|
||||
if containerConfig.Image == "" {
|
||||
containerConfig.Image = imageName()
|
||||
}
|
||||
@@ -274,23 +300,22 @@ func runContainerWithHostConfig(t *testing.T, cli ce.ContainerInterface, contain
|
||||
if containerConfig.User == "" {
|
||||
containerConfig.User = generateRandomUID()
|
||||
}
|
||||
if coverage() {
|
||||
containerConfig.Env = append(containerConfig.Env, "COVERAGE_FILE="+t.Name()+".cov")
|
||||
containerConfig.Env = append(containerConfig.Env, "EXIT_CODE_FILE="+getExitCodeFilename(t))
|
||||
}
|
||||
networkingConfig := ce.ContainerNetworkSettings{}
|
||||
// if coverage
|
||||
containerConfig.Env = append(containerConfig.Env, "COVERAGE_FILE="+t.Name()+".cov")
|
||||
containerConfig.Env = append(containerConfig.Env, "EXIT_CODE_FILE="+getExitCodeFilename(t))
|
||||
networkingConfig := network.NetworkingConfig{}
|
||||
t.Logf("Running container (%s)", containerConfig.Image)
|
||||
ID, err := cli.ContainerCreate(containerConfig, hostConfig, &networkingConfig, t.Name())
|
||||
ctr, err := cli.ContainerCreate(context.Background(), containerConfig, hostConfig, &networkingConfig, t.Name())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
startContainer(t, cli, ID)
|
||||
return ID
|
||||
startContainer(t, cli, ctr.ID)
|
||||
return ctr.ID
|
||||
}
|
||||
|
||||
// runContainerWithAllConfig creates and starts a container, using the supplied ContainerConfig, HostConfig,
|
||||
// NetworkingConfig, and container name (or the value of t.Name if containerName="").
|
||||
func runContainerWithAllConfig(t *testing.T, cli ce.ContainerInterface, containerConfig *ce.ContainerConfig, hostConfig *ce.ContainerHostConfig, networkingConfig *ce.ContainerNetworkSettings, containerName string) string {
|
||||
func runContainerWithAllConfig(t *testing.T, cli *client.Client, containerConfig *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) string {
|
||||
if containerName == "" {
|
||||
containerName = t.Name()
|
||||
}
|
||||
@@ -301,32 +326,30 @@ func runContainerWithAllConfig(t *testing.T, cli ce.ContainerInterface, containe
|
||||
if containerConfig.User == "" {
|
||||
containerConfig.User = generateRandomUID()
|
||||
}
|
||||
if coverage() {
|
||||
containerConfig.Env = append(containerConfig.Env, "COVERAGE_FILE="+t.Name()+".cov")
|
||||
containerConfig.Env = append(containerConfig.Env, "EXIT_CODE_FILE="+getExitCodeFilename(t))
|
||||
}
|
||||
// if coverage
|
||||
containerConfig.Env = append(containerConfig.Env, "COVERAGE_FILE="+t.Name()+".cov")
|
||||
containerConfig.Env = append(containerConfig.Env, "EXIT_CODE_FILE="+getExitCodeFilename(t))
|
||||
t.Logf("Running container (%s)", containerConfig.Image)
|
||||
ID, err := cli.ContainerCreate(containerConfig, hostConfig, networkingConfig, containerName)
|
||||
ctr, err := cli.ContainerCreate(context.Background(), containerConfig, hostConfig, networkingConfig, containerName)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
startContainer(t, cli, ID)
|
||||
return ID
|
||||
startContainer(t, cli, ctr.ID)
|
||||
return ctr.ID
|
||||
}
|
||||
|
||||
// runContainerWithPorts creates and starts a container, exposing the specified ports on the host.
|
||||
// If no image is specified in the container config, then the image name is retrieved from the TEST_IMAGE
|
||||
// environment variable.
|
||||
func runContainerWithPorts(t *testing.T, cli ce.ContainerInterface, containerConfig *ce.ContainerConfig, ports []int) string {
|
||||
func runContainerWithPorts(t *testing.T, cli *client.Client, containerConfig *container.Config, ports []int) string {
|
||||
hostConfig := getDefaultHostConfig(t, cli)
|
||||
var binding ce.PortBinding
|
||||
for _, p := range ports {
|
||||
port := fmt.Sprintf("%v/tcp", p)
|
||||
binding = ce.PortBinding{
|
||||
ContainerPort: port,
|
||||
HostIP: "0.0.0.0",
|
||||
port := nat.Port(fmt.Sprintf("%v/tcp", p))
|
||||
hostConfig.PortBindings[port] = []nat.PortBinding{
|
||||
{
|
||||
HostIP: "0.0.0.0",
|
||||
},
|
||||
}
|
||||
hostConfig.PortBindings = append(hostConfig.PortBindings, binding)
|
||||
}
|
||||
return runContainerWithHostConfig(t, cli, containerConfig, hostConfig)
|
||||
}
|
||||
@@ -334,160 +357,161 @@ func runContainerWithPorts(t *testing.T, cli ce.ContainerInterface, containerCon
|
||||
// runContainer creates and starts a container. If no image is specified in
|
||||
// the container config, then the image name is retrieved from the TEST_IMAGE
|
||||
// environment variable.
|
||||
func runContainer(t *testing.T, cli ce.ContainerInterface, containerConfig *ce.ContainerConfig) string {
|
||||
func runContainer(t *testing.T, cli *client.Client, containerConfig *container.Config) string {
|
||||
return runContainerWithPorts(t, cli, containerConfig, nil)
|
||||
}
|
||||
|
||||
// runContainerOneShot runs a container with a custom entrypoint, as the root
|
||||
// user and with default capabilities
|
||||
func runContainerOneShot(t *testing.T, cli ce.ContainerInterface, command ...string) (int64, string) {
|
||||
containerConfig := ce.ContainerConfig{
|
||||
func runContainerOneShot(t *testing.T, cli *client.Client, command ...string) (int64, string) {
|
||||
containerConfig := container.Config{
|
||||
Entrypoint: command,
|
||||
User: "root",
|
||||
Image: imageName(),
|
||||
}
|
||||
hostConfig := ce.ContainerHostConfig{}
|
||||
networkingConfig := ce.ContainerNetworkSettings{}
|
||||
hostConfig := container.HostConfig{}
|
||||
networkingConfig := network.NetworkingConfig{}
|
||||
t.Logf("Running one shot container (%s): %v", containerConfig.Image, command)
|
||||
ID, err := cli.ContainerCreate(&containerConfig, &hostConfig, &networkingConfig, t.Name()+"OneShot")
|
||||
ctr, err := cli.ContainerCreate(context.Background(), &containerConfig, &hostConfig, &networkingConfig, t.Name()+"OneShot")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
startOptions := ce.ContainerStartOptions{}
|
||||
err = cli.ContainerStart(ID, startOptions)
|
||||
startOptions := types.ContainerStartOptions{}
|
||||
err = cli.ContainerStart(context.Background(), ctr.ID, startOptions)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer cleanContainerQuiet(t, cli, ID)
|
||||
rc := waitForContainer(t, cli, ID, 20*time.Second)
|
||||
out := inspectLogs(t, cli, ID)
|
||||
defer cleanContainerQuiet(t, cli, ctr.ID)
|
||||
rc := waitForContainer(t, cli, ctr.ID, 20*time.Second)
|
||||
out := inspectLogs(t, cli, ctr.ID)
|
||||
t.Logf("One shot container finished with rc=%v, output=%v", rc, out)
|
||||
return rc, out
|
||||
}
|
||||
|
||||
// runContainerOneShot runs a container with a custom entrypoint, as the root
|
||||
// user, with default capabilities, and a volume mounted
|
||||
func runContainerOneShotWithVolume(t *testing.T, cli ce.ContainerInterface, bind string, command ...string) (int64, string) {
|
||||
containerConfig := ce.ContainerConfig{
|
||||
func runContainerOneShotWithVolume(t *testing.T, cli *client.Client, bind string, command ...string) (int64, string) {
|
||||
containerConfig := container.Config{
|
||||
Entrypoint: command,
|
||||
User: "root",
|
||||
Image: imageName(),
|
||||
}
|
||||
hostConfig := ce.ContainerHostConfig{
|
||||
hostConfig := container.HostConfig{
|
||||
Binds: []string{
|
||||
bind,
|
||||
},
|
||||
}
|
||||
networkingConfig := ce.ContainerNetworkSettings{}
|
||||
networkingConfig := network.NetworkingConfig{}
|
||||
t.Logf("Running one shot container with volume (%s): %v", containerConfig.Image, command)
|
||||
ID, err := cli.ContainerCreate(&containerConfig, &hostConfig, &networkingConfig, t.Name()+"OneShotVolume")
|
||||
ctr, err := cli.ContainerCreate(context.Background(), &containerConfig, &hostConfig, &networkingConfig, t.Name()+"OneShotVolume")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
startOptions := ce.ContainerStartOptions{}
|
||||
err = cli.ContainerStart(ID, startOptions)
|
||||
startOptions := types.ContainerStartOptions{}
|
||||
err = cli.ContainerStart(context.Background(), ctr.ID, startOptions)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer cleanContainerQuiet(t, cli, ID)
|
||||
rc := waitForContainer(t, cli, ID, 20*time.Second)
|
||||
out := inspectLogs(t, cli, ID)
|
||||
defer cleanContainerQuiet(t, cli, ctr.ID)
|
||||
rc := waitForContainer(t, cli, ctr.ID, 20*time.Second)
|
||||
out := inspectLogs(t, cli, ctr.ID)
|
||||
t.Logf("One shot container finished with rc=%v, output=%v", rc, out)
|
||||
return rc, out
|
||||
}
|
||||
|
||||
func startMultiVolumeQueueManager(t *testing.T, cli ce.ContainerInterface, dataVol bool, qmsharedlogs string, qmshareddata string, env []string) (error, string, string) {
|
||||
func startMultiVolumeQueueManager(t *testing.T, cli *client.Client, dataVol bool, qmsharedlogs string, qmshareddata string, env []string) (error, string, string) {
|
||||
id := strconv.FormatInt(time.Now().UnixNano(), 10)
|
||||
volume := createVolume(t, cli, id)
|
||||
containerConfig := ce.ContainerConfig{
|
||||
qmdata := createVolume(t, cli, id)
|
||||
containerConfig := container.Config{
|
||||
Image: imageName(),
|
||||
Env: env,
|
||||
}
|
||||
var hostConfig ce.ContainerHostConfig
|
||||
var hostConfig container.HostConfig
|
||||
|
||||
if !dataVol {
|
||||
hostConfig = ce.ContainerHostConfig{}
|
||||
hostConfig = container.HostConfig{}
|
||||
} else if qmsharedlogs == "" && qmshareddata == "" {
|
||||
hostConfig = getHostConfig(t, 1, "", "", volume)
|
||||
hostConfig = getHostConfig(t, 1, "", "", qmdata.Name)
|
||||
} else if qmsharedlogs == "" {
|
||||
hostConfig = getHostConfig(t, 2, "", qmshareddata, volume)
|
||||
hostConfig = getHostConfig(t, 2, "", qmshareddata, qmdata.Name)
|
||||
} else if qmshareddata == "" {
|
||||
hostConfig = getHostConfig(t, 3, qmsharedlogs, "", volume)
|
||||
hostConfig = getHostConfig(t, 3, qmsharedlogs, "", qmdata.Name)
|
||||
} else {
|
||||
hostConfig = getHostConfig(t, 4, qmsharedlogs, qmshareddata, volume)
|
||||
hostConfig = getHostConfig(t, 4, qmsharedlogs, qmshareddata, qmdata.Name)
|
||||
}
|
||||
networkingConfig := ce.ContainerNetworkSettings{}
|
||||
qmID, err := cli.ContainerCreate(&containerConfig, &hostConfig, &networkingConfig, t.Name()+id)
|
||||
networkingConfig := network.NetworkingConfig{}
|
||||
qm, err := cli.ContainerCreate(context.Background(), &containerConfig, &hostConfig, &networkingConfig, t.Name()+id)
|
||||
if err != nil {
|
||||
return err, "", ""
|
||||
}
|
||||
startContainer(t, cli, qmID)
|
||||
startContainer(t, cli, qm.ID)
|
||||
|
||||
return nil, qmID, volume
|
||||
return nil, qm.ID, qmdata.Name
|
||||
}
|
||||
|
||||
func getHostConfig(t *testing.T, mounts int, qmsharedlogs string, qmshareddata string, qmdata string) ce.ContainerHostConfig {
|
||||
func getHostConfig(t *testing.T, mounts int, qmsharedlogs string, qmshareddata string, qmdata string) container.HostConfig {
|
||||
|
||||
var hostConfig ce.ContainerHostConfig
|
||||
var hostConfig container.HostConfig
|
||||
|
||||
switch mounts {
|
||||
case 1:
|
||||
hostConfig = ce.ContainerHostConfig{
|
||||
hostConfig = container.HostConfig{
|
||||
Binds: []string{
|
||||
coverageBind(t),
|
||||
qmdata + ":/mnt/mqm",
|
||||
},
|
||||
}
|
||||
case 2:
|
||||
hostConfig = ce.ContainerHostConfig{
|
||||
hostConfig = container.HostConfig{
|
||||
Binds: []string{
|
||||
coverageBind(t),
|
||||
qmdata + ":/mnt/mqm",
|
||||
qmshareddata + ":/mnt/mqm-data",
|
||||
},
|
||||
}
|
||||
case 3:
|
||||
hostConfig = ce.ContainerHostConfig{
|
||||
hostConfig = container.HostConfig{
|
||||
Binds: []string{
|
||||
coverageBind(t),
|
||||
qmdata + ":/mnt/mqm",
|
||||
qmsharedlogs + ":/mnt/mqm-log",
|
||||
},
|
||||
}
|
||||
case 4:
|
||||
hostConfig = ce.ContainerHostConfig{
|
||||
hostConfig = container.HostConfig{
|
||||
Binds: []string{
|
||||
coverageBind(t),
|
||||
qmdata + ":/mnt/mqm",
|
||||
qmsharedlogs + ":/mnt/mqm-log",
|
||||
qmshareddata + ":/mnt/mqm-data",
|
||||
},
|
||||
}
|
||||
}
|
||||
if coverage() {
|
||||
hostConfig.Binds = append(hostConfig.Binds, coverageBind(t))
|
||||
}
|
||||
|
||||
return hostConfig
|
||||
}
|
||||
|
||||
func startContainer(t *testing.T, cli ce.ContainerInterface, ID string) {
|
||||
func startContainer(t *testing.T, cli *client.Client, ID string) {
|
||||
t.Logf("Starting container: %v", ID)
|
||||
startOptions := ce.ContainerStartOptions{}
|
||||
err := cli.ContainerStart(ID, startOptions)
|
||||
startOptions := types.ContainerStartOptions{}
|
||||
err := cli.ContainerStart(context.Background(), ID, startOptions)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func stopContainer(t *testing.T, cli ce.ContainerInterface, ID string) {
|
||||
func stopContainer(t *testing.T, cli *client.Client, ID string) {
|
||||
t.Logf("Stopping container: %v", ID)
|
||||
timeout := 10 * time.Second
|
||||
err := cli.ContainerStop(ID, &timeout) //Duration(20)*time.Second)
|
||||
err := cli.ContainerStop(context.Background(), ID, &timeout) //Duration(20)*time.Second)
|
||||
if err != nil {
|
||||
// Just log the error and continue
|
||||
t.Log(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func killContainer(t *testing.T, cli ce.ContainerInterface, ID string, signal string) {
|
||||
func killContainer(t *testing.T, cli *client.Client, ID string, signal string) {
|
||||
t.Logf("Killing container: %v", ID)
|
||||
err := cli.ContainerKill(ID, signal)
|
||||
err := cli.ContainerKill(context.Background(), ID, signal)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -521,17 +545,17 @@ func getCoverageExitCode(t *testing.T, orig int64) int64 {
|
||||
}
|
||||
|
||||
// waitForContainer waits until a container has exited
|
||||
func waitForContainer(t *testing.T, cli ce.ContainerInterface, ID string, timeout time.Duration) int64 {
|
||||
func waitForContainer(t *testing.T, cli *client.Client, ID string, timeout time.Duration) int64 {
|
||||
c, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
t.Logf("Waiting for container for %s", timeout)
|
||||
okC, errC := cli.ContainerWait(c, ID, ce.ContainerStateNotRunning)
|
||||
okC, errC := cli.ContainerWait(c, ID, container.WaitConditionNotRunning)
|
||||
var rc int64
|
||||
select {
|
||||
case err := <-errC:
|
||||
t.Fatal(err)
|
||||
case ok := <-okC:
|
||||
rc = ok
|
||||
rc = ok.StatusCode
|
||||
}
|
||||
if coverage() {
|
||||
// COVERAGE: When running coverage, the exit code is written to a file,
|
||||
@@ -543,15 +567,78 @@ func waitForContainer(t *testing.T, cli ce.ContainerInterface, ID string, timeou
|
||||
}
|
||||
|
||||
// execContainer runs a command in a running container, and returns the exit code and output
|
||||
func execContainer(t *testing.T, cli ce.ContainerInterface, ID string, user string, cmd []string) (int, string) {
|
||||
func execContainer(t *testing.T, cli *client.Client, ID string, user string, cmd []string) (int, string) {
|
||||
t.Logf("Running command: %v", cmd)
|
||||
exitcode, outputStr := cli.ExecContainer(ID, user, cmd)
|
||||
config := types.ExecConfig{
|
||||
User: user,
|
||||
Privileged: false,
|
||||
Tty: false,
|
||||
AttachStdin: false,
|
||||
// Note that you still need to attach stdout/stderr, even though they're not wanted
|
||||
AttachStdout: true,
|
||||
AttachStderr: true,
|
||||
Detach: false,
|
||||
Cmd: cmd,
|
||||
}
|
||||
resp, err := cli.ContainerExecCreate(context.Background(), ID, config)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
hijack, err := cli.ContainerExecAttach(context.Background(), resp.ID, types.ExecStartCheck{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer hijack.Close()
|
||||
time.Sleep(time.Millisecond * 10)
|
||||
err = cli.ContainerExecStart(context.Background(), resp.ID, types.ExecStartCheck{
|
||||
Detach: false,
|
||||
Tty: false,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Wait for the command to finish
|
||||
var exitcode int
|
||||
var outputStr string
|
||||
for {
|
||||
inspect, err := cli.ContainerExecInspect(context.Background(), resp.ID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if inspect.Running {
|
||||
continue
|
||||
}
|
||||
|
||||
exitcode = inspect.ExitCode
|
||||
buf := new(bytes.Buffer)
|
||||
// Each output line has a header, which needs to be removed
|
||||
_, err = stdcopy.StdCopy(buf, buf, hijack.Reader)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
outputStr = strings.TrimSpace(buf.String())
|
||||
|
||||
/* Commented out on 14/06/2018 as it might not be needed after adding
|
||||
* pause between ContainerExecAttach and ContainerExecStart.
|
||||
* TODO If intermittent failures do not occur, remove and refactor.
|
||||
*
|
||||
* // Before we go let's just double check it did actually finish running
|
||||
* // because sometimes we get a "Exec command already running error"
|
||||
* alreadyRunningErr := regexp.MustCompile("Error: Exec command .* is already running")
|
||||
* if alreadyRunningErr.MatchString(outputStr) {
|
||||
* continue
|
||||
* }
|
||||
*/
|
||||
break
|
||||
}
|
||||
|
||||
return exitcode, outputStr
|
||||
}
|
||||
|
||||
func waitForReady(t *testing.T, cli ce.ContainerInterface, ID string) {
|
||||
func waitForReady(t *testing.T, cli *client.Client, ID string) {
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 4*time.Minute)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||
defer cancel()
|
||||
|
||||
for {
|
||||
@@ -575,47 +662,57 @@ func waitForReady(t *testing.T, cli ce.ContainerInterface, ID string) {
|
||||
}
|
||||
}
|
||||
|
||||
func createNetwork(t *testing.T, cli ce.ContainerInterface) string {
|
||||
func getIPAddress(t *testing.T, cli *client.Client, ID string) string {
|
||||
ctr, err := cli.ContainerInspect(context.Background(), ID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return ctr.NetworkSettings.IPAddress
|
||||
}
|
||||
|
||||
func createNetwork(t *testing.T, cli *client.Client) string {
|
||||
name := "test"
|
||||
t.Logf("Creating network: %v", name)
|
||||
opts := ce.NetworkCreateOptions{}
|
||||
netID, err := cli.NetworkCreate(name, opts)
|
||||
opts := types.NetworkCreate{}
|
||||
net, err := cli.NetworkCreate(context.Background(), name, opts)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Logf("Created network %v with ID %v", name, netID)
|
||||
return netID
|
||||
t.Logf("Created network %v with ID %v", name, net.ID)
|
||||
return net.ID
|
||||
}
|
||||
|
||||
func removeNetwork(t *testing.T, cli ce.ContainerInterface, ID string) {
|
||||
func removeNetwork(t *testing.T, cli *client.Client, ID string) {
|
||||
t.Logf("Removing network ID: %v", ID)
|
||||
err := cli.NetworkRemove(ID)
|
||||
err := cli.NetworkRemove(context.Background(), ID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func createVolume(t *testing.T, cli ce.ContainerInterface, name string) string {
|
||||
v, err := cli.VolumeCreate(ce.VolumeCreateOptions{
|
||||
Driver: "local",
|
||||
Name: name,
|
||||
func createVolume(t *testing.T, cli *client.Client, name string) types.Volume {
|
||||
v, err := cli.VolumeCreate(context.Background(), volume.VolumeCreateBody{
|
||||
Driver: "local",
|
||||
DriverOpts: map[string]string{},
|
||||
Labels: map[string]string{},
|
||||
Name: name,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Logf("Created volume %v", v)
|
||||
t.Logf("Created volume %v", v.Name)
|
||||
return v
|
||||
}
|
||||
|
||||
func removeVolume(t *testing.T, cli ce.ContainerInterface, name string) {
|
||||
func removeVolume(t *testing.T, cli *client.Client, name string) {
|
||||
t.Logf("Removing volume %v", name)
|
||||
err := cli.VolumeRemove(name, true)
|
||||
err := cli.VolumeRemove(context.Background(), name, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func inspectTextLogs(t *testing.T, cli ce.ContainerInterface, ID string) string {
|
||||
func inspectTextLogs(t *testing.T, cli *client.Client, ID string) string {
|
||||
jsonLogs := inspectLogs(t, cli, ID)
|
||||
scanner := bufio.NewScanner(strings.NewReader(jsonLogs))
|
||||
b := make([]byte, 64*1024)
|
||||
@@ -623,11 +720,9 @@ func inspectTextLogs(t *testing.T, cli ce.ContainerInterface, ID string) string
|
||||
for scanner.Scan() {
|
||||
text := scanner.Text()
|
||||
if strings.HasPrefix(text, "{") {
|
||||
// If it's a JSON log message, it makes it hard to debug the test, as the JSON
|
||||
// is embedded in the long test output. So just summarize the JSON instead.
|
||||
var e map[string]interface{}
|
||||
json.Unmarshal([]byte(text), &e)
|
||||
fmt.Fprintf(buf, "{\"ibm_datetime\": \"%v\", \"message\": \"%v\", ...}\n", e["ibm_datetime"], e["message"])
|
||||
fmt.Fprintf(buf, "{\"message\": \"%v\"}\n", e["message"])
|
||||
} else {
|
||||
fmt.Fprintln(buf, text)
|
||||
}
|
||||
@@ -639,14 +734,24 @@ func inspectTextLogs(t *testing.T, cli ce.ContainerInterface, ID string) string
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func inspectLogs(t *testing.T, cli ce.ContainerInterface, ID string) string {
|
||||
func inspectLogs(t *testing.T, cli *client.Client, ID string) string {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
logs, err := cli.GetContainerLogs(ctx, ID, ce.ContainerLogsOptions{})
|
||||
reader, err := cli.ContainerLogs(ctx, ID, types.ContainerLogsOptions{
|
||||
ShowStdout: true,
|
||||
ShowStderr: true,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return logs
|
||||
buf := new(bytes.Buffer)
|
||||
|
||||
// Each output line has a header, which needs to be removed
|
||||
_, err = stdcopy.StdCopy(buf, buf, reader)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
// generateTAR creates a TAR-formatted []byte, with the specified files included.
|
||||
@@ -676,54 +781,76 @@ func generateTAR(t *testing.T, files []struct{ Name, Body string }) []byte {
|
||||
}
|
||||
|
||||
// createImage creates a new Docker image with the specified files included.
|
||||
func createImage(t *testing.T, cli ce.ContainerInterface, files []struct{ Name, Body string }) string {
|
||||
func createImage(t *testing.T, cli *client.Client, files []struct{ Name, Body string }) string {
|
||||
r := bytes.NewReader(generateTAR(t, files))
|
||||
tag := strings.ToLower(t.Name())
|
||||
|
||||
tmpDir, err := os.MkdirTemp("", "tmp")
|
||||
buildOptions := types.ImageBuildOptions{
|
||||
Context: r,
|
||||
Tags: []string{tag},
|
||||
}
|
||||
resp, err := cli.ImageBuild(context.Background(), r, buildOptions)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
//Write files to temp directory
|
||||
for _, file := range files {
|
||||
//Add tag to file name to allow parallel testing
|
||||
f, err := os.Create(filepath.Join(tmpDir, file.Name))
|
||||
// resp (ImageBuildResponse) contains a series of JSON messages
|
||||
dec := json.NewDecoder(resp.Body)
|
||||
for {
|
||||
m := jsonmessage.JSONMessage{}
|
||||
err := dec.Decode(&m)
|
||||
if m.Error != nil {
|
||||
t.Fatal(m.ErrorMessage)
|
||||
}
|
||||
t.Log(strings.TrimSpace(m.Stream))
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
body := []byte(file.Body)
|
||||
_, err = f.Write(body)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
_, err = cli.ImageBuild(r, tag, filepath.Join(tmpDir, files[0].Name))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return tag
|
||||
}
|
||||
|
||||
// deleteImage deletes a Docker image
|
||||
func deleteImage(t *testing.T, cli ce.ContainerInterface, id string) {
|
||||
cli.ImageRemove(id, ce.ImageRemoveOptions{
|
||||
func deleteImage(t *testing.T, cli *client.Client, id string) {
|
||||
cli.ImageRemove(context.Background(), id, types.ImageRemoveOptions{
|
||||
Force: true,
|
||||
})
|
||||
}
|
||||
|
||||
func copyFromContainer(t *testing.T, cli ce.ContainerInterface, id string, file string) []byte {
|
||||
b, err := cli.CopyFromContainer(id, file)
|
||||
func copyFromContainer(t *testing.T, cli *client.Client, id string, file string) []byte {
|
||||
reader, _, err := cli.CopyFromContainer(context.Background(), id, file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer reader.Close()
|
||||
b, err := ioutil.ReadAll(reader)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func getPort(t *testing.T, cli *client.Client, ID string, port int) string {
|
||||
var inspectInfo types.ContainerJSON
|
||||
var err error
|
||||
for attemptsRemaining := 3; attemptsRemaining > 0; attemptsRemaining-- {
|
||||
inspectInfo, err = cli.ContainerInspect(context.Background(), ID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
portNat := nat.Port(fmt.Sprintf("%d/tcp", port))
|
||||
if inspectInfo.NetworkSettings.Ports[portNat] == nil || len(inspectInfo.NetworkSettings.Ports[portNat]) == 0 {
|
||||
t.Log("Container port not yet bound")
|
||||
time.Sleep(1 * time.Second)
|
||||
continue
|
||||
}
|
||||
return inspectInfo.NetworkSettings.Ports[portNat][0].HostPort
|
||||
}
|
||||
t.Fatal("Failed to get port")
|
||||
return ""
|
||||
}
|
||||
|
||||
func countLines(t *testing.T, r io.Reader) int {
|
||||
scanner := bufio.NewScanner(r)
|
||||
count := 0
|
||||
@@ -755,6 +882,15 @@ func countTarLines(t *testing.T, b []byte) int {
|
||||
return total
|
||||
}
|
||||
|
||||
func getMQVersion(t *testing.T, cli *client.Client) (string, error) {
|
||||
inspect, _, err := cli.ImageInspectWithRaw(context.Background(), imageName())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
version := inspect.ContainerConfig.Labels["version"]
|
||||
return version, nil
|
||||
}
|
||||
|
||||
// scanForExcludedEntries scans for default excluded messages
|
||||
func scanForExcludedEntries(msg string) bool {
|
||||
if strings.Contains(msg, "AMQ5041I") || strings.Contains(msg, "AMQ5052I") ||
|
||||
@@ -781,7 +917,7 @@ func checkLogForValidJSON(jsonLogs string) bool {
|
||||
|
||||
// runContainerWithAllConfig creates and starts a container, using the supplied ContainerConfig, HostConfig,
|
||||
// NetworkingConfig, and container name (or the value of t.Name if containerName="").
|
||||
func runContainerWithAllConfigError(t *testing.T, cli ce.ContainerInterface, containerConfig *ce.ContainerConfig, hostConfig *ce.ContainerHostConfig, networkingConfig *ce.ContainerNetworkSettings, containerName string) (string, error) {
|
||||
func runContainerWithAllConfigError(t *testing.T, cli *client.Client, containerConfig *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (string, error) {
|
||||
if containerName == "" {
|
||||
containerName = t.Name()
|
||||
}
|
||||
@@ -792,26 +928,25 @@ func runContainerWithAllConfigError(t *testing.T, cli ce.ContainerInterface, con
|
||||
if containerConfig.User == "" {
|
||||
containerConfig.User = generateRandomUID()
|
||||
}
|
||||
if coverage() {
|
||||
containerConfig.Env = append(containerConfig.Env, "COVERAGE_FILE="+t.Name()+".cov")
|
||||
containerConfig.Env = append(containerConfig.Env, "EXIT_CODE_FILE="+getExitCodeFilename(t))
|
||||
}
|
||||
// if coverage
|
||||
containerConfig.Env = append(containerConfig.Env, "COVERAGE_FILE="+t.Name()+".cov")
|
||||
containerConfig.Env = append(containerConfig.Env, "EXIT_CODE_FILE="+getExitCodeFilename(t))
|
||||
t.Logf("Running container (%s)", containerConfig.Image)
|
||||
ID, err := cli.ContainerCreate(containerConfig, hostConfig, networkingConfig, containerName)
|
||||
ctr, err := cli.ContainerCreate(context.Background(), containerConfig, hostConfig, networkingConfig, containerName)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
err = startContainerError(t, cli, ID)
|
||||
err = startContainerError(t, cli, ctr.ID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return ID, nil
|
||||
return ctr.ID, nil
|
||||
}
|
||||
|
||||
func startContainerError(t *testing.T, cli ce.ContainerInterface, ID string) error {
|
||||
func startContainerError(t *testing.T, cli *client.Client, ID string) error {
|
||||
t.Logf("Starting container: %v", ID)
|
||||
startOptions := ce.ContainerStartOptions{}
|
||||
err := cli.ContainerStart(ID, startOptions)
|
||||
startOptions := types.ContainerStartOptions{}
|
||||
err := cli.ContainerStart(context.Background(), ID, startOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -820,7 +955,7 @@ func startContainerError(t *testing.T, cli ce.ContainerInterface, ID string) err
|
||||
}
|
||||
|
||||
// testLogFilePages validates that the specified number of logFilePages is present in the qm.ini file.
|
||||
func testLogFilePages(t *testing.T, cli ce.ContainerInterface, id string, qmName string, expectedLogFilePages string) {
|
||||
func testLogFilePages(t *testing.T, cli *client.Client, id string, qmName string, expectedLogFilePages string) {
|
||||
catIniFileCommand := fmt.Sprintf("cat /var/mqm/qmgrs/" + qmName + "/qm.ini")
|
||||
_, iniContent := execContainer(t, cli, id, "", []string{"bash", "-c", catIniFileCommand})
|
||||
|
||||
@@ -829,8 +964,8 @@ func testLogFilePages(t *testing.T, cli ce.ContainerInterface, id string, qmName
|
||||
}
|
||||
}
|
||||
|
||||
// waitForMessageInLog will check for a particular message with wait
|
||||
func waitForMessageInLog(t *testing.T, cli ce.ContainerInterface, id string, expectedMessageId string) (string, error) {
|
||||
//waitForMessageInLog will check for a particular message with wait
|
||||
func waitForMessageInLog(t *testing.T, cli *client.Client, id string, expecteMessageId string) (string, error) {
|
||||
var jsonLogs string
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||
defer cancel()
|
||||
@@ -838,29 +973,11 @@ func waitForMessageInLog(t *testing.T, cli ce.ContainerInterface, id string, exp
|
||||
select {
|
||||
case <-time.After(1 * time.Second):
|
||||
jsonLogs = inspectLogs(t, cli, id)
|
||||
if strings.Contains(jsonLogs, expectedMessageId) {
|
||||
if strings.Contains(jsonLogs, expecteMessageId) {
|
||||
return jsonLogs, nil
|
||||
}
|
||||
case <-ctx.Done():
|
||||
return "", fmt.Errorf("expected message Id %s was not logged", expectedMessageId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// waitForMessageCountInLog will check for a particular message with wait and must occur exact number of times in log as specified by count
|
||||
func waitForMessageCountInLog(t *testing.T, cli ce.ContainerInterface, id string, expectedMessageId string, count int) (string, error) {
|
||||
var jsonLogs string
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||
defer cancel()
|
||||
for {
|
||||
select {
|
||||
case <-time.After(1 * time.Second):
|
||||
jsonLogs = inspectLogs(t, cli, id)
|
||||
if strings.Contains(jsonLogs, expectedMessageId) && strings.Count(jsonLogs, expectedMessageId) == count {
|
||||
return jsonLogs, nil
|
||||
}
|
||||
case <-ctx.Done():
|
||||
return "", fmt.Errorf("expected message Id %s was not logged or it was not logged %v times", expectedMessageId, count)
|
||||
return "", fmt.Errorf("Expected message Id %s was not logged.", expecteMessageId)
|
||||
}
|
||||
}
|
||||
}
|
||||
40
test/docker/go.mod
Normal file
40
test/docker/go.mod
Normal file
@@ -0,0 +1,40 @@
|
||||
module github.com/ibm-messaging/mq-container/test/docker
|
||||
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
// Note: This is not actually Docker v17.12!
|
||||
// Go modules require the use of semver, but Docker does not use semver and has not
|
||||
// [opted-in to use Go modules](https://github.com/golang/go/wiki/Modules#can-a-module-consume-a-package-that-has-not-opted-in-to-modules)
|
||||
// This means that when you `go get` Docker, you need to do so based on a commit,
|
||||
// e.g. `go get -v github.com/docker/docker@420b1d36250f9cfdc561f086f25a213ecb669b6f`,
|
||||
// which uses the commit for [Docker v19.03.15](https://github.com/moby/moby/releases/tag/v19.03.15)
|
||||
// Go will then find the latest tag with a semver-compatible tag. In Docker's case,
|
||||
// v17.12.0 is valid semver, but v18.09 and v19.03 are not.
|
||||
// Also note: Docker v20.10 is valid semver, but the v20.10 client API requires use of Docker API
|
||||
// version 1.41 on the server, which is currently too new for the version of Docker in Travis (Ubuntu Bionic)
|
||||
github.com/docker/docker v17.12.0-ce-rc1.0.20210128214336-420b1d36250f+incompatible
|
||||
github.com/docker/go-connections v0.4.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
|
||||
github.com/Microsoft/go-winio v0.5.2 // indirect
|
||||
github.com/containerd/containerd v1.6.18 // indirect
|
||||
github.com/docker/distribution v2.8.1+incompatible // indirect
|
||||
github.com/docker/go-units v0.4.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/gorilla/mux v1.8.0 // indirect
|
||||
github.com/morikuni/aec v1.0.0 // indirect
|
||||
github.com/opencontainers/go-digest v1.0.0 // indirect
|
||||
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/sirupsen/logrus v1.8.1 // indirect
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
|
||||
google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21 // indirect
|
||||
google.golang.org/grpc v1.47.0 // indirect
|
||||
google.golang.org/protobuf v1.28.0 // indirect
|
||||
gotest.tools v2.2.0+incompatible // indirect
|
||||
)
|
||||
195
test/docker/go.sum
Normal file
195
test/docker/go.sum
Normal file
@@ -0,0 +1,195 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0=
|
||||
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA=
|
||||
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=
|
||||
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/containerd/containerd v1.6.18 h1:qZbsLvmyu+Vlty0/Ex5xc0z2YtKpIsb5n45mAMI+2Ns=
|
||||
github.com/containerd/containerd v1.6.18/go.mod h1:1RdCUu95+gc2v9t3IL+zIlpClSmew7/0YS8O5eQZrOw=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68=
|
||||
github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
||||
github.com/docker/docker v17.12.0-ce-rc1.0.20210128214336-420b1d36250f+incompatible h1:nhVo1udYfMj0Jsw0lnqrTjjf33aLpdgW9Wve9fHVzhQ=
|
||||
github.com/docker/docker v17.12.0-ce-rc1.0.20210128214336-420b1d36250f+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
|
||||
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
|
||||
github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=
|
||||
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
||||
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
|
||||
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
|
||||
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
|
||||
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
|
||||
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
|
||||
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 h1:rc3tiVYb5z54aKaDfakKn0dDjIyPpTtszkjuMzyt7ec=
|
||||
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
|
||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac h1:7zkz7BUtwNFFqcowJ+RIgu2MaV/MapERkDIy+mwPyjs=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||
google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21 h1:hrbNEivu7Zn1pxvHk6MBrq9iE22woVILTHqexqBxe6I=
|
||||
google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
|
||||
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||
google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
|
||||
google.golang.org/grpc v1.47.0 h1:9n77onPX5F3qfFCqjy9dhn8PbNQsIKeVU04J9G7umt8=
|
||||
google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
|
||||
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
|
||||
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
© Copyright IBM Corporation 2019, 2023
|
||||
© Copyright IBM Corporation 2019, 2022
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
ce "github.com/ibm-messaging/mq-container/test/container/containerengine"
|
||||
"github.com/docker/docker/client"
|
||||
)
|
||||
|
||||
var miEnv = []string{
|
||||
@@ -34,7 +34,10 @@ var miEnv = []string{
|
||||
// and starts/stop them checking we always have an active and standby
|
||||
func TestMultiInstanceStartStop(t *testing.T) {
|
||||
t.Skipf("Skipping %v until test defect fixed", t.Name())
|
||||
cli := ce.NewContainerClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err, qm1aId, qm1bId, volumes := configureMultiInstance(t, cli)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -73,7 +76,10 @@ func TestMultiInstanceStartStop(t *testing.T) {
|
||||
// TestMultiInstanceContainerStop starts 2 containers in a multi instance queue manager configuration,
|
||||
// stops the active queue manager, then checks to ensure the backup queue manager becomes active
|
||||
func TestMultiInstanceContainerStop(t *testing.T) {
|
||||
cli := ce.NewContainerClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err, qm1aId, qm1bId, volumes := configureMultiInstance(t, cli)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -116,16 +122,21 @@ func TestMultiInstanceContainerStop(t *testing.T) {
|
||||
// configuration, then checks to ensure that both an active and standby queue manager have been started
|
||||
func TestMultiInstanceRace(t *testing.T) {
|
||||
t.Skipf("Skipping %v until file lock is implemented", t.Name())
|
||||
cli := ce.NewContainerClient()
|
||||
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
qmsharedlogs := createVolume(t, cli, "qmsharedlogs")
|
||||
defer removeVolume(t, cli, qmsharedlogs)
|
||||
defer removeVolume(t, cli, qmsharedlogs.Name)
|
||||
qmshareddata := createVolume(t, cli, "qmshareddata")
|
||||
defer removeVolume(t, cli, qmshareddata)
|
||||
defer removeVolume(t, cli, qmshareddata.Name)
|
||||
|
||||
qmsChannel := make(chan QMChan)
|
||||
|
||||
go singleMultiInstanceQueueManager(t, cli, qmsharedlogs, qmshareddata, qmsChannel)
|
||||
go singleMultiInstanceQueueManager(t, cli, qmsharedlogs, qmshareddata, qmsChannel)
|
||||
go singleMultiInstanceQueueManager(t, cli, qmsharedlogs.Name, qmshareddata.Name, qmsChannel)
|
||||
go singleMultiInstanceQueueManager(t, cli, qmsharedlogs.Name, qmshareddata.Name, qmsChannel)
|
||||
|
||||
qm1a := <-qmsChannel
|
||||
if qm1a.Error != nil {
|
||||
@@ -148,7 +159,7 @@ func TestMultiInstanceRace(t *testing.T) {
|
||||
waitForReady(t, cli, qm1aId)
|
||||
waitForReady(t, cli, qm1bId)
|
||||
|
||||
err, _, _ := getActiveStandbyQueueManager(t, cli, qm1aId, qm1bId)
|
||||
err, _, _ = getActiveStandbyQueueManager(t, cli, qm1aId, qm1bId)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -158,7 +169,10 @@ func TestMultiInstanceRace(t *testing.T) {
|
||||
// mounts, then checks to ensure that the container terminates with the expected message
|
||||
func TestMultiInstanceNoSharedMounts(t *testing.T) {
|
||||
t.Parallel()
|
||||
cli := ce.NewContainerClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err, qm1aId, qm1aData := startMultiVolumeQueueManager(t, cli, true, "", "", miEnv)
|
||||
if err != nil {
|
||||
@@ -174,12 +188,15 @@ func TestMultiInstanceNoSharedMounts(t *testing.T) {
|
||||
// TestMultiInstanceNoSharedLogs starts 2 multi instance queue managers without providing a shared log
|
||||
// mount, then checks to ensure that the container terminates with the expected message
|
||||
func TestMultiInstanceNoSharedLogs(t *testing.T) {
|
||||
cli := ce.NewContainerClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
qmshareddata := createVolume(t, cli, "qmshareddata")
|
||||
defer removeVolume(t, cli, qmshareddata)
|
||||
defer removeVolume(t, cli, qmshareddata.Name)
|
||||
|
||||
err, qm1aId, qm1aData := startMultiVolumeQueueManager(t, cli, true, "", qmshareddata, miEnv)
|
||||
err, qm1aId, qm1aData := startMultiVolumeQueueManager(t, cli, true, "", qmshareddata.Name, miEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -193,12 +210,15 @@ func TestMultiInstanceNoSharedLogs(t *testing.T) {
|
||||
// TestMultiInstanceNoSharedData starts 2 multi instance queue managers without providing a shared data
|
||||
// mount, then checks to ensure that the container terminates with the expected message
|
||||
func TestMultiInstanceNoSharedData(t *testing.T) {
|
||||
cli := ce.NewContainerClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
qmsharedlogs := createVolume(t, cli, "qmsharedlogs")
|
||||
defer removeVolume(t, cli, qmsharedlogs)
|
||||
defer removeVolume(t, cli, qmsharedlogs.Name)
|
||||
|
||||
err, qm1aId, qm1aData := startMultiVolumeQueueManager(t, cli, true, qmsharedlogs, "", miEnv)
|
||||
err, qm1aId, qm1aData := startMultiVolumeQueueManager(t, cli, true, qmsharedlogs.Name, "", miEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -212,7 +232,10 @@ func TestMultiInstanceNoSharedData(t *testing.T) {
|
||||
// TestMultiInstanceNoMounts starts 2 multi instance queue managers without providing a shared data
|
||||
// mount, then checks to ensure that the container terminates with the expected message
|
||||
func TestMultiInstanceNoMounts(t *testing.T) {
|
||||
cli := ce.NewContainerClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err, qm1aId, qm1aData := startMultiVolumeQueueManager(t, cli, false, "", "", miEnv)
|
||||
if err != nil {
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
© Copyright IBM Corporation 2019, 2023
|
||||
© Copyright IBM Corporation 2019, 2022
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
ce "github.com/ibm-messaging/mq-container/test/container/containerengine"
|
||||
"github.com/docker/docker/client"
|
||||
)
|
||||
|
||||
type QMChan struct {
|
||||
@@ -34,27 +34,27 @@ type QMChan struct {
|
||||
|
||||
// configureMultiInstance creates the volumes and containers required for basic testing
|
||||
// of multi instance queue managers. Returns error, qm1a ID, qm1b ID, slice of volume names
|
||||
func configureMultiInstance(t *testing.T, cli ce.ContainerInterface) (error, string, string, []string) {
|
||||
func configureMultiInstance(t *testing.T, cli *client.Client) (error, string, string, []string) {
|
||||
|
||||
qmsharedlogs := createVolume(t, cli, "qmsharedlogs")
|
||||
qmshareddata := createVolume(t, cli, "qmshareddata")
|
||||
|
||||
err, qm1aId, qm1aData := startMultiVolumeQueueManager(t, cli, true, qmsharedlogs, qmshareddata, miEnv)
|
||||
err, qm1aId, qm1aData := startMultiVolumeQueueManager(t, cli, true, qmsharedlogs.Name, qmshareddata.Name, miEnv)
|
||||
if err != nil {
|
||||
return err, "", "", []string{}
|
||||
}
|
||||
time.Sleep(10 * time.Second)
|
||||
err, qm1bId, qm1bData := startMultiVolumeQueueManager(t, cli, true, qmsharedlogs, qmshareddata, miEnv)
|
||||
err, qm1bId, qm1bData := startMultiVolumeQueueManager(t, cli, true, qmsharedlogs.Name, qmshareddata.Name, miEnv)
|
||||
if err != nil {
|
||||
return err, "", "", []string{}
|
||||
}
|
||||
|
||||
volumes := []string{qmsharedlogs, qmshareddata, qm1aData, qm1bData}
|
||||
volumes := []string{qmsharedlogs.Name, qmshareddata.Name, qm1aData, qm1bData}
|
||||
|
||||
return nil, qm1aId, qm1bId, volumes
|
||||
}
|
||||
|
||||
func singleMultiInstanceQueueManager(t *testing.T, cli ce.ContainerInterface, qmsharedlogs string, qmshareddata string, qmsChannel chan QMChan) {
|
||||
func singleMultiInstanceQueueManager(t *testing.T, cli *client.Client, qmsharedlogs string, qmshareddata string, qmsChannel chan QMChan) {
|
||||
err, qmId, qmData := startMultiVolumeQueueManager(t, cli, true, qmsharedlogs, qmshareddata, miEnv)
|
||||
if err != nil {
|
||||
qmsChannel <- QMChan{Error: err}
|
||||
@@ -62,7 +62,7 @@ func singleMultiInstanceQueueManager(t *testing.T, cli ce.ContainerInterface, qm
|
||||
qmsChannel <- QMChan{QMId: qmId, QMData: qmData}
|
||||
}
|
||||
|
||||
func getActiveStandbyQueueManager(t *testing.T, cli ce.ContainerInterface, qm1aId string, qm1bId string) (error, string, string) {
|
||||
func getActiveStandbyQueueManager(t *testing.T, cli *client.Client, qm1aId string, qm1bId string) (error, string, string) {
|
||||
qm1aStatus := getQueueManagerStatus(t, cli, qm1aId, "QM1")
|
||||
qm1bStatus := getQueueManagerStatus(t, cli, qm1bId, "QM1")
|
||||
|
||||
@@ -75,7 +75,7 @@ func getActiveStandbyQueueManager(t *testing.T, cli ce.ContainerInterface, qm1aI
|
||||
return err, "", ""
|
||||
}
|
||||
|
||||
func getQueueManagerStatus(t *testing.T, cli ce.ContainerInterface, containerID string, queueManagerName string) string {
|
||||
func getQueueManagerStatus(t *testing.T, cli *client.Client, containerID string, queueManagerName string) string {
|
||||
_, dspmqOut := execContainer(t, cli, containerID, "", []string{"bash", "-c", "dspmq", "-m", queueManagerName})
|
||||
t.Logf("dspmq for %v (%v) returned: %v", containerID, queueManagerName, dspmqOut)
|
||||
regex := regexp.MustCompile(`STATUS\(.*\)`)
|
||||
@@ -84,7 +84,7 @@ func getQueueManagerStatus(t *testing.T, cli ce.ContainerInterface, containerID
|
||||
return status
|
||||
}
|
||||
|
||||
func waitForTerminationMessage(t *testing.T, cli ce.ContainerInterface, qmId string, terminationString string, timeout time.Duration) {
|
||||
func waitForTerminationMessage(t *testing.T, cli *client.Client, qmId string, terminationString string, timeout time.Duration) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
for {
|
||||
@@ -93,7 +93,7 @@ func waitForTerminationMessage(t *testing.T, cli ce.ContainerInterface, qmId str
|
||||
m := terminationMessage(t, cli, qmId)
|
||||
if m != "" {
|
||||
if !strings.Contains(m, terminationString) {
|
||||
t.Fatalf("Expected container to fail with termination message %v. Got termination message: %v", terminationString, m)
|
||||
t.Fatalf("Expected container to fail on missing required mount. Got termination message: %v", m)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
© Copyright IBM Corporation 2021, 2023
|
||||
© Copyright IBM Corporation 2021, 2022
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -16,19 +16,20 @@ limitations under the License.
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/client"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
ce "github.com/ibm-messaging/mq-container/test/container/containerengine"
|
||||
)
|
||||
|
||||
// TestNativeHABasic creates 3 containers in a Native HA queue manager configuration
|
||||
// and ensures the queue manger and replicas start as expected
|
||||
func TestNativeHABasic(t *testing.T) {
|
||||
cli := ce.NewContainerClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
version, err := cli.GetMQVersion(imageName())
|
||||
version, err := getMQVersion(t, cli)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -39,18 +40,21 @@ func TestNativeHABasic(t *testing.T) {
|
||||
containerNames := [3]string{"QM1_1", "QM1_2", "QM1_3"}
|
||||
qmReplicaIDs := [3]string{}
|
||||
qmVolumes := []string{}
|
||||
//Each native HA qmgr instance is exposed on subsequent ports on the host starting with basePort
|
||||
//If the qmgr exposes more than one port (tests do not do this currently) then they are offset by +50
|
||||
basePort := 14551
|
||||
qmNetwork, err := createBridgeNetwork(cli, t)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer removeBridgeNetwork(cli, qmNetwork.ID)
|
||||
|
||||
for i := 0; i <= 2; i++ {
|
||||
nhaPort := basePort + i
|
||||
vol := createVolume(t, cli, containerNames[i])
|
||||
defer removeVolume(t, cli, vol)
|
||||
qmVolumes = append(qmVolumes, vol)
|
||||
containerConfig := getNativeHAContainerConfig(containerNames[i], containerNames, basePort)
|
||||
hostConfig := getHostConfig(t, 1, "", "", vol)
|
||||
hostConfig = populateNativeHAPortBindings([]int{9414}, nhaPort, hostConfig)
|
||||
networkingConfig := getNativeHANetworkConfig("host")
|
||||
defer removeVolume(t, cli, vol.Name)
|
||||
qmVolumes = append(qmVolumes, vol.Name)
|
||||
|
||||
containerConfig := getNativeHAContainerConfig(containerNames[i], containerNames, defaultHAPort)
|
||||
hostConfig := getHostConfig(t, 1, "", "", vol.Name)
|
||||
networkingConfig := getNativeHANetworkConfig(qmNetwork.ID)
|
||||
|
||||
ctr := runContainerWithAllConfig(t, cli, &containerConfig, &hostConfig, &networkingConfig, containerNames[i])
|
||||
defer cleanContainer(t, cli, ctr)
|
||||
qmReplicaIDs[i] = ctr
|
||||
@@ -70,9 +74,12 @@ func TestNativeHABasic(t *testing.T) {
|
||||
// queue manager comes back as a replica
|
||||
func TestNativeHAFailover(t *testing.T) {
|
||||
|
||||
cli := ce.NewContainerClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
version, err := cli.GetMQVersion(imageName())
|
||||
version, err := getMQVersion(t, cli)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -83,18 +90,21 @@ func TestNativeHAFailover(t *testing.T) {
|
||||
containerNames := [3]string{"QM1_1", "QM1_2", "QM1_3"}
|
||||
qmReplicaIDs := [3]string{}
|
||||
qmVolumes := []string{}
|
||||
//Each native HA qmgr instance is exposed on subsequent ports on the host starting with basePort
|
||||
//If the qmgr exposes more than one port (tests do not do this currently) then they are offset by +50
|
||||
basePort := 14551
|
||||
qmNetwork, err := createBridgeNetwork(cli, t)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer removeBridgeNetwork(cli, qmNetwork.ID)
|
||||
|
||||
for i := 0; i <= 2; i++ {
|
||||
nhaPort := basePort + i
|
||||
vol := createVolume(t, cli, containerNames[i])
|
||||
defer removeVolume(t, cli, vol)
|
||||
qmVolumes = append(qmVolumes, vol)
|
||||
containerConfig := getNativeHAContainerConfig(containerNames[i], containerNames, basePort)
|
||||
hostConfig := getHostConfig(t, 1, "", "", vol)
|
||||
hostConfig = populateNativeHAPortBindings([]int{9414}, nhaPort, hostConfig)
|
||||
networkingConfig := getNativeHANetworkConfig("host")
|
||||
defer removeVolume(t, cli, vol.Name)
|
||||
qmVolumes = append(qmVolumes, vol.Name)
|
||||
|
||||
containerConfig := getNativeHAContainerConfig(containerNames[i], containerNames, defaultHAPort)
|
||||
hostConfig := getHostConfig(t, 1, "", "", vol.Name)
|
||||
networkingConfig := getNativeHANetworkConfig(qmNetwork.ID)
|
||||
|
||||
ctr := runContainerWithAllConfig(t, cli, &containerConfig, &hostConfig, &networkingConfig, containerNames[i])
|
||||
defer cleanContainer(t, cli, ctr)
|
||||
qmReplicaIDs[i] = ctr
|
||||
@@ -122,31 +132,33 @@ func TestNativeHAFailover(t *testing.T) {
|
||||
// TestNativeHASecure creates 3 containers in a Native HA queue manager configuration
|
||||
// with HA TLS enabled, and ensures the queue manger and replicas start as expected
|
||||
func TestNativeHASecure(t *testing.T) {
|
||||
cli := ce.NewContainerClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
version, err := cli.GetMQVersion(imageName())
|
||||
version, err := getMQVersion(t, cli)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if version < "9.2.2.0" {
|
||||
t.Skipf("Skipping %s as test requires at least MQ 9.2.2.0, but image is version %s", t.Name(), version)
|
||||
}
|
||||
if isARM(t) {
|
||||
t.Skip("Skipping as an issue has been identified for the arm64 MQ image")
|
||||
}
|
||||
|
||||
containerNames := [3]string{"QM1_1", "QM1_2", "QM1_3"}
|
||||
qmReplicaIDs := [3]string{}
|
||||
//Each native HA qmgr instance is exposed on subsequent ports on the host starting with basePort
|
||||
//If the qmgr exposes more than one port (tests do not do this currently) then they are offset by +50
|
||||
basePort := 14551
|
||||
qmNetwork, err := createBridgeNetwork(cli, t)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer removeBridgeNetwork(cli, qmNetwork.ID)
|
||||
|
||||
for i := 0; i <= 2; i++ {
|
||||
nhaPort := basePort + i
|
||||
containerConfig := getNativeHAContainerConfig(containerNames[i], containerNames, defaultHAPort)
|
||||
containerConfig.Env = append(containerConfig.Env, "MQ_NATIVE_HA_TLS=true")
|
||||
hostConfig := getNativeHASecureHostConfig(t)
|
||||
hostConfig = populateNativeHAPortBindings([]int{9414}, nhaPort, hostConfig)
|
||||
networkingConfig := getNativeHANetworkConfig("host")
|
||||
networkingConfig := getNativeHANetworkConfig(qmNetwork.ID)
|
||||
|
||||
ctr := runContainerWithAllConfig(t, cli, &containerConfig, &hostConfig, &networkingConfig, containerNames[i])
|
||||
defer cleanContainer(t, cli, ctr)
|
||||
qmReplicaIDs[i] = ctr
|
||||
@@ -165,9 +177,12 @@ func TestNativeHASecure(t *testing.T) {
|
||||
// with HA TLS enabled, overrides the default CipherSpec, and ensures the queue manger
|
||||
// and replicas start as expected
|
||||
func TestNativeHASecureCipherSpec(t *testing.T) {
|
||||
cli := ce.NewContainerClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
version, err := cli.GetMQVersion(imageName())
|
||||
version, err := getMQVersion(t, cli)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -177,16 +192,18 @@ func TestNativeHASecureCipherSpec(t *testing.T) {
|
||||
|
||||
containerNames := [3]string{"QM1_1", "QM1_2", "QM1_3"}
|
||||
qmReplicaIDs := [3]string{}
|
||||
//Each native HA qmgr instance is exposed on subsequent ports on the host starting with basePort
|
||||
//If the qmgr exposes more than one port (tests do not do this currently) then they are offset by +50
|
||||
basePort := 14551
|
||||
qmNetwork, err := createBridgeNetwork(cli, t)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer removeBridgeNetwork(cli, qmNetwork.ID)
|
||||
|
||||
for i := 0; i <= 2; i++ {
|
||||
nhaPort := basePort + i
|
||||
containerConfig := getNativeHAContainerConfig(containerNames[i], containerNames, defaultHAPort)
|
||||
containerConfig.Env = append(containerConfig.Env, "MQ_NATIVE_HA_TLS=true", "MQ_NATIVE_HA_CIPHERSPEC=TLS_AES_256_GCM_SHA384")
|
||||
hostConfig := getNativeHASecureHostConfig(t)
|
||||
hostConfig = populateNativeHAPortBindings([]int{9414}, nhaPort, hostConfig)
|
||||
networkingConfig := getNativeHANetworkConfig("host")
|
||||
networkingConfig := getNativeHANetworkConfig(qmNetwork.ID)
|
||||
|
||||
ctr := runContainerWithAllConfig(t, cli, &containerConfig, &hostConfig, &networkingConfig, containerNames[i])
|
||||
defer cleanContainer(t, cli, ctr)
|
||||
qmReplicaIDs[i] = ctr
|
||||
@@ -205,9 +222,12 @@ func TestNativeHASecureCipherSpec(t *testing.T) {
|
||||
// with HA TLS FIPS enabled, overrides the default CipherSpec, and ensures the queue manger
|
||||
// and replicas start as expected. This test uses FIPS compliant cipher.
|
||||
func TestNativeHASecureCipherSpecFIPS(t *testing.T) {
|
||||
cli := ce.NewContainerClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
version, err := cli.GetMQVersion(imageName())
|
||||
version, err := getMQVersion(t, cli)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -217,17 +237,19 @@ func TestNativeHASecureCipherSpecFIPS(t *testing.T) {
|
||||
|
||||
containerNames := [3]string{"QM1_1", "QM1_2", "QM1_3"}
|
||||
qmReplicaIDs := [3]string{}
|
||||
//Each native HA qmgr instance is exposed on subsequent ports on the host starting with basePort
|
||||
//If the qmgr exposes more than one port (tests do not do this currently) then they are offset by +50
|
||||
basePort := 14551
|
||||
qmNetwork, err := createBridgeNetwork(cli, t)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer removeBridgeNetwork(cli, qmNetwork.ID)
|
||||
|
||||
for i := 0; i <= 2; i++ {
|
||||
nhaPort := basePort + i
|
||||
containerConfig := getNativeHAContainerConfig(containerNames[i], containerNames, defaultHAPort)
|
||||
// MQ_NATIVE_HA_CIPHERSPEC is set a FIPS compliant cipherspec.
|
||||
containerConfig.Env = append(containerConfig.Env, "MQ_NATIVE_HA_TLS=true", "MQ_NATIVE_HA_CIPHERSPEC=TLS_RSA_WITH_AES_128_GCM_SHA256", "MQ_ENABLE_FIPS=true")
|
||||
hostConfig := getNativeHASecureHostConfig(t)
|
||||
hostConfig = populateNativeHAPortBindings([]int{9414}, nhaPort, hostConfig)
|
||||
networkingConfig := getNativeHANetworkConfig("host")
|
||||
networkingConfig := getNativeHANetworkConfig(qmNetwork.ID)
|
||||
|
||||
ctr := runContainerWithAllConfig(t, cli, &containerConfig, &hostConfig, &networkingConfig, containerNames[i])
|
||||
defer cleanContainer(t, cli, ctr)
|
||||
qmReplicaIDs[i] = ctr
|
||||
@@ -250,9 +272,12 @@ func TestNativeHASecureCipherSpecFIPS(t *testing.T) {
|
||||
// with HA TLS FIPS enabled with non-FIPS cipher, overrides the default CipherSpec, and
|
||||
// ensures the queue manger and replicas don't start as expected
|
||||
func TestNativeHASecureCipherSpecNonFIPSCipher(t *testing.T) {
|
||||
cli := ce.NewContainerClient()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
version, err := cli.GetMQVersion(imageName())
|
||||
version, err := getMQVersion(t, cli)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -262,24 +287,26 @@ func TestNativeHASecureCipherSpecNonFIPSCipher(t *testing.T) {
|
||||
|
||||
containerNames := [3]string{"QM1_1", "QM1_2", "QM1_3"}
|
||||
qmReplicaIDs := [3]string{}
|
||||
//Each native HA qmgr instance is exposed on subsequent ports on the host starting with basePort
|
||||
//If the qmgr exposes more than one port (tests do not do this currently) then they are offset by +50
|
||||
basePort := 14551
|
||||
qmNetwork, err := createBridgeNetwork(cli, t)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer removeBridgeNetwork(cli, qmNetwork.ID)
|
||||
|
||||
for i := 0; i <= 2; i++ {
|
||||
nhaPort := basePort + i
|
||||
containerConfig := getNativeHAContainerConfig(containerNames[i], containerNames, defaultHAPort)
|
||||
// MQ_NATIVE_HA_CIPHERSPEC is set a FIPS non-compliant cipherspec - SSL_ECDHE_ECDSA_WITH_RC4_128_SHA
|
||||
containerConfig.Env = append(containerConfig.Env, "MQ_NATIVE_HA_TLS=true", "MQ_NATIVE_HA_CIPHERSPEC=SSL_ECDHE_ECDSA_WITH_RC4_128_SHA", "MQ_ENABLE_FIPS=true")
|
||||
containerConfig.Env = append(containerConfig.Env, "MQ_NATIVE_HA_TLS=true", "MQ_NATIVE_HA_CIPHERSPEC=TLS_RSA_WITH_AES_128_GCM_SHA256", "MQ_ENABLE_FIPS=true")
|
||||
hostConfig := getNativeHASecureHostConfig(t)
|
||||
hostConfig = populateNativeHAPortBindings([]int{9414}, nhaPort, hostConfig)
|
||||
networkingConfig := getNativeHANetworkConfig("host")
|
||||
ctr := runContainerWithAllConfig(t, cli, &containerConfig, &hostConfig, &networkingConfig, containerNames[i])
|
||||
networkingConfig := getNativeHANetworkConfig(qmNetwork.ID)
|
||||
|
||||
ctr, err := runContainerWithAllConfigError(t, cli, &containerConfig, &hostConfig, &networkingConfig, containerNames[i])
|
||||
defer cleanContainer(t, cli, ctr)
|
||||
// We expect container to fail in this case because the cipher is non-FIPS and we have asked for FIPS compliance
|
||||
// by setting MQ_ENABLE_FIPS=true
|
||||
if err == nil {
|
||||
t.Logf("Container start expected to fail but did not. %v", err)
|
||||
}
|
||||
qmReplicaIDs[i] = ctr
|
||||
}
|
||||
for i := 0; i <= 2; i++ {
|
||||
waitForTerminationMessage(t, cli, qmReplicaIDs[i], "/opt/mqm/bin/strmqm: exit status 23", 60*time.Second)
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
© Copyright IBM Corporation 2021, 2023
|
||||
© Copyright IBM Corporation 2021
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -19,11 +19,13 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
ce "github.com/ibm-messaging/mq-container/test/container/containerengine"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
"github.com/docker/docker/client"
|
||||
)
|
||||
|
||||
const defaultHAPort = 9414
|
||||
@@ -34,8 +36,16 @@ type HAReplicaStatus struct {
|
||||
Replica [2]string
|
||||
}
|
||||
|
||||
func getNativeHAContainerConfig(containerName string, replicaNames [3]string, haPort int) ce.ContainerConfig {
|
||||
return ce.ContainerConfig{
|
||||
func createBridgeNetwork(cli *client.Client, t *testing.T) (types.NetworkCreateResponse, error) {
|
||||
return cli.NetworkCreate(context.Background(), t.Name(), types.NetworkCreate{})
|
||||
}
|
||||
|
||||
func removeBridgeNetwork(cli *client.Client, networkID string) error {
|
||||
return cli.NetworkRemove(context.Background(), networkID)
|
||||
}
|
||||
|
||||
func getNativeHAContainerConfig(containerName string, replicaNames [3]string, haPort int) container.Config {
|
||||
return container.Config{
|
||||
Env: []string{
|
||||
"LICENSE=accept",
|
||||
"MQ_QMGR_NAME=QM1",
|
||||
@@ -45,18 +55,15 @@ func getNativeHAContainerConfig(containerName string, replicaNames [3]string, ha
|
||||
fmt.Sprintf("MQ_NATIVE_HA_INSTANCE_0_NAME=%s", replicaNames[0]),
|
||||
fmt.Sprintf("MQ_NATIVE_HA_INSTANCE_1_NAME=%s", replicaNames[1]),
|
||||
fmt.Sprintf("MQ_NATIVE_HA_INSTANCE_2_NAME=%s", replicaNames[2]),
|
||||
fmt.Sprintf("MQ_NATIVE_HA_INSTANCE_0_REPLICATION_ADDRESS=%s(%d)", "127.0.0.1", haPort+0),
|
||||
fmt.Sprintf("MQ_NATIVE_HA_INSTANCE_1_REPLICATION_ADDRESS=%s(%d)", "127.0.0.1", haPort+1),
|
||||
fmt.Sprintf("MQ_NATIVE_HA_INSTANCE_2_REPLICATION_ADDRESS=%s(%d)", "127.0.0.1", haPort+2),
|
||||
fmt.Sprintf("MQ_NATIVE_HA_INSTANCE_0_REPLICATION_ADDRESS=%s(%d)", replicaNames[0], haPort),
|
||||
fmt.Sprintf("MQ_NATIVE_HA_INSTANCE_1_REPLICATION_ADDRESS=%s(%d)", replicaNames[1], haPort),
|
||||
fmt.Sprintf("MQ_NATIVE_HA_INSTANCE_2_REPLICATION_ADDRESS=%s(%d)", replicaNames[2], haPort),
|
||||
},
|
||||
//When using the host for networking a consistent user was required. If a random user is used then the following example error was recorded.
|
||||
//AMQ3209E: Native HA connection rejected due to configuration mismatch of 'QmgrUserId=5024'
|
||||
User: "1111",
|
||||
}
|
||||
}
|
||||
|
||||
func getNativeHASecureHostConfig(t *testing.T) ce.ContainerHostConfig {
|
||||
return ce.ContainerHostConfig{
|
||||
func getNativeHASecureHostConfig(t *testing.T) container.HostConfig {
|
||||
return container.HostConfig{
|
||||
Binds: []string{
|
||||
coverageBind(t),
|
||||
filepath.Join(getCwd(t, true), "../tls") + ":/etc/mqm/ha/pki/keys/ha",
|
||||
@@ -64,30 +71,15 @@ func getNativeHASecureHostConfig(t *testing.T) ce.ContainerHostConfig {
|
||||
}
|
||||
}
|
||||
|
||||
func getNativeHANetworkConfig(networkID string) ce.ContainerNetworkSettings {
|
||||
return ce.ContainerNetworkSettings{
|
||||
Networks: []string{networkID},
|
||||
func getNativeHANetworkConfig(networkID string) network.NetworkingConfig {
|
||||
return network.NetworkingConfig{
|
||||
EndpointsConfig: map[string]*network.EndpointSettings{
|
||||
networkID: &network.EndpointSettings{},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// populatePortBindings writes port bindings to the host config
|
||||
func populateNativeHAPortBindings(ports []int, nativeHaPort int, hostConfig ce.ContainerHostConfig) ce.ContainerHostConfig {
|
||||
hostConfig.PortBindings = []ce.PortBinding{}
|
||||
var binding ce.PortBinding
|
||||
for i, p := range ports {
|
||||
port := fmt.Sprintf("%v/tcp", p)
|
||||
binding = ce.PortBinding{
|
||||
ContainerPort: port,
|
||||
HostIP: "0.0.0.0",
|
||||
//Offset the ports by 50 if there are multiple
|
||||
HostPort: strconv.Itoa(nativeHaPort + 50*i),
|
||||
}
|
||||
hostConfig.PortBindings = append(hostConfig.PortBindings, binding)
|
||||
}
|
||||
return hostConfig
|
||||
}
|
||||
|
||||
func getActiveReplicaInstances(t *testing.T, cli ce.ContainerInterface, qmReplicaIDs [3]string) (HAReplicaStatus, error) {
|
||||
func getActiveReplicaInstances(t *testing.T, cli *client.Client, qmReplicaIDs [3]string) (HAReplicaStatus, error) {
|
||||
|
||||
var actives []string
|
||||
var replicas []string
|
||||
@@ -112,7 +104,7 @@ func getActiveReplicaInstances(t *testing.T, cli ce.ContainerInterface, qmReplic
|
||||
return HAReplicaStatus{actives[0], [2]string{replicas[0], replicas[1]}}, nil
|
||||
}
|
||||
|
||||
func waitForReadyHA(t *testing.T, cli ce.ContainerInterface, qmReplicaIDs [3]string) {
|
||||
func waitForReadyHA(t *testing.T, cli *client.Client, qmReplicaIDs [3]string) {
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 4*time.Minute)
|
||||
defer cancel()
|
||||
@@ -137,7 +129,7 @@ func waitForReadyHA(t *testing.T, cli ce.ContainerInterface, qmReplicaIDs [3]str
|
||||
}
|
||||
}
|
||||
|
||||
func waitForFailoverHA(t *testing.T, cli ce.ContainerInterface, replicas [2]string) {
|
||||
func waitForFailoverHA(t *testing.T, cli *client.Client, replicas [2]string) {
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||
defer cancel()
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
© Copyright IBM Corporation 2018, 2023
|
||||
© Copyright IBM Corporation 2018, 2022
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -22,20 +22,20 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
ce "github.com/ibm-messaging/mq-container/test/container/containerengine"
|
||||
"github.com/docker/docker/client"
|
||||
)
|
||||
|
||||
func TestGoldenPathMetric(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cli := ce.NewContainerClient()
|
||||
id := runContainerWithPorts(t, cli, metricsContainerConfig(), []int{defaultMetricPort})
|
||||
defer cleanContainer(t, cli, id)
|
||||
|
||||
port, err := cli.GetContainerPort(id, defaultMetricPort)
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
id := runContainerWithPorts(t, cli, metricsContainerConfig(), []int{defaultMetricPort})
|
||||
defer cleanContainer(t, cli, id)
|
||||
|
||||
port := getPort(t, cli, id, defaultMetricPort)
|
||||
// Now the container is ready we prod the prometheus endpoint until it's up.
|
||||
waitForMetricReady(t, port)
|
||||
|
||||
@@ -55,14 +55,14 @@ func TestGoldenPathMetric(t *testing.T) {
|
||||
func TestMetricNames(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cli := ce.NewContainerClient()
|
||||
id := runContainerWithPorts(t, cli, metricsContainerConfig(), []int{defaultMetricPort})
|
||||
defer cleanContainer(t, cli, id)
|
||||
|
||||
port, err := cli.GetContainerPort(id, defaultMetricPort)
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
id := runContainerWithPorts(t, cli, metricsContainerConfig(), []int{defaultMetricPort})
|
||||
defer cleanContainer(t, cli, id)
|
||||
|
||||
port := getPort(t, cli, id, defaultMetricPort)
|
||||
// Now the container is ready we prod the prometheus endpoint until it's up.
|
||||
waitForMetricReady(t, port)
|
||||
|
||||
@@ -99,14 +99,14 @@ func TestMetricNames(t *testing.T) {
|
||||
func TestMetricLabels(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cli := ce.NewContainerClient()
|
||||
requiredLabels := []string{"qmgr"}
|
||||
id := runContainerWithPorts(t, cli, metricsContainerConfig(), []int{defaultMetricPort})
|
||||
defer cleanContainer(t, cli, id)
|
||||
port, err := cli.GetContainerPort(id, defaultMetricPort)
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
id := runContainerWithPorts(t, cli, metricsContainerConfig(), []int{defaultMetricPort})
|
||||
defer cleanContainer(t, cli, id)
|
||||
port := getPort(t, cli, id, defaultMetricPort)
|
||||
|
||||
// Now the container is ready we prod the prometheus endpoint until it's up.
|
||||
waitForMetricReady(t, port)
|
||||
@@ -148,13 +148,13 @@ func TestMetricLabels(t *testing.T) {
|
||||
func TestRapidFirePrometheus(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cli := ce.NewContainerClient()
|
||||
id := runContainerWithPorts(t, cli, metricsContainerConfig(), []int{defaultMetricPort})
|
||||
defer cleanContainer(t, cli, id)
|
||||
port, err := cli.GetContainerPort(id, defaultMetricPort)
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
id := runContainerWithPorts(t, cli, metricsContainerConfig(), []int{defaultMetricPort})
|
||||
defer cleanContainer(t, cli, id)
|
||||
port := getPort(t, cli, id, defaultMetricPort)
|
||||
|
||||
// Now the container is ready we prod the prometheus endpoint until it's up.
|
||||
waitForMetricReady(t, port)
|
||||
@@ -182,13 +182,13 @@ func TestRapidFirePrometheus(t *testing.T) {
|
||||
func TestSlowPrometheus(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cli := ce.NewContainerClient()
|
||||
id := runContainerWithPorts(t, cli, metricsContainerConfig(), []int{defaultMetricPort})
|
||||
defer cleanContainer(t, cli, id)
|
||||
port, err := cli.GetContainerPort(id, defaultMetricPort)
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
id := runContainerWithPorts(t, cli, metricsContainerConfig(), []int{defaultMetricPort})
|
||||
defer cleanContainer(t, cli, id)
|
||||
port := getPort(t, cli, id, defaultMetricPort)
|
||||
|
||||
// Now the container is ready we prod the prometheus endpoint until it's up.
|
||||
waitForMetricReady(t, port)
|
||||
@@ -213,14 +213,15 @@ func TestSlowPrometheus(t *testing.T) {
|
||||
func TestContainerRestart(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cli := ce.NewContainerClient()
|
||||
id := runContainerWithPorts(t, cli, metricsContainerConfig(), []int{defaultMetricPort})
|
||||
defer cleanContainer(t, cli, id)
|
||||
port, err := cli.GetContainerPort(id, defaultMetricPort)
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
id := runContainerWithPorts(t, cli, metricsContainerConfig(), []int{defaultMetricPort})
|
||||
defer cleanContainer(t, cli, id)
|
||||
port := getPort(t, cli, id, defaultMetricPort)
|
||||
|
||||
// Now the container is ready we prod the prometheus endpoint until it's up.
|
||||
waitForMetricReady(t, port)
|
||||
|
||||
@@ -238,10 +239,7 @@ func TestContainerRestart(t *testing.T) {
|
||||
stopContainer(t, cli, id)
|
||||
// Start the container cleanly
|
||||
startContainer(t, cli, id)
|
||||
port, err = cli.GetContainerPort(id, defaultMetricPort)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
port = getPort(t, cli, id, defaultMetricPort)
|
||||
|
||||
// Now the container is ready we prod the prometheus endpoint until it's up.
|
||||
waitForMetricReady(t, port)
|
||||
@@ -263,15 +261,16 @@ func TestContainerRestart(t *testing.T) {
|
||||
func TestQMRestart(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cli := ce.NewContainerClient()
|
||||
id := runContainerWithPorts(t, cli, metricsContainerConfig(), []int{defaultMetricPort})
|
||||
defer cleanContainer(t, cli, id)
|
||||
|
||||
port, err := cli.GetContainerPort(id, defaultMetricPort)
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
id := runContainerWithPorts(t, cli, metricsContainerConfig(), []int{defaultMetricPort})
|
||||
defer cleanContainer(t, cli, id)
|
||||
|
||||
port := getPort(t, cli, id, defaultMetricPort)
|
||||
|
||||
// Now the container is ready we prod the prometheus endpoint until it's up.
|
||||
waitForMetricReady(t, port)
|
||||
|
||||
@@ -320,14 +319,14 @@ func TestQMRestart(t *testing.T) {
|
||||
func TestValidValues(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cli := ce.NewContainerClient()
|
||||
id := runContainerWithPorts(t, cli, metricsContainerConfig(), []int{defaultMetricPort})
|
||||
defer cleanContainer(t, cli, id)
|
||||
// hostname := getIPAddress(t, cli, id)
|
||||
port, err := cli.GetContainerPort(id, defaultMetricPort)
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
id := runContainerWithPorts(t, cli, metricsContainerConfig(), []int{defaultMetricPort})
|
||||
defer cleanContainer(t, cli, id)
|
||||
// hostname := getIPAddress(t, cli, id)
|
||||
port := getPort(t, cli, id, defaultMetricPort)
|
||||
// Now the container is ready we prod the prometheus endpoint until it's up.
|
||||
waitForMetricReady(t, port)
|
||||
|
||||
@@ -344,7 +343,7 @@ func TestValidValues(t *testing.T) {
|
||||
// Check that the values for each metric are valid numbers
|
||||
// can be either int, float or exponential - all these can be parsed by ParseFloat function
|
||||
for _, e := range metrics {
|
||||
if _, err := strconv.ParseFloat(e.Value, 64); err != nil {
|
||||
if _, err = strconv.ParseFloat(e.Value, 64); err != nil {
|
||||
t.Errorf("Value (%s) for key (%s) is not a valid number", e.Value, e.Key)
|
||||
}
|
||||
}
|
||||
@@ -356,14 +355,14 @@ func TestValidValues(t *testing.T) {
|
||||
func TestChangingValues(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cli := ce.NewContainerClient()
|
||||
id := runContainerWithPorts(t, cli, metricsContainerConfig(), []int{1414, defaultMetricPort})
|
||||
defer cleanContainer(t, cli, id)
|
||||
// hostname := getIPAddress(t, cli, id)
|
||||
port, err := cli.GetContainerPort(id, defaultMetricPort)
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
id := runContainerWithPorts(t, cli, metricsContainerConfig(), []int{1414, defaultMetricPort})
|
||||
defer cleanContainer(t, cli, id)
|
||||
// hostname := getIPAddress(t, cli, id)
|
||||
port := getPort(t, cli, id, defaultMetricPort)
|
||||
// Now the container is ready we prod the prometheus endpoint until it's up.
|
||||
waitForMetricReady(t, port)
|
||||
|
||||
@@ -387,11 +386,7 @@ func TestChangingValues(t *testing.T) {
|
||||
}
|
||||
|
||||
// Send invalid data to the MQ listener to generate a FDC
|
||||
noport, err := cli.GetContainerPort(id, 1414)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
listener := fmt.Sprintf("localhost:%s", noport)
|
||||
listener := fmt.Sprintf("localhost:%s", getPort(t, cli, id, 1414))
|
||||
conn, err := net.Dial("tcp", listener)
|
||||
if err != nil {
|
||||
t.Fatalf("Could not connect to the listener - %v", err)
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
© Copyright IBM Corporation 2018, 2023
|
||||
© Copyright IBM Corporation 2018
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -24,7 +24,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
ce "github.com/ibm-messaging/mq-container/test/container/containerengine"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
)
|
||||
|
||||
type mqmetric struct {
|
||||
@@ -146,8 +146,8 @@ func waitForMetricReady(t *testing.T, port string) {
|
||||
t.Fatalf("Metric endpoint failed to startup in timely manner")
|
||||
}
|
||||
|
||||
func metricsContainerConfig() *ce.ContainerConfig {
|
||||
return &ce.ContainerConfig{
|
||||
func metricsContainerConfig() *container.Config {
|
||||
return &container.Config{
|
||||
Env: []string{
|
||||
"LICENSE=accept",
|
||||
"MQ_QMGR_NAME=" + defaultMetricQMName,
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
© Copyright IBM Corporation 2018, 2023
|
||||
© Copyright IBM Corporation 2018, 2022
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -51,7 +51,6 @@ class JMSTests {
|
||||
private static final Logger LOGGER = Logger.getLogger(JMSTests.class.getName());
|
||||
protected static final String ADDR = System.getenv("MQ_PORT_1414_TCP_ADDR");
|
||||
protected static final String USER = System.getenv("MQ_USERNAME");
|
||||
protected static final String PORT = System.getenv().getOrDefault("MQ_PORT_1414_OVERRIDE", "1414");
|
||||
protected static final String PASSWORD = System.getenv("MQ_PASSWORD");
|
||||
protected static final String CHANNEL = System.getenv("MQ_CHANNEL");
|
||||
protected static final String TRUSTSTORE = System.getenv("MQ_TLS_TRUSTSTORE");
|
||||
@@ -68,11 +67,11 @@ class JMSTests {
|
||||
return ctx.getSocketFactory();
|
||||
}
|
||||
|
||||
static MQConnectionFactory createMQConnectionFactory(String channel, String addr, String port) throws JMSException, IOException, GeneralSecurityException {
|
||||
static MQConnectionFactory createMQConnectionFactory(String channel, String addr) throws JMSException, IOException, GeneralSecurityException {
|
||||
MQConnectionFactory factory = new MQConnectionFactory();
|
||||
factory.setTransportType(WMQConstants.WMQ_CM_CLIENT);
|
||||
factory.setChannel(channel);
|
||||
factory.setConnectionNameList(String.format("%s(%s)", addr, port));
|
||||
factory.setConnectionNameList(String.format("%s(1414)", addr));
|
||||
if (TRUSTSTORE == null) {
|
||||
LOGGER.info("Not using TLS");
|
||||
}
|
||||
@@ -84,7 +83,7 @@ class JMSTests {
|
||||
if (ibmjre){
|
||||
System.setProperty("com.ibm.mq.cfg.useIBMCipherMappings", "true");
|
||||
} else {
|
||||
System.setProperty("com.ibm.mq.cfg.useIBMCipherMappings", "false");
|
||||
System.setProperty("com.ibm.mq.cfg.useIBMCipherMappings", "false");
|
||||
}
|
||||
factory.setSSLCipherSuite(System.getenv("MQ_TLS_CIPHER"));
|
||||
}
|
||||
@@ -94,9 +93,9 @@ class JMSTests {
|
||||
/**
|
||||
* Create a JMSContext with the supplied user and password.
|
||||
*/
|
||||
static JMSContext create(String channel, String addr, String port, String user, String password) throws JMSException, IOException, GeneralSecurityException {
|
||||
LOGGER.info(String.format("Connecting to %s/TCP/%s(%s) as %s", channel, addr, port, user));
|
||||
MQConnectionFactory factory = createMQConnectionFactory(channel, addr, port);
|
||||
static JMSContext create(String channel, String addr, String user, String password) throws JMSException, IOException, GeneralSecurityException {
|
||||
LOGGER.info(String.format("Connecting to %s/TCP/%s(1414) as %s", channel, addr, user));
|
||||
MQConnectionFactory factory = createMQConnectionFactory(channel, addr);
|
||||
// If a password is set, make sure it gets sent to the queue manager for authentication
|
||||
if (password != null) {
|
||||
factory.setBooleanProperty(WMQConstants.USER_AUTHENTICATION_MQCSP, true);
|
||||
@@ -108,9 +107,9 @@ class JMSTests {
|
||||
/**
|
||||
* Create a JMSContext with the default user identity (from the OS)
|
||||
*/
|
||||
static JMSContext create(String channel, String addr, String port) throws JMSException, IOException, GeneralSecurityException {
|
||||
LOGGER.info(String.format("Connecting to %s/TCP/%s(%s) as OS user '%s'", channel, addr, port, System.getProperty("user.name")));
|
||||
MQConnectionFactory factory = createMQConnectionFactory(channel, addr, port);
|
||||
static JMSContext create(String channel, String addr) throws JMSException, IOException, GeneralSecurityException {
|
||||
LOGGER.info(String.format("Connecting to %s/TCP/%s(1414) as OS user '%s'", channel, addr, System.getProperty("user.name")));
|
||||
MQConnectionFactory factory = createMQConnectionFactory(channel, addr);
|
||||
LOGGER.info(String.format("CSP authentication: %s", factory.getBooleanProperty(WMQConstants.USER_AUTHENTICATION_MQCSP)));
|
||||
return factory.createContext();
|
||||
}
|
||||
@@ -119,7 +118,7 @@ class JMSTests {
|
||||
private static void waitForQueueManager() {
|
||||
for (int i = 0; i < 20; i++) {
|
||||
try {
|
||||
Socket s = new Socket(ADDR, Integer.parseInt(PORT));
|
||||
Socket s = new Socket(ADDR, 1414);
|
||||
s.close();
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
@@ -133,7 +132,7 @@ class JMSTests {
|
||||
|
||||
@Test
|
||||
void putGetTest(TestInfo t) throws Exception {
|
||||
context = create(CHANNEL, ADDR, PORT, USER, PASSWORD);
|
||||
context = create(CHANNEL, ADDR, USER, PASSWORD);
|
||||
Queue queue = new MQQueue("DEV.QUEUE.1");
|
||||
context.createProducer().send(queue, t.getDisplayName());
|
||||
Message m = context.createConsumer(queue).receive();
|
||||
@@ -145,7 +144,7 @@ class JMSTests {
|
||||
LOGGER.info(String.format("Password='%s'", PASSWORD));
|
||||
try {
|
||||
// Don't pass a user/password, which should cause the default identity to be used
|
||||
context = create(CHANNEL, ADDR, PORT);
|
||||
context = create(CHANNEL, ADDR);
|
||||
} catch (DetailedJMSSecurityRuntimeException ex) {
|
||||
Throwable cause = ex.getCause();
|
||||
assertNotNull(cause);
|
||||
|
||||
10
vendor/github.com/golang/protobuf/proto/registry.go
generated
vendored
10
vendor/github.com/golang/protobuf/proto/registry.go
generated
vendored
@@ -13,7 +13,6 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"google.golang.org/protobuf/reflect/protodesc"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
"google.golang.org/protobuf/runtime/protoimpl"
|
||||
@@ -63,7 +62,14 @@ func FileDescriptor(s filePath) fileDescGZIP {
|
||||
// Find the descriptor in the v2 registry.
|
||||
var b []byte
|
||||
if fd, _ := protoregistry.GlobalFiles.FindFileByPath(s); fd != nil {
|
||||
b, _ = Marshal(protodesc.ToFileDescriptorProto(fd))
|
||||
if fd, ok := fd.(interface{ ProtoLegacyRawDesc() []byte }); ok {
|
||||
b = fd.ProtoLegacyRawDesc()
|
||||
} else {
|
||||
// TODO: Use protodesc.ToFileDescriptorProto to construct
|
||||
// a descriptorpb.FileDescriptorProto and marshal it.
|
||||
// However, doing so causes the proto package to have a dependency
|
||||
// on descriptorpb, leading to cyclic dependency issues.
|
||||
}
|
||||
}
|
||||
|
||||
// Locally cache the raw descriptor form for the file.
|
||||
|
||||
14
vendor/github.com/golang/protobuf/ptypes/any.go
generated
vendored
14
vendor/github.com/golang/protobuf/ptypes/any.go
generated
vendored
@@ -19,8 +19,6 @@ const urlPrefix = "type.googleapis.com/"
|
||||
|
||||
// AnyMessageName returns the message name contained in an anypb.Any message.
|
||||
// Most type assertions should use the Is function instead.
|
||||
//
|
||||
// Deprecated: Call the any.MessageName method instead.
|
||||
func AnyMessageName(any *anypb.Any) (string, error) {
|
||||
name, err := anyMessageName(any)
|
||||
return string(name), err
|
||||
@@ -40,8 +38,6 @@ func anyMessageName(any *anypb.Any) (protoreflect.FullName, error) {
|
||||
}
|
||||
|
||||
// MarshalAny marshals the given message m into an anypb.Any message.
|
||||
//
|
||||
// Deprecated: Call the anypb.New function instead.
|
||||
func MarshalAny(m proto.Message) (*anypb.Any, error) {
|
||||
switch dm := m.(type) {
|
||||
case DynamicAny:
|
||||
@@ -62,9 +58,6 @@ func MarshalAny(m proto.Message) (*anypb.Any, error) {
|
||||
// Empty returns a new message of the type specified in an anypb.Any message.
|
||||
// It returns protoregistry.NotFound if the corresponding message type could not
|
||||
// be resolved in the global registry.
|
||||
//
|
||||
// Deprecated: Use protoregistry.GlobalTypes.FindMessageByName instead
|
||||
// to resolve the message name and create a new instance of it.
|
||||
func Empty(any *anypb.Any) (proto.Message, error) {
|
||||
name, err := anyMessageName(any)
|
||||
if err != nil {
|
||||
@@ -83,8 +76,6 @@ func Empty(any *anypb.Any) (proto.Message, error) {
|
||||
//
|
||||
// The target message m may be a *DynamicAny message. If the underlying message
|
||||
// type could not be resolved, then this returns protoregistry.NotFound.
|
||||
//
|
||||
// Deprecated: Call the any.UnmarshalTo method instead.
|
||||
func UnmarshalAny(any *anypb.Any, m proto.Message) error {
|
||||
if dm, ok := m.(*DynamicAny); ok {
|
||||
if dm.Message == nil {
|
||||
@@ -109,8 +100,6 @@ func UnmarshalAny(any *anypb.Any, m proto.Message) error {
|
||||
}
|
||||
|
||||
// Is reports whether the Any message contains a message of the specified type.
|
||||
//
|
||||
// Deprecated: Call the any.MessageIs method instead.
|
||||
func Is(any *anypb.Any, m proto.Message) bool {
|
||||
if any == nil || m == nil {
|
||||
return false
|
||||
@@ -130,9 +119,6 @@ func Is(any *anypb.Any, m proto.Message) bool {
|
||||
// var x ptypes.DynamicAny
|
||||
// if err := ptypes.UnmarshalAny(a, &x); err != nil { ... }
|
||||
// fmt.Printf("unmarshaled message: %v", x.Message)
|
||||
//
|
||||
// Deprecated: Use the any.UnmarshalNew method instead to unmarshal
|
||||
// the any message contents into a new instance of the underlying message.
|
||||
type DynamicAny struct{ proto.Message }
|
||||
|
||||
func (m DynamicAny) String() string {
|
||||
|
||||
4
vendor/github.com/golang/protobuf/ptypes/doc.go
generated
vendored
4
vendor/github.com/golang/protobuf/ptypes/doc.go
generated
vendored
@@ -3,8 +3,4 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package ptypes provides functionality for interacting with well-known types.
|
||||
//
|
||||
// Deprecated: Well-known types have specialized functionality directly
|
||||
// injected into the generated packages for each message type.
|
||||
// See the deprecation notice for each function for the suggested alternative.
|
||||
package ptypes
|
||||
|
||||
4
vendor/github.com/golang/protobuf/ptypes/duration.go
generated
vendored
4
vendor/github.com/golang/protobuf/ptypes/duration.go
generated
vendored
@@ -21,8 +21,6 @@ const (
|
||||
|
||||
// Duration converts a durationpb.Duration to a time.Duration.
|
||||
// Duration returns an error if dur is invalid or overflows a time.Duration.
|
||||
//
|
||||
// Deprecated: Call the dur.AsDuration and dur.CheckValid methods instead.
|
||||
func Duration(dur *durationpb.Duration) (time.Duration, error) {
|
||||
if err := validateDuration(dur); err != nil {
|
||||
return 0, err
|
||||
@@ -41,8 +39,6 @@ func Duration(dur *durationpb.Duration) (time.Duration, error) {
|
||||
}
|
||||
|
||||
// DurationProto converts a time.Duration to a durationpb.Duration.
|
||||
//
|
||||
// Deprecated: Call the durationpb.New function instead.
|
||||
func DurationProto(d time.Duration) *durationpb.Duration {
|
||||
nanos := d.Nanoseconds()
|
||||
secs := nanos / 1e9
|
||||
|
||||
9
vendor/github.com/golang/protobuf/ptypes/timestamp.go
generated
vendored
9
vendor/github.com/golang/protobuf/ptypes/timestamp.go
generated
vendored
@@ -33,8 +33,6 @@ const (
|
||||
//
|
||||
// A nil Timestamp returns an error. The first return value in that case is
|
||||
// undefined.
|
||||
//
|
||||
// Deprecated: Call the ts.AsTime and ts.CheckValid methods instead.
|
||||
func Timestamp(ts *timestamppb.Timestamp) (time.Time, error) {
|
||||
// Don't return the zero value on error, because corresponds to a valid
|
||||
// timestamp. Instead return whatever time.Unix gives us.
|
||||
@@ -48,8 +46,6 @@ func Timestamp(ts *timestamppb.Timestamp) (time.Time, error) {
|
||||
}
|
||||
|
||||
// TimestampNow returns a google.protobuf.Timestamp for the current time.
|
||||
//
|
||||
// Deprecated: Call the timestamppb.Now function instead.
|
||||
func TimestampNow() *timestamppb.Timestamp {
|
||||
ts, err := TimestampProto(time.Now())
|
||||
if err != nil {
|
||||
@@ -60,8 +56,6 @@ func TimestampNow() *timestamppb.Timestamp {
|
||||
|
||||
// TimestampProto converts the time.Time to a google.protobuf.Timestamp proto.
|
||||
// It returns an error if the resulting Timestamp is invalid.
|
||||
//
|
||||
// Deprecated: Call the timestamppb.New function instead.
|
||||
func TimestampProto(t time.Time) (*timestamppb.Timestamp, error) {
|
||||
ts := ×tamppb.Timestamp{
|
||||
Seconds: t.Unix(),
|
||||
@@ -75,9 +69,6 @@ func TimestampProto(t time.Time) (*timestamppb.Timestamp, error) {
|
||||
|
||||
// TimestampString returns the RFC 3339 string for valid Timestamps.
|
||||
// For invalid Timestamps, it returns an error message in parentheses.
|
||||
//
|
||||
// Deprecated: Call the ts.AsTime method instead,
|
||||
// followed by a call to the Format method on the time.Time value.
|
||||
func TimestampString(ts *timestamppb.Timestamp) string {
|
||||
t, err := Timestamp(ts)
|
||||
if err != nil {
|
||||
|
||||
1666
vendor/github.com/prometheus/client_model/go/metrics.pb.go
generated
vendored
1666
vendor/github.com/prometheus/client_model/go/metrics.pb.go
generated
vendored
File diff suppressed because it is too large
Load Diff
3
vendor/google.golang.org/protobuf/AUTHORS
generated
vendored
Normal file
3
vendor/google.golang.org/protobuf/AUTHORS
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# This source code refers to The Go Authors for copyright purposes.
|
||||
# The master list of authors is in the main Go distribution,
|
||||
# visible at https://tip.golang.org/AUTHORS.
|
||||
3
vendor/google.golang.org/protobuf/CONTRIBUTORS
generated
vendored
Normal file
3
vendor/google.golang.org/protobuf/CONTRIBUTORS
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# This source code was written by the Go contributors.
|
||||
# The master list of contributors is in the main Go distribution,
|
||||
# visible at https://tip.golang.org/CONTRIBUTORS.
|
||||
127
vendor/google.golang.org/protobuf/encoding/prototext/decode.go
generated
vendored
127
vendor/google.golang.org/protobuf/encoding/prototext/decode.go
generated
vendored
@@ -17,11 +17,11 @@ import (
|
||||
"google.golang.org/protobuf/internal/set"
|
||||
"google.golang.org/protobuf/internal/strs"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
)
|
||||
|
||||
// Unmarshal reads the given []byte into the given [proto.Message].
|
||||
// Unmarshal reads the given []byte into the given proto.Message.
|
||||
// The provided message must be mutable (e.g., a non-nil pointer to a message).
|
||||
func Unmarshal(b []byte, m proto.Message) error {
|
||||
return UnmarshalOptions{}.Unmarshal(b, m)
|
||||
@@ -51,7 +51,7 @@ type UnmarshalOptions struct {
|
||||
}
|
||||
}
|
||||
|
||||
// Unmarshal reads the given []byte and populates the given [proto.Message]
|
||||
// Unmarshal reads the given []byte and populates the given proto.Message
|
||||
// using options in the UnmarshalOptions object.
|
||||
// The provided message must be mutable (e.g., a non-nil pointer to a message).
|
||||
func (o UnmarshalOptions) Unmarshal(b []byte, m proto.Message) error {
|
||||
@@ -103,7 +103,7 @@ func (d decoder) syntaxError(pos int, f string, x ...interface{}) error {
|
||||
}
|
||||
|
||||
// unmarshalMessage unmarshals into the given protoreflect.Message.
|
||||
func (d decoder) unmarshalMessage(m protoreflect.Message, checkDelims bool) error {
|
||||
func (d decoder) unmarshalMessage(m pref.Message, checkDelims bool) error {
|
||||
messageDesc := m.Descriptor()
|
||||
if !flags.ProtoLegacy && messageset.IsMessageSet(messageDesc) {
|
||||
return errors.New("no support for proto1 MessageSets")
|
||||
@@ -150,24 +150,24 @@ func (d decoder) unmarshalMessage(m protoreflect.Message, checkDelims bool) erro
|
||||
}
|
||||
|
||||
// Resolve the field descriptor.
|
||||
var name protoreflect.Name
|
||||
var fd protoreflect.FieldDescriptor
|
||||
var xt protoreflect.ExtensionType
|
||||
var name pref.Name
|
||||
var fd pref.FieldDescriptor
|
||||
var xt pref.ExtensionType
|
||||
var xtErr error
|
||||
var isFieldNumberName bool
|
||||
|
||||
switch tok.NameKind() {
|
||||
case text.IdentName:
|
||||
name = protoreflect.Name(tok.IdentName())
|
||||
name = pref.Name(tok.IdentName())
|
||||
fd = fieldDescs.ByTextName(string(name))
|
||||
|
||||
case text.TypeName:
|
||||
// Handle extensions only. This code path is not for Any.
|
||||
xt, xtErr = d.opts.Resolver.FindExtensionByName(protoreflect.FullName(tok.TypeName()))
|
||||
xt, xtErr = d.opts.Resolver.FindExtensionByName(pref.FullName(tok.TypeName()))
|
||||
|
||||
case text.FieldNumber:
|
||||
isFieldNumberName = true
|
||||
num := protoreflect.FieldNumber(tok.FieldNumber())
|
||||
num := pref.FieldNumber(tok.FieldNumber())
|
||||
if !num.IsValid() {
|
||||
return d.newError(tok.Pos(), "invalid field number: %d", num)
|
||||
}
|
||||
@@ -215,7 +215,7 @@ func (d decoder) unmarshalMessage(m protoreflect.Message, checkDelims bool) erro
|
||||
switch {
|
||||
case fd.IsList():
|
||||
kind := fd.Kind()
|
||||
if kind != protoreflect.MessageKind && kind != protoreflect.GroupKind && !tok.HasSeparator() {
|
||||
if kind != pref.MessageKind && kind != pref.GroupKind && !tok.HasSeparator() {
|
||||
return d.syntaxError(tok.Pos(), "missing field separator :")
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ func (d decoder) unmarshalMessage(m protoreflect.Message, checkDelims bool) erro
|
||||
|
||||
default:
|
||||
kind := fd.Kind()
|
||||
if kind != protoreflect.MessageKind && kind != protoreflect.GroupKind && !tok.HasSeparator() {
|
||||
if kind != pref.MessageKind && kind != pref.GroupKind && !tok.HasSeparator() {
|
||||
return d.syntaxError(tok.Pos(), "missing field separator :")
|
||||
}
|
||||
|
||||
@@ -262,11 +262,11 @@ func (d decoder) unmarshalMessage(m protoreflect.Message, checkDelims bool) erro
|
||||
|
||||
// unmarshalSingular unmarshals a non-repeated field value specified by the
|
||||
// given FieldDescriptor.
|
||||
func (d decoder) unmarshalSingular(fd protoreflect.FieldDescriptor, m protoreflect.Message) error {
|
||||
var val protoreflect.Value
|
||||
func (d decoder) unmarshalSingular(fd pref.FieldDescriptor, m pref.Message) error {
|
||||
var val pref.Value
|
||||
var err error
|
||||
switch fd.Kind() {
|
||||
case protoreflect.MessageKind, protoreflect.GroupKind:
|
||||
case pref.MessageKind, pref.GroupKind:
|
||||
val = m.NewField(fd)
|
||||
err = d.unmarshalMessage(val.Message(), true)
|
||||
default:
|
||||
@@ -280,94 +280,94 @@ func (d decoder) unmarshalSingular(fd protoreflect.FieldDescriptor, m protorefle
|
||||
|
||||
// unmarshalScalar unmarshals a scalar/enum protoreflect.Value specified by the
|
||||
// given FieldDescriptor.
|
||||
func (d decoder) unmarshalScalar(fd protoreflect.FieldDescriptor) (protoreflect.Value, error) {
|
||||
func (d decoder) unmarshalScalar(fd pref.FieldDescriptor) (pref.Value, error) {
|
||||
tok, err := d.Read()
|
||||
if err != nil {
|
||||
return protoreflect.Value{}, err
|
||||
return pref.Value{}, err
|
||||
}
|
||||
|
||||
if tok.Kind() != text.Scalar {
|
||||
return protoreflect.Value{}, d.unexpectedTokenError(tok)
|
||||
return pref.Value{}, d.unexpectedTokenError(tok)
|
||||
}
|
||||
|
||||
kind := fd.Kind()
|
||||
switch kind {
|
||||
case protoreflect.BoolKind:
|
||||
case pref.BoolKind:
|
||||
if b, ok := tok.Bool(); ok {
|
||||
return protoreflect.ValueOfBool(b), nil
|
||||
return pref.ValueOfBool(b), nil
|
||||
}
|
||||
|
||||
case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind:
|
||||
case pref.Int32Kind, pref.Sint32Kind, pref.Sfixed32Kind:
|
||||
if n, ok := tok.Int32(); ok {
|
||||
return protoreflect.ValueOfInt32(n), nil
|
||||
return pref.ValueOfInt32(n), nil
|
||||
}
|
||||
|
||||
case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind:
|
||||
case pref.Int64Kind, pref.Sint64Kind, pref.Sfixed64Kind:
|
||||
if n, ok := tok.Int64(); ok {
|
||||
return protoreflect.ValueOfInt64(n), nil
|
||||
return pref.ValueOfInt64(n), nil
|
||||
}
|
||||
|
||||
case protoreflect.Uint32Kind, protoreflect.Fixed32Kind:
|
||||
case pref.Uint32Kind, pref.Fixed32Kind:
|
||||
if n, ok := tok.Uint32(); ok {
|
||||
return protoreflect.ValueOfUint32(n), nil
|
||||
return pref.ValueOfUint32(n), nil
|
||||
}
|
||||
|
||||
case protoreflect.Uint64Kind, protoreflect.Fixed64Kind:
|
||||
case pref.Uint64Kind, pref.Fixed64Kind:
|
||||
if n, ok := tok.Uint64(); ok {
|
||||
return protoreflect.ValueOfUint64(n), nil
|
||||
return pref.ValueOfUint64(n), nil
|
||||
}
|
||||
|
||||
case protoreflect.FloatKind:
|
||||
case pref.FloatKind:
|
||||
if n, ok := tok.Float32(); ok {
|
||||
return protoreflect.ValueOfFloat32(n), nil
|
||||
return pref.ValueOfFloat32(n), nil
|
||||
}
|
||||
|
||||
case protoreflect.DoubleKind:
|
||||
case pref.DoubleKind:
|
||||
if n, ok := tok.Float64(); ok {
|
||||
return protoreflect.ValueOfFloat64(n), nil
|
||||
return pref.ValueOfFloat64(n), nil
|
||||
}
|
||||
|
||||
case protoreflect.StringKind:
|
||||
case pref.StringKind:
|
||||
if s, ok := tok.String(); ok {
|
||||
if strs.EnforceUTF8(fd) && !utf8.ValidString(s) {
|
||||
return protoreflect.Value{}, d.newError(tok.Pos(), "contains invalid UTF-8")
|
||||
return pref.Value{}, d.newError(tok.Pos(), "contains invalid UTF-8")
|
||||
}
|
||||
return protoreflect.ValueOfString(s), nil
|
||||
return pref.ValueOfString(s), nil
|
||||
}
|
||||
|
||||
case protoreflect.BytesKind:
|
||||
case pref.BytesKind:
|
||||
if b, ok := tok.String(); ok {
|
||||
return protoreflect.ValueOfBytes([]byte(b)), nil
|
||||
return pref.ValueOfBytes([]byte(b)), nil
|
||||
}
|
||||
|
||||
case protoreflect.EnumKind:
|
||||
case pref.EnumKind:
|
||||
if lit, ok := tok.Enum(); ok {
|
||||
// Lookup EnumNumber based on name.
|
||||
if enumVal := fd.Enum().Values().ByName(protoreflect.Name(lit)); enumVal != nil {
|
||||
return protoreflect.ValueOfEnum(enumVal.Number()), nil
|
||||
if enumVal := fd.Enum().Values().ByName(pref.Name(lit)); enumVal != nil {
|
||||
return pref.ValueOfEnum(enumVal.Number()), nil
|
||||
}
|
||||
}
|
||||
if num, ok := tok.Int32(); ok {
|
||||
return protoreflect.ValueOfEnum(protoreflect.EnumNumber(num)), nil
|
||||
return pref.ValueOfEnum(pref.EnumNumber(num)), nil
|
||||
}
|
||||
|
||||
default:
|
||||
panic(fmt.Sprintf("invalid scalar kind %v", kind))
|
||||
}
|
||||
|
||||
return protoreflect.Value{}, d.newError(tok.Pos(), "invalid value for %v type: %v", kind, tok.RawString())
|
||||
return pref.Value{}, d.newError(tok.Pos(), "invalid value for %v type: %v", kind, tok.RawString())
|
||||
}
|
||||
|
||||
// unmarshalList unmarshals into given protoreflect.List. A list value can
|
||||
// either be in [] syntax or simply just a single scalar/message value.
|
||||
func (d decoder) unmarshalList(fd protoreflect.FieldDescriptor, list protoreflect.List) error {
|
||||
func (d decoder) unmarshalList(fd pref.FieldDescriptor, list pref.List) error {
|
||||
tok, err := d.Peek()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch fd.Kind() {
|
||||
case protoreflect.MessageKind, protoreflect.GroupKind:
|
||||
case pref.MessageKind, pref.GroupKind:
|
||||
switch tok.Kind() {
|
||||
case text.ListOpen:
|
||||
d.Read()
|
||||
@@ -441,22 +441,22 @@ func (d decoder) unmarshalList(fd protoreflect.FieldDescriptor, list protoreflec
|
||||
|
||||
// unmarshalMap unmarshals into given protoreflect.Map. A map value is a
|
||||
// textproto message containing {key: <kvalue>, value: <mvalue>}.
|
||||
func (d decoder) unmarshalMap(fd protoreflect.FieldDescriptor, mmap protoreflect.Map) error {
|
||||
func (d decoder) unmarshalMap(fd pref.FieldDescriptor, mmap pref.Map) error {
|
||||
// Determine ahead whether map entry is a scalar type or a message type in
|
||||
// order to call the appropriate unmarshalMapValue func inside
|
||||
// unmarshalMapEntry.
|
||||
var unmarshalMapValue func() (protoreflect.Value, error)
|
||||
var unmarshalMapValue func() (pref.Value, error)
|
||||
switch fd.MapValue().Kind() {
|
||||
case protoreflect.MessageKind, protoreflect.GroupKind:
|
||||
unmarshalMapValue = func() (protoreflect.Value, error) {
|
||||
case pref.MessageKind, pref.GroupKind:
|
||||
unmarshalMapValue = func() (pref.Value, error) {
|
||||
pval := mmap.NewValue()
|
||||
if err := d.unmarshalMessage(pval.Message(), true); err != nil {
|
||||
return protoreflect.Value{}, err
|
||||
return pref.Value{}, err
|
||||
}
|
||||
return pval, nil
|
||||
}
|
||||
default:
|
||||
unmarshalMapValue = func() (protoreflect.Value, error) {
|
||||
unmarshalMapValue = func() (pref.Value, error) {
|
||||
return d.unmarshalScalar(fd.MapValue())
|
||||
}
|
||||
}
|
||||
@@ -494,9 +494,9 @@ func (d decoder) unmarshalMap(fd protoreflect.FieldDescriptor, mmap protoreflect
|
||||
|
||||
// unmarshalMap unmarshals into given protoreflect.Map. A map value is a
|
||||
// textproto message containing {key: <kvalue>, value: <mvalue>}.
|
||||
func (d decoder) unmarshalMapEntry(fd protoreflect.FieldDescriptor, mmap protoreflect.Map, unmarshalMapValue func() (protoreflect.Value, error)) error {
|
||||
var key protoreflect.MapKey
|
||||
var pval protoreflect.Value
|
||||
func (d decoder) unmarshalMapEntry(fd pref.FieldDescriptor, mmap pref.Map, unmarshalMapValue func() (pref.Value, error)) error {
|
||||
var key pref.MapKey
|
||||
var pval pref.Value
|
||||
Loop:
|
||||
for {
|
||||
// Read field name.
|
||||
@@ -520,7 +520,7 @@ Loop:
|
||||
return d.unexpectedTokenError(tok)
|
||||
}
|
||||
|
||||
switch name := protoreflect.Name(tok.IdentName()); name {
|
||||
switch name := pref.Name(tok.IdentName()); name {
|
||||
case genid.MapEntry_Key_field_name:
|
||||
if !tok.HasSeparator() {
|
||||
return d.syntaxError(tok.Pos(), "missing field separator :")
|
||||
@@ -535,7 +535,7 @@ Loop:
|
||||
key = val.MapKey()
|
||||
|
||||
case genid.MapEntry_Value_field_name:
|
||||
if kind := fd.MapValue().Kind(); (kind != protoreflect.MessageKind) && (kind != protoreflect.GroupKind) {
|
||||
if kind := fd.MapValue().Kind(); (kind != pref.MessageKind) && (kind != pref.GroupKind) {
|
||||
if !tok.HasSeparator() {
|
||||
return d.syntaxError(tok.Pos(), "missing field separator :")
|
||||
}
|
||||
@@ -561,7 +561,7 @@ Loop:
|
||||
}
|
||||
if !pval.IsValid() {
|
||||
switch fd.MapValue().Kind() {
|
||||
case protoreflect.MessageKind, protoreflect.GroupKind:
|
||||
case pref.MessageKind, pref.GroupKind:
|
||||
// If value field is not set for message/group types, construct an
|
||||
// empty one as default.
|
||||
pval = mmap.NewValue()
|
||||
@@ -575,7 +575,7 @@ Loop:
|
||||
|
||||
// unmarshalAny unmarshals an Any textproto. It can either be in expanded form
|
||||
// or non-expanded form.
|
||||
func (d decoder) unmarshalAny(m protoreflect.Message, checkDelims bool) error {
|
||||
func (d decoder) unmarshalAny(m pref.Message, checkDelims bool) error {
|
||||
var typeURL string
|
||||
var bValue []byte
|
||||
var seenTypeUrl bool
|
||||
@@ -619,7 +619,7 @@ Loop:
|
||||
return d.syntaxError(tok.Pos(), "missing field separator :")
|
||||
}
|
||||
|
||||
switch name := protoreflect.Name(tok.IdentName()); name {
|
||||
switch name := pref.Name(tok.IdentName()); name {
|
||||
case genid.Any_TypeUrl_field_name:
|
||||
if seenTypeUrl {
|
||||
return d.newError(tok.Pos(), "duplicate %v field", genid.Any_TypeUrl_field_fullname)
|
||||
@@ -686,10 +686,10 @@ Loop:
|
||||
|
||||
fds := m.Descriptor().Fields()
|
||||
if len(typeURL) > 0 {
|
||||
m.Set(fds.ByNumber(genid.Any_TypeUrl_field_number), protoreflect.ValueOfString(typeURL))
|
||||
m.Set(fds.ByNumber(genid.Any_TypeUrl_field_number), pref.ValueOfString(typeURL))
|
||||
}
|
||||
if len(bValue) > 0 {
|
||||
m.Set(fds.ByNumber(genid.Any_Value_field_number), protoreflect.ValueOfBytes(bValue))
|
||||
m.Set(fds.ByNumber(genid.Any_Value_field_number), pref.ValueOfBytes(bValue))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -739,13 +739,14 @@ func (d decoder) skipValue() error {
|
||||
case text.ListClose:
|
||||
return nil
|
||||
case text.MessageOpen:
|
||||
if err := d.skipMessageValue(); err != nil {
|
||||
return err
|
||||
}
|
||||
return d.skipMessageValue()
|
||||
default:
|
||||
// Skip items. This will not validate whether skipped values are
|
||||
// of the same type or not, same behavior as C++
|
||||
// TextFormat::Parser::AllowUnknownField(true) version 3.8.0.
|
||||
if err := d.skipValue(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
57
vendor/google.golang.org/protobuf/encoding/prototext/encode.go
generated
vendored
57
vendor/google.golang.org/protobuf/encoding/prototext/encode.go
generated
vendored
@@ -20,6 +20,7 @@ import (
|
||||
"google.golang.org/protobuf/internal/strs"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
)
|
||||
|
||||
@@ -33,7 +34,7 @@ func Format(m proto.Message) string {
|
||||
return MarshalOptions{Multiline: true}.Format(m)
|
||||
}
|
||||
|
||||
// Marshal writes the given [proto.Message] in textproto format using default
|
||||
// Marshal writes the given proto.Message in textproto format using default
|
||||
// options. Do not depend on the output being stable. It may change over time
|
||||
// across different versions of the program.
|
||||
func Marshal(m proto.Message) ([]byte, error) {
|
||||
@@ -97,23 +98,17 @@ func (o MarshalOptions) Format(m proto.Message) string {
|
||||
return string(b)
|
||||
}
|
||||
|
||||
// Marshal writes the given [proto.Message] in textproto format using options in
|
||||
// Marshal writes the given proto.Message in textproto format using options in
|
||||
// MarshalOptions object. Do not depend on the output being stable. It may
|
||||
// change over time across different versions of the program.
|
||||
func (o MarshalOptions) Marshal(m proto.Message) ([]byte, error) {
|
||||
return o.marshal(nil, m)
|
||||
}
|
||||
|
||||
// MarshalAppend appends the textproto format encoding of m to b,
|
||||
// returning the result.
|
||||
func (o MarshalOptions) MarshalAppend(b []byte, m proto.Message) ([]byte, error) {
|
||||
return o.marshal(b, m)
|
||||
return o.marshal(m)
|
||||
}
|
||||
|
||||
// marshal is a centralized function that all marshal operations go through.
|
||||
// For profiling purposes, avoid changing the name of this function or
|
||||
// introducing other code paths for marshal that do not go through this.
|
||||
func (o MarshalOptions) marshal(b []byte, m proto.Message) ([]byte, error) {
|
||||
func (o MarshalOptions) marshal(m proto.Message) ([]byte, error) {
|
||||
var delims = [2]byte{'{', '}'}
|
||||
|
||||
if o.Multiline && o.Indent == "" {
|
||||
@@ -123,7 +118,7 @@ func (o MarshalOptions) marshal(b []byte, m proto.Message) ([]byte, error) {
|
||||
o.Resolver = protoregistry.GlobalTypes
|
||||
}
|
||||
|
||||
internalEnc, err := text.NewEncoder(b, o.Indent, delims, o.EmitASCII)
|
||||
internalEnc, err := text.NewEncoder(o.Indent, delims, o.EmitASCII)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -131,7 +126,7 @@ func (o MarshalOptions) marshal(b []byte, m proto.Message) ([]byte, error) {
|
||||
// Treat nil message interface as an empty message,
|
||||
// in which case there is nothing to output.
|
||||
if m == nil {
|
||||
return b, nil
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
enc := encoder{internalEnc, o}
|
||||
@@ -155,7 +150,7 @@ type encoder struct {
|
||||
}
|
||||
|
||||
// marshalMessage marshals the given protoreflect.Message.
|
||||
func (e encoder) marshalMessage(m protoreflect.Message, inclDelims bool) error {
|
||||
func (e encoder) marshalMessage(m pref.Message, inclDelims bool) error {
|
||||
messageDesc := m.Descriptor()
|
||||
if !flags.ProtoLegacy && messageset.IsMessageSet(messageDesc) {
|
||||
return errors.New("no support for proto1 MessageSets")
|
||||
@@ -195,7 +190,7 @@ func (e encoder) marshalMessage(m protoreflect.Message, inclDelims bool) error {
|
||||
}
|
||||
|
||||
// marshalField marshals the given field with protoreflect.Value.
|
||||
func (e encoder) marshalField(name string, val protoreflect.Value, fd protoreflect.FieldDescriptor) error {
|
||||
func (e encoder) marshalField(name string, val pref.Value, fd pref.FieldDescriptor) error {
|
||||
switch {
|
||||
case fd.IsList():
|
||||
return e.marshalList(name, val.List(), fd)
|
||||
@@ -209,40 +204,40 @@ func (e encoder) marshalField(name string, val protoreflect.Value, fd protorefle
|
||||
|
||||
// marshalSingular marshals the given non-repeated field value. This includes
|
||||
// all scalar types, enums, messages, and groups.
|
||||
func (e encoder) marshalSingular(val protoreflect.Value, fd protoreflect.FieldDescriptor) error {
|
||||
func (e encoder) marshalSingular(val pref.Value, fd pref.FieldDescriptor) error {
|
||||
kind := fd.Kind()
|
||||
switch kind {
|
||||
case protoreflect.BoolKind:
|
||||
case pref.BoolKind:
|
||||
e.WriteBool(val.Bool())
|
||||
|
||||
case protoreflect.StringKind:
|
||||
case pref.StringKind:
|
||||
s := val.String()
|
||||
if !e.opts.allowInvalidUTF8 && strs.EnforceUTF8(fd) && !utf8.ValidString(s) {
|
||||
return errors.InvalidUTF8(string(fd.FullName()))
|
||||
}
|
||||
e.WriteString(s)
|
||||
|
||||
case protoreflect.Int32Kind, protoreflect.Int64Kind,
|
||||
protoreflect.Sint32Kind, protoreflect.Sint64Kind,
|
||||
protoreflect.Sfixed32Kind, protoreflect.Sfixed64Kind:
|
||||
case pref.Int32Kind, pref.Int64Kind,
|
||||
pref.Sint32Kind, pref.Sint64Kind,
|
||||
pref.Sfixed32Kind, pref.Sfixed64Kind:
|
||||
e.WriteInt(val.Int())
|
||||
|
||||
case protoreflect.Uint32Kind, protoreflect.Uint64Kind,
|
||||
protoreflect.Fixed32Kind, protoreflect.Fixed64Kind:
|
||||
case pref.Uint32Kind, pref.Uint64Kind,
|
||||
pref.Fixed32Kind, pref.Fixed64Kind:
|
||||
e.WriteUint(val.Uint())
|
||||
|
||||
case protoreflect.FloatKind:
|
||||
case pref.FloatKind:
|
||||
// Encoder.WriteFloat handles the special numbers NaN and infinites.
|
||||
e.WriteFloat(val.Float(), 32)
|
||||
|
||||
case protoreflect.DoubleKind:
|
||||
case pref.DoubleKind:
|
||||
// Encoder.WriteFloat handles the special numbers NaN and infinites.
|
||||
e.WriteFloat(val.Float(), 64)
|
||||
|
||||
case protoreflect.BytesKind:
|
||||
case pref.BytesKind:
|
||||
e.WriteString(string(val.Bytes()))
|
||||
|
||||
case protoreflect.EnumKind:
|
||||
case pref.EnumKind:
|
||||
num := val.Enum()
|
||||
if desc := fd.Enum().Values().ByNumber(num); desc != nil {
|
||||
e.WriteLiteral(string(desc.Name()))
|
||||
@@ -251,7 +246,7 @@ func (e encoder) marshalSingular(val protoreflect.Value, fd protoreflect.FieldDe
|
||||
e.WriteInt(int64(num))
|
||||
}
|
||||
|
||||
case protoreflect.MessageKind, protoreflect.GroupKind:
|
||||
case pref.MessageKind, pref.GroupKind:
|
||||
return e.marshalMessage(val.Message(), true)
|
||||
|
||||
default:
|
||||
@@ -261,7 +256,7 @@ func (e encoder) marshalSingular(val protoreflect.Value, fd protoreflect.FieldDe
|
||||
}
|
||||
|
||||
// marshalList marshals the given protoreflect.List as multiple name-value fields.
|
||||
func (e encoder) marshalList(name string, list protoreflect.List, fd protoreflect.FieldDescriptor) error {
|
||||
func (e encoder) marshalList(name string, list pref.List, fd pref.FieldDescriptor) error {
|
||||
size := list.Len()
|
||||
for i := 0; i < size; i++ {
|
||||
e.WriteName(name)
|
||||
@@ -273,9 +268,9 @@ func (e encoder) marshalList(name string, list protoreflect.List, fd protoreflec
|
||||
}
|
||||
|
||||
// marshalMap marshals the given protoreflect.Map as multiple name-value fields.
|
||||
func (e encoder) marshalMap(name string, mmap protoreflect.Map, fd protoreflect.FieldDescriptor) error {
|
||||
func (e encoder) marshalMap(name string, mmap pref.Map, fd pref.FieldDescriptor) error {
|
||||
var err error
|
||||
order.RangeEntries(mmap, order.GenericKeyOrder, func(key protoreflect.MapKey, val protoreflect.Value) bool {
|
||||
order.RangeEntries(mmap, order.GenericKeyOrder, func(key pref.MapKey, val pref.Value) bool {
|
||||
e.WriteName(name)
|
||||
e.StartMessage()
|
||||
defer e.EndMessage()
|
||||
@@ -339,7 +334,7 @@ func (e encoder) marshalUnknown(b []byte) {
|
||||
|
||||
// marshalAny marshals the given google.protobuf.Any message in expanded form.
|
||||
// It returns true if it was able to marshal, else false.
|
||||
func (e encoder) marshalAny(any protoreflect.Message) bool {
|
||||
func (e encoder) marshalAny(any pref.Message) bool {
|
||||
// Construct the embedded message.
|
||||
fds := any.Descriptor().Fields()
|
||||
fdType := fds.ByNumber(genid.Any_TypeUrl_field_number)
|
||||
|
||||
59
vendor/google.golang.org/protobuf/encoding/protowire/wire.go
generated
vendored
59
vendor/google.golang.org/protobuf/encoding/protowire/wire.go
generated
vendored
@@ -3,10 +3,10 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package protowire parses and formats the raw wire encoding.
|
||||
// See https://protobuf.dev/programming-guides/encoding.
|
||||
// See https://developers.google.com/protocol-buffers/docs/encoding.
|
||||
//
|
||||
// For marshaling and unmarshaling entire protobuf messages,
|
||||
// use the [google.golang.org/protobuf/proto] package instead.
|
||||
// use the "google.golang.org/protobuf/proto" package instead.
|
||||
package protowire
|
||||
|
||||
import (
|
||||
@@ -21,16 +21,19 @@ import (
|
||||
type Number int32
|
||||
|
||||
const (
|
||||
MinValidNumber Number = 1
|
||||
FirstReservedNumber Number = 19000
|
||||
LastReservedNumber Number = 19999
|
||||
MaxValidNumber Number = 1<<29 - 1
|
||||
DefaultRecursionLimit = 10000
|
||||
MinValidNumber Number = 1
|
||||
FirstReservedNumber Number = 19000
|
||||
LastReservedNumber Number = 19999
|
||||
MaxValidNumber Number = 1<<29 - 1
|
||||
)
|
||||
|
||||
// IsValid reports whether the field number is semantically valid.
|
||||
//
|
||||
// Note that while numbers within the reserved range are semantically invalid,
|
||||
// they are syntactically valid in the wire format.
|
||||
// Implementations may treat records with reserved field numbers as unknown.
|
||||
func (n Number) IsValid() bool {
|
||||
return MinValidNumber <= n && n <= MaxValidNumber
|
||||
return MinValidNumber <= n && n < FirstReservedNumber || LastReservedNumber < n && n <= MaxValidNumber
|
||||
}
|
||||
|
||||
// Type represents the wire type.
|
||||
@@ -52,7 +55,6 @@ const (
|
||||
errCodeOverflow
|
||||
errCodeReserved
|
||||
errCodeEndGroup
|
||||
errCodeRecursionDepth
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -87,7 +89,7 @@ func ParseError(n int) error {
|
||||
|
||||
// ConsumeField parses an entire field record (both tag and value) and returns
|
||||
// the field number, the wire type, and the total length.
|
||||
// This returns a negative length upon an error (see [ParseError]).
|
||||
// This returns a negative length upon an error (see ParseError).
|
||||
//
|
||||
// The total length includes the tag header and the end group marker (if the
|
||||
// field is a group).
|
||||
@@ -104,16 +106,12 @@ func ConsumeField(b []byte) (Number, Type, int) {
|
||||
}
|
||||
|
||||
// ConsumeFieldValue parses a field value and returns its length.
|
||||
// This assumes that the field [Number] and wire [Type] have already been parsed.
|
||||
// This returns a negative length upon an error (see [ParseError]).
|
||||
// This assumes that the field Number and wire Type have already been parsed.
|
||||
// This returns a negative length upon an error (see ParseError).
|
||||
//
|
||||
// When parsing a group, the length includes the end group marker and
|
||||
// the end group is verified to match the starting field number.
|
||||
func ConsumeFieldValue(num Number, typ Type, b []byte) (n int) {
|
||||
return consumeFieldValueD(num, typ, b, DefaultRecursionLimit)
|
||||
}
|
||||
|
||||
func consumeFieldValueD(num Number, typ Type, b []byte, depth int) (n int) {
|
||||
switch typ {
|
||||
case VarintType:
|
||||
_, n = ConsumeVarint(b)
|
||||
@@ -128,9 +126,6 @@ func consumeFieldValueD(num Number, typ Type, b []byte, depth int) (n int) {
|
||||
_, n = ConsumeBytes(b)
|
||||
return n
|
||||
case StartGroupType:
|
||||
if depth < 0 {
|
||||
return errCodeRecursionDepth
|
||||
}
|
||||
n0 := len(b)
|
||||
for {
|
||||
num2, typ2, n := ConsumeTag(b)
|
||||
@@ -145,7 +140,7 @@ func consumeFieldValueD(num Number, typ Type, b []byte, depth int) (n int) {
|
||||
return n0 - len(b)
|
||||
}
|
||||
|
||||
n = consumeFieldValueD(num2, typ2, b, depth-1)
|
||||
n = ConsumeFieldValue(num2, typ2, b)
|
||||
if n < 0 {
|
||||
return n // forward error code
|
||||
}
|
||||
@@ -164,7 +159,7 @@ func AppendTag(b []byte, num Number, typ Type) []byte {
|
||||
}
|
||||
|
||||
// ConsumeTag parses b as a varint-encoded tag, reporting its length.
|
||||
// This returns a negative length upon an error (see [ParseError]).
|
||||
// This returns a negative length upon an error (see ParseError).
|
||||
func ConsumeTag(b []byte) (Number, Type, int) {
|
||||
v, n := ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
@@ -263,7 +258,7 @@ func AppendVarint(b []byte, v uint64) []byte {
|
||||
}
|
||||
|
||||
// ConsumeVarint parses b as a varint-encoded uint64, reporting its length.
|
||||
// This returns a negative length upon an error (see [ParseError]).
|
||||
// This returns a negative length upon an error (see ParseError).
|
||||
func ConsumeVarint(b []byte) (v uint64, n int) {
|
||||
var y uint64
|
||||
if len(b) <= 0 {
|
||||
@@ -384,7 +379,7 @@ func AppendFixed32(b []byte, v uint32) []byte {
|
||||
}
|
||||
|
||||
// ConsumeFixed32 parses b as a little-endian uint32, reporting its length.
|
||||
// This returns a negative length upon an error (see [ParseError]).
|
||||
// This returns a negative length upon an error (see ParseError).
|
||||
func ConsumeFixed32(b []byte) (v uint32, n int) {
|
||||
if len(b) < 4 {
|
||||
return 0, errCodeTruncated
|
||||
@@ -412,7 +407,7 @@ func AppendFixed64(b []byte, v uint64) []byte {
|
||||
}
|
||||
|
||||
// ConsumeFixed64 parses b as a little-endian uint64, reporting its length.
|
||||
// This returns a negative length upon an error (see [ParseError]).
|
||||
// This returns a negative length upon an error (see ParseError).
|
||||
func ConsumeFixed64(b []byte) (v uint64, n int) {
|
||||
if len(b) < 8 {
|
||||
return 0, errCodeTruncated
|
||||
@@ -432,7 +427,7 @@ func AppendBytes(b []byte, v []byte) []byte {
|
||||
}
|
||||
|
||||
// ConsumeBytes parses b as a length-prefixed bytes value, reporting its length.
|
||||
// This returns a negative length upon an error (see [ParseError]).
|
||||
// This returns a negative length upon an error (see ParseError).
|
||||
func ConsumeBytes(b []byte) (v []byte, n int) {
|
||||
m, n := ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
@@ -456,7 +451,7 @@ func AppendString(b []byte, v string) []byte {
|
||||
}
|
||||
|
||||
// ConsumeString parses b as a length-prefixed bytes value, reporting its length.
|
||||
// This returns a negative length upon an error (see [ParseError]).
|
||||
// This returns a negative length upon an error (see ParseError).
|
||||
func ConsumeString(b []byte) (v string, n int) {
|
||||
bb, n := ConsumeBytes(b)
|
||||
return string(bb), n
|
||||
@@ -471,7 +466,7 @@ func AppendGroup(b []byte, num Number, v []byte) []byte {
|
||||
// ConsumeGroup parses b as a group value until the trailing end group marker,
|
||||
// and verifies that the end marker matches the provided num. The value v
|
||||
// does not contain the end marker, while the length does contain the end marker.
|
||||
// This returns a negative length upon an error (see [ParseError]).
|
||||
// This returns a negative length upon an error (see ParseError).
|
||||
func ConsumeGroup(num Number, b []byte) (v []byte, n int) {
|
||||
n = ConsumeFieldValue(num, StartGroupType, b)
|
||||
if n < 0 {
|
||||
@@ -495,8 +490,8 @@ func SizeGroup(num Number, n int) int {
|
||||
return n + SizeTag(num)
|
||||
}
|
||||
|
||||
// DecodeTag decodes the field [Number] and wire [Type] from its unified form.
|
||||
// The [Number] is -1 if the decoded field number overflows int32.
|
||||
// DecodeTag decodes the field Number and wire Type from its unified form.
|
||||
// The Number is -1 if the decoded field number overflows int32.
|
||||
// Other than overflow, this does not check for field number validity.
|
||||
func DecodeTag(x uint64) (Number, Type) {
|
||||
// NOTE: MessageSet allows for larger field numbers than normal.
|
||||
@@ -506,13 +501,12 @@ func DecodeTag(x uint64) (Number, Type) {
|
||||
return Number(x >> 3), Type(x & 7)
|
||||
}
|
||||
|
||||
// EncodeTag encodes the field [Number] and wire [Type] into its unified form.
|
||||
// EncodeTag encodes the field Number and wire Type into its unified form.
|
||||
func EncodeTag(num Number, typ Type) uint64 {
|
||||
return uint64(num)<<3 | uint64(typ&7)
|
||||
}
|
||||
|
||||
// DecodeZigZag decodes a zig-zag-encoded uint64 as an int64.
|
||||
//
|
||||
// Input: {…, 5, 3, 1, 0, 2, 4, 6, …}
|
||||
// Output: {…, -3, -2, -1, 0, +1, +2, +3, …}
|
||||
func DecodeZigZag(x uint64) int64 {
|
||||
@@ -520,7 +514,6 @@ func DecodeZigZag(x uint64) int64 {
|
||||
}
|
||||
|
||||
// EncodeZigZag encodes an int64 as a zig-zag-encoded uint64.
|
||||
//
|
||||
// Input: {…, -3, -2, -1, 0, +1, +2, +3, …}
|
||||
// Output: {…, 5, 3, 1, 0, 2, 4, 6, …}
|
||||
func EncodeZigZag(x int64) uint64 {
|
||||
@@ -528,7 +521,6 @@ func EncodeZigZag(x int64) uint64 {
|
||||
}
|
||||
|
||||
// DecodeBool decodes a uint64 as a bool.
|
||||
//
|
||||
// Input: { 0, 1, 2, …}
|
||||
// Output: {false, true, true, …}
|
||||
func DecodeBool(x uint64) bool {
|
||||
@@ -536,7 +528,6 @@ func DecodeBool(x uint64) bool {
|
||||
}
|
||||
|
||||
// EncodeBool encodes a bool as a uint64.
|
||||
//
|
||||
// Input: {false, true}
|
||||
// Output: { 0, 1}
|
||||
func EncodeBool(x bool) uint64 {
|
||||
|
||||
229
vendor/google.golang.org/protobuf/internal/descfmt/stringer.go
generated
vendored
229
vendor/google.golang.org/protobuf/internal/descfmt/stringer.go
generated
vendored
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
"google.golang.org/protobuf/internal/detrand"
|
||||
"google.golang.org/protobuf/internal/pragma"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
type list interface {
|
||||
@@ -30,17 +30,17 @@ func formatListOpt(vs list, isRoot, allowMulti bool) string {
|
||||
if isRoot {
|
||||
var name string
|
||||
switch vs.(type) {
|
||||
case protoreflect.Names:
|
||||
case pref.Names:
|
||||
name = "Names"
|
||||
case protoreflect.FieldNumbers:
|
||||
case pref.FieldNumbers:
|
||||
name = "FieldNumbers"
|
||||
case protoreflect.FieldRanges:
|
||||
case pref.FieldRanges:
|
||||
name = "FieldRanges"
|
||||
case protoreflect.EnumRanges:
|
||||
case pref.EnumRanges:
|
||||
name = "EnumRanges"
|
||||
case protoreflect.FileImports:
|
||||
case pref.FileImports:
|
||||
name = "FileImports"
|
||||
case protoreflect.Descriptor:
|
||||
case pref.Descriptor:
|
||||
name = reflect.ValueOf(vs).MethodByName("Get").Type().Out(0).Name() + "s"
|
||||
default:
|
||||
name = reflect.ValueOf(vs).Elem().Type().Name()
|
||||
@@ -50,17 +50,17 @@ func formatListOpt(vs list, isRoot, allowMulti bool) string {
|
||||
|
||||
var ss []string
|
||||
switch vs := vs.(type) {
|
||||
case protoreflect.Names:
|
||||
case pref.Names:
|
||||
for i := 0; i < vs.Len(); i++ {
|
||||
ss = append(ss, fmt.Sprint(vs.Get(i)))
|
||||
}
|
||||
return start + joinStrings(ss, false) + end
|
||||
case protoreflect.FieldNumbers:
|
||||
case pref.FieldNumbers:
|
||||
for i := 0; i < vs.Len(); i++ {
|
||||
ss = append(ss, fmt.Sprint(vs.Get(i)))
|
||||
}
|
||||
return start + joinStrings(ss, false) + end
|
||||
case protoreflect.FieldRanges:
|
||||
case pref.FieldRanges:
|
||||
for i := 0; i < vs.Len(); i++ {
|
||||
r := vs.Get(i)
|
||||
if r[0]+1 == r[1] {
|
||||
@@ -70,7 +70,7 @@ func formatListOpt(vs list, isRoot, allowMulti bool) string {
|
||||
}
|
||||
}
|
||||
return start + joinStrings(ss, false) + end
|
||||
case protoreflect.EnumRanges:
|
||||
case pref.EnumRanges:
|
||||
for i := 0; i < vs.Len(); i++ {
|
||||
r := vs.Get(i)
|
||||
if r[0] == r[1] {
|
||||
@@ -80,44 +80,46 @@ func formatListOpt(vs list, isRoot, allowMulti bool) string {
|
||||
}
|
||||
}
|
||||
return start + joinStrings(ss, false) + end
|
||||
case protoreflect.FileImports:
|
||||
case pref.FileImports:
|
||||
for i := 0; i < vs.Len(); i++ {
|
||||
var rs records
|
||||
rv := reflect.ValueOf(vs.Get(i))
|
||||
rs.Append(rv, []methodAndName{
|
||||
{rv.MethodByName("Path"), "Path"},
|
||||
{rv.MethodByName("Package"), "Package"},
|
||||
{rv.MethodByName("IsPublic"), "IsPublic"},
|
||||
{rv.MethodByName("IsWeak"), "IsWeak"},
|
||||
}...)
|
||||
rs.Append(reflect.ValueOf(vs.Get(i)), "Path", "Package", "IsPublic", "IsWeak")
|
||||
ss = append(ss, "{"+rs.Join()+"}")
|
||||
}
|
||||
return start + joinStrings(ss, allowMulti) + end
|
||||
default:
|
||||
_, isEnumValue := vs.(protoreflect.EnumValueDescriptors)
|
||||
_, isEnumValue := vs.(pref.EnumValueDescriptors)
|
||||
for i := 0; i < vs.Len(); i++ {
|
||||
m := reflect.ValueOf(vs).MethodByName("Get")
|
||||
v := m.Call([]reflect.Value{reflect.ValueOf(i)})[0].Interface()
|
||||
ss = append(ss, formatDescOpt(v.(protoreflect.Descriptor), false, allowMulti && !isEnumValue, nil))
|
||||
ss = append(ss, formatDescOpt(v.(pref.Descriptor), false, allowMulti && !isEnumValue))
|
||||
}
|
||||
return start + joinStrings(ss, allowMulti && isEnumValue) + end
|
||||
}
|
||||
}
|
||||
|
||||
type methodAndName struct {
|
||||
method reflect.Value
|
||||
name string
|
||||
// descriptorAccessors is a list of accessors to print for each descriptor.
|
||||
//
|
||||
// Do not print all accessors since some contain redundant information,
|
||||
// while others are pointers that we do not want to follow since the descriptor
|
||||
// is actually a cyclic graph.
|
||||
//
|
||||
// Using a list allows us to print the accessors in a sensible order.
|
||||
var descriptorAccessors = map[reflect.Type][]string{
|
||||
reflect.TypeOf((*pref.FileDescriptor)(nil)).Elem(): {"Path", "Package", "Imports", "Messages", "Enums", "Extensions", "Services"},
|
||||
reflect.TypeOf((*pref.MessageDescriptor)(nil)).Elem(): {"IsMapEntry", "Fields", "Oneofs", "ReservedNames", "ReservedRanges", "RequiredNumbers", "ExtensionRanges", "Messages", "Enums", "Extensions"},
|
||||
reflect.TypeOf((*pref.FieldDescriptor)(nil)).Elem(): {"Number", "Cardinality", "Kind", "HasJSONName", "JSONName", "HasPresence", "IsExtension", "IsPacked", "IsWeak", "IsList", "IsMap", "MapKey", "MapValue", "HasDefault", "Default", "ContainingOneof", "ContainingMessage", "Message", "Enum"},
|
||||
reflect.TypeOf((*pref.OneofDescriptor)(nil)).Elem(): {"Fields"}, // not directly used; must keep in sync with formatDescOpt
|
||||
reflect.TypeOf((*pref.EnumDescriptor)(nil)).Elem(): {"Values", "ReservedNames", "ReservedRanges"},
|
||||
reflect.TypeOf((*pref.EnumValueDescriptor)(nil)).Elem(): {"Number"},
|
||||
reflect.TypeOf((*pref.ServiceDescriptor)(nil)).Elem(): {"Methods"},
|
||||
reflect.TypeOf((*pref.MethodDescriptor)(nil)).Elem(): {"Input", "Output", "IsStreamingClient", "IsStreamingServer"},
|
||||
}
|
||||
|
||||
func FormatDesc(s fmt.State, r rune, t protoreflect.Descriptor) {
|
||||
io.WriteString(s, formatDescOpt(t, true, r == 'v' && (s.Flag('+') || s.Flag('#')), nil))
|
||||
func FormatDesc(s fmt.State, r rune, t pref.Descriptor) {
|
||||
io.WriteString(s, formatDescOpt(t, true, r == 'v' && (s.Flag('+') || s.Flag('#'))))
|
||||
}
|
||||
|
||||
func InternalFormatDescOptForTesting(t protoreflect.Descriptor, isRoot, allowMulti bool, record func(string)) string {
|
||||
return formatDescOpt(t, isRoot, allowMulti, record)
|
||||
}
|
||||
|
||||
func formatDescOpt(t protoreflect.Descriptor, isRoot, allowMulti bool, record func(string)) string {
|
||||
func formatDescOpt(t pref.Descriptor, isRoot, allowMulti bool) string {
|
||||
rv := reflect.ValueOf(t)
|
||||
rt := rv.MethodByName("ProtoType").Type().In(0)
|
||||
|
||||
@@ -126,61 +128,27 @@ func formatDescOpt(t protoreflect.Descriptor, isRoot, allowMulti bool, record fu
|
||||
start = rt.Name() + "{"
|
||||
}
|
||||
|
||||
_, isFile := t.(protoreflect.FileDescriptor)
|
||||
rs := records{
|
||||
allowMulti: allowMulti,
|
||||
record: record,
|
||||
}
|
||||
_, isFile := t.(pref.FileDescriptor)
|
||||
rs := records{allowMulti: allowMulti}
|
||||
if t.IsPlaceholder() {
|
||||
if isFile {
|
||||
rs.Append(rv, []methodAndName{
|
||||
{rv.MethodByName("Path"), "Path"},
|
||||
{rv.MethodByName("Package"), "Package"},
|
||||
{rv.MethodByName("IsPlaceholder"), "IsPlaceholder"},
|
||||
}...)
|
||||
rs.Append(rv, "Path", "Package", "IsPlaceholder")
|
||||
} else {
|
||||
rs.Append(rv, []methodAndName{
|
||||
{rv.MethodByName("FullName"), "FullName"},
|
||||
{rv.MethodByName("IsPlaceholder"), "IsPlaceholder"},
|
||||
}...)
|
||||
rs.Append(rv, "FullName", "IsPlaceholder")
|
||||
}
|
||||
} else {
|
||||
switch {
|
||||
case isFile:
|
||||
rs.Append(rv, methodAndName{rv.MethodByName("Syntax"), "Syntax"})
|
||||
rs.Append(rv, "Syntax")
|
||||
case isRoot:
|
||||
rs.Append(rv, []methodAndName{
|
||||
{rv.MethodByName("Syntax"), "Syntax"},
|
||||
{rv.MethodByName("FullName"), "FullName"},
|
||||
}...)
|
||||
rs.Append(rv, "Syntax", "FullName")
|
||||
default:
|
||||
rs.Append(rv, methodAndName{rv.MethodByName("Name"), "Name"})
|
||||
rs.Append(rv, "Name")
|
||||
}
|
||||
switch t := t.(type) {
|
||||
case protoreflect.FieldDescriptor:
|
||||
accessors := []methodAndName{
|
||||
{rv.MethodByName("Number"), "Number"},
|
||||
{rv.MethodByName("Cardinality"), "Cardinality"},
|
||||
{rv.MethodByName("Kind"), "Kind"},
|
||||
{rv.MethodByName("HasJSONName"), "HasJSONName"},
|
||||
{rv.MethodByName("JSONName"), "JSONName"},
|
||||
{rv.MethodByName("HasPresence"), "HasPresence"},
|
||||
{rv.MethodByName("IsExtension"), "IsExtension"},
|
||||
{rv.MethodByName("IsPacked"), "IsPacked"},
|
||||
{rv.MethodByName("IsWeak"), "IsWeak"},
|
||||
{rv.MethodByName("IsList"), "IsList"},
|
||||
{rv.MethodByName("IsMap"), "IsMap"},
|
||||
{rv.MethodByName("MapKey"), "MapKey"},
|
||||
{rv.MethodByName("MapValue"), "MapValue"},
|
||||
{rv.MethodByName("HasDefault"), "HasDefault"},
|
||||
{rv.MethodByName("Default"), "Default"},
|
||||
{rv.MethodByName("ContainingOneof"), "ContainingOneof"},
|
||||
{rv.MethodByName("ContainingMessage"), "ContainingMessage"},
|
||||
{rv.MethodByName("Message"), "Message"},
|
||||
{rv.MethodByName("Enum"), "Enum"},
|
||||
}
|
||||
for _, s := range accessors {
|
||||
switch s.name {
|
||||
case pref.FieldDescriptor:
|
||||
for _, s := range descriptorAccessors[rt] {
|
||||
switch s {
|
||||
case "MapKey":
|
||||
if k := t.MapKey(); k != nil {
|
||||
rs.recs = append(rs.recs, [2]string{"MapKey", k.Kind().String()})
|
||||
@@ -188,21 +156,21 @@ func formatDescOpt(t protoreflect.Descriptor, isRoot, allowMulti bool, record fu
|
||||
case "MapValue":
|
||||
if v := t.MapValue(); v != nil {
|
||||
switch v.Kind() {
|
||||
case protoreflect.EnumKind:
|
||||
rs.AppendRecs("MapValue", [2]string{"MapValue", string(v.Enum().FullName())})
|
||||
case protoreflect.MessageKind, protoreflect.GroupKind:
|
||||
rs.AppendRecs("MapValue", [2]string{"MapValue", string(v.Message().FullName())})
|
||||
case pref.EnumKind:
|
||||
rs.recs = append(rs.recs, [2]string{"MapValue", string(v.Enum().FullName())})
|
||||
case pref.MessageKind, pref.GroupKind:
|
||||
rs.recs = append(rs.recs, [2]string{"MapValue", string(v.Message().FullName())})
|
||||
default:
|
||||
rs.AppendRecs("MapValue", [2]string{"MapValue", v.Kind().String()})
|
||||
rs.recs = append(rs.recs, [2]string{"MapValue", v.Kind().String()})
|
||||
}
|
||||
}
|
||||
case "ContainingOneof":
|
||||
if od := t.ContainingOneof(); od != nil {
|
||||
rs.AppendRecs("ContainingOneof", [2]string{"Oneof", string(od.Name())})
|
||||
rs.recs = append(rs.recs, [2]string{"Oneof", string(od.Name())})
|
||||
}
|
||||
case "ContainingMessage":
|
||||
if t.IsExtension() {
|
||||
rs.AppendRecs("ContainingMessage", [2]string{"Extendee", string(t.ContainingMessage().FullName())})
|
||||
rs.recs = append(rs.recs, [2]string{"Extendee", string(t.ContainingMessage().FullName())})
|
||||
}
|
||||
case "Message":
|
||||
if !t.IsMap() {
|
||||
@@ -212,68 +180,20 @@ func formatDescOpt(t protoreflect.Descriptor, isRoot, allowMulti bool, record fu
|
||||
rs.Append(rv, s)
|
||||
}
|
||||
}
|
||||
case protoreflect.OneofDescriptor:
|
||||
case pref.OneofDescriptor:
|
||||
var ss []string
|
||||
fs := t.Fields()
|
||||
for i := 0; i < fs.Len(); i++ {
|
||||
ss = append(ss, string(fs.Get(i).Name()))
|
||||
}
|
||||
if len(ss) > 0 {
|
||||
rs.AppendRecs("Fields", [2]string{"Fields", "[" + joinStrings(ss, false) + "]"})
|
||||
rs.recs = append(rs.recs, [2]string{"Fields", "[" + joinStrings(ss, false) + "]"})
|
||||
}
|
||||
|
||||
case protoreflect.FileDescriptor:
|
||||
rs.Append(rv, []methodAndName{
|
||||
{rv.MethodByName("Path"), "Path"},
|
||||
{rv.MethodByName("Package"), "Package"},
|
||||
{rv.MethodByName("Imports"), "Imports"},
|
||||
{rv.MethodByName("Messages"), "Messages"},
|
||||
{rv.MethodByName("Enums"), "Enums"},
|
||||
{rv.MethodByName("Extensions"), "Extensions"},
|
||||
{rv.MethodByName("Services"), "Services"},
|
||||
}...)
|
||||
|
||||
case protoreflect.MessageDescriptor:
|
||||
rs.Append(rv, []methodAndName{
|
||||
{rv.MethodByName("IsMapEntry"), "IsMapEntry"},
|
||||
{rv.MethodByName("Fields"), "Fields"},
|
||||
{rv.MethodByName("Oneofs"), "Oneofs"},
|
||||
{rv.MethodByName("ReservedNames"), "ReservedNames"},
|
||||
{rv.MethodByName("ReservedRanges"), "ReservedRanges"},
|
||||
{rv.MethodByName("RequiredNumbers"), "RequiredNumbers"},
|
||||
{rv.MethodByName("ExtensionRanges"), "ExtensionRanges"},
|
||||
{rv.MethodByName("Messages"), "Messages"},
|
||||
{rv.MethodByName("Enums"), "Enums"},
|
||||
{rv.MethodByName("Extensions"), "Extensions"},
|
||||
}...)
|
||||
|
||||
case protoreflect.EnumDescriptor:
|
||||
rs.Append(rv, []methodAndName{
|
||||
{rv.MethodByName("Values"), "Values"},
|
||||
{rv.MethodByName("ReservedNames"), "ReservedNames"},
|
||||
{rv.MethodByName("ReservedRanges"), "ReservedRanges"},
|
||||
}...)
|
||||
|
||||
case protoreflect.EnumValueDescriptor:
|
||||
rs.Append(rv, []methodAndName{
|
||||
{rv.MethodByName("Number"), "Number"},
|
||||
}...)
|
||||
|
||||
case protoreflect.ServiceDescriptor:
|
||||
rs.Append(rv, []methodAndName{
|
||||
{rv.MethodByName("Methods"), "Methods"},
|
||||
}...)
|
||||
|
||||
case protoreflect.MethodDescriptor:
|
||||
rs.Append(rv, []methodAndName{
|
||||
{rv.MethodByName("Input"), "Input"},
|
||||
{rv.MethodByName("Output"), "Output"},
|
||||
{rv.MethodByName("IsStreamingClient"), "IsStreamingClient"},
|
||||
{rv.MethodByName("IsStreamingServer"), "IsStreamingServer"},
|
||||
}...)
|
||||
default:
|
||||
rs.Append(rv, descriptorAccessors[rt]...)
|
||||
}
|
||||
if m := rv.MethodByName("GoType"); m.IsValid() {
|
||||
rs.Append(rv, methodAndName{m, "GoType"})
|
||||
if rv.MethodByName("GoType").IsValid() {
|
||||
rs.Append(rv, "GoType")
|
||||
}
|
||||
}
|
||||
return start + rs.Join() + end
|
||||
@@ -282,36 +202,21 @@ func formatDescOpt(t protoreflect.Descriptor, isRoot, allowMulti bool, record fu
|
||||
type records struct {
|
||||
recs [][2]string
|
||||
allowMulti bool
|
||||
|
||||
// record is a function that will be called for every Append() or
|
||||
// AppendRecs() call, to be used for testing with the
|
||||
// InternalFormatDescOptForTesting function.
|
||||
record func(string)
|
||||
}
|
||||
|
||||
func (rs *records) AppendRecs(fieldName string, newRecs [2]string) {
|
||||
if rs.record != nil {
|
||||
rs.record(fieldName)
|
||||
}
|
||||
rs.recs = append(rs.recs, newRecs)
|
||||
}
|
||||
|
||||
func (rs *records) Append(v reflect.Value, accessors ...methodAndName) {
|
||||
func (rs *records) Append(v reflect.Value, accessors ...string) {
|
||||
for _, a := range accessors {
|
||||
if rs.record != nil {
|
||||
rs.record(a.name)
|
||||
}
|
||||
var rv reflect.Value
|
||||
if a.method.IsValid() {
|
||||
rv = a.method.Call(nil)[0]
|
||||
if m := v.MethodByName(a); m.IsValid() {
|
||||
rv = m.Call(nil)[0]
|
||||
}
|
||||
if v.Kind() == reflect.Struct && !rv.IsValid() {
|
||||
rv = v.FieldByName(a.name)
|
||||
rv = v.FieldByName(a)
|
||||
}
|
||||
if !rv.IsValid() {
|
||||
panic(fmt.Sprintf("unknown accessor: %v.%s", v.Type(), a.name))
|
||||
panic(fmt.Sprintf("unknown accessor: %v.%s", v.Type(), a))
|
||||
}
|
||||
if _, ok := rv.Interface().(protoreflect.Value); ok {
|
||||
if _, ok := rv.Interface().(pref.Value); ok {
|
||||
rv = rv.MethodByName("Interface").Call(nil)[0]
|
||||
if !rv.IsNil() {
|
||||
rv = rv.Elem()
|
||||
@@ -345,9 +250,9 @@ func (rs *records) Append(v reflect.Value, accessors ...methodAndName) {
|
||||
switch v := v.(type) {
|
||||
case list:
|
||||
s = formatListOpt(v, false, rs.allowMulti)
|
||||
case protoreflect.FieldDescriptor, protoreflect.OneofDescriptor, protoreflect.EnumValueDescriptor, protoreflect.MethodDescriptor:
|
||||
s = string(v.(protoreflect.Descriptor).Name())
|
||||
case protoreflect.Descriptor:
|
||||
case pref.FieldDescriptor, pref.OneofDescriptor, pref.EnumValueDescriptor, pref.MethodDescriptor:
|
||||
s = string(v.(pref.Descriptor).Name())
|
||||
case pref.Descriptor:
|
||||
s = string(v.FullName())
|
||||
case string:
|
||||
s = strconv.Quote(v)
|
||||
@@ -356,7 +261,7 @@ func (rs *records) Append(v reflect.Value, accessors ...methodAndName) {
|
||||
default:
|
||||
s = fmt.Sprint(v)
|
||||
}
|
||||
rs.recs = append(rs.recs, [2]string{a.name, s})
|
||||
rs.recs = append(rs.recs, [2]string{a, s})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
12
vendor/google.golang.org/protobuf/internal/editiondefaults/defaults.go
generated
vendored
12
vendor/google.golang.org/protobuf/internal/editiondefaults/defaults.go
generated
vendored
@@ -1,12 +0,0 @@
|
||||
// Copyright 2024 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package editiondefaults contains the binary representation of the editions
|
||||
// defaults.
|
||||
package editiondefaults
|
||||
|
||||
import _ "embed"
|
||||
|
||||
//go:embed editions_defaults.binpb
|
||||
var Defaults []byte
|
||||
4
vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb
generated
vendored
4
vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb
generated
vendored
@@ -1,4 +0,0 @@
|
||||
|
||||
(0ж
|
||||
(0з
|
||||
(0и ж(и
|
||||
78
vendor/google.golang.org/protobuf/internal/encoding/defval/default.go
generated
vendored
78
vendor/google.golang.org/protobuf/internal/encoding/defval/default.go
generated
vendored
@@ -15,8 +15,8 @@ import (
|
||||
"strconv"
|
||||
|
||||
ptext "google.golang.org/protobuf/internal/encoding/text"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
errors "google.golang.org/protobuf/internal/errors"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
// Format is the serialization format used to represent the default value.
|
||||
@@ -35,56 +35,56 @@ const (
|
||||
|
||||
// Unmarshal deserializes the default string s according to the given kind k.
|
||||
// When k is an enum, a list of enum value descriptors must be provided.
|
||||
func Unmarshal(s string, k protoreflect.Kind, evs protoreflect.EnumValueDescriptors, f Format) (protoreflect.Value, protoreflect.EnumValueDescriptor, error) {
|
||||
func Unmarshal(s string, k pref.Kind, evs pref.EnumValueDescriptors, f Format) (pref.Value, pref.EnumValueDescriptor, error) {
|
||||
switch k {
|
||||
case protoreflect.BoolKind:
|
||||
case pref.BoolKind:
|
||||
if f == GoTag {
|
||||
switch s {
|
||||
case "1":
|
||||
return protoreflect.ValueOfBool(true), nil, nil
|
||||
return pref.ValueOfBool(true), nil, nil
|
||||
case "0":
|
||||
return protoreflect.ValueOfBool(false), nil, nil
|
||||
return pref.ValueOfBool(false), nil, nil
|
||||
}
|
||||
} else {
|
||||
switch s {
|
||||
case "true":
|
||||
return protoreflect.ValueOfBool(true), nil, nil
|
||||
return pref.ValueOfBool(true), nil, nil
|
||||
case "false":
|
||||
return protoreflect.ValueOfBool(false), nil, nil
|
||||
return pref.ValueOfBool(false), nil, nil
|
||||
}
|
||||
}
|
||||
case protoreflect.EnumKind:
|
||||
case pref.EnumKind:
|
||||
if f == GoTag {
|
||||
// Go tags use the numeric form of the enum value.
|
||||
if n, err := strconv.ParseInt(s, 10, 32); err == nil {
|
||||
if ev := evs.ByNumber(protoreflect.EnumNumber(n)); ev != nil {
|
||||
return protoreflect.ValueOfEnum(ev.Number()), ev, nil
|
||||
if ev := evs.ByNumber(pref.EnumNumber(n)); ev != nil {
|
||||
return pref.ValueOfEnum(ev.Number()), ev, nil
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Descriptor default_value use the enum identifier.
|
||||
ev := evs.ByName(protoreflect.Name(s))
|
||||
ev := evs.ByName(pref.Name(s))
|
||||
if ev != nil {
|
||||
return protoreflect.ValueOfEnum(ev.Number()), ev, nil
|
||||
return pref.ValueOfEnum(ev.Number()), ev, nil
|
||||
}
|
||||
}
|
||||
case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind:
|
||||
case pref.Int32Kind, pref.Sint32Kind, pref.Sfixed32Kind:
|
||||
if v, err := strconv.ParseInt(s, 10, 32); err == nil {
|
||||
return protoreflect.ValueOfInt32(int32(v)), nil, nil
|
||||
return pref.ValueOfInt32(int32(v)), nil, nil
|
||||
}
|
||||
case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind:
|
||||
case pref.Int64Kind, pref.Sint64Kind, pref.Sfixed64Kind:
|
||||
if v, err := strconv.ParseInt(s, 10, 64); err == nil {
|
||||
return protoreflect.ValueOfInt64(int64(v)), nil, nil
|
||||
return pref.ValueOfInt64(int64(v)), nil, nil
|
||||
}
|
||||
case protoreflect.Uint32Kind, protoreflect.Fixed32Kind:
|
||||
case pref.Uint32Kind, pref.Fixed32Kind:
|
||||
if v, err := strconv.ParseUint(s, 10, 32); err == nil {
|
||||
return protoreflect.ValueOfUint32(uint32(v)), nil, nil
|
||||
return pref.ValueOfUint32(uint32(v)), nil, nil
|
||||
}
|
||||
case protoreflect.Uint64Kind, protoreflect.Fixed64Kind:
|
||||
case pref.Uint64Kind, pref.Fixed64Kind:
|
||||
if v, err := strconv.ParseUint(s, 10, 64); err == nil {
|
||||
return protoreflect.ValueOfUint64(uint64(v)), nil, nil
|
||||
return pref.ValueOfUint64(uint64(v)), nil, nil
|
||||
}
|
||||
case protoreflect.FloatKind, protoreflect.DoubleKind:
|
||||
case pref.FloatKind, pref.DoubleKind:
|
||||
var v float64
|
||||
var err error
|
||||
switch s {
|
||||
@@ -98,29 +98,29 @@ func Unmarshal(s string, k protoreflect.Kind, evs protoreflect.EnumValueDescript
|
||||
v, err = strconv.ParseFloat(s, 64)
|
||||
}
|
||||
if err == nil {
|
||||
if k == protoreflect.FloatKind {
|
||||
return protoreflect.ValueOfFloat32(float32(v)), nil, nil
|
||||
if k == pref.FloatKind {
|
||||
return pref.ValueOfFloat32(float32(v)), nil, nil
|
||||
} else {
|
||||
return protoreflect.ValueOfFloat64(float64(v)), nil, nil
|
||||
return pref.ValueOfFloat64(float64(v)), nil, nil
|
||||
}
|
||||
}
|
||||
case protoreflect.StringKind:
|
||||
case pref.StringKind:
|
||||
// String values are already unescaped and can be used as is.
|
||||
return protoreflect.ValueOfString(s), nil, nil
|
||||
case protoreflect.BytesKind:
|
||||
return pref.ValueOfString(s), nil, nil
|
||||
case pref.BytesKind:
|
||||
if b, ok := unmarshalBytes(s); ok {
|
||||
return protoreflect.ValueOfBytes(b), nil, nil
|
||||
return pref.ValueOfBytes(b), nil, nil
|
||||
}
|
||||
}
|
||||
return protoreflect.Value{}, nil, errors.New("could not parse value for %v: %q", k, s)
|
||||
return pref.Value{}, nil, errors.New("could not parse value for %v: %q", k, s)
|
||||
}
|
||||
|
||||
// Marshal serializes v as the default string according to the given kind k.
|
||||
// When specifying the Descriptor format for an enum kind, the associated
|
||||
// enum value descriptor must be provided.
|
||||
func Marshal(v protoreflect.Value, ev protoreflect.EnumValueDescriptor, k protoreflect.Kind, f Format) (string, error) {
|
||||
func Marshal(v pref.Value, ev pref.EnumValueDescriptor, k pref.Kind, f Format) (string, error) {
|
||||
switch k {
|
||||
case protoreflect.BoolKind:
|
||||
case pref.BoolKind:
|
||||
if f == GoTag {
|
||||
if v.Bool() {
|
||||
return "1", nil
|
||||
@@ -134,17 +134,17 @@ func Marshal(v protoreflect.Value, ev protoreflect.EnumValueDescriptor, k protor
|
||||
return "false", nil
|
||||
}
|
||||
}
|
||||
case protoreflect.EnumKind:
|
||||
case pref.EnumKind:
|
||||
if f == GoTag {
|
||||
return strconv.FormatInt(int64(v.Enum()), 10), nil
|
||||
} else {
|
||||
return string(ev.Name()), nil
|
||||
}
|
||||
case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind, protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind:
|
||||
case pref.Int32Kind, pref.Sint32Kind, pref.Sfixed32Kind, pref.Int64Kind, pref.Sint64Kind, pref.Sfixed64Kind:
|
||||
return strconv.FormatInt(v.Int(), 10), nil
|
||||
case protoreflect.Uint32Kind, protoreflect.Fixed32Kind, protoreflect.Uint64Kind, protoreflect.Fixed64Kind:
|
||||
case pref.Uint32Kind, pref.Fixed32Kind, pref.Uint64Kind, pref.Fixed64Kind:
|
||||
return strconv.FormatUint(v.Uint(), 10), nil
|
||||
case protoreflect.FloatKind, protoreflect.DoubleKind:
|
||||
case pref.FloatKind, pref.DoubleKind:
|
||||
f := v.Float()
|
||||
switch {
|
||||
case math.IsInf(f, -1):
|
||||
@@ -154,16 +154,16 @@ func Marshal(v protoreflect.Value, ev protoreflect.EnumValueDescriptor, k protor
|
||||
case math.IsNaN(f):
|
||||
return "nan", nil
|
||||
default:
|
||||
if k == protoreflect.FloatKind {
|
||||
if k == pref.FloatKind {
|
||||
return strconv.FormatFloat(f, 'g', -1, 32), nil
|
||||
} else {
|
||||
return strconv.FormatFloat(f, 'g', -1, 64), nil
|
||||
}
|
||||
}
|
||||
case protoreflect.StringKind:
|
||||
case pref.StringKind:
|
||||
// String values are serialized as is without any escaping.
|
||||
return v.String(), nil
|
||||
case protoreflect.BytesKind:
|
||||
case pref.BytesKind:
|
||||
if s, ok := marshalBytes(v.Bytes()); ok {
|
||||
return s, nil
|
||||
}
|
||||
|
||||
7
vendor/google.golang.org/protobuf/internal/encoding/messageset/messageset.go
generated
vendored
7
vendor/google.golang.org/protobuf/internal/encoding/messageset/messageset.go
generated
vendored
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
// The MessageSet wire format is equivalent to a message defined as follows,
|
||||
@@ -33,7 +33,6 @@ const (
|
||||
// ExtensionName is the field name for extensions of MessageSet.
|
||||
//
|
||||
// A valid MessageSet extension must be of the form:
|
||||
//
|
||||
// message MyMessage {
|
||||
// extend proto2.bridge.MessageSet {
|
||||
// optional MyMessage message_set_extension = 1234;
|
||||
@@ -43,13 +42,13 @@ const (
|
||||
const ExtensionName = "message_set_extension"
|
||||
|
||||
// IsMessageSet returns whether the message uses the MessageSet wire format.
|
||||
func IsMessageSet(md protoreflect.MessageDescriptor) bool {
|
||||
func IsMessageSet(md pref.MessageDescriptor) bool {
|
||||
xmd, ok := md.(interface{ IsMessageSet() bool })
|
||||
return ok && xmd.IsMessageSet()
|
||||
}
|
||||
|
||||
// IsMessageSetExtension reports this field properly extends a MessageSet.
|
||||
func IsMessageSetExtension(fd protoreflect.FieldDescriptor) bool {
|
||||
func IsMessageSetExtension(fd pref.FieldDescriptor) bool {
|
||||
switch {
|
||||
case fd.Name() != ExtensionName:
|
||||
return false
|
||||
|
||||
96
vendor/google.golang.org/protobuf/internal/encoding/tag/tag.go
generated
vendored
96
vendor/google.golang.org/protobuf/internal/encoding/tag/tag.go
generated
vendored
@@ -11,10 +11,10 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"google.golang.org/protobuf/internal/encoding/defval"
|
||||
"google.golang.org/protobuf/internal/filedesc"
|
||||
defval "google.golang.org/protobuf/internal/encoding/defval"
|
||||
fdesc "google.golang.org/protobuf/internal/filedesc"
|
||||
"google.golang.org/protobuf/internal/strs"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
var byteType = reflect.TypeOf(byte(0))
|
||||
@@ -29,9 +29,9 @@ var byteType = reflect.TypeOf(byte(0))
|
||||
// This does not populate the Enum or Message (except for weak message).
|
||||
//
|
||||
// This function is a best effort attempt; parsing errors are ignored.
|
||||
func Unmarshal(tag string, goType reflect.Type, evs protoreflect.EnumValueDescriptors) protoreflect.FieldDescriptor {
|
||||
f := new(filedesc.Field)
|
||||
f.L0.ParentFile = filedesc.SurrogateProto2
|
||||
func Unmarshal(tag string, goType reflect.Type, evs pref.EnumValueDescriptors) pref.FieldDescriptor {
|
||||
f := new(fdesc.Field)
|
||||
f.L0.ParentFile = fdesc.SurrogateProto2
|
||||
for len(tag) > 0 {
|
||||
i := strings.IndexByte(tag, ',')
|
||||
if i < 0 {
|
||||
@@ -39,68 +39,68 @@ func Unmarshal(tag string, goType reflect.Type, evs protoreflect.EnumValueDescri
|
||||
}
|
||||
switch s := tag[:i]; {
|
||||
case strings.HasPrefix(s, "name="):
|
||||
f.L0.FullName = protoreflect.FullName(s[len("name="):])
|
||||
f.L0.FullName = pref.FullName(s[len("name="):])
|
||||
case strings.Trim(s, "0123456789") == "":
|
||||
n, _ := strconv.ParseUint(s, 10, 32)
|
||||
f.L1.Number = protoreflect.FieldNumber(n)
|
||||
f.L1.Number = pref.FieldNumber(n)
|
||||
case s == "opt":
|
||||
f.L1.Cardinality = protoreflect.Optional
|
||||
f.L1.Cardinality = pref.Optional
|
||||
case s == "req":
|
||||
f.L1.Cardinality = protoreflect.Required
|
||||
f.L1.Cardinality = pref.Required
|
||||
case s == "rep":
|
||||
f.L1.Cardinality = protoreflect.Repeated
|
||||
f.L1.Cardinality = pref.Repeated
|
||||
case s == "varint":
|
||||
switch goType.Kind() {
|
||||
case reflect.Bool:
|
||||
f.L1.Kind = protoreflect.BoolKind
|
||||
f.L1.Kind = pref.BoolKind
|
||||
case reflect.Int32:
|
||||
f.L1.Kind = protoreflect.Int32Kind
|
||||
f.L1.Kind = pref.Int32Kind
|
||||
case reflect.Int64:
|
||||
f.L1.Kind = protoreflect.Int64Kind
|
||||
f.L1.Kind = pref.Int64Kind
|
||||
case reflect.Uint32:
|
||||
f.L1.Kind = protoreflect.Uint32Kind
|
||||
f.L1.Kind = pref.Uint32Kind
|
||||
case reflect.Uint64:
|
||||
f.L1.Kind = protoreflect.Uint64Kind
|
||||
f.L1.Kind = pref.Uint64Kind
|
||||
}
|
||||
case s == "zigzag32":
|
||||
if goType.Kind() == reflect.Int32 {
|
||||
f.L1.Kind = protoreflect.Sint32Kind
|
||||
f.L1.Kind = pref.Sint32Kind
|
||||
}
|
||||
case s == "zigzag64":
|
||||
if goType.Kind() == reflect.Int64 {
|
||||
f.L1.Kind = protoreflect.Sint64Kind
|
||||
f.L1.Kind = pref.Sint64Kind
|
||||
}
|
||||
case s == "fixed32":
|
||||
switch goType.Kind() {
|
||||
case reflect.Int32:
|
||||
f.L1.Kind = protoreflect.Sfixed32Kind
|
||||
f.L1.Kind = pref.Sfixed32Kind
|
||||
case reflect.Uint32:
|
||||
f.L1.Kind = protoreflect.Fixed32Kind
|
||||
f.L1.Kind = pref.Fixed32Kind
|
||||
case reflect.Float32:
|
||||
f.L1.Kind = protoreflect.FloatKind
|
||||
f.L1.Kind = pref.FloatKind
|
||||
}
|
||||
case s == "fixed64":
|
||||
switch goType.Kind() {
|
||||
case reflect.Int64:
|
||||
f.L1.Kind = protoreflect.Sfixed64Kind
|
||||
f.L1.Kind = pref.Sfixed64Kind
|
||||
case reflect.Uint64:
|
||||
f.L1.Kind = protoreflect.Fixed64Kind
|
||||
f.L1.Kind = pref.Fixed64Kind
|
||||
case reflect.Float64:
|
||||
f.L1.Kind = protoreflect.DoubleKind
|
||||
f.L1.Kind = pref.DoubleKind
|
||||
}
|
||||
case s == "bytes":
|
||||
switch {
|
||||
case goType.Kind() == reflect.String:
|
||||
f.L1.Kind = protoreflect.StringKind
|
||||
f.L1.Kind = pref.StringKind
|
||||
case goType.Kind() == reflect.Slice && goType.Elem() == byteType:
|
||||
f.L1.Kind = protoreflect.BytesKind
|
||||
f.L1.Kind = pref.BytesKind
|
||||
default:
|
||||
f.L1.Kind = protoreflect.MessageKind
|
||||
f.L1.Kind = pref.MessageKind
|
||||
}
|
||||
case s == "group":
|
||||
f.L1.Kind = protoreflect.GroupKind
|
||||
f.L1.Kind = pref.GroupKind
|
||||
case strings.HasPrefix(s, "enum="):
|
||||
f.L1.Kind = protoreflect.EnumKind
|
||||
f.L1.Kind = pref.EnumKind
|
||||
case strings.HasPrefix(s, "json="):
|
||||
jsonName := s[len("json="):]
|
||||
if jsonName != strs.JSONCamelCase(string(f.L0.FullName.Name())) {
|
||||
@@ -111,23 +111,23 @@ func Unmarshal(tag string, goType reflect.Type, evs protoreflect.EnumValueDescri
|
||||
f.L1.IsPacked = true
|
||||
case strings.HasPrefix(s, "weak="):
|
||||
f.L1.IsWeak = true
|
||||
f.L1.Message = filedesc.PlaceholderMessage(protoreflect.FullName(s[len("weak="):]))
|
||||
f.L1.Message = fdesc.PlaceholderMessage(pref.FullName(s[len("weak="):]))
|
||||
case strings.HasPrefix(s, "def="):
|
||||
// The default tag is special in that everything afterwards is the
|
||||
// default regardless of the presence of commas.
|
||||
s, i = tag[len("def="):], len(tag)
|
||||
v, ev, _ := defval.Unmarshal(s, f.L1.Kind, evs, defval.GoTag)
|
||||
f.L1.Default = filedesc.DefaultValue(v, ev)
|
||||
f.L1.Default = fdesc.DefaultValue(v, ev)
|
||||
case s == "proto3":
|
||||
f.L0.ParentFile = filedesc.SurrogateProto3
|
||||
f.L0.ParentFile = fdesc.SurrogateProto3
|
||||
}
|
||||
tag = strings.TrimPrefix(tag[i:], ",")
|
||||
}
|
||||
|
||||
// The generator uses the group message name instead of the field name.
|
||||
// We obtain the real field name by lowercasing the group name.
|
||||
if f.L1.Kind == protoreflect.GroupKind {
|
||||
f.L0.FullName = protoreflect.FullName(strings.ToLower(string(f.L0.FullName)))
|
||||
if f.L1.Kind == pref.GroupKind {
|
||||
f.L0.FullName = pref.FullName(strings.ToLower(string(f.L0.FullName)))
|
||||
}
|
||||
return f
|
||||
}
|
||||
@@ -140,38 +140,38 @@ func Unmarshal(tag string, goType reflect.Type, evs protoreflect.EnumValueDescri
|
||||
// Depending on the context on how Marshal is called, there are different ways
|
||||
// through which that information is determined. As such it is the caller's
|
||||
// responsibility to provide a function to obtain that information.
|
||||
func Marshal(fd protoreflect.FieldDescriptor, enumName string) string {
|
||||
func Marshal(fd pref.FieldDescriptor, enumName string) string {
|
||||
var tag []string
|
||||
switch fd.Kind() {
|
||||
case protoreflect.BoolKind, protoreflect.EnumKind, protoreflect.Int32Kind, protoreflect.Uint32Kind, protoreflect.Int64Kind, protoreflect.Uint64Kind:
|
||||
case pref.BoolKind, pref.EnumKind, pref.Int32Kind, pref.Uint32Kind, pref.Int64Kind, pref.Uint64Kind:
|
||||
tag = append(tag, "varint")
|
||||
case protoreflect.Sint32Kind:
|
||||
case pref.Sint32Kind:
|
||||
tag = append(tag, "zigzag32")
|
||||
case protoreflect.Sint64Kind:
|
||||
case pref.Sint64Kind:
|
||||
tag = append(tag, "zigzag64")
|
||||
case protoreflect.Sfixed32Kind, protoreflect.Fixed32Kind, protoreflect.FloatKind:
|
||||
case pref.Sfixed32Kind, pref.Fixed32Kind, pref.FloatKind:
|
||||
tag = append(tag, "fixed32")
|
||||
case protoreflect.Sfixed64Kind, protoreflect.Fixed64Kind, protoreflect.DoubleKind:
|
||||
case pref.Sfixed64Kind, pref.Fixed64Kind, pref.DoubleKind:
|
||||
tag = append(tag, "fixed64")
|
||||
case protoreflect.StringKind, protoreflect.BytesKind, protoreflect.MessageKind:
|
||||
case pref.StringKind, pref.BytesKind, pref.MessageKind:
|
||||
tag = append(tag, "bytes")
|
||||
case protoreflect.GroupKind:
|
||||
case pref.GroupKind:
|
||||
tag = append(tag, "group")
|
||||
}
|
||||
tag = append(tag, strconv.Itoa(int(fd.Number())))
|
||||
switch fd.Cardinality() {
|
||||
case protoreflect.Optional:
|
||||
case pref.Optional:
|
||||
tag = append(tag, "opt")
|
||||
case protoreflect.Required:
|
||||
case pref.Required:
|
||||
tag = append(tag, "req")
|
||||
case protoreflect.Repeated:
|
||||
case pref.Repeated:
|
||||
tag = append(tag, "rep")
|
||||
}
|
||||
if fd.IsPacked() {
|
||||
tag = append(tag, "packed")
|
||||
}
|
||||
name := string(fd.Name())
|
||||
if fd.Kind() == protoreflect.GroupKind {
|
||||
if fd.Kind() == pref.GroupKind {
|
||||
// The name of the FieldDescriptor for a group field is
|
||||
// lowercased. To find the original capitalization, we
|
||||
// look in the field's MessageType.
|
||||
@@ -189,10 +189,10 @@ func Marshal(fd protoreflect.FieldDescriptor, enumName string) string {
|
||||
// The previous implementation does not tag extension fields as proto3,
|
||||
// even when the field is defined in a proto3 file. Match that behavior
|
||||
// for consistency.
|
||||
if fd.Syntax() == protoreflect.Proto3 && !fd.IsExtension() {
|
||||
if fd.Syntax() == pref.Proto3 && !fd.IsExtension() {
|
||||
tag = append(tag, "proto3")
|
||||
}
|
||||
if fd.Kind() == protoreflect.EnumKind && enumName != "" {
|
||||
if fd.Kind() == pref.EnumKind && enumName != "" {
|
||||
tag = append(tag, "enum="+enumName)
|
||||
}
|
||||
if fd.ContainingOneof() != nil {
|
||||
|
||||
37
vendor/google.golang.org/protobuf/internal/encoding/text/decode.go
generated
vendored
37
vendor/google.golang.org/protobuf/internal/encoding/text/decode.go
generated
vendored
@@ -8,6 +8,7 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"unicode/utf8"
|
||||
|
||||
@@ -380,7 +381,7 @@ func (d *Decoder) currentOpenKind() (Kind, byte) {
|
||||
case '[':
|
||||
return ListOpen, ']'
|
||||
}
|
||||
panic(fmt.Sprintf("Decoder: openStack contains invalid byte %c", openCh))
|
||||
panic(fmt.Sprintf("Decoder: openStack contains invalid byte %s", string(openCh)))
|
||||
}
|
||||
|
||||
func (d *Decoder) pushOpenStack(ch byte) {
|
||||
@@ -412,16 +413,15 @@ func (d *Decoder) parseFieldName() (tok Token, err error) {
|
||||
// Field number. Identify if input is a valid number that is not negative
|
||||
// and is decimal integer within 32-bit range.
|
||||
if num := parseNumber(d.in); num.size > 0 {
|
||||
str := num.string(d.in)
|
||||
if !num.neg && num.kind == numDec {
|
||||
if _, err := strconv.ParseInt(str, 10, 32); err == nil {
|
||||
if _, err := strconv.ParseInt(string(d.in[:num.size]), 10, 32); err == nil {
|
||||
return d.consumeToken(Name, num.size, uint8(FieldNumber)), nil
|
||||
}
|
||||
}
|
||||
return Token{}, d.newSyntaxError("invalid field number: %s", str)
|
||||
return Token{}, d.newSyntaxError("invalid field number: %s", d.in[:num.size])
|
||||
}
|
||||
|
||||
return Token{}, d.newSyntaxError("invalid field name: %s", errId(d.in))
|
||||
return Token{}, d.newSyntaxError("invalid field name: %s", errRegexp.Find(d.in))
|
||||
}
|
||||
|
||||
// parseTypeName parses Any type URL or extension field name. The name is
|
||||
@@ -571,7 +571,7 @@ func (d *Decoder) parseScalar() (Token, error) {
|
||||
return tok, nil
|
||||
}
|
||||
|
||||
return Token{}, d.newSyntaxError("invalid scalar value: %s", errId(d.in))
|
||||
return Token{}, d.newSyntaxError("invalid scalar value: %s", errRegexp.Find(d.in))
|
||||
}
|
||||
|
||||
// parseLiteralValue parses a literal value. A literal value is used for
|
||||
@@ -653,29 +653,8 @@ func consume(b []byte, n int) []byte {
|
||||
return b
|
||||
}
|
||||
|
||||
// errId extracts a byte sequence that looks like an invalid ID
|
||||
// (for the purposes of error reporting).
|
||||
func errId(seq []byte) []byte {
|
||||
const maxLen = 32
|
||||
for i := 0; i < len(seq); {
|
||||
if i > maxLen {
|
||||
return append(seq[:i:i], "…"...)
|
||||
}
|
||||
r, size := utf8.DecodeRune(seq[i:])
|
||||
if r > utf8.RuneSelf || (r != '/' && isDelim(byte(r))) {
|
||||
if i == 0 {
|
||||
// Either the first byte is invalid UTF-8 or a
|
||||
// delimiter, or the first rune is non-ASCII.
|
||||
// Return it as-is.
|
||||
i = size
|
||||
}
|
||||
return seq[:i:i]
|
||||
}
|
||||
i += size
|
||||
}
|
||||
// No delimiter found.
|
||||
return seq
|
||||
}
|
||||
// Any sequence that looks like a non-delimiter (for error reporting).
|
||||
var errRegexp = regexp.MustCompile(`^([-+._a-zA-Z0-9\/]+|.)`)
|
||||
|
||||
// isDelim returns true if given byte is a delimiter character.
|
||||
func isDelim(c byte) bool {
|
||||
|
||||
49
vendor/google.golang.org/protobuf/internal/encoding/text/decode_number.go
generated
vendored
49
vendor/google.golang.org/protobuf/internal/encoding/text/decode_number.go
generated
vendored
@@ -15,12 +15,17 @@ func (d *Decoder) parseNumberValue() (Token, bool) {
|
||||
if num.neg {
|
||||
numAttrs |= isNegative
|
||||
}
|
||||
strSize := num.size
|
||||
last := num.size - 1
|
||||
if num.kind == numFloat && (d.in[last] == 'f' || d.in[last] == 'F') {
|
||||
strSize = last
|
||||
}
|
||||
tok := Token{
|
||||
kind: Scalar,
|
||||
attrs: numberValue,
|
||||
pos: len(d.orig) - len(d.in),
|
||||
raw: d.in[:num.size],
|
||||
str: num.string(d.in),
|
||||
str: string(d.in[:strSize]),
|
||||
numAttrs: numAttrs,
|
||||
}
|
||||
d.consume(num.size)
|
||||
@@ -41,35 +46,12 @@ type number struct {
|
||||
kind uint8
|
||||
neg bool
|
||||
size int
|
||||
// if neg, this is the length of whitespace and comments between
|
||||
// the minus sign and the rest fo the number literal
|
||||
sep int
|
||||
}
|
||||
|
||||
func (num number) string(data []byte) string {
|
||||
strSize := num.size
|
||||
last := num.size - 1
|
||||
if num.kind == numFloat && (data[last] == 'f' || data[last] == 'F') {
|
||||
strSize = last
|
||||
}
|
||||
if num.neg && num.sep > 0 {
|
||||
// strip whitespace/comments between negative sign and the rest
|
||||
strLen := strSize - num.sep
|
||||
str := make([]byte, strLen)
|
||||
str[0] = data[0]
|
||||
copy(str[1:], data[num.sep+1:strSize])
|
||||
return string(str)
|
||||
}
|
||||
return string(data[:strSize])
|
||||
|
||||
}
|
||||
|
||||
// parseNumber constructs a number object from given input. It allows for the
|
||||
// following patterns:
|
||||
//
|
||||
// integer: ^-?([1-9][0-9]*|0[xX][0-9a-fA-F]+|0[0-7]*)
|
||||
// float: ^-?((0|[1-9][0-9]*)?([.][0-9]*)?([eE][+-]?[0-9]+)?[fF]?)
|
||||
//
|
||||
// integer: ^-?([1-9][0-9]*|0[xX][0-9a-fA-F]+|0[0-7]*)
|
||||
// float: ^-?((0|[1-9][0-9]*)?([.][0-9]*)?([eE][+-]?[0-9]+)?[fF]?)
|
||||
// It also returns the number of parsed bytes for the given number, 0 if it is
|
||||
// not a number.
|
||||
func parseNumber(input []byte) number {
|
||||
@@ -83,22 +65,19 @@ func parseNumber(input []byte) number {
|
||||
}
|
||||
|
||||
// Optional -
|
||||
var sep int
|
||||
if s[0] == '-' {
|
||||
neg = true
|
||||
s = s[1:]
|
||||
size++
|
||||
// Consume any whitespace or comments between the
|
||||
// negative sign and the rest of the number
|
||||
lenBefore := len(s)
|
||||
s = consume(s, 0)
|
||||
sep = lenBefore - len(s)
|
||||
size += sep
|
||||
if len(s) == 0 {
|
||||
return number{}
|
||||
}
|
||||
}
|
||||
|
||||
// C++ allows for whitespace and comments in between the negative sign and
|
||||
// the rest of the number. This logic currently does not but is consistent
|
||||
// with v1.
|
||||
|
||||
switch {
|
||||
case s[0] == '0':
|
||||
if len(s) > 1 {
|
||||
@@ -135,7 +114,7 @@ func parseNumber(input []byte) number {
|
||||
if len(s) > 0 && !isDelim(s[0]) {
|
||||
return number{}
|
||||
}
|
||||
return number{kind: kind, neg: neg, size: size, sep: sep}
|
||||
return number{kind: kind, neg: neg, size: size}
|
||||
}
|
||||
}
|
||||
s = s[1:]
|
||||
@@ -207,5 +186,5 @@ func parseNumber(input []byte) number {
|
||||
return number{}
|
||||
}
|
||||
|
||||
return number{kind: kind, neg: neg, size: size, sep: sep}
|
||||
return number{kind: kind, neg: neg, size: size}
|
||||
}
|
||||
|
||||
4
vendor/google.golang.org/protobuf/internal/encoding/text/doc.go
generated
vendored
4
vendor/google.golang.org/protobuf/internal/encoding/text/doc.go
generated
vendored
@@ -24,6 +24,6 @@
|
||||
// the Go implementation should as well.
|
||||
//
|
||||
// The text format is almost a superset of JSON except:
|
||||
// - message keys are not quoted strings, but identifiers
|
||||
// - the top-level value must be a message without the delimiters
|
||||
// * message keys are not quoted strings, but identifiers
|
||||
// * the top-level value must be a message without the delimiters
|
||||
package text
|
||||
|
||||
15
vendor/google.golang.org/protobuf/internal/encoding/text/encode.go
generated
vendored
15
vendor/google.golang.org/protobuf/internal/encoding/text/encode.go
generated
vendored
@@ -53,10 +53,8 @@ type encoderState struct {
|
||||
// If outputASCII is true, strings will be serialized in such a way that
|
||||
// multi-byte UTF-8 sequences are escaped. This property ensures that the
|
||||
// overall output is ASCII (as opposed to UTF-8).
|
||||
func NewEncoder(buf []byte, indent string, delims [2]byte, outputASCII bool) (*Encoder, error) {
|
||||
e := &Encoder{
|
||||
encoderState: encoderState{out: buf},
|
||||
}
|
||||
func NewEncoder(indent string, delims [2]byte, outputASCII bool) (*Encoder, error) {
|
||||
e := &Encoder{}
|
||||
if len(indent) > 0 {
|
||||
if strings.Trim(indent, " \t") != "" {
|
||||
return nil, errors.New("indent may only be composed of space and tab characters")
|
||||
@@ -197,13 +195,13 @@ func appendFloat(out []byte, n float64, bitSize int) []byte {
|
||||
// WriteInt writes out the given signed integer value.
|
||||
func (e *Encoder) WriteInt(n int64) {
|
||||
e.prepareNext(scalar)
|
||||
e.out = strconv.AppendInt(e.out, n, 10)
|
||||
e.out = append(e.out, strconv.FormatInt(n, 10)...)
|
||||
}
|
||||
|
||||
// WriteUint writes out the given unsigned integer value.
|
||||
func (e *Encoder) WriteUint(n uint64) {
|
||||
e.prepareNext(scalar)
|
||||
e.out = strconv.AppendUint(e.out, n, 10)
|
||||
e.out = append(e.out, strconv.FormatUint(n, 10)...)
|
||||
}
|
||||
|
||||
// WriteLiteral writes out the given string as a literal value without quotes.
|
||||
@@ -265,8 +263,3 @@ func (e *Encoder) Snapshot() encoderState {
|
||||
func (e *Encoder) Reset(es encoderState) {
|
||||
e.encoderState = es
|
||||
}
|
||||
|
||||
// AppendString appends the escaped form of the input string to b.
|
||||
func AppendString(b []byte, s string) []byte {
|
||||
return appendString(b, s, false)
|
||||
}
|
||||
|
||||
1
vendor/google.golang.org/protobuf/internal/errors/is_go112.go
generated
vendored
1
vendor/google.golang.org/protobuf/internal/errors/is_go112.go
generated
vendored
@@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !go1.13
|
||||
// +build !go1.13
|
||||
|
||||
package errors
|
||||
|
||||
1
vendor/google.golang.org/protobuf/internal/errors/is_go113.go
generated
vendored
1
vendor/google.golang.org/protobuf/internal/errors/is_go113.go
generated
vendored
@@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build go1.13
|
||||
// +build go1.13
|
||||
|
||||
package errors
|
||||
|
||||
19
vendor/google.golang.org/protobuf/internal/filedesc/build.go
generated
vendored
19
vendor/google.golang.org/protobuf/internal/filedesc/build.go
generated
vendored
@@ -12,7 +12,8 @@ import (
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
preg "google.golang.org/protobuf/reflect/protoregistry"
|
||||
)
|
||||
|
||||
// Builder construct a protoreflect.FileDescriptor from the raw descriptor.
|
||||
@@ -37,7 +38,7 @@ type Builder struct {
|
||||
// TypeResolver resolves extension field types for descriptor options.
|
||||
// If nil, it uses protoregistry.GlobalTypes.
|
||||
TypeResolver interface {
|
||||
protoregistry.ExtensionTypeResolver
|
||||
preg.ExtensionTypeResolver
|
||||
}
|
||||
|
||||
// FileRegistry is use to lookup file, enum, and message dependencies.
|
||||
@@ -45,8 +46,8 @@ type Builder struct {
|
||||
// If nil, it uses protoregistry.GlobalFiles.
|
||||
FileRegistry interface {
|
||||
FindFileByPath(string) (protoreflect.FileDescriptor, error)
|
||||
FindDescriptorByName(protoreflect.FullName) (protoreflect.Descriptor, error)
|
||||
RegisterFile(protoreflect.FileDescriptor) error
|
||||
FindDescriptorByName(pref.FullName) (pref.Descriptor, error)
|
||||
RegisterFile(pref.FileDescriptor) error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,8 +55,8 @@ type Builder struct {
|
||||
// If so, it permits looking up an enum or message dependency based on the
|
||||
// sub-list and element index into filetype.Builder.DependencyIndexes.
|
||||
type resolverByIndex interface {
|
||||
FindEnumByIndex(int32, int32, []Enum, []Message) protoreflect.EnumDescriptor
|
||||
FindMessageByIndex(int32, int32, []Enum, []Message) protoreflect.MessageDescriptor
|
||||
FindEnumByIndex(int32, int32, []Enum, []Message) pref.EnumDescriptor
|
||||
FindMessageByIndex(int32, int32, []Enum, []Message) pref.MessageDescriptor
|
||||
}
|
||||
|
||||
// Indexes of each sub-list in filetype.Builder.DependencyIndexes.
|
||||
@@ -69,7 +70,7 @@ const (
|
||||
|
||||
// Out is the output of the Builder.
|
||||
type Out struct {
|
||||
File protoreflect.FileDescriptor
|
||||
File pref.FileDescriptor
|
||||
|
||||
// Enums is all enum descriptors in "flattened ordering".
|
||||
Enums []Enum
|
||||
@@ -96,10 +97,10 @@ func (db Builder) Build() (out Out) {
|
||||
|
||||
// Initialize resolvers and registries if unpopulated.
|
||||
if db.TypeResolver == nil {
|
||||
db.TypeResolver = protoregistry.GlobalTypes
|
||||
db.TypeResolver = preg.GlobalTypes
|
||||
}
|
||||
if db.FileRegistry == nil {
|
||||
db.FileRegistry = protoregistry.GlobalFiles
|
||||
db.FileRegistry = preg.GlobalFiles
|
||||
}
|
||||
|
||||
fd := newRawFile(db)
|
||||
|
||||
458
vendor/google.golang.org/protobuf/internal/filedesc/desc.go
generated
vendored
458
vendor/google.golang.org/protobuf/internal/filedesc/desc.go
generated
vendored
@@ -17,30 +17,15 @@ import (
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/internal/pragma"
|
||||
"google.golang.org/protobuf/internal/strs"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
)
|
||||
|
||||
// Edition is an Enum for proto2.Edition
|
||||
type Edition int32
|
||||
|
||||
// These values align with the value of Enum in descriptor.proto which allows
|
||||
// direct conversion between the proto enum and this enum.
|
||||
const (
|
||||
EditionUnknown Edition = 0
|
||||
EditionProto2 Edition = 998
|
||||
EditionProto3 Edition = 999
|
||||
Edition2023 Edition = 1000
|
||||
EditionUnsupported Edition = 100000
|
||||
)
|
||||
|
||||
// The types in this file may have a suffix:
|
||||
// • L0: Contains fields common to all descriptors (except File) and
|
||||
// must be initialized up front.
|
||||
// • L1: Contains fields specific to a descriptor and
|
||||
// must be initialized up front. If the associated proto uses Editions, the
|
||||
// Editions features must always be resolved. If not explicitly set, the
|
||||
// appropriate default must be resolved and set.
|
||||
// must be initialized up front.
|
||||
// • L2: Contains fields that are lazily initialized when constructing
|
||||
// from the raw file descriptor. When constructing as a literal, the L2
|
||||
// fields must be initialized up front.
|
||||
@@ -58,76 +43,46 @@ type (
|
||||
L2 *FileL2
|
||||
}
|
||||
FileL1 struct {
|
||||
Syntax protoreflect.Syntax
|
||||
Edition Edition // Only used if Syntax == Editions
|
||||
Syntax pref.Syntax
|
||||
Path string
|
||||
Package protoreflect.FullName
|
||||
Package pref.FullName
|
||||
|
||||
Enums Enums
|
||||
Messages Messages
|
||||
Extensions Extensions
|
||||
Services Services
|
||||
|
||||
EditionFeatures EditionFeatures
|
||||
}
|
||||
FileL2 struct {
|
||||
Options func() protoreflect.ProtoMessage
|
||||
Options func() pref.ProtoMessage
|
||||
Imports FileImports
|
||||
Locations SourceLocations
|
||||
}
|
||||
|
||||
EditionFeatures struct {
|
||||
// IsFieldPresence is true if field_presence is EXPLICIT
|
||||
// https://protobuf.dev/editions/features/#field_presence
|
||||
IsFieldPresence bool
|
||||
// IsFieldPresence is true if field_presence is LEGACY_REQUIRED
|
||||
// https://protobuf.dev/editions/features/#field_presence
|
||||
IsLegacyRequired bool
|
||||
// IsOpenEnum is true if enum_type is OPEN
|
||||
// https://protobuf.dev/editions/features/#enum_type
|
||||
IsOpenEnum bool
|
||||
// IsPacked is true if repeated_field_encoding is PACKED
|
||||
// https://protobuf.dev/editions/features/#repeated_field_encoding
|
||||
IsPacked bool
|
||||
// IsUTF8Validated is true if utf_validation is VERIFY
|
||||
// https://protobuf.dev/editions/features/#utf8_validation
|
||||
IsUTF8Validated bool
|
||||
// IsDelimitedEncoded is true if message_encoding is DELIMITED
|
||||
// https://protobuf.dev/editions/features/#message_encoding
|
||||
IsDelimitedEncoded bool
|
||||
// IsJSONCompliant is true if json_format is ALLOW
|
||||
// https://protobuf.dev/editions/features/#json_format
|
||||
IsJSONCompliant bool
|
||||
// GenerateLegacyUnmarshalJSON determines if the plugin generates the
|
||||
// UnmarshalJSON([]byte) error method for enums.
|
||||
GenerateLegacyUnmarshalJSON bool
|
||||
}
|
||||
)
|
||||
|
||||
func (fd *File) ParentFile() protoreflect.FileDescriptor { return fd }
|
||||
func (fd *File) Parent() protoreflect.Descriptor { return nil }
|
||||
func (fd *File) Index() int { return 0 }
|
||||
func (fd *File) Syntax() protoreflect.Syntax { return fd.L1.Syntax }
|
||||
func (fd *File) Name() protoreflect.Name { return fd.L1.Package.Name() }
|
||||
func (fd *File) FullName() protoreflect.FullName { return fd.L1.Package }
|
||||
func (fd *File) IsPlaceholder() bool { return false }
|
||||
func (fd *File) Options() protoreflect.ProtoMessage {
|
||||
func (fd *File) ParentFile() pref.FileDescriptor { return fd }
|
||||
func (fd *File) Parent() pref.Descriptor { return nil }
|
||||
func (fd *File) Index() int { return 0 }
|
||||
func (fd *File) Syntax() pref.Syntax { return fd.L1.Syntax }
|
||||
func (fd *File) Name() pref.Name { return fd.L1.Package.Name() }
|
||||
func (fd *File) FullName() pref.FullName { return fd.L1.Package }
|
||||
func (fd *File) IsPlaceholder() bool { return false }
|
||||
func (fd *File) Options() pref.ProtoMessage {
|
||||
if f := fd.lazyInit().Options; f != nil {
|
||||
return f()
|
||||
}
|
||||
return descopts.File
|
||||
}
|
||||
func (fd *File) Path() string { return fd.L1.Path }
|
||||
func (fd *File) Package() protoreflect.FullName { return fd.L1.Package }
|
||||
func (fd *File) Imports() protoreflect.FileImports { return &fd.lazyInit().Imports }
|
||||
func (fd *File) Enums() protoreflect.EnumDescriptors { return &fd.L1.Enums }
|
||||
func (fd *File) Messages() protoreflect.MessageDescriptors { return &fd.L1.Messages }
|
||||
func (fd *File) Extensions() protoreflect.ExtensionDescriptors { return &fd.L1.Extensions }
|
||||
func (fd *File) Services() protoreflect.ServiceDescriptors { return &fd.L1.Services }
|
||||
func (fd *File) SourceLocations() protoreflect.SourceLocations { return &fd.lazyInit().Locations }
|
||||
func (fd *File) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, fd) }
|
||||
func (fd *File) ProtoType(protoreflect.FileDescriptor) {}
|
||||
func (fd *File) ProtoInternal(pragma.DoNotImplement) {}
|
||||
func (fd *File) Path() string { return fd.L1.Path }
|
||||
func (fd *File) Package() pref.FullName { return fd.L1.Package }
|
||||
func (fd *File) Imports() pref.FileImports { return &fd.lazyInit().Imports }
|
||||
func (fd *File) Enums() pref.EnumDescriptors { return &fd.L1.Enums }
|
||||
func (fd *File) Messages() pref.MessageDescriptors { return &fd.L1.Messages }
|
||||
func (fd *File) Extensions() pref.ExtensionDescriptors { return &fd.L1.Extensions }
|
||||
func (fd *File) Services() pref.ServiceDescriptors { return &fd.L1.Services }
|
||||
func (fd *File) SourceLocations() pref.SourceLocations { return &fd.lazyInit().Locations }
|
||||
func (fd *File) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, fd) }
|
||||
func (fd *File) ProtoType(pref.FileDescriptor) {}
|
||||
func (fd *File) ProtoInternal(pragma.DoNotImplement) {}
|
||||
|
||||
func (fd *File) lazyInit() *FileL2 {
|
||||
if atomic.LoadUint32(&fd.once) == 0 {
|
||||
@@ -162,11 +117,9 @@ type (
|
||||
}
|
||||
EnumL1 struct {
|
||||
eagerValues bool // controls whether EnumL2.Values is already populated
|
||||
|
||||
EditionFeatures EditionFeatures
|
||||
}
|
||||
EnumL2 struct {
|
||||
Options func() protoreflect.ProtoMessage
|
||||
Options func() pref.ProtoMessage
|
||||
Values EnumValues
|
||||
ReservedNames Names
|
||||
ReservedRanges EnumRanges
|
||||
@@ -177,41 +130,41 @@ type (
|
||||
L1 EnumValueL1
|
||||
}
|
||||
EnumValueL1 struct {
|
||||
Options func() protoreflect.ProtoMessage
|
||||
Number protoreflect.EnumNumber
|
||||
Options func() pref.ProtoMessage
|
||||
Number pref.EnumNumber
|
||||
}
|
||||
)
|
||||
|
||||
func (ed *Enum) Options() protoreflect.ProtoMessage {
|
||||
func (ed *Enum) Options() pref.ProtoMessage {
|
||||
if f := ed.lazyInit().Options; f != nil {
|
||||
return f()
|
||||
}
|
||||
return descopts.Enum
|
||||
}
|
||||
func (ed *Enum) Values() protoreflect.EnumValueDescriptors {
|
||||
func (ed *Enum) Values() pref.EnumValueDescriptors {
|
||||
if ed.L1.eagerValues {
|
||||
return &ed.L2.Values
|
||||
}
|
||||
return &ed.lazyInit().Values
|
||||
}
|
||||
func (ed *Enum) ReservedNames() protoreflect.Names { return &ed.lazyInit().ReservedNames }
|
||||
func (ed *Enum) ReservedRanges() protoreflect.EnumRanges { return &ed.lazyInit().ReservedRanges }
|
||||
func (ed *Enum) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, ed) }
|
||||
func (ed *Enum) ProtoType(protoreflect.EnumDescriptor) {}
|
||||
func (ed *Enum) ReservedNames() pref.Names { return &ed.lazyInit().ReservedNames }
|
||||
func (ed *Enum) ReservedRanges() pref.EnumRanges { return &ed.lazyInit().ReservedRanges }
|
||||
func (ed *Enum) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, ed) }
|
||||
func (ed *Enum) ProtoType(pref.EnumDescriptor) {}
|
||||
func (ed *Enum) lazyInit() *EnumL2 {
|
||||
ed.L0.ParentFile.lazyInit() // implicitly initializes L2
|
||||
return ed.L2
|
||||
}
|
||||
|
||||
func (ed *EnumValue) Options() protoreflect.ProtoMessage {
|
||||
func (ed *EnumValue) Options() pref.ProtoMessage {
|
||||
if f := ed.L1.Options; f != nil {
|
||||
return f()
|
||||
}
|
||||
return descopts.EnumValue
|
||||
}
|
||||
func (ed *EnumValue) Number() protoreflect.EnumNumber { return ed.L1.Number }
|
||||
func (ed *EnumValue) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, ed) }
|
||||
func (ed *EnumValue) ProtoType(protoreflect.EnumValueDescriptor) {}
|
||||
func (ed *EnumValue) Number() pref.EnumNumber { return ed.L1.Number }
|
||||
func (ed *EnumValue) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, ed) }
|
||||
func (ed *EnumValue) ProtoType(pref.EnumValueDescriptor) {}
|
||||
|
||||
type (
|
||||
Message struct {
|
||||
@@ -225,18 +178,16 @@ type (
|
||||
Extensions Extensions
|
||||
IsMapEntry bool // promoted from google.protobuf.MessageOptions
|
||||
IsMessageSet bool // promoted from google.protobuf.MessageOptions
|
||||
|
||||
EditionFeatures EditionFeatures
|
||||
}
|
||||
MessageL2 struct {
|
||||
Options func() protoreflect.ProtoMessage
|
||||
Options func() pref.ProtoMessage
|
||||
Fields Fields
|
||||
Oneofs Oneofs
|
||||
ReservedNames Names
|
||||
ReservedRanges FieldRanges
|
||||
RequiredNumbers FieldNumbers // must be consistent with Fields.Cardinality
|
||||
ExtensionRanges FieldRanges
|
||||
ExtensionRangeOptions []func() protoreflect.ProtoMessage // must be same length as ExtensionRanges
|
||||
ExtensionRangeOptions []func() pref.ProtoMessage // must be same length as ExtensionRanges
|
||||
}
|
||||
|
||||
Field struct {
|
||||
@@ -244,10 +195,10 @@ type (
|
||||
L1 FieldL1
|
||||
}
|
||||
FieldL1 struct {
|
||||
Options func() protoreflect.ProtoMessage
|
||||
Number protoreflect.FieldNumber
|
||||
Cardinality protoreflect.Cardinality // must be consistent with Message.RequiredNumbers
|
||||
Kind protoreflect.Kind
|
||||
Options func() pref.ProtoMessage
|
||||
Number pref.FieldNumber
|
||||
Cardinality pref.Cardinality // must be consistent with Message.RequiredNumbers
|
||||
Kind pref.Kind
|
||||
StringName stringName
|
||||
IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto
|
||||
IsWeak bool // promoted from google.protobuf.FieldOptions
|
||||
@@ -256,11 +207,9 @@ type (
|
||||
HasEnforceUTF8 bool // promoted from google.protobuf.FieldOptions
|
||||
EnforceUTF8 bool // promoted from google.protobuf.FieldOptions
|
||||
Default defaultValue
|
||||
ContainingOneof protoreflect.OneofDescriptor // must be consistent with Message.Oneofs.Fields
|
||||
Enum protoreflect.EnumDescriptor
|
||||
Message protoreflect.MessageDescriptor
|
||||
|
||||
EditionFeatures EditionFeatures
|
||||
ContainingOneof pref.OneofDescriptor // must be consistent with Message.Oneofs.Fields
|
||||
Enum pref.EnumDescriptor
|
||||
Message pref.MessageDescriptor
|
||||
}
|
||||
|
||||
Oneof struct {
|
||||
@@ -268,37 +217,35 @@ type (
|
||||
L1 OneofL1
|
||||
}
|
||||
OneofL1 struct {
|
||||
Options func() protoreflect.ProtoMessage
|
||||
Options func() pref.ProtoMessage
|
||||
Fields OneofFields // must be consistent with Message.Fields.ContainingOneof
|
||||
|
||||
EditionFeatures EditionFeatures
|
||||
}
|
||||
)
|
||||
|
||||
func (md *Message) Options() protoreflect.ProtoMessage {
|
||||
func (md *Message) Options() pref.ProtoMessage {
|
||||
if f := md.lazyInit().Options; f != nil {
|
||||
return f()
|
||||
}
|
||||
return descopts.Message
|
||||
}
|
||||
func (md *Message) IsMapEntry() bool { return md.L1.IsMapEntry }
|
||||
func (md *Message) Fields() protoreflect.FieldDescriptors { return &md.lazyInit().Fields }
|
||||
func (md *Message) Oneofs() protoreflect.OneofDescriptors { return &md.lazyInit().Oneofs }
|
||||
func (md *Message) ReservedNames() protoreflect.Names { return &md.lazyInit().ReservedNames }
|
||||
func (md *Message) ReservedRanges() protoreflect.FieldRanges { return &md.lazyInit().ReservedRanges }
|
||||
func (md *Message) RequiredNumbers() protoreflect.FieldNumbers { return &md.lazyInit().RequiredNumbers }
|
||||
func (md *Message) ExtensionRanges() protoreflect.FieldRanges { return &md.lazyInit().ExtensionRanges }
|
||||
func (md *Message) ExtensionRangeOptions(i int) protoreflect.ProtoMessage {
|
||||
func (md *Message) IsMapEntry() bool { return md.L1.IsMapEntry }
|
||||
func (md *Message) Fields() pref.FieldDescriptors { return &md.lazyInit().Fields }
|
||||
func (md *Message) Oneofs() pref.OneofDescriptors { return &md.lazyInit().Oneofs }
|
||||
func (md *Message) ReservedNames() pref.Names { return &md.lazyInit().ReservedNames }
|
||||
func (md *Message) ReservedRanges() pref.FieldRanges { return &md.lazyInit().ReservedRanges }
|
||||
func (md *Message) RequiredNumbers() pref.FieldNumbers { return &md.lazyInit().RequiredNumbers }
|
||||
func (md *Message) ExtensionRanges() pref.FieldRanges { return &md.lazyInit().ExtensionRanges }
|
||||
func (md *Message) ExtensionRangeOptions(i int) pref.ProtoMessage {
|
||||
if f := md.lazyInit().ExtensionRangeOptions[i]; f != nil {
|
||||
return f()
|
||||
}
|
||||
return descopts.ExtensionRange
|
||||
}
|
||||
func (md *Message) Enums() protoreflect.EnumDescriptors { return &md.L1.Enums }
|
||||
func (md *Message) Messages() protoreflect.MessageDescriptors { return &md.L1.Messages }
|
||||
func (md *Message) Extensions() protoreflect.ExtensionDescriptors { return &md.L1.Extensions }
|
||||
func (md *Message) ProtoType(protoreflect.MessageDescriptor) {}
|
||||
func (md *Message) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, md) }
|
||||
func (md *Message) Enums() pref.EnumDescriptors { return &md.L1.Enums }
|
||||
func (md *Message) Messages() pref.MessageDescriptors { return &md.L1.Messages }
|
||||
func (md *Message) Extensions() pref.ExtensionDescriptors { return &md.L1.Extensions }
|
||||
func (md *Message) ProtoType(pref.MessageDescriptor) {}
|
||||
func (md *Message) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, md) }
|
||||
func (md *Message) lazyInit() *MessageL2 {
|
||||
md.L0.ParentFile.lazyInit() // implicitly initializes L2
|
||||
return md.L2
|
||||
@@ -313,83 +260,70 @@ func (md *Message) IsMessageSet() bool {
|
||||
return md.L1.IsMessageSet
|
||||
}
|
||||
|
||||
func (fd *Field) Options() protoreflect.ProtoMessage {
|
||||
func (fd *Field) Options() pref.ProtoMessage {
|
||||
if f := fd.L1.Options; f != nil {
|
||||
return f()
|
||||
}
|
||||
return descopts.Field
|
||||
}
|
||||
func (fd *Field) Number() protoreflect.FieldNumber { return fd.L1.Number }
|
||||
func (fd *Field) Cardinality() protoreflect.Cardinality { return fd.L1.Cardinality }
|
||||
func (fd *Field) Kind() protoreflect.Kind {
|
||||
return fd.L1.Kind
|
||||
}
|
||||
func (fd *Field) HasJSONName() bool { return fd.L1.StringName.hasJSON }
|
||||
func (fd *Field) JSONName() string { return fd.L1.StringName.getJSON(fd) }
|
||||
func (fd *Field) TextName() string { return fd.L1.StringName.getText(fd) }
|
||||
func (fd *Field) Number() pref.FieldNumber { return fd.L1.Number }
|
||||
func (fd *Field) Cardinality() pref.Cardinality { return fd.L1.Cardinality }
|
||||
func (fd *Field) Kind() pref.Kind { return fd.L1.Kind }
|
||||
func (fd *Field) HasJSONName() bool { return fd.L1.StringName.hasJSON }
|
||||
func (fd *Field) JSONName() string { return fd.L1.StringName.getJSON(fd) }
|
||||
func (fd *Field) TextName() string { return fd.L1.StringName.getText(fd) }
|
||||
func (fd *Field) HasPresence() bool {
|
||||
if fd.L1.Cardinality == protoreflect.Repeated {
|
||||
return false
|
||||
}
|
||||
explicitFieldPresence := fd.Syntax() == protoreflect.Editions && fd.L1.EditionFeatures.IsFieldPresence
|
||||
return fd.Syntax() == protoreflect.Proto2 || explicitFieldPresence || fd.L1.Message != nil || fd.L1.ContainingOneof != nil
|
||||
return fd.L1.Cardinality != pref.Repeated && (fd.L0.ParentFile.L1.Syntax == pref.Proto2 || fd.L1.Message != nil || fd.L1.ContainingOneof != nil)
|
||||
}
|
||||
func (fd *Field) HasOptionalKeyword() bool {
|
||||
return (fd.L0.ParentFile.L1.Syntax == protoreflect.Proto2 && fd.L1.Cardinality == protoreflect.Optional && fd.L1.ContainingOneof == nil) || fd.L1.IsProto3Optional
|
||||
return (fd.L0.ParentFile.L1.Syntax == pref.Proto2 && fd.L1.Cardinality == pref.Optional && fd.L1.ContainingOneof == nil) || fd.L1.IsProto3Optional
|
||||
}
|
||||
func (fd *Field) IsPacked() bool {
|
||||
if fd.L1.Cardinality != protoreflect.Repeated {
|
||||
return false
|
||||
}
|
||||
switch fd.L1.Kind {
|
||||
case protoreflect.StringKind, protoreflect.BytesKind, protoreflect.MessageKind, protoreflect.GroupKind:
|
||||
return false
|
||||
}
|
||||
if fd.L0.ParentFile.L1.Syntax == protoreflect.Editions {
|
||||
return fd.L1.EditionFeatures.IsPacked
|
||||
}
|
||||
if fd.L0.ParentFile.L1.Syntax == protoreflect.Proto3 {
|
||||
// proto3 repeated fields are packed by default.
|
||||
return !fd.L1.HasPacked || fd.L1.IsPacked
|
||||
if !fd.L1.HasPacked && fd.L0.ParentFile.L1.Syntax != pref.Proto2 && fd.L1.Cardinality == pref.Repeated {
|
||||
switch fd.L1.Kind {
|
||||
case pref.StringKind, pref.BytesKind, pref.MessageKind, pref.GroupKind:
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
return fd.L1.IsPacked
|
||||
}
|
||||
func (fd *Field) IsExtension() bool { return false }
|
||||
func (fd *Field) IsWeak() bool { return fd.L1.IsWeak }
|
||||
func (fd *Field) IsList() bool { return fd.Cardinality() == protoreflect.Repeated && !fd.IsMap() }
|
||||
func (fd *Field) IsList() bool { return fd.Cardinality() == pref.Repeated && !fd.IsMap() }
|
||||
func (fd *Field) IsMap() bool { return fd.Message() != nil && fd.Message().IsMapEntry() }
|
||||
func (fd *Field) MapKey() protoreflect.FieldDescriptor {
|
||||
func (fd *Field) MapKey() pref.FieldDescriptor {
|
||||
if !fd.IsMap() {
|
||||
return nil
|
||||
}
|
||||
return fd.Message().Fields().ByNumber(genid.MapEntry_Key_field_number)
|
||||
}
|
||||
func (fd *Field) MapValue() protoreflect.FieldDescriptor {
|
||||
func (fd *Field) MapValue() pref.FieldDescriptor {
|
||||
if !fd.IsMap() {
|
||||
return nil
|
||||
}
|
||||
return fd.Message().Fields().ByNumber(genid.MapEntry_Value_field_number)
|
||||
}
|
||||
func (fd *Field) HasDefault() bool { return fd.L1.Default.has }
|
||||
func (fd *Field) Default() protoreflect.Value { return fd.L1.Default.get(fd) }
|
||||
func (fd *Field) DefaultEnumValue() protoreflect.EnumValueDescriptor { return fd.L1.Default.enum }
|
||||
func (fd *Field) ContainingOneof() protoreflect.OneofDescriptor { return fd.L1.ContainingOneof }
|
||||
func (fd *Field) ContainingMessage() protoreflect.MessageDescriptor {
|
||||
return fd.L0.Parent.(protoreflect.MessageDescriptor)
|
||||
func (fd *Field) HasDefault() bool { return fd.L1.Default.has }
|
||||
func (fd *Field) Default() pref.Value { return fd.L1.Default.get(fd) }
|
||||
func (fd *Field) DefaultEnumValue() pref.EnumValueDescriptor { return fd.L1.Default.enum }
|
||||
func (fd *Field) ContainingOneof() pref.OneofDescriptor { return fd.L1.ContainingOneof }
|
||||
func (fd *Field) ContainingMessage() pref.MessageDescriptor {
|
||||
return fd.L0.Parent.(pref.MessageDescriptor)
|
||||
}
|
||||
func (fd *Field) Enum() protoreflect.EnumDescriptor {
|
||||
func (fd *Field) Enum() pref.EnumDescriptor {
|
||||
return fd.L1.Enum
|
||||
}
|
||||
func (fd *Field) Message() protoreflect.MessageDescriptor {
|
||||
func (fd *Field) Message() pref.MessageDescriptor {
|
||||
if fd.L1.IsWeak {
|
||||
if d, _ := protoregistry.GlobalFiles.FindDescriptorByName(fd.L1.Message.FullName()); d != nil {
|
||||
return d.(protoreflect.MessageDescriptor)
|
||||
return d.(pref.MessageDescriptor)
|
||||
}
|
||||
}
|
||||
return fd.L1.Message
|
||||
}
|
||||
func (fd *Field) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, fd) }
|
||||
func (fd *Field) ProtoType(protoreflect.FieldDescriptor) {}
|
||||
func (fd *Field) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, fd) }
|
||||
func (fd *Field) ProtoType(pref.FieldDescriptor) {}
|
||||
|
||||
// EnforceUTF8 is a pseudo-internal API to determine whether to enforce UTF-8
|
||||
// validation for the string field. This exists for Google-internal use only
|
||||
@@ -399,27 +333,24 @@ func (fd *Field) ProtoType(protoreflect.FieldDescriptor) {}
|
||||
// WARNING: This method is exempt from the compatibility promise and may be
|
||||
// removed in the future without warning.
|
||||
func (fd *Field) EnforceUTF8() bool {
|
||||
if fd.L0.ParentFile.L1.Syntax == protoreflect.Editions {
|
||||
return fd.L1.EditionFeatures.IsUTF8Validated
|
||||
}
|
||||
if fd.L1.HasEnforceUTF8 {
|
||||
return fd.L1.EnforceUTF8
|
||||
}
|
||||
return fd.L0.ParentFile.L1.Syntax == protoreflect.Proto3
|
||||
return fd.L0.ParentFile.L1.Syntax == pref.Proto3
|
||||
}
|
||||
|
||||
func (od *Oneof) IsSynthetic() bool {
|
||||
return od.L0.ParentFile.L1.Syntax == protoreflect.Proto3 && len(od.L1.Fields.List) == 1 && od.L1.Fields.List[0].HasOptionalKeyword()
|
||||
return od.L0.ParentFile.L1.Syntax == pref.Proto3 && len(od.L1.Fields.List) == 1 && od.L1.Fields.List[0].HasOptionalKeyword()
|
||||
}
|
||||
func (od *Oneof) Options() protoreflect.ProtoMessage {
|
||||
func (od *Oneof) Options() pref.ProtoMessage {
|
||||
if f := od.L1.Options; f != nil {
|
||||
return f()
|
||||
}
|
||||
return descopts.Oneof
|
||||
}
|
||||
func (od *Oneof) Fields() protoreflect.FieldDescriptors { return &od.L1.Fields }
|
||||
func (od *Oneof) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, od) }
|
||||
func (od *Oneof) ProtoType(protoreflect.OneofDescriptor) {}
|
||||
func (od *Oneof) Fields() pref.FieldDescriptors { return &od.L1.Fields }
|
||||
func (od *Oneof) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, od) }
|
||||
func (od *Oneof) ProtoType(pref.OneofDescriptor) {}
|
||||
|
||||
type (
|
||||
Extension struct {
|
||||
@@ -428,58 +359,55 @@ type (
|
||||
L2 *ExtensionL2 // protected by fileDesc.once
|
||||
}
|
||||
ExtensionL1 struct {
|
||||
Number protoreflect.FieldNumber
|
||||
Extendee protoreflect.MessageDescriptor
|
||||
Cardinality protoreflect.Cardinality
|
||||
Kind protoreflect.Kind
|
||||
EditionFeatures EditionFeatures
|
||||
Number pref.FieldNumber
|
||||
Extendee pref.MessageDescriptor
|
||||
Cardinality pref.Cardinality
|
||||
Kind pref.Kind
|
||||
}
|
||||
ExtensionL2 struct {
|
||||
Options func() protoreflect.ProtoMessage
|
||||
Options func() pref.ProtoMessage
|
||||
StringName stringName
|
||||
IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto
|
||||
IsPacked bool // promoted from google.protobuf.FieldOptions
|
||||
Default defaultValue
|
||||
Enum protoreflect.EnumDescriptor
|
||||
Message protoreflect.MessageDescriptor
|
||||
Enum pref.EnumDescriptor
|
||||
Message pref.MessageDescriptor
|
||||
}
|
||||
)
|
||||
|
||||
func (xd *Extension) Options() protoreflect.ProtoMessage {
|
||||
func (xd *Extension) Options() pref.ProtoMessage {
|
||||
if f := xd.lazyInit().Options; f != nil {
|
||||
return f()
|
||||
}
|
||||
return descopts.Field
|
||||
}
|
||||
func (xd *Extension) Number() protoreflect.FieldNumber { return xd.L1.Number }
|
||||
func (xd *Extension) Cardinality() protoreflect.Cardinality { return xd.L1.Cardinality }
|
||||
func (xd *Extension) Kind() protoreflect.Kind { return xd.L1.Kind }
|
||||
func (xd *Extension) HasJSONName() bool { return xd.lazyInit().StringName.hasJSON }
|
||||
func (xd *Extension) JSONName() string { return xd.lazyInit().StringName.getJSON(xd) }
|
||||
func (xd *Extension) TextName() string { return xd.lazyInit().StringName.getText(xd) }
|
||||
func (xd *Extension) HasPresence() bool { return xd.L1.Cardinality != protoreflect.Repeated }
|
||||
func (xd *Extension) Number() pref.FieldNumber { return xd.L1.Number }
|
||||
func (xd *Extension) Cardinality() pref.Cardinality { return xd.L1.Cardinality }
|
||||
func (xd *Extension) Kind() pref.Kind { return xd.L1.Kind }
|
||||
func (xd *Extension) HasJSONName() bool { return xd.lazyInit().StringName.hasJSON }
|
||||
func (xd *Extension) JSONName() string { return xd.lazyInit().StringName.getJSON(xd) }
|
||||
func (xd *Extension) TextName() string { return xd.lazyInit().StringName.getText(xd) }
|
||||
func (xd *Extension) HasPresence() bool { return xd.L1.Cardinality != pref.Repeated }
|
||||
func (xd *Extension) HasOptionalKeyword() bool {
|
||||
return (xd.L0.ParentFile.L1.Syntax == protoreflect.Proto2 && xd.L1.Cardinality == protoreflect.Optional) || xd.lazyInit().IsProto3Optional
|
||||
return (xd.L0.ParentFile.L1.Syntax == pref.Proto2 && xd.L1.Cardinality == pref.Optional) || xd.lazyInit().IsProto3Optional
|
||||
}
|
||||
func (xd *Extension) IsPacked() bool { return xd.lazyInit().IsPacked }
|
||||
func (xd *Extension) IsExtension() bool { return true }
|
||||
func (xd *Extension) IsWeak() bool { return false }
|
||||
func (xd *Extension) IsList() bool { return xd.Cardinality() == protoreflect.Repeated }
|
||||
func (xd *Extension) IsMap() bool { return false }
|
||||
func (xd *Extension) MapKey() protoreflect.FieldDescriptor { return nil }
|
||||
func (xd *Extension) MapValue() protoreflect.FieldDescriptor { return nil }
|
||||
func (xd *Extension) HasDefault() bool { return xd.lazyInit().Default.has }
|
||||
func (xd *Extension) Default() protoreflect.Value { return xd.lazyInit().Default.get(xd) }
|
||||
func (xd *Extension) DefaultEnumValue() protoreflect.EnumValueDescriptor {
|
||||
return xd.lazyInit().Default.enum
|
||||
}
|
||||
func (xd *Extension) ContainingOneof() protoreflect.OneofDescriptor { return nil }
|
||||
func (xd *Extension) ContainingMessage() protoreflect.MessageDescriptor { return xd.L1.Extendee }
|
||||
func (xd *Extension) Enum() protoreflect.EnumDescriptor { return xd.lazyInit().Enum }
|
||||
func (xd *Extension) Message() protoreflect.MessageDescriptor { return xd.lazyInit().Message }
|
||||
func (xd *Extension) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, xd) }
|
||||
func (xd *Extension) ProtoType(protoreflect.FieldDescriptor) {}
|
||||
func (xd *Extension) ProtoInternal(pragma.DoNotImplement) {}
|
||||
func (xd *Extension) IsPacked() bool { return xd.lazyInit().IsPacked }
|
||||
func (xd *Extension) IsExtension() bool { return true }
|
||||
func (xd *Extension) IsWeak() bool { return false }
|
||||
func (xd *Extension) IsList() bool { return xd.Cardinality() == pref.Repeated }
|
||||
func (xd *Extension) IsMap() bool { return false }
|
||||
func (xd *Extension) MapKey() pref.FieldDescriptor { return nil }
|
||||
func (xd *Extension) MapValue() pref.FieldDescriptor { return nil }
|
||||
func (xd *Extension) HasDefault() bool { return xd.lazyInit().Default.has }
|
||||
func (xd *Extension) Default() pref.Value { return xd.lazyInit().Default.get(xd) }
|
||||
func (xd *Extension) DefaultEnumValue() pref.EnumValueDescriptor { return xd.lazyInit().Default.enum }
|
||||
func (xd *Extension) ContainingOneof() pref.OneofDescriptor { return nil }
|
||||
func (xd *Extension) ContainingMessage() pref.MessageDescriptor { return xd.L1.Extendee }
|
||||
func (xd *Extension) Enum() pref.EnumDescriptor { return xd.lazyInit().Enum }
|
||||
func (xd *Extension) Message() pref.MessageDescriptor { return xd.lazyInit().Message }
|
||||
func (xd *Extension) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, xd) }
|
||||
func (xd *Extension) ProtoType(pref.FieldDescriptor) {}
|
||||
func (xd *Extension) ProtoInternal(pragma.DoNotImplement) {}
|
||||
func (xd *Extension) lazyInit() *ExtensionL2 {
|
||||
xd.L0.ParentFile.lazyInit() // implicitly initializes L2
|
||||
return xd.L2
|
||||
@@ -493,7 +421,7 @@ type (
|
||||
}
|
||||
ServiceL1 struct{}
|
||||
ServiceL2 struct {
|
||||
Options func() protoreflect.ProtoMessage
|
||||
Options func() pref.ProtoMessage
|
||||
Methods Methods
|
||||
}
|
||||
|
||||
@@ -502,48 +430,48 @@ type (
|
||||
L1 MethodL1
|
||||
}
|
||||
MethodL1 struct {
|
||||
Options func() protoreflect.ProtoMessage
|
||||
Input protoreflect.MessageDescriptor
|
||||
Output protoreflect.MessageDescriptor
|
||||
Options func() pref.ProtoMessage
|
||||
Input pref.MessageDescriptor
|
||||
Output pref.MessageDescriptor
|
||||
IsStreamingClient bool
|
||||
IsStreamingServer bool
|
||||
}
|
||||
)
|
||||
|
||||
func (sd *Service) Options() protoreflect.ProtoMessage {
|
||||
func (sd *Service) Options() pref.ProtoMessage {
|
||||
if f := sd.lazyInit().Options; f != nil {
|
||||
return f()
|
||||
}
|
||||
return descopts.Service
|
||||
}
|
||||
func (sd *Service) Methods() protoreflect.MethodDescriptors { return &sd.lazyInit().Methods }
|
||||
func (sd *Service) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, sd) }
|
||||
func (sd *Service) ProtoType(protoreflect.ServiceDescriptor) {}
|
||||
func (sd *Service) ProtoInternal(pragma.DoNotImplement) {}
|
||||
func (sd *Service) Methods() pref.MethodDescriptors { return &sd.lazyInit().Methods }
|
||||
func (sd *Service) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, sd) }
|
||||
func (sd *Service) ProtoType(pref.ServiceDescriptor) {}
|
||||
func (sd *Service) ProtoInternal(pragma.DoNotImplement) {}
|
||||
func (sd *Service) lazyInit() *ServiceL2 {
|
||||
sd.L0.ParentFile.lazyInit() // implicitly initializes L2
|
||||
return sd.L2
|
||||
}
|
||||
|
||||
func (md *Method) Options() protoreflect.ProtoMessage {
|
||||
func (md *Method) Options() pref.ProtoMessage {
|
||||
if f := md.L1.Options; f != nil {
|
||||
return f()
|
||||
}
|
||||
return descopts.Method
|
||||
}
|
||||
func (md *Method) Input() protoreflect.MessageDescriptor { return md.L1.Input }
|
||||
func (md *Method) Output() protoreflect.MessageDescriptor { return md.L1.Output }
|
||||
func (md *Method) IsStreamingClient() bool { return md.L1.IsStreamingClient }
|
||||
func (md *Method) IsStreamingServer() bool { return md.L1.IsStreamingServer }
|
||||
func (md *Method) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, md) }
|
||||
func (md *Method) ProtoType(protoreflect.MethodDescriptor) {}
|
||||
func (md *Method) ProtoInternal(pragma.DoNotImplement) {}
|
||||
func (md *Method) Input() pref.MessageDescriptor { return md.L1.Input }
|
||||
func (md *Method) Output() pref.MessageDescriptor { return md.L1.Output }
|
||||
func (md *Method) IsStreamingClient() bool { return md.L1.IsStreamingClient }
|
||||
func (md *Method) IsStreamingServer() bool { return md.L1.IsStreamingServer }
|
||||
func (md *Method) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, md) }
|
||||
func (md *Method) ProtoType(pref.MethodDescriptor) {}
|
||||
func (md *Method) ProtoInternal(pragma.DoNotImplement) {}
|
||||
|
||||
// Surrogate files are can be used to create standalone descriptors
|
||||
// where the syntax is only information derived from the parent file.
|
||||
var (
|
||||
SurrogateProto2 = &File{L1: FileL1{Syntax: protoreflect.Proto2}, L2: &FileL2{}}
|
||||
SurrogateProto3 = &File{L1: FileL1{Syntax: protoreflect.Proto3}, L2: &FileL2{}}
|
||||
SurrogateProto2 = &File{L1: FileL1{Syntax: pref.Proto2}, L2: &FileL2{}}
|
||||
SurrogateProto3 = &File{L1: FileL1{Syntax: pref.Proto3}, L2: &FileL2{}}
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -551,24 +479,24 @@ type (
|
||||
L0 BaseL0
|
||||
}
|
||||
BaseL0 struct {
|
||||
FullName protoreflect.FullName // must be populated
|
||||
ParentFile *File // must be populated
|
||||
Parent protoreflect.Descriptor
|
||||
FullName pref.FullName // must be populated
|
||||
ParentFile *File // must be populated
|
||||
Parent pref.Descriptor
|
||||
Index int
|
||||
}
|
||||
)
|
||||
|
||||
func (d *Base) Name() protoreflect.Name { return d.L0.FullName.Name() }
|
||||
func (d *Base) FullName() protoreflect.FullName { return d.L0.FullName }
|
||||
func (d *Base) ParentFile() protoreflect.FileDescriptor {
|
||||
func (d *Base) Name() pref.Name { return d.L0.FullName.Name() }
|
||||
func (d *Base) FullName() pref.FullName { return d.L0.FullName }
|
||||
func (d *Base) ParentFile() pref.FileDescriptor {
|
||||
if d.L0.ParentFile == SurrogateProto2 || d.L0.ParentFile == SurrogateProto3 {
|
||||
return nil // surrogate files are not real parents
|
||||
}
|
||||
return d.L0.ParentFile
|
||||
}
|
||||
func (d *Base) Parent() protoreflect.Descriptor { return d.L0.Parent }
|
||||
func (d *Base) Parent() pref.Descriptor { return d.L0.Parent }
|
||||
func (d *Base) Index() int { return d.L0.Index }
|
||||
func (d *Base) Syntax() protoreflect.Syntax { return d.L0.ParentFile.Syntax() }
|
||||
func (d *Base) Syntax() pref.Syntax { return d.L0.ParentFile.Syntax() }
|
||||
func (d *Base) IsPlaceholder() bool { return false }
|
||||
func (d *Base) ProtoInternal(pragma.DoNotImplement) {}
|
||||
|
||||
@@ -585,7 +513,7 @@ func (s *stringName) InitJSON(name string) {
|
||||
s.nameJSON = name
|
||||
}
|
||||
|
||||
func (s *stringName) lazyInit(fd protoreflect.FieldDescriptor) *stringName {
|
||||
func (s *stringName) lazyInit(fd pref.FieldDescriptor) *stringName {
|
||||
s.once.Do(func() {
|
||||
if fd.IsExtension() {
|
||||
// For extensions, JSON and text are formatted the same way.
|
||||
@@ -605,7 +533,7 @@ func (s *stringName) lazyInit(fd protoreflect.FieldDescriptor) *stringName {
|
||||
|
||||
// Format the text name.
|
||||
s.nameText = string(fd.Name())
|
||||
if fd.Kind() == protoreflect.GroupKind {
|
||||
if fd.Kind() == pref.GroupKind {
|
||||
s.nameText = string(fd.Message().Name())
|
||||
}
|
||||
}
|
||||
@@ -613,10 +541,10 @@ func (s *stringName) lazyInit(fd protoreflect.FieldDescriptor) *stringName {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *stringName) getJSON(fd protoreflect.FieldDescriptor) string { return s.lazyInit(fd).nameJSON }
|
||||
func (s *stringName) getText(fd protoreflect.FieldDescriptor) string { return s.lazyInit(fd).nameText }
|
||||
func (s *stringName) getJSON(fd pref.FieldDescriptor) string { return s.lazyInit(fd).nameJSON }
|
||||
func (s *stringName) getText(fd pref.FieldDescriptor) string { return s.lazyInit(fd).nameText }
|
||||
|
||||
func DefaultValue(v protoreflect.Value, ev protoreflect.EnumValueDescriptor) defaultValue {
|
||||
func DefaultValue(v pref.Value, ev pref.EnumValueDescriptor) defaultValue {
|
||||
dv := defaultValue{has: v.IsValid(), val: v, enum: ev}
|
||||
if b, ok := v.Interface().([]byte); ok {
|
||||
// Store a copy of the default bytes, so that we can detect
|
||||
@@ -626,9 +554,9 @@ func DefaultValue(v protoreflect.Value, ev protoreflect.EnumValueDescriptor) def
|
||||
return dv
|
||||
}
|
||||
|
||||
func unmarshalDefault(b []byte, k protoreflect.Kind, pf *File, ed protoreflect.EnumDescriptor) defaultValue {
|
||||
var evs protoreflect.EnumValueDescriptors
|
||||
if k == protoreflect.EnumKind {
|
||||
func unmarshalDefault(b []byte, k pref.Kind, pf *File, ed pref.EnumDescriptor) defaultValue {
|
||||
var evs pref.EnumValueDescriptors
|
||||
if k == pref.EnumKind {
|
||||
// If the enum is declared within the same file, be careful not to
|
||||
// blindly call the Values method, lest we bind ourselves in a deadlock.
|
||||
if e, ok := ed.(*Enum); ok && e.L0.ParentFile == pf {
|
||||
@@ -639,9 +567,9 @@ func unmarshalDefault(b []byte, k protoreflect.Kind, pf *File, ed protoreflect.E
|
||||
|
||||
// If we are unable to resolve the enum dependency, use a placeholder
|
||||
// enum value since we will not be able to parse the default value.
|
||||
if ed.IsPlaceholder() && protoreflect.Name(b).IsValid() {
|
||||
v := protoreflect.ValueOfEnum(0)
|
||||
ev := PlaceholderEnumValue(ed.FullName().Parent().Append(protoreflect.Name(b)))
|
||||
if ed.IsPlaceholder() && pref.Name(b).IsValid() {
|
||||
v := pref.ValueOfEnum(0)
|
||||
ev := PlaceholderEnumValue(ed.FullName().Parent().Append(pref.Name(b)))
|
||||
return DefaultValue(v, ev)
|
||||
}
|
||||
}
|
||||
@@ -655,41 +583,41 @@ func unmarshalDefault(b []byte, k protoreflect.Kind, pf *File, ed protoreflect.E
|
||||
|
||||
type defaultValue struct {
|
||||
has bool
|
||||
val protoreflect.Value
|
||||
enum protoreflect.EnumValueDescriptor
|
||||
val pref.Value
|
||||
enum pref.EnumValueDescriptor
|
||||
bytes []byte
|
||||
}
|
||||
|
||||
func (dv *defaultValue) get(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
func (dv *defaultValue) get(fd pref.FieldDescriptor) pref.Value {
|
||||
// Return the zero value as the default if unpopulated.
|
||||
if !dv.has {
|
||||
if fd.Cardinality() == protoreflect.Repeated {
|
||||
return protoreflect.Value{}
|
||||
if fd.Cardinality() == pref.Repeated {
|
||||
return pref.Value{}
|
||||
}
|
||||
switch fd.Kind() {
|
||||
case protoreflect.BoolKind:
|
||||
return protoreflect.ValueOfBool(false)
|
||||
case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind:
|
||||
return protoreflect.ValueOfInt32(0)
|
||||
case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind:
|
||||
return protoreflect.ValueOfInt64(0)
|
||||
case protoreflect.Uint32Kind, protoreflect.Fixed32Kind:
|
||||
return protoreflect.ValueOfUint32(0)
|
||||
case protoreflect.Uint64Kind, protoreflect.Fixed64Kind:
|
||||
return protoreflect.ValueOfUint64(0)
|
||||
case protoreflect.FloatKind:
|
||||
return protoreflect.ValueOfFloat32(0)
|
||||
case protoreflect.DoubleKind:
|
||||
return protoreflect.ValueOfFloat64(0)
|
||||
case protoreflect.StringKind:
|
||||
return protoreflect.ValueOfString("")
|
||||
case protoreflect.BytesKind:
|
||||
return protoreflect.ValueOfBytes(nil)
|
||||
case protoreflect.EnumKind:
|
||||
case pref.BoolKind:
|
||||
return pref.ValueOfBool(false)
|
||||
case pref.Int32Kind, pref.Sint32Kind, pref.Sfixed32Kind:
|
||||
return pref.ValueOfInt32(0)
|
||||
case pref.Int64Kind, pref.Sint64Kind, pref.Sfixed64Kind:
|
||||
return pref.ValueOfInt64(0)
|
||||
case pref.Uint32Kind, pref.Fixed32Kind:
|
||||
return pref.ValueOfUint32(0)
|
||||
case pref.Uint64Kind, pref.Fixed64Kind:
|
||||
return pref.ValueOfUint64(0)
|
||||
case pref.FloatKind:
|
||||
return pref.ValueOfFloat32(0)
|
||||
case pref.DoubleKind:
|
||||
return pref.ValueOfFloat64(0)
|
||||
case pref.StringKind:
|
||||
return pref.ValueOfString("")
|
||||
case pref.BytesKind:
|
||||
return pref.ValueOfBytes(nil)
|
||||
case pref.EnumKind:
|
||||
if evs := fd.Enum().Values(); evs.Len() > 0 {
|
||||
return protoreflect.ValueOfEnum(evs.Get(0).Number())
|
||||
return pref.ValueOfEnum(evs.Get(0).Number())
|
||||
}
|
||||
return protoreflect.ValueOfEnum(0)
|
||||
return pref.ValueOfEnum(0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
88
vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go
generated
vendored
88
vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go
generated
vendored
@@ -5,13 +5,12 @@
|
||||
package filedesc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/internal/strs"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
// fileRaw is a data struct used when initializing a file descriptor from
|
||||
@@ -96,10 +95,9 @@ func (fd *File) unmarshalSeed(b []byte) {
|
||||
sb := getBuilder()
|
||||
defer putBuilder(sb)
|
||||
|
||||
var prevField protoreflect.FieldNumber
|
||||
var prevField pref.FieldNumber
|
||||
var numEnums, numMessages, numExtensions, numServices int
|
||||
var posEnums, posMessages, posExtensions, posServices int
|
||||
var options []byte
|
||||
b0 := b
|
||||
for len(b) > 0 {
|
||||
num, typ, n := protowire.ConsumeTag(b)
|
||||
@@ -112,20 +110,16 @@ func (fd *File) unmarshalSeed(b []byte) {
|
||||
case genid.FileDescriptorProto_Syntax_field_number:
|
||||
switch string(v) {
|
||||
case "proto2":
|
||||
fd.L1.Syntax = protoreflect.Proto2
|
||||
fd.L1.Syntax = pref.Proto2
|
||||
case "proto3":
|
||||
fd.L1.Syntax = protoreflect.Proto3
|
||||
case "editions":
|
||||
fd.L1.Syntax = protoreflect.Editions
|
||||
fd.L1.Syntax = pref.Proto3
|
||||
default:
|
||||
panic("invalid syntax")
|
||||
}
|
||||
case genid.FileDescriptorProto_Name_field_number:
|
||||
fd.L1.Path = sb.MakeString(v)
|
||||
case genid.FileDescriptorProto_Package_field_number:
|
||||
fd.L1.Package = protoreflect.FullName(sb.MakeString(v))
|
||||
case genid.FileDescriptorProto_Options_field_number:
|
||||
options = v
|
||||
fd.L1.Package = pref.FullName(sb.MakeString(v))
|
||||
case genid.FileDescriptorProto_EnumType_field_number:
|
||||
if prevField != genid.FileDescriptorProto_EnumType_field_number {
|
||||
if numEnums > 0 {
|
||||
@@ -160,13 +154,6 @@ func (fd *File) unmarshalSeed(b []byte) {
|
||||
numServices++
|
||||
}
|
||||
prevField = num
|
||||
case protowire.VarintType:
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FileDescriptorProto_Edition_field_number:
|
||||
fd.L1.Edition = Edition(v)
|
||||
}
|
||||
default:
|
||||
m := protowire.ConsumeFieldValue(num, typ, b)
|
||||
b = b[m:]
|
||||
@@ -176,16 +163,7 @@ func (fd *File) unmarshalSeed(b []byte) {
|
||||
|
||||
// If syntax is missing, it is assumed to be proto2.
|
||||
if fd.L1.Syntax == 0 {
|
||||
fd.L1.Syntax = protoreflect.Proto2
|
||||
}
|
||||
|
||||
if fd.L1.Syntax == protoreflect.Editions {
|
||||
fd.L1.EditionFeatures = getFeaturesFor(fd.L1.Edition)
|
||||
}
|
||||
|
||||
// Parse editions features from options if any
|
||||
if options != nil {
|
||||
fd.unmarshalSeedOptions(options)
|
||||
fd.L1.Syntax = pref.Proto2
|
||||
}
|
||||
|
||||
// Must allocate all declarations before parsing each descriptor type
|
||||
@@ -241,29 +219,7 @@ func (fd *File) unmarshalSeed(b []byte) {
|
||||
}
|
||||
}
|
||||
|
||||
func (fd *File) unmarshalSeedOptions(b []byte) {
|
||||
for b := b; len(b) > 0; {
|
||||
num, typ, n := protowire.ConsumeTag(b)
|
||||
b = b[n:]
|
||||
switch typ {
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FileOptions_Features_field_number:
|
||||
if fd.Syntax() != protoreflect.Editions {
|
||||
panic(fmt.Sprintf("invalid descriptor: using edition features in a proto with syntax %s", fd.Syntax()))
|
||||
}
|
||||
fd.L1.EditionFeatures = unmarshalFeatureSet(v, fd.L1.EditionFeatures)
|
||||
}
|
||||
default:
|
||||
m := protowire.ConsumeFieldValue(num, typ, b)
|
||||
b = b[m:]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (ed *Enum) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd protoreflect.Descriptor, i int) {
|
||||
func (ed *Enum) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd pref.Descriptor, i int) {
|
||||
ed.L0.ParentFile = pf
|
||||
ed.L0.Parent = pd
|
||||
ed.L0.Index = i
|
||||
@@ -315,13 +271,12 @@ func (ed *Enum) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd protorefl
|
||||
}
|
||||
}
|
||||
|
||||
func (md *Message) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd protoreflect.Descriptor, i int) {
|
||||
func (md *Message) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd pref.Descriptor, i int) {
|
||||
md.L0.ParentFile = pf
|
||||
md.L0.Parent = pd
|
||||
md.L0.Index = i
|
||||
md.L1.EditionFeatures = featuresFromParentDesc(md.Parent())
|
||||
|
||||
var prevField protoreflect.FieldNumber
|
||||
var prevField pref.FieldNumber
|
||||
var numEnums, numMessages, numExtensions int
|
||||
var posEnums, posMessages, posExtensions int
|
||||
b0 := b
|
||||
@@ -425,13 +380,6 @@ func (md *Message) unmarshalSeedOptions(b []byte) {
|
||||
case genid.MessageOptions_MessageSetWireFormat_field_number:
|
||||
md.L1.IsMessageSet = protowire.DecodeBool(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.MessageOptions_Features_field_number:
|
||||
md.L1.EditionFeatures = unmarshalFeatureSet(v, md.L1.EditionFeatures)
|
||||
}
|
||||
default:
|
||||
m := protowire.ConsumeFieldValue(num, typ, b)
|
||||
b = b[m:]
|
||||
@@ -439,7 +387,7 @@ func (md *Message) unmarshalSeedOptions(b []byte) {
|
||||
}
|
||||
}
|
||||
|
||||
func (xd *Extension) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd protoreflect.Descriptor, i int) {
|
||||
func (xd *Extension) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd pref.Descriptor, i int) {
|
||||
xd.L0.ParentFile = pf
|
||||
xd.L0.Parent = pd
|
||||
xd.L0.Index = i
|
||||
@@ -453,11 +401,11 @@ func (xd *Extension) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd prot
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FieldDescriptorProto_Number_field_number:
|
||||
xd.L1.Number = protoreflect.FieldNumber(v)
|
||||
xd.L1.Number = pref.FieldNumber(v)
|
||||
case genid.FieldDescriptorProto_Label_field_number:
|
||||
xd.L1.Cardinality = protoreflect.Cardinality(v)
|
||||
xd.L1.Cardinality = pref.Cardinality(v)
|
||||
case genid.FieldDescriptorProto_Type_field_number:
|
||||
xd.L1.Kind = protoreflect.Kind(v)
|
||||
xd.L1.Kind = pref.Kind(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
@@ -475,7 +423,7 @@ func (xd *Extension) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd prot
|
||||
}
|
||||
}
|
||||
|
||||
func (sd *Service) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd protoreflect.Descriptor, i int) {
|
||||
func (sd *Service) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd pref.Descriptor, i int) {
|
||||
sd.L0.ParentFile = pf
|
||||
sd.L0.Parent = pd
|
||||
sd.L0.Index = i
|
||||
@@ -511,13 +459,13 @@ func putBuilder(b *strs.Builder) {
|
||||
|
||||
// makeFullName converts b to a protoreflect.FullName,
|
||||
// where b must start with a leading dot.
|
||||
func makeFullName(sb *strs.Builder, b []byte) protoreflect.FullName {
|
||||
func makeFullName(sb *strs.Builder, b []byte) pref.FullName {
|
||||
if len(b) == 0 || b[0] != '.' {
|
||||
panic("name reference must be fully qualified")
|
||||
}
|
||||
return protoreflect.FullName(sb.MakeString(b[1:]))
|
||||
return pref.FullName(sb.MakeString(b[1:]))
|
||||
}
|
||||
|
||||
func appendFullName(sb *strs.Builder, prefix protoreflect.FullName, suffix []byte) protoreflect.FullName {
|
||||
return sb.AppendFullName(prefix, protoreflect.Name(strs.UnsafeString(suffix)))
|
||||
func appendFullName(sb *strs.Builder, prefix pref.FullName, suffix []byte) pref.FullName {
|
||||
return sb.AppendFullName(prefix, pref.Name(strs.UnsafeString(suffix)))
|
||||
}
|
||||
|
||||
108
vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go
generated
vendored
108
vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go
generated
vendored
@@ -13,7 +13,7 @@ import (
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/internal/strs"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
func (fd *File) lazyRawInit() {
|
||||
@@ -39,10 +39,10 @@ func (file *File) resolveMessages() {
|
||||
|
||||
// Resolve message field dependency.
|
||||
switch fd.L1.Kind {
|
||||
case protoreflect.EnumKind:
|
||||
case pref.EnumKind:
|
||||
fd.L1.Enum = file.resolveEnumDependency(fd.L1.Enum, listFieldDeps, depIdx)
|
||||
depIdx++
|
||||
case protoreflect.MessageKind, protoreflect.GroupKind:
|
||||
case pref.MessageKind, pref.GroupKind:
|
||||
fd.L1.Message = file.resolveMessageDependency(fd.L1.Message, listFieldDeps, depIdx)
|
||||
depIdx++
|
||||
}
|
||||
@@ -62,10 +62,10 @@ func (file *File) resolveExtensions() {
|
||||
|
||||
// Resolve extension field dependency.
|
||||
switch xd.L1.Kind {
|
||||
case protoreflect.EnumKind:
|
||||
case pref.EnumKind:
|
||||
xd.L2.Enum = file.resolveEnumDependency(xd.L2.Enum, listExtDeps, depIdx)
|
||||
depIdx++
|
||||
case protoreflect.MessageKind, protoreflect.GroupKind:
|
||||
case pref.MessageKind, pref.GroupKind:
|
||||
xd.L2.Message = file.resolveMessageDependency(xd.L2.Message, listExtDeps, depIdx)
|
||||
depIdx++
|
||||
}
|
||||
@@ -92,7 +92,7 @@ func (file *File) resolveServices() {
|
||||
}
|
||||
}
|
||||
|
||||
func (file *File) resolveEnumDependency(ed protoreflect.EnumDescriptor, i, j int32) protoreflect.EnumDescriptor {
|
||||
func (file *File) resolveEnumDependency(ed pref.EnumDescriptor, i, j int32) pref.EnumDescriptor {
|
||||
r := file.builder.FileRegistry
|
||||
if r, ok := r.(resolverByIndex); ok {
|
||||
if ed2 := r.FindEnumByIndex(i, j, file.allEnums, file.allMessages); ed2 != nil {
|
||||
@@ -105,12 +105,12 @@ func (file *File) resolveEnumDependency(ed protoreflect.EnumDescriptor, i, j int
|
||||
}
|
||||
}
|
||||
if d, _ := r.FindDescriptorByName(ed.FullName()); d != nil {
|
||||
return d.(protoreflect.EnumDescriptor)
|
||||
return d.(pref.EnumDescriptor)
|
||||
}
|
||||
return ed
|
||||
}
|
||||
|
||||
func (file *File) resolveMessageDependency(md protoreflect.MessageDescriptor, i, j int32) protoreflect.MessageDescriptor {
|
||||
func (file *File) resolveMessageDependency(md pref.MessageDescriptor, i, j int32) pref.MessageDescriptor {
|
||||
r := file.builder.FileRegistry
|
||||
if r, ok := r.(resolverByIndex); ok {
|
||||
if md2 := r.FindMessageByIndex(i, j, file.allEnums, file.allMessages); md2 != nil {
|
||||
@@ -123,7 +123,7 @@ func (file *File) resolveMessageDependency(md protoreflect.MessageDescriptor, i,
|
||||
}
|
||||
}
|
||||
if d, _ := r.FindDescriptorByName(md.FullName()); d != nil {
|
||||
return d.(protoreflect.MessageDescriptor)
|
||||
return d.(pref.MessageDescriptor)
|
||||
}
|
||||
return md
|
||||
}
|
||||
@@ -158,7 +158,7 @@ func (fd *File) unmarshalFull(b []byte) {
|
||||
if imp == nil {
|
||||
imp = PlaceholderFile(path)
|
||||
}
|
||||
fd.L2.Imports = append(fd.L2.Imports, protoreflect.FileImport{FileDescriptor: imp})
|
||||
fd.L2.Imports = append(fd.L2.Imports, pref.FileImport{FileDescriptor: imp})
|
||||
case genid.FileDescriptorProto_EnumType_field_number:
|
||||
fd.L1.Enums.List[enumIdx].unmarshalFull(v, sb)
|
||||
enumIdx++
|
||||
@@ -199,7 +199,7 @@ func (ed *Enum) unmarshalFull(b []byte, sb *strs.Builder) {
|
||||
case genid.EnumDescriptorProto_Value_field_number:
|
||||
rawValues = append(rawValues, v)
|
||||
case genid.EnumDescriptorProto_ReservedName_field_number:
|
||||
ed.L2.ReservedNames.List = append(ed.L2.ReservedNames.List, protoreflect.Name(sb.MakeString(v)))
|
||||
ed.L2.ReservedNames.List = append(ed.L2.ReservedNames.List, pref.Name(sb.MakeString(v)))
|
||||
case genid.EnumDescriptorProto_ReservedRange_field_number:
|
||||
ed.L2.ReservedRanges.List = append(ed.L2.ReservedRanges.List, unmarshalEnumReservedRange(v))
|
||||
case genid.EnumDescriptorProto_Options_field_number:
|
||||
@@ -219,7 +219,7 @@ func (ed *Enum) unmarshalFull(b []byte, sb *strs.Builder) {
|
||||
ed.L2.Options = ed.L0.ParentFile.builder.optionsUnmarshaler(&descopts.Enum, rawOptions)
|
||||
}
|
||||
|
||||
func unmarshalEnumReservedRange(b []byte) (r [2]protoreflect.EnumNumber) {
|
||||
func unmarshalEnumReservedRange(b []byte) (r [2]pref.EnumNumber) {
|
||||
for len(b) > 0 {
|
||||
num, typ, n := protowire.ConsumeTag(b)
|
||||
b = b[n:]
|
||||
@@ -229,9 +229,9 @@ func unmarshalEnumReservedRange(b []byte) (r [2]protoreflect.EnumNumber) {
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.EnumDescriptorProto_EnumReservedRange_Start_field_number:
|
||||
r[0] = protoreflect.EnumNumber(v)
|
||||
r[0] = pref.EnumNumber(v)
|
||||
case genid.EnumDescriptorProto_EnumReservedRange_End_field_number:
|
||||
r[1] = protoreflect.EnumNumber(v)
|
||||
r[1] = pref.EnumNumber(v)
|
||||
}
|
||||
default:
|
||||
m := protowire.ConsumeFieldValue(num, typ, b)
|
||||
@@ -241,7 +241,7 @@ func unmarshalEnumReservedRange(b []byte) (r [2]protoreflect.EnumNumber) {
|
||||
return r
|
||||
}
|
||||
|
||||
func (vd *EnumValue) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd protoreflect.Descriptor, i int) {
|
||||
func (vd *EnumValue) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd pref.Descriptor, i int) {
|
||||
vd.L0.ParentFile = pf
|
||||
vd.L0.Parent = pd
|
||||
vd.L0.Index = i
|
||||
@@ -256,7 +256,7 @@ func (vd *EnumValue) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd prot
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.EnumValueDescriptorProto_Number_field_number:
|
||||
vd.L1.Number = protoreflect.EnumNumber(v)
|
||||
vd.L1.Number = pref.EnumNumber(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
@@ -294,7 +294,7 @@ func (md *Message) unmarshalFull(b []byte, sb *strs.Builder) {
|
||||
case genid.DescriptorProto_OneofDecl_field_number:
|
||||
rawOneofs = append(rawOneofs, v)
|
||||
case genid.DescriptorProto_ReservedName_field_number:
|
||||
md.L2.ReservedNames.List = append(md.L2.ReservedNames.List, protoreflect.Name(sb.MakeString(v)))
|
||||
md.L2.ReservedNames.List = append(md.L2.ReservedNames.List, pref.Name(sb.MakeString(v)))
|
||||
case genid.DescriptorProto_ReservedRange_field_number:
|
||||
md.L2.ReservedRanges.List = append(md.L2.ReservedRanges.List, unmarshalMessageReservedRange(v))
|
||||
case genid.DescriptorProto_ExtensionRange_field_number:
|
||||
@@ -326,7 +326,7 @@ func (md *Message) unmarshalFull(b []byte, sb *strs.Builder) {
|
||||
for i, b := range rawFields {
|
||||
fd := &md.L2.Fields.List[i]
|
||||
fd.unmarshalFull(b, sb, md.L0.ParentFile, md, i)
|
||||
if fd.L1.Cardinality == protoreflect.Required {
|
||||
if fd.L1.Cardinality == pref.Required {
|
||||
md.L2.RequiredNumbers.List = append(md.L2.RequiredNumbers.List, fd.L1.Number)
|
||||
}
|
||||
}
|
||||
@@ -359,7 +359,7 @@ func (md *Message) unmarshalOptions(b []byte) {
|
||||
}
|
||||
}
|
||||
|
||||
func unmarshalMessageReservedRange(b []byte) (r [2]protoreflect.FieldNumber) {
|
||||
func unmarshalMessageReservedRange(b []byte) (r [2]pref.FieldNumber) {
|
||||
for len(b) > 0 {
|
||||
num, typ, n := protowire.ConsumeTag(b)
|
||||
b = b[n:]
|
||||
@@ -369,9 +369,9 @@ func unmarshalMessageReservedRange(b []byte) (r [2]protoreflect.FieldNumber) {
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.DescriptorProto_ReservedRange_Start_field_number:
|
||||
r[0] = protoreflect.FieldNumber(v)
|
||||
r[0] = pref.FieldNumber(v)
|
||||
case genid.DescriptorProto_ReservedRange_End_field_number:
|
||||
r[1] = protoreflect.FieldNumber(v)
|
||||
r[1] = pref.FieldNumber(v)
|
||||
}
|
||||
default:
|
||||
m := protowire.ConsumeFieldValue(num, typ, b)
|
||||
@@ -381,7 +381,7 @@ func unmarshalMessageReservedRange(b []byte) (r [2]protoreflect.FieldNumber) {
|
||||
return r
|
||||
}
|
||||
|
||||
func unmarshalMessageExtensionRange(b []byte) (r [2]protoreflect.FieldNumber, rawOptions []byte) {
|
||||
func unmarshalMessageExtensionRange(b []byte) (r [2]pref.FieldNumber, rawOptions []byte) {
|
||||
for len(b) > 0 {
|
||||
num, typ, n := protowire.ConsumeTag(b)
|
||||
b = b[n:]
|
||||
@@ -391,9 +391,9 @@ func unmarshalMessageExtensionRange(b []byte) (r [2]protoreflect.FieldNumber, ra
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.DescriptorProto_ExtensionRange_Start_field_number:
|
||||
r[0] = protoreflect.FieldNumber(v)
|
||||
r[0] = pref.FieldNumber(v)
|
||||
case genid.DescriptorProto_ExtensionRange_End_field_number:
|
||||
r[1] = protoreflect.FieldNumber(v)
|
||||
r[1] = pref.FieldNumber(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
@@ -410,11 +410,10 @@ func unmarshalMessageExtensionRange(b []byte) (r [2]protoreflect.FieldNumber, ra
|
||||
return r, rawOptions
|
||||
}
|
||||
|
||||
func (fd *Field) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd protoreflect.Descriptor, i int) {
|
||||
func (fd *Field) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd pref.Descriptor, i int) {
|
||||
fd.L0.ParentFile = pf
|
||||
fd.L0.Parent = pd
|
||||
fd.L0.Index = i
|
||||
fd.L1.EditionFeatures = featuresFromParentDesc(fd.Parent())
|
||||
|
||||
var rawTypeName []byte
|
||||
var rawOptions []byte
|
||||
@@ -427,11 +426,11 @@ func (fd *Field) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd protoref
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FieldDescriptorProto_Number_field_number:
|
||||
fd.L1.Number = protoreflect.FieldNumber(v)
|
||||
fd.L1.Number = pref.FieldNumber(v)
|
||||
case genid.FieldDescriptorProto_Label_field_number:
|
||||
fd.L1.Cardinality = protoreflect.Cardinality(v)
|
||||
fd.L1.Cardinality = pref.Cardinality(v)
|
||||
case genid.FieldDescriptorProto_Type_field_number:
|
||||
fd.L1.Kind = protoreflect.Kind(v)
|
||||
fd.L1.Kind = pref.Kind(v)
|
||||
case genid.FieldDescriptorProto_OneofIndex_field_number:
|
||||
// In Message.unmarshalFull, we allocate slices for both
|
||||
// the field and oneof descriptors before unmarshaling either
|
||||
@@ -454,7 +453,7 @@ func (fd *Field) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd protoref
|
||||
case genid.FieldDescriptorProto_JsonName_field_number:
|
||||
fd.L1.StringName.InitJSON(sb.MakeString(v))
|
||||
case genid.FieldDescriptorProto_DefaultValue_field_number:
|
||||
fd.L1.Default.val = protoreflect.ValueOfBytes(v) // temporarily store as bytes; later resolved in resolveMessages
|
||||
fd.L1.Default.val = pref.ValueOfBytes(v) // temporarily store as bytes; later resolved in resolveMessages
|
||||
case genid.FieldDescriptorProto_TypeName_field_number:
|
||||
rawTypeName = v
|
||||
case genid.FieldDescriptorProto_Options_field_number:
|
||||
@@ -466,18 +465,12 @@ func (fd *Field) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd protoref
|
||||
b = b[m:]
|
||||
}
|
||||
}
|
||||
if fd.Syntax() == protoreflect.Editions && fd.L1.Kind == protoreflect.MessageKind && fd.L1.EditionFeatures.IsDelimitedEncoded {
|
||||
fd.L1.Kind = protoreflect.GroupKind
|
||||
}
|
||||
if fd.Syntax() == protoreflect.Editions && fd.L1.EditionFeatures.IsLegacyRequired {
|
||||
fd.L1.Cardinality = protoreflect.Required
|
||||
}
|
||||
if rawTypeName != nil {
|
||||
name := makeFullName(sb, rawTypeName)
|
||||
switch fd.L1.Kind {
|
||||
case protoreflect.EnumKind:
|
||||
case pref.EnumKind:
|
||||
fd.L1.Enum = PlaceholderEnum(name)
|
||||
case protoreflect.MessageKind, protoreflect.GroupKind:
|
||||
case pref.MessageKind, pref.GroupKind:
|
||||
fd.L1.Message = PlaceholderMessage(name)
|
||||
}
|
||||
}
|
||||
@@ -504,13 +497,6 @@ func (fd *Field) unmarshalOptions(b []byte) {
|
||||
fd.L1.HasEnforceUTF8 = true
|
||||
fd.L1.EnforceUTF8 = protowire.DecodeBool(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FieldOptions_Features_field_number:
|
||||
fd.L1.EditionFeatures = unmarshalFeatureSet(v, fd.L1.EditionFeatures)
|
||||
}
|
||||
default:
|
||||
m := protowire.ConsumeFieldValue(num, typ, b)
|
||||
b = b[m:]
|
||||
@@ -518,7 +504,7 @@ func (fd *Field) unmarshalOptions(b []byte) {
|
||||
}
|
||||
}
|
||||
|
||||
func (od *Oneof) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd protoreflect.Descriptor, i int) {
|
||||
func (od *Oneof) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd pref.Descriptor, i int) {
|
||||
od.L0.ParentFile = pf
|
||||
od.L0.Parent = pd
|
||||
od.L0.Index = i
|
||||
@@ -548,7 +534,6 @@ func (od *Oneof) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd protoref
|
||||
func (xd *Extension) unmarshalFull(b []byte, sb *strs.Builder) {
|
||||
var rawTypeName []byte
|
||||
var rawOptions []byte
|
||||
xd.L1.EditionFeatures = featuresFromParentDesc(xd.L1.Extendee)
|
||||
xd.L2 = new(ExtensionL2)
|
||||
for len(b) > 0 {
|
||||
num, typ, n := protowire.ConsumeTag(b)
|
||||
@@ -568,7 +553,7 @@ func (xd *Extension) unmarshalFull(b []byte, sb *strs.Builder) {
|
||||
case genid.FieldDescriptorProto_JsonName_field_number:
|
||||
xd.L2.StringName.InitJSON(sb.MakeString(v))
|
||||
case genid.FieldDescriptorProto_DefaultValue_field_number:
|
||||
xd.L2.Default.val = protoreflect.ValueOfBytes(v) // temporarily store as bytes; later resolved in resolveExtensions
|
||||
xd.L2.Default.val = pref.ValueOfBytes(v) // temporarily store as bytes; later resolved in resolveExtensions
|
||||
case genid.FieldDescriptorProto_TypeName_field_number:
|
||||
rawTypeName = v
|
||||
case genid.FieldDescriptorProto_Options_field_number:
|
||||
@@ -580,18 +565,12 @@ func (xd *Extension) unmarshalFull(b []byte, sb *strs.Builder) {
|
||||
b = b[m:]
|
||||
}
|
||||
}
|
||||
if xd.Syntax() == protoreflect.Editions && xd.L1.Kind == protoreflect.MessageKind && xd.L1.EditionFeatures.IsDelimitedEncoded {
|
||||
xd.L1.Kind = protoreflect.GroupKind
|
||||
}
|
||||
if xd.Syntax() == protoreflect.Editions && xd.L1.EditionFeatures.IsLegacyRequired {
|
||||
xd.L1.Cardinality = protoreflect.Required
|
||||
}
|
||||
if rawTypeName != nil {
|
||||
name := makeFullName(sb, rawTypeName)
|
||||
switch xd.L1.Kind {
|
||||
case protoreflect.EnumKind:
|
||||
case pref.EnumKind:
|
||||
xd.L2.Enum = PlaceholderEnum(name)
|
||||
case protoreflect.MessageKind, protoreflect.GroupKind:
|
||||
case pref.MessageKind, pref.GroupKind:
|
||||
xd.L2.Message = PlaceholderMessage(name)
|
||||
}
|
||||
}
|
||||
@@ -610,13 +589,6 @@ func (xd *Extension) unmarshalOptions(b []byte) {
|
||||
case genid.FieldOptions_Packed_field_number:
|
||||
xd.L2.IsPacked = protowire.DecodeBool(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FieldOptions_Features_field_number:
|
||||
xd.L1.EditionFeatures = unmarshalFeatureSet(v, xd.L1.EditionFeatures)
|
||||
}
|
||||
default:
|
||||
m := protowire.ConsumeFieldValue(num, typ, b)
|
||||
b = b[m:]
|
||||
@@ -655,7 +627,7 @@ func (sd *Service) unmarshalFull(b []byte, sb *strs.Builder) {
|
||||
sd.L2.Options = sd.L0.ParentFile.builder.optionsUnmarshaler(&descopts.Service, rawOptions)
|
||||
}
|
||||
|
||||
func (md *Method) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd protoreflect.Descriptor, i int) {
|
||||
func (md *Method) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd pref.Descriptor, i int) {
|
||||
md.L0.ParentFile = pf
|
||||
md.L0.Parent = pd
|
||||
md.L0.Index = i
|
||||
@@ -708,18 +680,18 @@ func appendOptions(dst, src []byte) []byte {
|
||||
//
|
||||
// The type of message to unmarshal to is passed as a pointer since the
|
||||
// vars in descopts may not yet be populated at the time this function is called.
|
||||
func (db *Builder) optionsUnmarshaler(p *protoreflect.ProtoMessage, b []byte) func() protoreflect.ProtoMessage {
|
||||
func (db *Builder) optionsUnmarshaler(p *pref.ProtoMessage, b []byte) func() pref.ProtoMessage {
|
||||
if b == nil {
|
||||
return nil
|
||||
}
|
||||
var opts protoreflect.ProtoMessage
|
||||
var opts pref.ProtoMessage
|
||||
var once sync.Once
|
||||
return func() protoreflect.ProtoMessage {
|
||||
return func() pref.ProtoMessage {
|
||||
once.Do(func() {
|
||||
if *p == nil {
|
||||
panic("Descriptor.Options called without importing the descriptor package")
|
||||
}
|
||||
opts = reflect.New(reflect.TypeOf(*p).Elem()).Interface().(protoreflect.ProtoMessage)
|
||||
opts = reflect.New(reflect.TypeOf(*p).Elem()).Interface().(pref.ProtoMessage)
|
||||
if err := (proto.UnmarshalOptions{
|
||||
AllowPartial: true,
|
||||
Resolver: db.TypeResolver,
|
||||
|
||||
167
vendor/google.golang.org/protobuf/internal/filedesc/desc_list.go
generated
vendored
167
vendor/google.golang.org/protobuf/internal/filedesc/desc_list.go
generated
vendored
@@ -17,30 +17,31 @@ import (
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/internal/pragma"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
type FileImports []protoreflect.FileImport
|
||||
type FileImports []pref.FileImport
|
||||
|
||||
func (p *FileImports) Len() int { return len(*p) }
|
||||
func (p *FileImports) Get(i int) protoreflect.FileImport { return (*p)[i] }
|
||||
func (p *FileImports) Get(i int) pref.FileImport { return (*p)[i] }
|
||||
func (p *FileImports) Format(s fmt.State, r rune) { descfmt.FormatList(s, r, p) }
|
||||
func (p *FileImports) ProtoInternal(pragma.DoNotImplement) {}
|
||||
|
||||
type Names struct {
|
||||
List []protoreflect.Name
|
||||
List []pref.Name
|
||||
once sync.Once
|
||||
has map[protoreflect.Name]int // protected by once
|
||||
has map[pref.Name]int // protected by once
|
||||
}
|
||||
|
||||
func (p *Names) Len() int { return len(p.List) }
|
||||
func (p *Names) Get(i int) protoreflect.Name { return p.List[i] }
|
||||
func (p *Names) Has(s protoreflect.Name) bool { return p.lazyInit().has[s] > 0 }
|
||||
func (p *Names) Get(i int) pref.Name { return p.List[i] }
|
||||
func (p *Names) Has(s pref.Name) bool { return p.lazyInit().has[s] > 0 }
|
||||
func (p *Names) Format(s fmt.State, r rune) { descfmt.FormatList(s, r, p) }
|
||||
func (p *Names) ProtoInternal(pragma.DoNotImplement) {}
|
||||
func (p *Names) lazyInit() *Names {
|
||||
p.once.Do(func() {
|
||||
if len(p.List) > 0 {
|
||||
p.has = make(map[protoreflect.Name]int, len(p.List))
|
||||
p.has = make(map[pref.Name]int, len(p.List))
|
||||
for _, s := range p.List {
|
||||
p.has[s] = p.has[s] + 1
|
||||
}
|
||||
@@ -66,14 +67,14 @@ func (p *Names) CheckValid() error {
|
||||
}
|
||||
|
||||
type EnumRanges struct {
|
||||
List [][2]protoreflect.EnumNumber // start inclusive; end inclusive
|
||||
List [][2]pref.EnumNumber // start inclusive; end inclusive
|
||||
once sync.Once
|
||||
sorted [][2]protoreflect.EnumNumber // protected by once
|
||||
sorted [][2]pref.EnumNumber // protected by once
|
||||
}
|
||||
|
||||
func (p *EnumRanges) Len() int { return len(p.List) }
|
||||
func (p *EnumRanges) Get(i int) [2]protoreflect.EnumNumber { return p.List[i] }
|
||||
func (p *EnumRanges) Has(n protoreflect.EnumNumber) bool {
|
||||
func (p *EnumRanges) Len() int { return len(p.List) }
|
||||
func (p *EnumRanges) Get(i int) [2]pref.EnumNumber { return p.List[i] }
|
||||
func (p *EnumRanges) Has(n pref.EnumNumber) bool {
|
||||
for ls := p.lazyInit().sorted; len(ls) > 0; {
|
||||
i := len(ls) / 2
|
||||
switch r := enumRange(ls[i]); {
|
||||
@@ -128,14 +129,14 @@ func (r enumRange) String() string {
|
||||
}
|
||||
|
||||
type FieldRanges struct {
|
||||
List [][2]protoreflect.FieldNumber // start inclusive; end exclusive
|
||||
List [][2]pref.FieldNumber // start inclusive; end exclusive
|
||||
once sync.Once
|
||||
sorted [][2]protoreflect.FieldNumber // protected by once
|
||||
sorted [][2]pref.FieldNumber // protected by once
|
||||
}
|
||||
|
||||
func (p *FieldRanges) Len() int { return len(p.List) }
|
||||
func (p *FieldRanges) Get(i int) [2]protoreflect.FieldNumber { return p.List[i] }
|
||||
func (p *FieldRanges) Has(n protoreflect.FieldNumber) bool {
|
||||
func (p *FieldRanges) Len() int { return len(p.List) }
|
||||
func (p *FieldRanges) Get(i int) [2]pref.FieldNumber { return p.List[i] }
|
||||
func (p *FieldRanges) Has(n pref.FieldNumber) bool {
|
||||
for ls := p.lazyInit().sorted; len(ls) > 0; {
|
||||
i := len(ls) / 2
|
||||
switch r := fieldRange(ls[i]); {
|
||||
@@ -220,17 +221,17 @@ func (r fieldRange) String() string {
|
||||
}
|
||||
|
||||
type FieldNumbers struct {
|
||||
List []protoreflect.FieldNumber
|
||||
List []pref.FieldNumber
|
||||
once sync.Once
|
||||
has map[protoreflect.FieldNumber]struct{} // protected by once
|
||||
has map[pref.FieldNumber]struct{} // protected by once
|
||||
}
|
||||
|
||||
func (p *FieldNumbers) Len() int { return len(p.List) }
|
||||
func (p *FieldNumbers) Get(i int) protoreflect.FieldNumber { return p.List[i] }
|
||||
func (p *FieldNumbers) Has(n protoreflect.FieldNumber) bool {
|
||||
func (p *FieldNumbers) Len() int { return len(p.List) }
|
||||
func (p *FieldNumbers) Get(i int) pref.FieldNumber { return p.List[i] }
|
||||
func (p *FieldNumbers) Has(n pref.FieldNumber) bool {
|
||||
p.once.Do(func() {
|
||||
if len(p.List) > 0 {
|
||||
p.has = make(map[protoreflect.FieldNumber]struct{}, len(p.List))
|
||||
p.has = make(map[pref.FieldNumber]struct{}, len(p.List))
|
||||
for _, n := range p.List {
|
||||
p.has[n] = struct{}{}
|
||||
}
|
||||
@@ -243,38 +244,30 @@ func (p *FieldNumbers) Format(s fmt.State, r rune) { descfmt.FormatList
|
||||
func (p *FieldNumbers) ProtoInternal(pragma.DoNotImplement) {}
|
||||
|
||||
type OneofFields struct {
|
||||
List []protoreflect.FieldDescriptor
|
||||
List []pref.FieldDescriptor
|
||||
once sync.Once
|
||||
byName map[protoreflect.Name]protoreflect.FieldDescriptor // protected by once
|
||||
byJSON map[string]protoreflect.FieldDescriptor // protected by once
|
||||
byText map[string]protoreflect.FieldDescriptor // protected by once
|
||||
byNum map[protoreflect.FieldNumber]protoreflect.FieldDescriptor // protected by once
|
||||
byName map[pref.Name]pref.FieldDescriptor // protected by once
|
||||
byJSON map[string]pref.FieldDescriptor // protected by once
|
||||
byText map[string]pref.FieldDescriptor // protected by once
|
||||
byNum map[pref.FieldNumber]pref.FieldDescriptor // protected by once
|
||||
}
|
||||
|
||||
func (p *OneofFields) Len() int { return len(p.List) }
|
||||
func (p *OneofFields) Get(i int) protoreflect.FieldDescriptor { return p.List[i] }
|
||||
func (p *OneofFields) ByName(s protoreflect.Name) protoreflect.FieldDescriptor {
|
||||
return p.lazyInit().byName[s]
|
||||
}
|
||||
func (p *OneofFields) ByJSONName(s string) protoreflect.FieldDescriptor {
|
||||
return p.lazyInit().byJSON[s]
|
||||
}
|
||||
func (p *OneofFields) ByTextName(s string) protoreflect.FieldDescriptor {
|
||||
return p.lazyInit().byText[s]
|
||||
}
|
||||
func (p *OneofFields) ByNumber(n protoreflect.FieldNumber) protoreflect.FieldDescriptor {
|
||||
return p.lazyInit().byNum[n]
|
||||
}
|
||||
func (p *OneofFields) Format(s fmt.State, r rune) { descfmt.FormatList(s, r, p) }
|
||||
func (p *OneofFields) ProtoInternal(pragma.DoNotImplement) {}
|
||||
func (p *OneofFields) Len() int { return len(p.List) }
|
||||
func (p *OneofFields) Get(i int) pref.FieldDescriptor { return p.List[i] }
|
||||
func (p *OneofFields) ByName(s pref.Name) pref.FieldDescriptor { return p.lazyInit().byName[s] }
|
||||
func (p *OneofFields) ByJSONName(s string) pref.FieldDescriptor { return p.lazyInit().byJSON[s] }
|
||||
func (p *OneofFields) ByTextName(s string) pref.FieldDescriptor { return p.lazyInit().byText[s] }
|
||||
func (p *OneofFields) ByNumber(n pref.FieldNumber) pref.FieldDescriptor { return p.lazyInit().byNum[n] }
|
||||
func (p *OneofFields) Format(s fmt.State, r rune) { descfmt.FormatList(s, r, p) }
|
||||
func (p *OneofFields) ProtoInternal(pragma.DoNotImplement) {}
|
||||
|
||||
func (p *OneofFields) lazyInit() *OneofFields {
|
||||
p.once.Do(func() {
|
||||
if len(p.List) > 0 {
|
||||
p.byName = make(map[protoreflect.Name]protoreflect.FieldDescriptor, len(p.List))
|
||||
p.byJSON = make(map[string]protoreflect.FieldDescriptor, len(p.List))
|
||||
p.byText = make(map[string]protoreflect.FieldDescriptor, len(p.List))
|
||||
p.byNum = make(map[protoreflect.FieldNumber]protoreflect.FieldDescriptor, len(p.List))
|
||||
p.byName = make(map[pref.Name]pref.FieldDescriptor, len(p.List))
|
||||
p.byJSON = make(map[string]pref.FieldDescriptor, len(p.List))
|
||||
p.byText = make(map[string]pref.FieldDescriptor, len(p.List))
|
||||
p.byNum = make(map[pref.FieldNumber]pref.FieldDescriptor, len(p.List))
|
||||
for _, f := range p.List {
|
||||
// Field names and numbers are guaranteed to be unique.
|
||||
p.byName[f.Name()] = f
|
||||
@@ -291,123 +284,123 @@ type SourceLocations struct {
|
||||
// List is a list of SourceLocations.
|
||||
// The SourceLocation.Next field does not need to be populated
|
||||
// as it will be lazily populated upon first need.
|
||||
List []protoreflect.SourceLocation
|
||||
List []pref.SourceLocation
|
||||
|
||||
// File is the parent file descriptor that these locations are relative to.
|
||||
// If non-nil, ByDescriptor verifies that the provided descriptor
|
||||
// is a child of this file descriptor.
|
||||
File protoreflect.FileDescriptor
|
||||
File pref.FileDescriptor
|
||||
|
||||
once sync.Once
|
||||
byPath map[pathKey]int
|
||||
}
|
||||
|
||||
func (p *SourceLocations) Len() int { return len(p.List) }
|
||||
func (p *SourceLocations) Get(i int) protoreflect.SourceLocation { return p.lazyInit().List[i] }
|
||||
func (p *SourceLocations) byKey(k pathKey) protoreflect.SourceLocation {
|
||||
func (p *SourceLocations) Len() int { return len(p.List) }
|
||||
func (p *SourceLocations) Get(i int) pref.SourceLocation { return p.lazyInit().List[i] }
|
||||
func (p *SourceLocations) byKey(k pathKey) pref.SourceLocation {
|
||||
if i, ok := p.lazyInit().byPath[k]; ok {
|
||||
return p.List[i]
|
||||
}
|
||||
return protoreflect.SourceLocation{}
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
func (p *SourceLocations) ByPath(path protoreflect.SourcePath) protoreflect.SourceLocation {
|
||||
func (p *SourceLocations) ByPath(path pref.SourcePath) pref.SourceLocation {
|
||||
return p.byKey(newPathKey(path))
|
||||
}
|
||||
func (p *SourceLocations) ByDescriptor(desc protoreflect.Descriptor) protoreflect.SourceLocation {
|
||||
func (p *SourceLocations) ByDescriptor(desc pref.Descriptor) pref.SourceLocation {
|
||||
if p.File != nil && desc != nil && p.File != desc.ParentFile() {
|
||||
return protoreflect.SourceLocation{} // mismatching parent files
|
||||
return pref.SourceLocation{} // mismatching parent files
|
||||
}
|
||||
var pathArr [16]int32
|
||||
path := pathArr[:0]
|
||||
for {
|
||||
switch desc.(type) {
|
||||
case protoreflect.FileDescriptor:
|
||||
case pref.FileDescriptor:
|
||||
// Reverse the path since it was constructed in reverse.
|
||||
for i, j := 0, len(path)-1; i < j; i, j = i+1, j-1 {
|
||||
path[i], path[j] = path[j], path[i]
|
||||
}
|
||||
return p.byKey(newPathKey(path))
|
||||
case protoreflect.MessageDescriptor:
|
||||
case pref.MessageDescriptor:
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
switch desc.(type) {
|
||||
case protoreflect.FileDescriptor:
|
||||
case pref.FileDescriptor:
|
||||
path = append(path, int32(genid.FileDescriptorProto_MessageType_field_number))
|
||||
case protoreflect.MessageDescriptor:
|
||||
case pref.MessageDescriptor:
|
||||
path = append(path, int32(genid.DescriptorProto_NestedType_field_number))
|
||||
default:
|
||||
return protoreflect.SourceLocation{}
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
case protoreflect.FieldDescriptor:
|
||||
isExtension := desc.(protoreflect.FieldDescriptor).IsExtension()
|
||||
case pref.FieldDescriptor:
|
||||
isExtension := desc.(pref.FieldDescriptor).IsExtension()
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
if isExtension {
|
||||
switch desc.(type) {
|
||||
case protoreflect.FileDescriptor:
|
||||
case pref.FileDescriptor:
|
||||
path = append(path, int32(genid.FileDescriptorProto_Extension_field_number))
|
||||
case protoreflect.MessageDescriptor:
|
||||
case pref.MessageDescriptor:
|
||||
path = append(path, int32(genid.DescriptorProto_Extension_field_number))
|
||||
default:
|
||||
return protoreflect.SourceLocation{}
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
} else {
|
||||
switch desc.(type) {
|
||||
case protoreflect.MessageDescriptor:
|
||||
case pref.MessageDescriptor:
|
||||
path = append(path, int32(genid.DescriptorProto_Field_field_number))
|
||||
default:
|
||||
return protoreflect.SourceLocation{}
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
}
|
||||
case protoreflect.OneofDescriptor:
|
||||
case pref.OneofDescriptor:
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
switch desc.(type) {
|
||||
case protoreflect.MessageDescriptor:
|
||||
case pref.MessageDescriptor:
|
||||
path = append(path, int32(genid.DescriptorProto_OneofDecl_field_number))
|
||||
default:
|
||||
return protoreflect.SourceLocation{}
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
case protoreflect.EnumDescriptor:
|
||||
case pref.EnumDescriptor:
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
switch desc.(type) {
|
||||
case protoreflect.FileDescriptor:
|
||||
case pref.FileDescriptor:
|
||||
path = append(path, int32(genid.FileDescriptorProto_EnumType_field_number))
|
||||
case protoreflect.MessageDescriptor:
|
||||
case pref.MessageDescriptor:
|
||||
path = append(path, int32(genid.DescriptorProto_EnumType_field_number))
|
||||
default:
|
||||
return protoreflect.SourceLocation{}
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
case protoreflect.EnumValueDescriptor:
|
||||
case pref.EnumValueDescriptor:
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
switch desc.(type) {
|
||||
case protoreflect.EnumDescriptor:
|
||||
case pref.EnumDescriptor:
|
||||
path = append(path, int32(genid.EnumDescriptorProto_Value_field_number))
|
||||
default:
|
||||
return protoreflect.SourceLocation{}
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
case protoreflect.ServiceDescriptor:
|
||||
case pref.ServiceDescriptor:
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
switch desc.(type) {
|
||||
case protoreflect.FileDescriptor:
|
||||
case pref.FileDescriptor:
|
||||
path = append(path, int32(genid.FileDescriptorProto_Service_field_number))
|
||||
default:
|
||||
return protoreflect.SourceLocation{}
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
case protoreflect.MethodDescriptor:
|
||||
case pref.MethodDescriptor:
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
switch desc.(type) {
|
||||
case protoreflect.ServiceDescriptor:
|
||||
case pref.ServiceDescriptor:
|
||||
path = append(path, int32(genid.ServiceDescriptorProto_Method_field_number))
|
||||
default:
|
||||
return protoreflect.SourceLocation{}
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
default:
|
||||
return protoreflect.SourceLocation{}
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -442,7 +435,7 @@ type pathKey struct {
|
||||
str string // used if the path does not fit in arr
|
||||
}
|
||||
|
||||
func newPathKey(p protoreflect.SourcePath) (k pathKey) {
|
||||
func newPathKey(p pref.SourcePath) (k pathKey) {
|
||||
if len(p) < len(k.arr) {
|
||||
for i, ps := range p {
|
||||
if ps < 0 || math.MaxUint8 <= ps {
|
||||
|
||||
142
vendor/google.golang.org/protobuf/internal/filedesc/editions.go
generated
vendored
142
vendor/google.golang.org/protobuf/internal/filedesc/editions.go
generated
vendored
@@ -1,142 +0,0 @@
|
||||
// Copyright 2024 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package filedesc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/editiondefaults"
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
var defaultsCache = make(map[Edition]EditionFeatures)
|
||||
|
||||
func init() {
|
||||
unmarshalEditionDefaults(editiondefaults.Defaults)
|
||||
}
|
||||
|
||||
func unmarshalGoFeature(b []byte, parent EditionFeatures) EditionFeatures {
|
||||
for len(b) > 0 {
|
||||
num, _, n := protowire.ConsumeTag(b)
|
||||
b = b[n:]
|
||||
switch num {
|
||||
case genid.GoFeatures_LegacyUnmarshalJsonEnum_field_number:
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
parent.GenerateLegacyUnmarshalJSON = protowire.DecodeBool(v)
|
||||
default:
|
||||
panic(fmt.Sprintf("unkown field number %d while unmarshalling GoFeatures", num))
|
||||
}
|
||||
}
|
||||
return parent
|
||||
}
|
||||
|
||||
func unmarshalFeatureSet(b []byte, parent EditionFeatures) EditionFeatures {
|
||||
for len(b) > 0 {
|
||||
num, typ, n := protowire.ConsumeTag(b)
|
||||
b = b[n:]
|
||||
switch typ {
|
||||
case protowire.VarintType:
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FeatureSet_FieldPresence_field_number:
|
||||
parent.IsFieldPresence = v == genid.FeatureSet_EXPLICIT_enum_value || v == genid.FeatureSet_LEGACY_REQUIRED_enum_value
|
||||
parent.IsLegacyRequired = v == genid.FeatureSet_LEGACY_REQUIRED_enum_value
|
||||
case genid.FeatureSet_EnumType_field_number:
|
||||
parent.IsOpenEnum = v == genid.FeatureSet_OPEN_enum_value
|
||||
case genid.FeatureSet_RepeatedFieldEncoding_field_number:
|
||||
parent.IsPacked = v == genid.FeatureSet_PACKED_enum_value
|
||||
case genid.FeatureSet_Utf8Validation_field_number:
|
||||
parent.IsUTF8Validated = v == genid.FeatureSet_VERIFY_enum_value
|
||||
case genid.FeatureSet_MessageEncoding_field_number:
|
||||
parent.IsDelimitedEncoded = v == genid.FeatureSet_DELIMITED_enum_value
|
||||
case genid.FeatureSet_JsonFormat_field_number:
|
||||
parent.IsJSONCompliant = v == genid.FeatureSet_ALLOW_enum_value
|
||||
default:
|
||||
panic(fmt.Sprintf("unkown field number %d while unmarshalling FeatureSet", num))
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.GoFeatures_LegacyUnmarshalJsonEnum_field_number:
|
||||
parent = unmarshalGoFeature(v, parent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return parent
|
||||
}
|
||||
|
||||
func featuresFromParentDesc(parentDesc protoreflect.Descriptor) EditionFeatures {
|
||||
var parentFS EditionFeatures
|
||||
switch p := parentDesc.(type) {
|
||||
case *File:
|
||||
parentFS = p.L1.EditionFeatures
|
||||
case *Message:
|
||||
parentFS = p.L1.EditionFeatures
|
||||
default:
|
||||
panic(fmt.Sprintf("unknown parent type %T", parentDesc))
|
||||
}
|
||||
return parentFS
|
||||
}
|
||||
|
||||
func unmarshalEditionDefault(b []byte) {
|
||||
var ed Edition
|
||||
var fs EditionFeatures
|
||||
for len(b) > 0 {
|
||||
num, typ, n := protowire.ConsumeTag(b)
|
||||
b = b[n:]
|
||||
switch typ {
|
||||
case protowire.VarintType:
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FeatureSetDefaults_FeatureSetEditionDefault_Edition_field_number:
|
||||
ed = Edition(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FeatureSetDefaults_FeatureSetEditionDefault_Features_field_number:
|
||||
fs = unmarshalFeatureSet(v, fs)
|
||||
}
|
||||
}
|
||||
}
|
||||
defaultsCache[ed] = fs
|
||||
}
|
||||
|
||||
func unmarshalEditionDefaults(b []byte) {
|
||||
for len(b) > 0 {
|
||||
num, _, n := protowire.ConsumeTag(b)
|
||||
b = b[n:]
|
||||
switch num {
|
||||
case genid.FeatureSetDefaults_Defaults_field_number:
|
||||
def, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
unmarshalEditionDefault(def)
|
||||
case genid.FeatureSetDefaults_MinimumEdition_field_number,
|
||||
genid.FeatureSetDefaults_MaximumEdition_field_number:
|
||||
// We don't care about the minimum and maximum editions. If the
|
||||
// edition we are looking for later on is not in the cache we know
|
||||
// it is outside of the range between minimum and maximum edition.
|
||||
_, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
default:
|
||||
panic(fmt.Sprintf("unkown field number %d while unmarshalling EditionDefault", num))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func getFeaturesFor(ed Edition) EditionFeatures {
|
||||
if def, ok := defaultsCache[ed]; ok {
|
||||
return def
|
||||
}
|
||||
panic(fmt.Sprintf("unsupported edition: %v", ed))
|
||||
}
|
||||
136
vendor/google.golang.org/protobuf/internal/filedesc/placeholder.go
generated
vendored
136
vendor/google.golang.org/protobuf/internal/filedesc/placeholder.go
generated
vendored
@@ -7,7 +7,7 @@ package filedesc
|
||||
import (
|
||||
"google.golang.org/protobuf/internal/descopts"
|
||||
"google.golang.org/protobuf/internal/pragma"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -30,80 +30,78 @@ var (
|
||||
// PlaceholderFile is a placeholder, representing only the file path.
|
||||
type PlaceholderFile string
|
||||
|
||||
func (f PlaceholderFile) ParentFile() protoreflect.FileDescriptor { return f }
|
||||
func (f PlaceholderFile) Parent() protoreflect.Descriptor { return nil }
|
||||
func (f PlaceholderFile) Index() int { return 0 }
|
||||
func (f PlaceholderFile) Syntax() protoreflect.Syntax { return 0 }
|
||||
func (f PlaceholderFile) Name() protoreflect.Name { return "" }
|
||||
func (f PlaceholderFile) FullName() protoreflect.FullName { return "" }
|
||||
func (f PlaceholderFile) IsPlaceholder() bool { return true }
|
||||
func (f PlaceholderFile) Options() protoreflect.ProtoMessage { return descopts.File }
|
||||
func (f PlaceholderFile) Path() string { return string(f) }
|
||||
func (f PlaceholderFile) Package() protoreflect.FullName { return "" }
|
||||
func (f PlaceholderFile) Imports() protoreflect.FileImports { return emptyFiles }
|
||||
func (f PlaceholderFile) Messages() protoreflect.MessageDescriptors { return emptyMessages }
|
||||
func (f PlaceholderFile) Enums() protoreflect.EnumDescriptors { return emptyEnums }
|
||||
func (f PlaceholderFile) Extensions() protoreflect.ExtensionDescriptors { return emptyExtensions }
|
||||
func (f PlaceholderFile) Services() protoreflect.ServiceDescriptors { return emptyServices }
|
||||
func (f PlaceholderFile) SourceLocations() protoreflect.SourceLocations { return emptySourceLocations }
|
||||
func (f PlaceholderFile) ProtoType(protoreflect.FileDescriptor) { return }
|
||||
func (f PlaceholderFile) ProtoInternal(pragma.DoNotImplement) { return }
|
||||
func (f PlaceholderFile) ParentFile() pref.FileDescriptor { return f }
|
||||
func (f PlaceholderFile) Parent() pref.Descriptor { return nil }
|
||||
func (f PlaceholderFile) Index() int { return 0 }
|
||||
func (f PlaceholderFile) Syntax() pref.Syntax { return 0 }
|
||||
func (f PlaceholderFile) Name() pref.Name { return "" }
|
||||
func (f PlaceholderFile) FullName() pref.FullName { return "" }
|
||||
func (f PlaceholderFile) IsPlaceholder() bool { return true }
|
||||
func (f PlaceholderFile) Options() pref.ProtoMessage { return descopts.File }
|
||||
func (f PlaceholderFile) Path() string { return string(f) }
|
||||
func (f PlaceholderFile) Package() pref.FullName { return "" }
|
||||
func (f PlaceholderFile) Imports() pref.FileImports { return emptyFiles }
|
||||
func (f PlaceholderFile) Messages() pref.MessageDescriptors { return emptyMessages }
|
||||
func (f PlaceholderFile) Enums() pref.EnumDescriptors { return emptyEnums }
|
||||
func (f PlaceholderFile) Extensions() pref.ExtensionDescriptors { return emptyExtensions }
|
||||
func (f PlaceholderFile) Services() pref.ServiceDescriptors { return emptyServices }
|
||||
func (f PlaceholderFile) SourceLocations() pref.SourceLocations { return emptySourceLocations }
|
||||
func (f PlaceholderFile) ProtoType(pref.FileDescriptor) { return }
|
||||
func (f PlaceholderFile) ProtoInternal(pragma.DoNotImplement) { return }
|
||||
|
||||
// PlaceholderEnum is a placeholder, representing only the full name.
|
||||
type PlaceholderEnum protoreflect.FullName
|
||||
type PlaceholderEnum pref.FullName
|
||||
|
||||
func (e PlaceholderEnum) ParentFile() protoreflect.FileDescriptor { return nil }
|
||||
func (e PlaceholderEnum) Parent() protoreflect.Descriptor { return nil }
|
||||
func (e PlaceholderEnum) Index() int { return 0 }
|
||||
func (e PlaceholderEnum) Syntax() protoreflect.Syntax { return 0 }
|
||||
func (e PlaceholderEnum) Name() protoreflect.Name { return protoreflect.FullName(e).Name() }
|
||||
func (e PlaceholderEnum) FullName() protoreflect.FullName { return protoreflect.FullName(e) }
|
||||
func (e PlaceholderEnum) IsPlaceholder() bool { return true }
|
||||
func (e PlaceholderEnum) Options() protoreflect.ProtoMessage { return descopts.Enum }
|
||||
func (e PlaceholderEnum) Values() protoreflect.EnumValueDescriptors { return emptyEnumValues }
|
||||
func (e PlaceholderEnum) ReservedNames() protoreflect.Names { return emptyNames }
|
||||
func (e PlaceholderEnum) ReservedRanges() protoreflect.EnumRanges { return emptyEnumRanges }
|
||||
func (e PlaceholderEnum) ProtoType(protoreflect.EnumDescriptor) { return }
|
||||
func (e PlaceholderEnum) ProtoInternal(pragma.DoNotImplement) { return }
|
||||
func (e PlaceholderEnum) ParentFile() pref.FileDescriptor { return nil }
|
||||
func (e PlaceholderEnum) Parent() pref.Descriptor { return nil }
|
||||
func (e PlaceholderEnum) Index() int { return 0 }
|
||||
func (e PlaceholderEnum) Syntax() pref.Syntax { return 0 }
|
||||
func (e PlaceholderEnum) Name() pref.Name { return pref.FullName(e).Name() }
|
||||
func (e PlaceholderEnum) FullName() pref.FullName { return pref.FullName(e) }
|
||||
func (e PlaceholderEnum) IsPlaceholder() bool { return true }
|
||||
func (e PlaceholderEnum) Options() pref.ProtoMessage { return descopts.Enum }
|
||||
func (e PlaceholderEnum) Values() pref.EnumValueDescriptors { return emptyEnumValues }
|
||||
func (e PlaceholderEnum) ReservedNames() pref.Names { return emptyNames }
|
||||
func (e PlaceholderEnum) ReservedRanges() pref.EnumRanges { return emptyEnumRanges }
|
||||
func (e PlaceholderEnum) ProtoType(pref.EnumDescriptor) { return }
|
||||
func (e PlaceholderEnum) ProtoInternal(pragma.DoNotImplement) { return }
|
||||
|
||||
// PlaceholderEnumValue is a placeholder, representing only the full name.
|
||||
type PlaceholderEnumValue protoreflect.FullName
|
||||
type PlaceholderEnumValue pref.FullName
|
||||
|
||||
func (e PlaceholderEnumValue) ParentFile() protoreflect.FileDescriptor { return nil }
|
||||
func (e PlaceholderEnumValue) Parent() protoreflect.Descriptor { return nil }
|
||||
func (e PlaceholderEnumValue) Index() int { return 0 }
|
||||
func (e PlaceholderEnumValue) Syntax() protoreflect.Syntax { return 0 }
|
||||
func (e PlaceholderEnumValue) Name() protoreflect.Name { return protoreflect.FullName(e).Name() }
|
||||
func (e PlaceholderEnumValue) FullName() protoreflect.FullName { return protoreflect.FullName(e) }
|
||||
func (e PlaceholderEnumValue) IsPlaceholder() bool { return true }
|
||||
func (e PlaceholderEnumValue) Options() protoreflect.ProtoMessage { return descopts.EnumValue }
|
||||
func (e PlaceholderEnumValue) Number() protoreflect.EnumNumber { return 0 }
|
||||
func (e PlaceholderEnumValue) ProtoType(protoreflect.EnumValueDescriptor) { return }
|
||||
func (e PlaceholderEnumValue) ProtoInternal(pragma.DoNotImplement) { return }
|
||||
func (e PlaceholderEnumValue) ParentFile() pref.FileDescriptor { return nil }
|
||||
func (e PlaceholderEnumValue) Parent() pref.Descriptor { return nil }
|
||||
func (e PlaceholderEnumValue) Index() int { return 0 }
|
||||
func (e PlaceholderEnumValue) Syntax() pref.Syntax { return 0 }
|
||||
func (e PlaceholderEnumValue) Name() pref.Name { return pref.FullName(e).Name() }
|
||||
func (e PlaceholderEnumValue) FullName() pref.FullName { return pref.FullName(e) }
|
||||
func (e PlaceholderEnumValue) IsPlaceholder() bool { return true }
|
||||
func (e PlaceholderEnumValue) Options() pref.ProtoMessage { return descopts.EnumValue }
|
||||
func (e PlaceholderEnumValue) Number() pref.EnumNumber { return 0 }
|
||||
func (e PlaceholderEnumValue) ProtoType(pref.EnumValueDescriptor) { return }
|
||||
func (e PlaceholderEnumValue) ProtoInternal(pragma.DoNotImplement) { return }
|
||||
|
||||
// PlaceholderMessage is a placeholder, representing only the full name.
|
||||
type PlaceholderMessage protoreflect.FullName
|
||||
type PlaceholderMessage pref.FullName
|
||||
|
||||
func (m PlaceholderMessage) ParentFile() protoreflect.FileDescriptor { return nil }
|
||||
func (m PlaceholderMessage) Parent() protoreflect.Descriptor { return nil }
|
||||
func (m PlaceholderMessage) Index() int { return 0 }
|
||||
func (m PlaceholderMessage) Syntax() protoreflect.Syntax { return 0 }
|
||||
func (m PlaceholderMessage) Name() protoreflect.Name { return protoreflect.FullName(m).Name() }
|
||||
func (m PlaceholderMessage) FullName() protoreflect.FullName { return protoreflect.FullName(m) }
|
||||
func (m PlaceholderMessage) IsPlaceholder() bool { return true }
|
||||
func (m PlaceholderMessage) Options() protoreflect.ProtoMessage { return descopts.Message }
|
||||
func (m PlaceholderMessage) IsMapEntry() bool { return false }
|
||||
func (m PlaceholderMessage) Fields() protoreflect.FieldDescriptors { return emptyFields }
|
||||
func (m PlaceholderMessage) Oneofs() protoreflect.OneofDescriptors { return emptyOneofs }
|
||||
func (m PlaceholderMessage) ReservedNames() protoreflect.Names { return emptyNames }
|
||||
func (m PlaceholderMessage) ReservedRanges() protoreflect.FieldRanges { return emptyFieldRanges }
|
||||
func (m PlaceholderMessage) RequiredNumbers() protoreflect.FieldNumbers { return emptyFieldNumbers }
|
||||
func (m PlaceholderMessage) ExtensionRanges() protoreflect.FieldRanges { return emptyFieldRanges }
|
||||
func (m PlaceholderMessage) ExtensionRangeOptions(int) protoreflect.ProtoMessage {
|
||||
panic("index out of range")
|
||||
}
|
||||
func (m PlaceholderMessage) Messages() protoreflect.MessageDescriptors { return emptyMessages }
|
||||
func (m PlaceholderMessage) Enums() protoreflect.EnumDescriptors { return emptyEnums }
|
||||
func (m PlaceholderMessage) Extensions() protoreflect.ExtensionDescriptors { return emptyExtensions }
|
||||
func (m PlaceholderMessage) ProtoType(protoreflect.MessageDescriptor) { return }
|
||||
func (m PlaceholderMessage) ProtoInternal(pragma.DoNotImplement) { return }
|
||||
func (m PlaceholderMessage) ParentFile() pref.FileDescriptor { return nil }
|
||||
func (m PlaceholderMessage) Parent() pref.Descriptor { return nil }
|
||||
func (m PlaceholderMessage) Index() int { return 0 }
|
||||
func (m PlaceholderMessage) Syntax() pref.Syntax { return 0 }
|
||||
func (m PlaceholderMessage) Name() pref.Name { return pref.FullName(m).Name() }
|
||||
func (m PlaceholderMessage) FullName() pref.FullName { return pref.FullName(m) }
|
||||
func (m PlaceholderMessage) IsPlaceholder() bool { return true }
|
||||
func (m PlaceholderMessage) Options() pref.ProtoMessage { return descopts.Message }
|
||||
func (m PlaceholderMessage) IsMapEntry() bool { return false }
|
||||
func (m PlaceholderMessage) Fields() pref.FieldDescriptors { return emptyFields }
|
||||
func (m PlaceholderMessage) Oneofs() pref.OneofDescriptors { return emptyOneofs }
|
||||
func (m PlaceholderMessage) ReservedNames() pref.Names { return emptyNames }
|
||||
func (m PlaceholderMessage) ReservedRanges() pref.FieldRanges { return emptyFieldRanges }
|
||||
func (m PlaceholderMessage) RequiredNumbers() pref.FieldNumbers { return emptyFieldNumbers }
|
||||
func (m PlaceholderMessage) ExtensionRanges() pref.FieldRanges { return emptyFieldRanges }
|
||||
func (m PlaceholderMessage) ExtensionRangeOptions(int) pref.ProtoMessage { panic("index out of range") }
|
||||
func (m PlaceholderMessage) Messages() pref.MessageDescriptors { return emptyMessages }
|
||||
func (m PlaceholderMessage) Enums() pref.EnumDescriptors { return emptyEnums }
|
||||
func (m PlaceholderMessage) Extensions() pref.ExtensionDescriptors { return emptyExtensions }
|
||||
func (m PlaceholderMessage) ProtoType(pref.MessageDescriptor) { return }
|
||||
func (m PlaceholderMessage) ProtoInternal(pragma.DoNotImplement) { return }
|
||||
|
||||
87
vendor/google.golang.org/protobuf/internal/filetype/build.go
generated
vendored
87
vendor/google.golang.org/protobuf/internal/filetype/build.go
generated
vendored
@@ -10,16 +10,17 @@ import (
|
||||
"reflect"
|
||||
|
||||
"google.golang.org/protobuf/internal/descopts"
|
||||
"google.golang.org/protobuf/internal/filedesc"
|
||||
fdesc "google.golang.org/protobuf/internal/filedesc"
|
||||
pimpl "google.golang.org/protobuf/internal/impl"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
preg "google.golang.org/protobuf/reflect/protoregistry"
|
||||
)
|
||||
|
||||
// Builder constructs type descriptors from a raw file descriptor
|
||||
// and associated Go types for each enum and message declaration.
|
||||
//
|
||||
// # Flattened Ordering
|
||||
//
|
||||
// Flattened Ordering
|
||||
//
|
||||
// The protobuf type system represents declarations as a tree. Certain nodes in
|
||||
// the tree require us to either associate it with a concrete Go type or to
|
||||
@@ -51,7 +52,7 @@ import (
|
||||
// that children themselves may have.
|
||||
type Builder struct {
|
||||
// File is the underlying file descriptor builder.
|
||||
File filedesc.Builder
|
||||
File fdesc.Builder
|
||||
|
||||
// GoTypes is a unique set of the Go types for all declarations and
|
||||
// dependencies. Each type is represented as a zero value of the Go type.
|
||||
@@ -107,22 +108,22 @@ type Builder struct {
|
||||
// TypeRegistry is the registry to register each type descriptor.
|
||||
// If nil, it uses protoregistry.GlobalTypes.
|
||||
TypeRegistry interface {
|
||||
RegisterMessage(protoreflect.MessageType) error
|
||||
RegisterEnum(protoreflect.EnumType) error
|
||||
RegisterExtension(protoreflect.ExtensionType) error
|
||||
RegisterMessage(pref.MessageType) error
|
||||
RegisterEnum(pref.EnumType) error
|
||||
RegisterExtension(pref.ExtensionType) error
|
||||
}
|
||||
}
|
||||
|
||||
// Out is the output of the builder.
|
||||
type Out struct {
|
||||
File protoreflect.FileDescriptor
|
||||
File pref.FileDescriptor
|
||||
}
|
||||
|
||||
func (tb Builder) Build() (out Out) {
|
||||
// Replace the resolver with one that resolves dependencies by index,
|
||||
// which is faster and more reliable than relying on the global registry.
|
||||
if tb.File.FileRegistry == nil {
|
||||
tb.File.FileRegistry = protoregistry.GlobalFiles
|
||||
tb.File.FileRegistry = preg.GlobalFiles
|
||||
}
|
||||
tb.File.FileRegistry = &resolverByIndex{
|
||||
goTypes: tb.GoTypes,
|
||||
@@ -132,7 +133,7 @@ func (tb Builder) Build() (out Out) {
|
||||
|
||||
// Initialize registry if unpopulated.
|
||||
if tb.TypeRegistry == nil {
|
||||
tb.TypeRegistry = protoregistry.GlobalTypes
|
||||
tb.TypeRegistry = preg.GlobalTypes
|
||||
}
|
||||
|
||||
fbOut := tb.File.Build()
|
||||
@@ -182,23 +183,23 @@ func (tb Builder) Build() (out Out) {
|
||||
for i := range fbOut.Messages {
|
||||
switch fbOut.Messages[i].Name() {
|
||||
case "FileOptions":
|
||||
descopts.File = messageGoTypes[i].(protoreflect.ProtoMessage)
|
||||
descopts.File = messageGoTypes[i].(pref.ProtoMessage)
|
||||
case "EnumOptions":
|
||||
descopts.Enum = messageGoTypes[i].(protoreflect.ProtoMessage)
|
||||
descopts.Enum = messageGoTypes[i].(pref.ProtoMessage)
|
||||
case "EnumValueOptions":
|
||||
descopts.EnumValue = messageGoTypes[i].(protoreflect.ProtoMessage)
|
||||
descopts.EnumValue = messageGoTypes[i].(pref.ProtoMessage)
|
||||
case "MessageOptions":
|
||||
descopts.Message = messageGoTypes[i].(protoreflect.ProtoMessage)
|
||||
descopts.Message = messageGoTypes[i].(pref.ProtoMessage)
|
||||
case "FieldOptions":
|
||||
descopts.Field = messageGoTypes[i].(protoreflect.ProtoMessage)
|
||||
descopts.Field = messageGoTypes[i].(pref.ProtoMessage)
|
||||
case "OneofOptions":
|
||||
descopts.Oneof = messageGoTypes[i].(protoreflect.ProtoMessage)
|
||||
descopts.Oneof = messageGoTypes[i].(pref.ProtoMessage)
|
||||
case "ExtensionRangeOptions":
|
||||
descopts.ExtensionRange = messageGoTypes[i].(protoreflect.ProtoMessage)
|
||||
descopts.ExtensionRange = messageGoTypes[i].(pref.ProtoMessage)
|
||||
case "ServiceOptions":
|
||||
descopts.Service = messageGoTypes[i].(protoreflect.ProtoMessage)
|
||||
descopts.Service = messageGoTypes[i].(pref.ProtoMessage)
|
||||
case "MethodOptions":
|
||||
descopts.Method = messageGoTypes[i].(protoreflect.ProtoMessage)
|
||||
descopts.Method = messageGoTypes[i].(pref.ProtoMessage)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -215,11 +216,11 @@ func (tb Builder) Build() (out Out) {
|
||||
const listExtDeps = 2
|
||||
var goType reflect.Type
|
||||
switch fbOut.Extensions[i].L1.Kind {
|
||||
case protoreflect.EnumKind:
|
||||
case pref.EnumKind:
|
||||
j := depIdxs.Get(tb.DependencyIndexes, listExtDeps, depIdx)
|
||||
goType = reflect.TypeOf(tb.GoTypes[j])
|
||||
depIdx++
|
||||
case protoreflect.MessageKind, protoreflect.GroupKind:
|
||||
case pref.MessageKind, pref.GroupKind:
|
||||
j := depIdxs.Get(tb.DependencyIndexes, listExtDeps, depIdx)
|
||||
goType = reflect.TypeOf(tb.GoTypes[j])
|
||||
depIdx++
|
||||
@@ -241,22 +242,22 @@ func (tb Builder) Build() (out Out) {
|
||||
return out
|
||||
}
|
||||
|
||||
var goTypeForPBKind = map[protoreflect.Kind]reflect.Type{
|
||||
protoreflect.BoolKind: reflect.TypeOf(bool(false)),
|
||||
protoreflect.Int32Kind: reflect.TypeOf(int32(0)),
|
||||
protoreflect.Sint32Kind: reflect.TypeOf(int32(0)),
|
||||
protoreflect.Sfixed32Kind: reflect.TypeOf(int32(0)),
|
||||
protoreflect.Int64Kind: reflect.TypeOf(int64(0)),
|
||||
protoreflect.Sint64Kind: reflect.TypeOf(int64(0)),
|
||||
protoreflect.Sfixed64Kind: reflect.TypeOf(int64(0)),
|
||||
protoreflect.Uint32Kind: reflect.TypeOf(uint32(0)),
|
||||
protoreflect.Fixed32Kind: reflect.TypeOf(uint32(0)),
|
||||
protoreflect.Uint64Kind: reflect.TypeOf(uint64(0)),
|
||||
protoreflect.Fixed64Kind: reflect.TypeOf(uint64(0)),
|
||||
protoreflect.FloatKind: reflect.TypeOf(float32(0)),
|
||||
protoreflect.DoubleKind: reflect.TypeOf(float64(0)),
|
||||
protoreflect.StringKind: reflect.TypeOf(string("")),
|
||||
protoreflect.BytesKind: reflect.TypeOf([]byte(nil)),
|
||||
var goTypeForPBKind = map[pref.Kind]reflect.Type{
|
||||
pref.BoolKind: reflect.TypeOf(bool(false)),
|
||||
pref.Int32Kind: reflect.TypeOf(int32(0)),
|
||||
pref.Sint32Kind: reflect.TypeOf(int32(0)),
|
||||
pref.Sfixed32Kind: reflect.TypeOf(int32(0)),
|
||||
pref.Int64Kind: reflect.TypeOf(int64(0)),
|
||||
pref.Sint64Kind: reflect.TypeOf(int64(0)),
|
||||
pref.Sfixed64Kind: reflect.TypeOf(int64(0)),
|
||||
pref.Uint32Kind: reflect.TypeOf(uint32(0)),
|
||||
pref.Fixed32Kind: reflect.TypeOf(uint32(0)),
|
||||
pref.Uint64Kind: reflect.TypeOf(uint64(0)),
|
||||
pref.Fixed64Kind: reflect.TypeOf(uint64(0)),
|
||||
pref.FloatKind: reflect.TypeOf(float32(0)),
|
||||
pref.DoubleKind: reflect.TypeOf(float64(0)),
|
||||
pref.StringKind: reflect.TypeOf(string("")),
|
||||
pref.BytesKind: reflect.TypeOf([]byte(nil)),
|
||||
}
|
||||
|
||||
type depIdxs []int32
|
||||
@@ -273,13 +274,13 @@ type (
|
||||
fileRegistry
|
||||
}
|
||||
fileRegistry interface {
|
||||
FindFileByPath(string) (protoreflect.FileDescriptor, error)
|
||||
FindDescriptorByName(protoreflect.FullName) (protoreflect.Descriptor, error)
|
||||
RegisterFile(protoreflect.FileDescriptor) error
|
||||
FindFileByPath(string) (pref.FileDescriptor, error)
|
||||
FindDescriptorByName(pref.FullName) (pref.Descriptor, error)
|
||||
RegisterFile(pref.FileDescriptor) error
|
||||
}
|
||||
)
|
||||
|
||||
func (r *resolverByIndex) FindEnumByIndex(i, j int32, es []filedesc.Enum, ms []filedesc.Message) protoreflect.EnumDescriptor {
|
||||
func (r *resolverByIndex) FindEnumByIndex(i, j int32, es []fdesc.Enum, ms []fdesc.Message) pref.EnumDescriptor {
|
||||
if depIdx := int(r.depIdxs.Get(i, j)); int(depIdx) < len(es)+len(ms) {
|
||||
return &es[depIdx]
|
||||
} else {
|
||||
@@ -287,7 +288,7 @@ func (r *resolverByIndex) FindEnumByIndex(i, j int32, es []filedesc.Enum, ms []f
|
||||
}
|
||||
}
|
||||
|
||||
func (r *resolverByIndex) FindMessageByIndex(i, j int32, es []filedesc.Enum, ms []filedesc.Message) protoreflect.MessageDescriptor {
|
||||
func (r *resolverByIndex) FindMessageByIndex(i, j int32, es []fdesc.Enum, ms []fdesc.Message) pref.MessageDescriptor {
|
||||
if depIdx := int(r.depIdxs.Get(i, j)); depIdx < len(es)+len(ms) {
|
||||
return &ms[depIdx-len(es)]
|
||||
} else {
|
||||
|
||||
1
vendor/google.golang.org/protobuf/internal/flags/proto_legacy_disable.go
generated
vendored
1
vendor/google.golang.org/protobuf/internal/flags/proto_legacy_disable.go
generated
vendored
@@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !protolegacy
|
||||
// +build !protolegacy
|
||||
|
||||
package flags
|
||||
|
||||
1
vendor/google.golang.org/protobuf/internal/flags/proto_legacy_enable.go
generated
vendored
1
vendor/google.golang.org/protobuf/internal/flags/proto_legacy_enable.go
generated
vendored
@@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build protolegacy
|
||||
// +build protolegacy
|
||||
|
||||
package flags
|
||||
|
||||
458
vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go
generated
vendored
458
vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go
generated
vendored
@@ -12,27 +12,6 @@ import (
|
||||
|
||||
const File_google_protobuf_descriptor_proto = "google/protobuf/descriptor.proto"
|
||||
|
||||
// Full and short names for google.protobuf.Edition.
|
||||
const (
|
||||
Edition_enum_fullname = "google.protobuf.Edition"
|
||||
Edition_enum_name = "Edition"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.Edition.
|
||||
const (
|
||||
Edition_EDITION_UNKNOWN_enum_value = 0
|
||||
Edition_EDITION_PROTO2_enum_value = 998
|
||||
Edition_EDITION_PROTO3_enum_value = 999
|
||||
Edition_EDITION_2023_enum_value = 1000
|
||||
Edition_EDITION_2024_enum_value = 1001
|
||||
Edition_EDITION_1_TEST_ONLY_enum_value = 1
|
||||
Edition_EDITION_2_TEST_ONLY_enum_value = 2
|
||||
Edition_EDITION_99997_TEST_ONLY_enum_value = 99997
|
||||
Edition_EDITION_99998_TEST_ONLY_enum_value = 99998
|
||||
Edition_EDITION_99999_TEST_ONLY_enum_value = 99999
|
||||
Edition_EDITION_MAX_enum_value = 2147483647
|
||||
)
|
||||
|
||||
// Names for google.protobuf.FileDescriptorSet.
|
||||
const (
|
||||
FileDescriptorSet_message_name protoreflect.Name = "FileDescriptorSet"
|
||||
@@ -71,7 +50,6 @@ const (
|
||||
FileDescriptorProto_Options_field_name protoreflect.Name = "options"
|
||||
FileDescriptorProto_SourceCodeInfo_field_name protoreflect.Name = "source_code_info"
|
||||
FileDescriptorProto_Syntax_field_name protoreflect.Name = "syntax"
|
||||
FileDescriptorProto_Edition_field_name protoreflect.Name = "edition"
|
||||
|
||||
FileDescriptorProto_Name_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.name"
|
||||
FileDescriptorProto_Package_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.package"
|
||||
@@ -85,7 +63,6 @@ const (
|
||||
FileDescriptorProto_Options_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.options"
|
||||
FileDescriptorProto_SourceCodeInfo_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.source_code_info"
|
||||
FileDescriptorProto_Syntax_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.syntax"
|
||||
FileDescriptorProto_Edition_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.edition"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.FileDescriptorProto.
|
||||
@@ -102,7 +79,6 @@ const (
|
||||
FileDescriptorProto_Options_field_number protoreflect.FieldNumber = 8
|
||||
FileDescriptorProto_SourceCodeInfo_field_number protoreflect.FieldNumber = 9
|
||||
FileDescriptorProto_Syntax_field_number protoreflect.FieldNumber = 12
|
||||
FileDescriptorProto_Edition_field_number protoreflect.FieldNumber = 14
|
||||
)
|
||||
|
||||
// Names for google.protobuf.DescriptorProto.
|
||||
@@ -204,64 +180,13 @@ const (
|
||||
// Field names for google.protobuf.ExtensionRangeOptions.
|
||||
const (
|
||||
ExtensionRangeOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
|
||||
ExtensionRangeOptions_Declaration_field_name protoreflect.Name = "declaration"
|
||||
ExtensionRangeOptions_Features_field_name protoreflect.Name = "features"
|
||||
ExtensionRangeOptions_Verification_field_name protoreflect.Name = "verification"
|
||||
|
||||
ExtensionRangeOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.ExtensionRangeOptions.uninterpreted_option"
|
||||
ExtensionRangeOptions_Declaration_field_fullname protoreflect.FullName = "google.protobuf.ExtensionRangeOptions.declaration"
|
||||
ExtensionRangeOptions_Features_field_fullname protoreflect.FullName = "google.protobuf.ExtensionRangeOptions.features"
|
||||
ExtensionRangeOptions_Verification_field_fullname protoreflect.FullName = "google.protobuf.ExtensionRangeOptions.verification"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.ExtensionRangeOptions.
|
||||
const (
|
||||
ExtensionRangeOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
|
||||
ExtensionRangeOptions_Declaration_field_number protoreflect.FieldNumber = 2
|
||||
ExtensionRangeOptions_Features_field_number protoreflect.FieldNumber = 50
|
||||
ExtensionRangeOptions_Verification_field_number protoreflect.FieldNumber = 3
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.ExtensionRangeOptions.VerificationState.
|
||||
const (
|
||||
ExtensionRangeOptions_VerificationState_enum_fullname = "google.protobuf.ExtensionRangeOptions.VerificationState"
|
||||
ExtensionRangeOptions_VerificationState_enum_name = "VerificationState"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.ExtensionRangeOptions.VerificationState.
|
||||
const (
|
||||
ExtensionRangeOptions_DECLARATION_enum_value = 0
|
||||
ExtensionRangeOptions_UNVERIFIED_enum_value = 1
|
||||
)
|
||||
|
||||
// Names for google.protobuf.ExtensionRangeOptions.Declaration.
|
||||
const (
|
||||
ExtensionRangeOptions_Declaration_message_name protoreflect.Name = "Declaration"
|
||||
ExtensionRangeOptions_Declaration_message_fullname protoreflect.FullName = "google.protobuf.ExtensionRangeOptions.Declaration"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.ExtensionRangeOptions.Declaration.
|
||||
const (
|
||||
ExtensionRangeOptions_Declaration_Number_field_name protoreflect.Name = "number"
|
||||
ExtensionRangeOptions_Declaration_FullName_field_name protoreflect.Name = "full_name"
|
||||
ExtensionRangeOptions_Declaration_Type_field_name protoreflect.Name = "type"
|
||||
ExtensionRangeOptions_Declaration_Reserved_field_name protoreflect.Name = "reserved"
|
||||
ExtensionRangeOptions_Declaration_Repeated_field_name protoreflect.Name = "repeated"
|
||||
|
||||
ExtensionRangeOptions_Declaration_Number_field_fullname protoreflect.FullName = "google.protobuf.ExtensionRangeOptions.Declaration.number"
|
||||
ExtensionRangeOptions_Declaration_FullName_field_fullname protoreflect.FullName = "google.protobuf.ExtensionRangeOptions.Declaration.full_name"
|
||||
ExtensionRangeOptions_Declaration_Type_field_fullname protoreflect.FullName = "google.protobuf.ExtensionRangeOptions.Declaration.type"
|
||||
ExtensionRangeOptions_Declaration_Reserved_field_fullname protoreflect.FullName = "google.protobuf.ExtensionRangeOptions.Declaration.reserved"
|
||||
ExtensionRangeOptions_Declaration_Repeated_field_fullname protoreflect.FullName = "google.protobuf.ExtensionRangeOptions.Declaration.repeated"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.ExtensionRangeOptions.Declaration.
|
||||
const (
|
||||
ExtensionRangeOptions_Declaration_Number_field_number protoreflect.FieldNumber = 1
|
||||
ExtensionRangeOptions_Declaration_FullName_field_number protoreflect.FieldNumber = 2
|
||||
ExtensionRangeOptions_Declaration_Type_field_number protoreflect.FieldNumber = 3
|
||||
ExtensionRangeOptions_Declaration_Reserved_field_number protoreflect.FieldNumber = 5
|
||||
ExtensionRangeOptions_Declaration_Repeated_field_number protoreflect.FieldNumber = 6
|
||||
)
|
||||
|
||||
// Names for google.protobuf.FieldDescriptorProto.
|
||||
@@ -318,41 +243,12 @@ const (
|
||||
FieldDescriptorProto_Type_enum_name = "Type"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FieldDescriptorProto.Type.
|
||||
const (
|
||||
FieldDescriptorProto_TYPE_DOUBLE_enum_value = 1
|
||||
FieldDescriptorProto_TYPE_FLOAT_enum_value = 2
|
||||
FieldDescriptorProto_TYPE_INT64_enum_value = 3
|
||||
FieldDescriptorProto_TYPE_UINT64_enum_value = 4
|
||||
FieldDescriptorProto_TYPE_INT32_enum_value = 5
|
||||
FieldDescriptorProto_TYPE_FIXED64_enum_value = 6
|
||||
FieldDescriptorProto_TYPE_FIXED32_enum_value = 7
|
||||
FieldDescriptorProto_TYPE_BOOL_enum_value = 8
|
||||
FieldDescriptorProto_TYPE_STRING_enum_value = 9
|
||||
FieldDescriptorProto_TYPE_GROUP_enum_value = 10
|
||||
FieldDescriptorProto_TYPE_MESSAGE_enum_value = 11
|
||||
FieldDescriptorProto_TYPE_BYTES_enum_value = 12
|
||||
FieldDescriptorProto_TYPE_UINT32_enum_value = 13
|
||||
FieldDescriptorProto_TYPE_ENUM_enum_value = 14
|
||||
FieldDescriptorProto_TYPE_SFIXED32_enum_value = 15
|
||||
FieldDescriptorProto_TYPE_SFIXED64_enum_value = 16
|
||||
FieldDescriptorProto_TYPE_SINT32_enum_value = 17
|
||||
FieldDescriptorProto_TYPE_SINT64_enum_value = 18
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FieldDescriptorProto.Label.
|
||||
const (
|
||||
FieldDescriptorProto_Label_enum_fullname = "google.protobuf.FieldDescriptorProto.Label"
|
||||
FieldDescriptorProto_Label_enum_name = "Label"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FieldDescriptorProto.Label.
|
||||
const (
|
||||
FieldDescriptorProto_LABEL_OPTIONAL_enum_value = 1
|
||||
FieldDescriptorProto_LABEL_REPEATED_enum_value = 3
|
||||
FieldDescriptorProto_LABEL_REQUIRED_enum_value = 2
|
||||
)
|
||||
|
||||
// Names for google.protobuf.OneofDescriptorProto.
|
||||
const (
|
||||
OneofDescriptorProto_message_name protoreflect.Name = "OneofDescriptorProto"
|
||||
@@ -524,6 +420,7 @@ const (
|
||||
FileOptions_CcGenericServices_field_name protoreflect.Name = "cc_generic_services"
|
||||
FileOptions_JavaGenericServices_field_name protoreflect.Name = "java_generic_services"
|
||||
FileOptions_PyGenericServices_field_name protoreflect.Name = "py_generic_services"
|
||||
FileOptions_PhpGenericServices_field_name protoreflect.Name = "php_generic_services"
|
||||
FileOptions_Deprecated_field_name protoreflect.Name = "deprecated"
|
||||
FileOptions_CcEnableArenas_field_name protoreflect.Name = "cc_enable_arenas"
|
||||
FileOptions_ObjcClassPrefix_field_name protoreflect.Name = "objc_class_prefix"
|
||||
@@ -533,7 +430,6 @@ const (
|
||||
FileOptions_PhpNamespace_field_name protoreflect.Name = "php_namespace"
|
||||
FileOptions_PhpMetadataNamespace_field_name protoreflect.Name = "php_metadata_namespace"
|
||||
FileOptions_RubyPackage_field_name protoreflect.Name = "ruby_package"
|
||||
FileOptions_Features_field_name protoreflect.Name = "features"
|
||||
FileOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
|
||||
|
||||
FileOptions_JavaPackage_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.java_package"
|
||||
@@ -546,6 +442,7 @@ const (
|
||||
FileOptions_CcGenericServices_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.cc_generic_services"
|
||||
FileOptions_JavaGenericServices_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.java_generic_services"
|
||||
FileOptions_PyGenericServices_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.py_generic_services"
|
||||
FileOptions_PhpGenericServices_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.php_generic_services"
|
||||
FileOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.deprecated"
|
||||
FileOptions_CcEnableArenas_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.cc_enable_arenas"
|
||||
FileOptions_ObjcClassPrefix_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.objc_class_prefix"
|
||||
@@ -555,7 +452,6 @@ const (
|
||||
FileOptions_PhpNamespace_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.php_namespace"
|
||||
FileOptions_PhpMetadataNamespace_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.php_metadata_namespace"
|
||||
FileOptions_RubyPackage_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.ruby_package"
|
||||
FileOptions_Features_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.features"
|
||||
FileOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.uninterpreted_option"
|
||||
)
|
||||
|
||||
@@ -571,6 +467,7 @@ const (
|
||||
FileOptions_CcGenericServices_field_number protoreflect.FieldNumber = 16
|
||||
FileOptions_JavaGenericServices_field_number protoreflect.FieldNumber = 17
|
||||
FileOptions_PyGenericServices_field_number protoreflect.FieldNumber = 18
|
||||
FileOptions_PhpGenericServices_field_number protoreflect.FieldNumber = 42
|
||||
FileOptions_Deprecated_field_number protoreflect.FieldNumber = 23
|
||||
FileOptions_CcEnableArenas_field_number protoreflect.FieldNumber = 31
|
||||
FileOptions_ObjcClassPrefix_field_number protoreflect.FieldNumber = 36
|
||||
@@ -580,7 +477,6 @@ const (
|
||||
FileOptions_PhpNamespace_field_number protoreflect.FieldNumber = 41
|
||||
FileOptions_PhpMetadataNamespace_field_number protoreflect.FieldNumber = 44
|
||||
FileOptions_RubyPackage_field_number protoreflect.FieldNumber = 45
|
||||
FileOptions_Features_field_number protoreflect.FieldNumber = 50
|
||||
FileOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
|
||||
)
|
||||
|
||||
@@ -590,13 +486,6 @@ const (
|
||||
FileOptions_OptimizeMode_enum_name = "OptimizeMode"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FileOptions.OptimizeMode.
|
||||
const (
|
||||
FileOptions_SPEED_enum_value = 1
|
||||
FileOptions_CODE_SIZE_enum_value = 2
|
||||
FileOptions_LITE_RUNTIME_enum_value = 3
|
||||
)
|
||||
|
||||
// Names for google.protobuf.MessageOptions.
|
||||
const (
|
||||
MessageOptions_message_name protoreflect.Name = "MessageOptions"
|
||||
@@ -605,32 +494,26 @@ const (
|
||||
|
||||
// Field names for google.protobuf.MessageOptions.
|
||||
const (
|
||||
MessageOptions_MessageSetWireFormat_field_name protoreflect.Name = "message_set_wire_format"
|
||||
MessageOptions_NoStandardDescriptorAccessor_field_name protoreflect.Name = "no_standard_descriptor_accessor"
|
||||
MessageOptions_Deprecated_field_name protoreflect.Name = "deprecated"
|
||||
MessageOptions_MapEntry_field_name protoreflect.Name = "map_entry"
|
||||
MessageOptions_DeprecatedLegacyJsonFieldConflicts_field_name protoreflect.Name = "deprecated_legacy_json_field_conflicts"
|
||||
MessageOptions_Features_field_name protoreflect.Name = "features"
|
||||
MessageOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
|
||||
MessageOptions_MessageSetWireFormat_field_name protoreflect.Name = "message_set_wire_format"
|
||||
MessageOptions_NoStandardDescriptorAccessor_field_name protoreflect.Name = "no_standard_descriptor_accessor"
|
||||
MessageOptions_Deprecated_field_name protoreflect.Name = "deprecated"
|
||||
MessageOptions_MapEntry_field_name protoreflect.Name = "map_entry"
|
||||
MessageOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
|
||||
|
||||
MessageOptions_MessageSetWireFormat_field_fullname protoreflect.FullName = "google.protobuf.MessageOptions.message_set_wire_format"
|
||||
MessageOptions_NoStandardDescriptorAccessor_field_fullname protoreflect.FullName = "google.protobuf.MessageOptions.no_standard_descriptor_accessor"
|
||||
MessageOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.MessageOptions.deprecated"
|
||||
MessageOptions_MapEntry_field_fullname protoreflect.FullName = "google.protobuf.MessageOptions.map_entry"
|
||||
MessageOptions_DeprecatedLegacyJsonFieldConflicts_field_fullname protoreflect.FullName = "google.protobuf.MessageOptions.deprecated_legacy_json_field_conflicts"
|
||||
MessageOptions_Features_field_fullname protoreflect.FullName = "google.protobuf.MessageOptions.features"
|
||||
MessageOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.MessageOptions.uninterpreted_option"
|
||||
MessageOptions_MessageSetWireFormat_field_fullname protoreflect.FullName = "google.protobuf.MessageOptions.message_set_wire_format"
|
||||
MessageOptions_NoStandardDescriptorAccessor_field_fullname protoreflect.FullName = "google.protobuf.MessageOptions.no_standard_descriptor_accessor"
|
||||
MessageOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.MessageOptions.deprecated"
|
||||
MessageOptions_MapEntry_field_fullname protoreflect.FullName = "google.protobuf.MessageOptions.map_entry"
|
||||
MessageOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.MessageOptions.uninterpreted_option"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.MessageOptions.
|
||||
const (
|
||||
MessageOptions_MessageSetWireFormat_field_number protoreflect.FieldNumber = 1
|
||||
MessageOptions_NoStandardDescriptorAccessor_field_number protoreflect.FieldNumber = 2
|
||||
MessageOptions_Deprecated_field_number protoreflect.FieldNumber = 3
|
||||
MessageOptions_MapEntry_field_number protoreflect.FieldNumber = 7
|
||||
MessageOptions_DeprecatedLegacyJsonFieldConflicts_field_number protoreflect.FieldNumber = 11
|
||||
MessageOptions_Features_field_number protoreflect.FieldNumber = 12
|
||||
MessageOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
|
||||
MessageOptions_MessageSetWireFormat_field_number protoreflect.FieldNumber = 1
|
||||
MessageOptions_NoStandardDescriptorAccessor_field_number protoreflect.FieldNumber = 2
|
||||
MessageOptions_Deprecated_field_number protoreflect.FieldNumber = 3
|
||||
MessageOptions_MapEntry_field_number protoreflect.FieldNumber = 7
|
||||
MessageOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
|
||||
)
|
||||
|
||||
// Names for google.protobuf.FieldOptions.
|
||||
@@ -645,28 +528,16 @@ const (
|
||||
FieldOptions_Packed_field_name protoreflect.Name = "packed"
|
||||
FieldOptions_Jstype_field_name protoreflect.Name = "jstype"
|
||||
FieldOptions_Lazy_field_name protoreflect.Name = "lazy"
|
||||
FieldOptions_UnverifiedLazy_field_name protoreflect.Name = "unverified_lazy"
|
||||
FieldOptions_Deprecated_field_name protoreflect.Name = "deprecated"
|
||||
FieldOptions_Weak_field_name protoreflect.Name = "weak"
|
||||
FieldOptions_DebugRedact_field_name protoreflect.Name = "debug_redact"
|
||||
FieldOptions_Retention_field_name protoreflect.Name = "retention"
|
||||
FieldOptions_Targets_field_name protoreflect.Name = "targets"
|
||||
FieldOptions_EditionDefaults_field_name protoreflect.Name = "edition_defaults"
|
||||
FieldOptions_Features_field_name protoreflect.Name = "features"
|
||||
FieldOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
|
||||
|
||||
FieldOptions_Ctype_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.ctype"
|
||||
FieldOptions_Packed_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.packed"
|
||||
FieldOptions_Jstype_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.jstype"
|
||||
FieldOptions_Lazy_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.lazy"
|
||||
FieldOptions_UnverifiedLazy_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.unverified_lazy"
|
||||
FieldOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.deprecated"
|
||||
FieldOptions_Weak_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.weak"
|
||||
FieldOptions_DebugRedact_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.debug_redact"
|
||||
FieldOptions_Retention_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.retention"
|
||||
FieldOptions_Targets_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.targets"
|
||||
FieldOptions_EditionDefaults_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.edition_defaults"
|
||||
FieldOptions_Features_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.features"
|
||||
FieldOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.uninterpreted_option"
|
||||
)
|
||||
|
||||
@@ -676,14 +547,8 @@ const (
|
||||
FieldOptions_Packed_field_number protoreflect.FieldNumber = 2
|
||||
FieldOptions_Jstype_field_number protoreflect.FieldNumber = 6
|
||||
FieldOptions_Lazy_field_number protoreflect.FieldNumber = 5
|
||||
FieldOptions_UnverifiedLazy_field_number protoreflect.FieldNumber = 15
|
||||
FieldOptions_Deprecated_field_number protoreflect.FieldNumber = 3
|
||||
FieldOptions_Weak_field_number protoreflect.FieldNumber = 10
|
||||
FieldOptions_DebugRedact_field_number protoreflect.FieldNumber = 16
|
||||
FieldOptions_Retention_field_number protoreflect.FieldNumber = 17
|
||||
FieldOptions_Targets_field_number protoreflect.FieldNumber = 19
|
||||
FieldOptions_EditionDefaults_field_number protoreflect.FieldNumber = 20
|
||||
FieldOptions_Features_field_number protoreflect.FieldNumber = 21
|
||||
FieldOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
|
||||
)
|
||||
|
||||
@@ -693,80 +558,12 @@ const (
|
||||
FieldOptions_CType_enum_name = "CType"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FieldOptions.CType.
|
||||
const (
|
||||
FieldOptions_STRING_enum_value = 0
|
||||
FieldOptions_CORD_enum_value = 1
|
||||
FieldOptions_STRING_PIECE_enum_value = 2
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FieldOptions.JSType.
|
||||
const (
|
||||
FieldOptions_JSType_enum_fullname = "google.protobuf.FieldOptions.JSType"
|
||||
FieldOptions_JSType_enum_name = "JSType"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FieldOptions.JSType.
|
||||
const (
|
||||
FieldOptions_JS_NORMAL_enum_value = 0
|
||||
FieldOptions_JS_STRING_enum_value = 1
|
||||
FieldOptions_JS_NUMBER_enum_value = 2
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FieldOptions.OptionRetention.
|
||||
const (
|
||||
FieldOptions_OptionRetention_enum_fullname = "google.protobuf.FieldOptions.OptionRetention"
|
||||
FieldOptions_OptionRetention_enum_name = "OptionRetention"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FieldOptions.OptionRetention.
|
||||
const (
|
||||
FieldOptions_RETENTION_UNKNOWN_enum_value = 0
|
||||
FieldOptions_RETENTION_RUNTIME_enum_value = 1
|
||||
FieldOptions_RETENTION_SOURCE_enum_value = 2
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FieldOptions.OptionTargetType.
|
||||
const (
|
||||
FieldOptions_OptionTargetType_enum_fullname = "google.protobuf.FieldOptions.OptionTargetType"
|
||||
FieldOptions_OptionTargetType_enum_name = "OptionTargetType"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FieldOptions.OptionTargetType.
|
||||
const (
|
||||
FieldOptions_TARGET_TYPE_UNKNOWN_enum_value = 0
|
||||
FieldOptions_TARGET_TYPE_FILE_enum_value = 1
|
||||
FieldOptions_TARGET_TYPE_EXTENSION_RANGE_enum_value = 2
|
||||
FieldOptions_TARGET_TYPE_MESSAGE_enum_value = 3
|
||||
FieldOptions_TARGET_TYPE_FIELD_enum_value = 4
|
||||
FieldOptions_TARGET_TYPE_ONEOF_enum_value = 5
|
||||
FieldOptions_TARGET_TYPE_ENUM_enum_value = 6
|
||||
FieldOptions_TARGET_TYPE_ENUM_ENTRY_enum_value = 7
|
||||
FieldOptions_TARGET_TYPE_SERVICE_enum_value = 8
|
||||
FieldOptions_TARGET_TYPE_METHOD_enum_value = 9
|
||||
)
|
||||
|
||||
// Names for google.protobuf.FieldOptions.EditionDefault.
|
||||
const (
|
||||
FieldOptions_EditionDefault_message_name protoreflect.Name = "EditionDefault"
|
||||
FieldOptions_EditionDefault_message_fullname protoreflect.FullName = "google.protobuf.FieldOptions.EditionDefault"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.FieldOptions.EditionDefault.
|
||||
const (
|
||||
FieldOptions_EditionDefault_Edition_field_name protoreflect.Name = "edition"
|
||||
FieldOptions_EditionDefault_Value_field_name protoreflect.Name = "value"
|
||||
|
||||
FieldOptions_EditionDefault_Edition_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.EditionDefault.edition"
|
||||
FieldOptions_EditionDefault_Value_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.EditionDefault.value"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.FieldOptions.EditionDefault.
|
||||
const (
|
||||
FieldOptions_EditionDefault_Edition_field_number protoreflect.FieldNumber = 3
|
||||
FieldOptions_EditionDefault_Value_field_number protoreflect.FieldNumber = 2
|
||||
)
|
||||
|
||||
// Names for google.protobuf.OneofOptions.
|
||||
const (
|
||||
OneofOptions_message_name protoreflect.Name = "OneofOptions"
|
||||
@@ -775,16 +572,13 @@ const (
|
||||
|
||||
// Field names for google.protobuf.OneofOptions.
|
||||
const (
|
||||
OneofOptions_Features_field_name protoreflect.Name = "features"
|
||||
OneofOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
|
||||
|
||||
OneofOptions_Features_field_fullname protoreflect.FullName = "google.protobuf.OneofOptions.features"
|
||||
OneofOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.OneofOptions.uninterpreted_option"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.OneofOptions.
|
||||
const (
|
||||
OneofOptions_Features_field_number protoreflect.FieldNumber = 1
|
||||
OneofOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
|
||||
)
|
||||
|
||||
@@ -796,26 +590,20 @@ const (
|
||||
|
||||
// Field names for google.protobuf.EnumOptions.
|
||||
const (
|
||||
EnumOptions_AllowAlias_field_name protoreflect.Name = "allow_alias"
|
||||
EnumOptions_Deprecated_field_name protoreflect.Name = "deprecated"
|
||||
EnumOptions_DeprecatedLegacyJsonFieldConflicts_field_name protoreflect.Name = "deprecated_legacy_json_field_conflicts"
|
||||
EnumOptions_Features_field_name protoreflect.Name = "features"
|
||||
EnumOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
|
||||
EnumOptions_AllowAlias_field_name protoreflect.Name = "allow_alias"
|
||||
EnumOptions_Deprecated_field_name protoreflect.Name = "deprecated"
|
||||
EnumOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
|
||||
|
||||
EnumOptions_AllowAlias_field_fullname protoreflect.FullName = "google.protobuf.EnumOptions.allow_alias"
|
||||
EnumOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.EnumOptions.deprecated"
|
||||
EnumOptions_DeprecatedLegacyJsonFieldConflicts_field_fullname protoreflect.FullName = "google.protobuf.EnumOptions.deprecated_legacy_json_field_conflicts"
|
||||
EnumOptions_Features_field_fullname protoreflect.FullName = "google.protobuf.EnumOptions.features"
|
||||
EnumOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.EnumOptions.uninterpreted_option"
|
||||
EnumOptions_AllowAlias_field_fullname protoreflect.FullName = "google.protobuf.EnumOptions.allow_alias"
|
||||
EnumOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.EnumOptions.deprecated"
|
||||
EnumOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.EnumOptions.uninterpreted_option"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.EnumOptions.
|
||||
const (
|
||||
EnumOptions_AllowAlias_field_number protoreflect.FieldNumber = 2
|
||||
EnumOptions_Deprecated_field_number protoreflect.FieldNumber = 3
|
||||
EnumOptions_DeprecatedLegacyJsonFieldConflicts_field_number protoreflect.FieldNumber = 6
|
||||
EnumOptions_Features_field_number protoreflect.FieldNumber = 7
|
||||
EnumOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
|
||||
EnumOptions_AllowAlias_field_number protoreflect.FieldNumber = 2
|
||||
EnumOptions_Deprecated_field_number protoreflect.FieldNumber = 3
|
||||
EnumOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
|
||||
)
|
||||
|
||||
// Names for google.protobuf.EnumValueOptions.
|
||||
@@ -827,21 +615,15 @@ const (
|
||||
// Field names for google.protobuf.EnumValueOptions.
|
||||
const (
|
||||
EnumValueOptions_Deprecated_field_name protoreflect.Name = "deprecated"
|
||||
EnumValueOptions_Features_field_name protoreflect.Name = "features"
|
||||
EnumValueOptions_DebugRedact_field_name protoreflect.Name = "debug_redact"
|
||||
EnumValueOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
|
||||
|
||||
EnumValueOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.EnumValueOptions.deprecated"
|
||||
EnumValueOptions_Features_field_fullname protoreflect.FullName = "google.protobuf.EnumValueOptions.features"
|
||||
EnumValueOptions_DebugRedact_field_fullname protoreflect.FullName = "google.protobuf.EnumValueOptions.debug_redact"
|
||||
EnumValueOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.EnumValueOptions.uninterpreted_option"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.EnumValueOptions.
|
||||
const (
|
||||
EnumValueOptions_Deprecated_field_number protoreflect.FieldNumber = 1
|
||||
EnumValueOptions_Features_field_number protoreflect.FieldNumber = 2
|
||||
EnumValueOptions_DebugRedact_field_number protoreflect.FieldNumber = 3
|
||||
EnumValueOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
|
||||
)
|
||||
|
||||
@@ -853,18 +635,15 @@ const (
|
||||
|
||||
// Field names for google.protobuf.ServiceOptions.
|
||||
const (
|
||||
ServiceOptions_Features_field_name protoreflect.Name = "features"
|
||||
ServiceOptions_Deprecated_field_name protoreflect.Name = "deprecated"
|
||||
ServiceOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
|
||||
|
||||
ServiceOptions_Features_field_fullname protoreflect.FullName = "google.protobuf.ServiceOptions.features"
|
||||
ServiceOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.ServiceOptions.deprecated"
|
||||
ServiceOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.ServiceOptions.uninterpreted_option"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.ServiceOptions.
|
||||
const (
|
||||
ServiceOptions_Features_field_number protoreflect.FieldNumber = 34
|
||||
ServiceOptions_Deprecated_field_number protoreflect.FieldNumber = 33
|
||||
ServiceOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
|
||||
)
|
||||
@@ -879,12 +658,10 @@ const (
|
||||
const (
|
||||
MethodOptions_Deprecated_field_name protoreflect.Name = "deprecated"
|
||||
MethodOptions_IdempotencyLevel_field_name protoreflect.Name = "idempotency_level"
|
||||
MethodOptions_Features_field_name protoreflect.Name = "features"
|
||||
MethodOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
|
||||
|
||||
MethodOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.MethodOptions.deprecated"
|
||||
MethodOptions_IdempotencyLevel_field_fullname protoreflect.FullName = "google.protobuf.MethodOptions.idempotency_level"
|
||||
MethodOptions_Features_field_fullname protoreflect.FullName = "google.protobuf.MethodOptions.features"
|
||||
MethodOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.MethodOptions.uninterpreted_option"
|
||||
)
|
||||
|
||||
@@ -892,7 +669,6 @@ const (
|
||||
const (
|
||||
MethodOptions_Deprecated_field_number protoreflect.FieldNumber = 33
|
||||
MethodOptions_IdempotencyLevel_field_number protoreflect.FieldNumber = 34
|
||||
MethodOptions_Features_field_number protoreflect.FieldNumber = 35
|
||||
MethodOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
|
||||
)
|
||||
|
||||
@@ -902,13 +678,6 @@ const (
|
||||
MethodOptions_IdempotencyLevel_enum_name = "IdempotencyLevel"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.MethodOptions.IdempotencyLevel.
|
||||
const (
|
||||
MethodOptions_IDEMPOTENCY_UNKNOWN_enum_value = 0
|
||||
MethodOptions_NO_SIDE_EFFECTS_enum_value = 1
|
||||
MethodOptions_IDEMPOTENT_enum_value = 2
|
||||
)
|
||||
|
||||
// Names for google.protobuf.UninterpretedOption.
|
||||
const (
|
||||
UninterpretedOption_message_name protoreflect.Name = "UninterpretedOption"
|
||||
@@ -966,163 +735,6 @@ const (
|
||||
UninterpretedOption_NamePart_IsExtension_field_number protoreflect.FieldNumber = 2
|
||||
)
|
||||
|
||||
// Names for google.protobuf.FeatureSet.
|
||||
const (
|
||||
FeatureSet_message_name protoreflect.Name = "FeatureSet"
|
||||
FeatureSet_message_fullname protoreflect.FullName = "google.protobuf.FeatureSet"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.FeatureSet.
|
||||
const (
|
||||
FeatureSet_FieldPresence_field_name protoreflect.Name = "field_presence"
|
||||
FeatureSet_EnumType_field_name protoreflect.Name = "enum_type"
|
||||
FeatureSet_RepeatedFieldEncoding_field_name protoreflect.Name = "repeated_field_encoding"
|
||||
FeatureSet_Utf8Validation_field_name protoreflect.Name = "utf8_validation"
|
||||
FeatureSet_MessageEncoding_field_name protoreflect.Name = "message_encoding"
|
||||
FeatureSet_JsonFormat_field_name protoreflect.Name = "json_format"
|
||||
|
||||
FeatureSet_FieldPresence_field_fullname protoreflect.FullName = "google.protobuf.FeatureSet.field_presence"
|
||||
FeatureSet_EnumType_field_fullname protoreflect.FullName = "google.protobuf.FeatureSet.enum_type"
|
||||
FeatureSet_RepeatedFieldEncoding_field_fullname protoreflect.FullName = "google.protobuf.FeatureSet.repeated_field_encoding"
|
||||
FeatureSet_Utf8Validation_field_fullname protoreflect.FullName = "google.protobuf.FeatureSet.utf8_validation"
|
||||
FeatureSet_MessageEncoding_field_fullname protoreflect.FullName = "google.protobuf.FeatureSet.message_encoding"
|
||||
FeatureSet_JsonFormat_field_fullname protoreflect.FullName = "google.protobuf.FeatureSet.json_format"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.FeatureSet.
|
||||
const (
|
||||
FeatureSet_FieldPresence_field_number protoreflect.FieldNumber = 1
|
||||
FeatureSet_EnumType_field_number protoreflect.FieldNumber = 2
|
||||
FeatureSet_RepeatedFieldEncoding_field_number protoreflect.FieldNumber = 3
|
||||
FeatureSet_Utf8Validation_field_number protoreflect.FieldNumber = 4
|
||||
FeatureSet_MessageEncoding_field_number protoreflect.FieldNumber = 5
|
||||
FeatureSet_JsonFormat_field_number protoreflect.FieldNumber = 6
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FeatureSet.FieldPresence.
|
||||
const (
|
||||
FeatureSet_FieldPresence_enum_fullname = "google.protobuf.FeatureSet.FieldPresence"
|
||||
FeatureSet_FieldPresence_enum_name = "FieldPresence"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FeatureSet.FieldPresence.
|
||||
const (
|
||||
FeatureSet_FIELD_PRESENCE_UNKNOWN_enum_value = 0
|
||||
FeatureSet_EXPLICIT_enum_value = 1
|
||||
FeatureSet_IMPLICIT_enum_value = 2
|
||||
FeatureSet_LEGACY_REQUIRED_enum_value = 3
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FeatureSet.EnumType.
|
||||
const (
|
||||
FeatureSet_EnumType_enum_fullname = "google.protobuf.FeatureSet.EnumType"
|
||||
FeatureSet_EnumType_enum_name = "EnumType"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FeatureSet.EnumType.
|
||||
const (
|
||||
FeatureSet_ENUM_TYPE_UNKNOWN_enum_value = 0
|
||||
FeatureSet_OPEN_enum_value = 1
|
||||
FeatureSet_CLOSED_enum_value = 2
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FeatureSet.RepeatedFieldEncoding.
|
||||
const (
|
||||
FeatureSet_RepeatedFieldEncoding_enum_fullname = "google.protobuf.FeatureSet.RepeatedFieldEncoding"
|
||||
FeatureSet_RepeatedFieldEncoding_enum_name = "RepeatedFieldEncoding"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FeatureSet.RepeatedFieldEncoding.
|
||||
const (
|
||||
FeatureSet_REPEATED_FIELD_ENCODING_UNKNOWN_enum_value = 0
|
||||
FeatureSet_PACKED_enum_value = 1
|
||||
FeatureSet_EXPANDED_enum_value = 2
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FeatureSet.Utf8Validation.
|
||||
const (
|
||||
FeatureSet_Utf8Validation_enum_fullname = "google.protobuf.FeatureSet.Utf8Validation"
|
||||
FeatureSet_Utf8Validation_enum_name = "Utf8Validation"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FeatureSet.Utf8Validation.
|
||||
const (
|
||||
FeatureSet_UTF8_VALIDATION_UNKNOWN_enum_value = 0
|
||||
FeatureSet_VERIFY_enum_value = 2
|
||||
FeatureSet_NONE_enum_value = 3
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FeatureSet.MessageEncoding.
|
||||
const (
|
||||
FeatureSet_MessageEncoding_enum_fullname = "google.protobuf.FeatureSet.MessageEncoding"
|
||||
FeatureSet_MessageEncoding_enum_name = "MessageEncoding"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FeatureSet.MessageEncoding.
|
||||
const (
|
||||
FeatureSet_MESSAGE_ENCODING_UNKNOWN_enum_value = 0
|
||||
FeatureSet_LENGTH_PREFIXED_enum_value = 1
|
||||
FeatureSet_DELIMITED_enum_value = 2
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FeatureSet.JsonFormat.
|
||||
const (
|
||||
FeatureSet_JsonFormat_enum_fullname = "google.protobuf.FeatureSet.JsonFormat"
|
||||
FeatureSet_JsonFormat_enum_name = "JsonFormat"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.FeatureSet.JsonFormat.
|
||||
const (
|
||||
FeatureSet_JSON_FORMAT_UNKNOWN_enum_value = 0
|
||||
FeatureSet_ALLOW_enum_value = 1
|
||||
FeatureSet_LEGACY_BEST_EFFORT_enum_value = 2
|
||||
)
|
||||
|
||||
// Names for google.protobuf.FeatureSetDefaults.
|
||||
const (
|
||||
FeatureSetDefaults_message_name protoreflect.Name = "FeatureSetDefaults"
|
||||
FeatureSetDefaults_message_fullname protoreflect.FullName = "google.protobuf.FeatureSetDefaults"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.FeatureSetDefaults.
|
||||
const (
|
||||
FeatureSetDefaults_Defaults_field_name protoreflect.Name = "defaults"
|
||||
FeatureSetDefaults_MinimumEdition_field_name protoreflect.Name = "minimum_edition"
|
||||
FeatureSetDefaults_MaximumEdition_field_name protoreflect.Name = "maximum_edition"
|
||||
|
||||
FeatureSetDefaults_Defaults_field_fullname protoreflect.FullName = "google.protobuf.FeatureSetDefaults.defaults"
|
||||
FeatureSetDefaults_MinimumEdition_field_fullname protoreflect.FullName = "google.protobuf.FeatureSetDefaults.minimum_edition"
|
||||
FeatureSetDefaults_MaximumEdition_field_fullname protoreflect.FullName = "google.protobuf.FeatureSetDefaults.maximum_edition"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.FeatureSetDefaults.
|
||||
const (
|
||||
FeatureSetDefaults_Defaults_field_number protoreflect.FieldNumber = 1
|
||||
FeatureSetDefaults_MinimumEdition_field_number protoreflect.FieldNumber = 4
|
||||
FeatureSetDefaults_MaximumEdition_field_number protoreflect.FieldNumber = 5
|
||||
)
|
||||
|
||||
// Names for google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.
|
||||
const (
|
||||
FeatureSetDefaults_FeatureSetEditionDefault_message_name protoreflect.Name = "FeatureSetEditionDefault"
|
||||
FeatureSetDefaults_FeatureSetEditionDefault_message_fullname protoreflect.FullName = "google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.
|
||||
const (
|
||||
FeatureSetDefaults_FeatureSetEditionDefault_Edition_field_name protoreflect.Name = "edition"
|
||||
FeatureSetDefaults_FeatureSetEditionDefault_Features_field_name protoreflect.Name = "features"
|
||||
|
||||
FeatureSetDefaults_FeatureSetEditionDefault_Edition_field_fullname protoreflect.FullName = "google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.edition"
|
||||
FeatureSetDefaults_FeatureSetEditionDefault_Features_field_fullname protoreflect.FullName = "google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.features"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.
|
||||
const (
|
||||
FeatureSetDefaults_FeatureSetEditionDefault_Edition_field_number protoreflect.FieldNumber = 3
|
||||
FeatureSetDefaults_FeatureSetEditionDefault_Features_field_number protoreflect.FieldNumber = 2
|
||||
)
|
||||
|
||||
// Names for google.protobuf.SourceCodeInfo.
|
||||
const (
|
||||
SourceCodeInfo_message_name protoreflect.Name = "SourceCodeInfo"
|
||||
@@ -1201,13 +813,11 @@ const (
|
||||
GeneratedCodeInfo_Annotation_SourceFile_field_name protoreflect.Name = "source_file"
|
||||
GeneratedCodeInfo_Annotation_Begin_field_name protoreflect.Name = "begin"
|
||||
GeneratedCodeInfo_Annotation_End_field_name protoreflect.Name = "end"
|
||||
GeneratedCodeInfo_Annotation_Semantic_field_name protoreflect.Name = "semantic"
|
||||
|
||||
GeneratedCodeInfo_Annotation_Path_field_fullname protoreflect.FullName = "google.protobuf.GeneratedCodeInfo.Annotation.path"
|
||||
GeneratedCodeInfo_Annotation_SourceFile_field_fullname protoreflect.FullName = "google.protobuf.GeneratedCodeInfo.Annotation.source_file"
|
||||
GeneratedCodeInfo_Annotation_Begin_field_fullname protoreflect.FullName = "google.protobuf.GeneratedCodeInfo.Annotation.begin"
|
||||
GeneratedCodeInfo_Annotation_End_field_fullname protoreflect.FullName = "google.protobuf.GeneratedCodeInfo.Annotation.end"
|
||||
GeneratedCodeInfo_Annotation_Semantic_field_fullname protoreflect.FullName = "google.protobuf.GeneratedCodeInfo.Annotation.semantic"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.GeneratedCodeInfo.Annotation.
|
||||
@@ -1216,18 +826,4 @@ const (
|
||||
GeneratedCodeInfo_Annotation_SourceFile_field_number protoreflect.FieldNumber = 2
|
||||
GeneratedCodeInfo_Annotation_Begin_field_number protoreflect.FieldNumber = 3
|
||||
GeneratedCodeInfo_Annotation_End_field_number protoreflect.FieldNumber = 4
|
||||
GeneratedCodeInfo_Annotation_Semantic_field_number protoreflect.FieldNumber = 5
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.GeneratedCodeInfo.Annotation.Semantic.
|
||||
const (
|
||||
GeneratedCodeInfo_Annotation_Semantic_enum_fullname = "google.protobuf.GeneratedCodeInfo.Annotation.Semantic"
|
||||
GeneratedCodeInfo_Annotation_Semantic_enum_name = "Semantic"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.GeneratedCodeInfo.Annotation.Semantic.
|
||||
const (
|
||||
GeneratedCodeInfo_Annotation_NONE_enum_value = 0
|
||||
GeneratedCodeInfo_Annotation_SET_enum_value = 1
|
||||
GeneratedCodeInfo_Annotation_ALIAS_enum_value = 2
|
||||
)
|
||||
|
||||
31
vendor/google.golang.org/protobuf/internal/genid/go_features_gen.go
generated
vendored
31
vendor/google.golang.org/protobuf/internal/genid/go_features_gen.go
generated
vendored
@@ -1,31 +0,0 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package genid
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
const File_reflect_protodesc_proto_go_features_proto = "reflect/protodesc/proto/go_features.proto"
|
||||
|
||||
// Names for google.protobuf.GoFeatures.
|
||||
const (
|
||||
GoFeatures_message_name protoreflect.Name = "GoFeatures"
|
||||
GoFeatures_message_fullname protoreflect.FullName = "google.protobuf.GoFeatures"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.GoFeatures.
|
||||
const (
|
||||
GoFeatures_LegacyUnmarshalJsonEnum_field_name protoreflect.Name = "legacy_unmarshal_json_enum"
|
||||
|
||||
GoFeatures_LegacyUnmarshalJsonEnum_field_fullname protoreflect.FullName = "google.protobuf.GoFeatures.legacy_unmarshal_json_enum"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.GoFeatures.
|
||||
const (
|
||||
GoFeatures_LegacyUnmarshalJsonEnum_field_number protoreflect.FieldNumber = 1
|
||||
)
|
||||
5
vendor/google.golang.org/protobuf/internal/genid/struct_gen.go
generated
vendored
5
vendor/google.golang.org/protobuf/internal/genid/struct_gen.go
generated
vendored
@@ -18,11 +18,6 @@ const (
|
||||
NullValue_enum_name = "NullValue"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.NullValue.
|
||||
const (
|
||||
NullValue_NULL_VALUE_enum_value = 0
|
||||
)
|
||||
|
||||
// Names for google.protobuf.Struct.
|
||||
const (
|
||||
Struct_message_name protoreflect.Name = "Struct"
|
||||
|
||||
44
vendor/google.golang.org/protobuf/internal/genid/type_gen.go
generated
vendored
44
vendor/google.golang.org/protobuf/internal/genid/type_gen.go
generated
vendored
@@ -18,13 +18,6 @@ const (
|
||||
Syntax_enum_name = "Syntax"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.Syntax.
|
||||
const (
|
||||
Syntax_SYNTAX_PROTO2_enum_value = 0
|
||||
Syntax_SYNTAX_PROTO3_enum_value = 1
|
||||
Syntax_SYNTAX_EDITIONS_enum_value = 2
|
||||
)
|
||||
|
||||
// Names for google.protobuf.Type.
|
||||
const (
|
||||
Type_message_name protoreflect.Name = "Type"
|
||||
@@ -39,7 +32,6 @@ const (
|
||||
Type_Options_field_name protoreflect.Name = "options"
|
||||
Type_SourceContext_field_name protoreflect.Name = "source_context"
|
||||
Type_Syntax_field_name protoreflect.Name = "syntax"
|
||||
Type_Edition_field_name protoreflect.Name = "edition"
|
||||
|
||||
Type_Name_field_fullname protoreflect.FullName = "google.protobuf.Type.name"
|
||||
Type_Fields_field_fullname protoreflect.FullName = "google.protobuf.Type.fields"
|
||||
@@ -47,7 +39,6 @@ const (
|
||||
Type_Options_field_fullname protoreflect.FullName = "google.protobuf.Type.options"
|
||||
Type_SourceContext_field_fullname protoreflect.FullName = "google.protobuf.Type.source_context"
|
||||
Type_Syntax_field_fullname protoreflect.FullName = "google.protobuf.Type.syntax"
|
||||
Type_Edition_field_fullname protoreflect.FullName = "google.protobuf.Type.edition"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Type.
|
||||
@@ -58,7 +49,6 @@ const (
|
||||
Type_Options_field_number protoreflect.FieldNumber = 4
|
||||
Type_SourceContext_field_number protoreflect.FieldNumber = 5
|
||||
Type_Syntax_field_number protoreflect.FieldNumber = 6
|
||||
Type_Edition_field_number protoreflect.FieldNumber = 7
|
||||
)
|
||||
|
||||
// Names for google.protobuf.Field.
|
||||
@@ -112,43 +102,12 @@ const (
|
||||
Field_Kind_enum_name = "Kind"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.Field.Kind.
|
||||
const (
|
||||
Field_TYPE_UNKNOWN_enum_value = 0
|
||||
Field_TYPE_DOUBLE_enum_value = 1
|
||||
Field_TYPE_FLOAT_enum_value = 2
|
||||
Field_TYPE_INT64_enum_value = 3
|
||||
Field_TYPE_UINT64_enum_value = 4
|
||||
Field_TYPE_INT32_enum_value = 5
|
||||
Field_TYPE_FIXED64_enum_value = 6
|
||||
Field_TYPE_FIXED32_enum_value = 7
|
||||
Field_TYPE_BOOL_enum_value = 8
|
||||
Field_TYPE_STRING_enum_value = 9
|
||||
Field_TYPE_GROUP_enum_value = 10
|
||||
Field_TYPE_MESSAGE_enum_value = 11
|
||||
Field_TYPE_BYTES_enum_value = 12
|
||||
Field_TYPE_UINT32_enum_value = 13
|
||||
Field_TYPE_ENUM_enum_value = 14
|
||||
Field_TYPE_SFIXED32_enum_value = 15
|
||||
Field_TYPE_SFIXED64_enum_value = 16
|
||||
Field_TYPE_SINT32_enum_value = 17
|
||||
Field_TYPE_SINT64_enum_value = 18
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.Field.Cardinality.
|
||||
const (
|
||||
Field_Cardinality_enum_fullname = "google.protobuf.Field.Cardinality"
|
||||
Field_Cardinality_enum_name = "Cardinality"
|
||||
)
|
||||
|
||||
// Enum values for google.protobuf.Field.Cardinality.
|
||||
const (
|
||||
Field_CARDINALITY_UNKNOWN_enum_value = 0
|
||||
Field_CARDINALITY_OPTIONAL_enum_value = 1
|
||||
Field_CARDINALITY_REQUIRED_enum_value = 2
|
||||
Field_CARDINALITY_REPEATED_enum_value = 3
|
||||
)
|
||||
|
||||
// Names for google.protobuf.Enum.
|
||||
const (
|
||||
Enum_message_name protoreflect.Name = "Enum"
|
||||
@@ -162,14 +121,12 @@ const (
|
||||
Enum_Options_field_name protoreflect.Name = "options"
|
||||
Enum_SourceContext_field_name protoreflect.Name = "source_context"
|
||||
Enum_Syntax_field_name protoreflect.Name = "syntax"
|
||||
Enum_Edition_field_name protoreflect.Name = "edition"
|
||||
|
||||
Enum_Name_field_fullname protoreflect.FullName = "google.protobuf.Enum.name"
|
||||
Enum_Enumvalue_field_fullname protoreflect.FullName = "google.protobuf.Enum.enumvalue"
|
||||
Enum_Options_field_fullname protoreflect.FullName = "google.protobuf.Enum.options"
|
||||
Enum_SourceContext_field_fullname protoreflect.FullName = "google.protobuf.Enum.source_context"
|
||||
Enum_Syntax_field_fullname protoreflect.FullName = "google.protobuf.Enum.syntax"
|
||||
Enum_Edition_field_fullname protoreflect.FullName = "google.protobuf.Enum.edition"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Enum.
|
||||
@@ -179,7 +136,6 @@ const (
|
||||
Enum_Options_field_number protoreflect.FieldNumber = 3
|
||||
Enum_SourceContext_field_number protoreflect.FieldNumber = 4
|
||||
Enum_Syntax_field_number protoreflect.FieldNumber = 5
|
||||
Enum_Edition_field_number protoreflect.FieldNumber = 6
|
||||
)
|
||||
|
||||
// Names for google.protobuf.EnumValue.
|
||||
|
||||
42
vendor/google.golang.org/protobuf/internal/impl/api_export.go
generated
vendored
42
vendor/google.golang.org/protobuf/internal/impl/api_export.go
generated
vendored
@@ -12,8 +12,8 @@ import (
|
||||
"google.golang.org/protobuf/encoding/prototext"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/runtime/protoiface"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
piface "google.golang.org/protobuf/runtime/protoiface"
|
||||
)
|
||||
|
||||
// Export is a zero-length named type that exists only to export a set of
|
||||
@@ -32,11 +32,11 @@ type enum = interface{}
|
||||
|
||||
// EnumOf returns the protoreflect.Enum interface over e.
|
||||
// It returns nil if e is nil.
|
||||
func (Export) EnumOf(e enum) protoreflect.Enum {
|
||||
func (Export) EnumOf(e enum) pref.Enum {
|
||||
switch e := e.(type) {
|
||||
case nil:
|
||||
return nil
|
||||
case protoreflect.Enum:
|
||||
case pref.Enum:
|
||||
return e
|
||||
default:
|
||||
return legacyWrapEnum(reflect.ValueOf(e))
|
||||
@@ -45,11 +45,11 @@ func (Export) EnumOf(e enum) protoreflect.Enum {
|
||||
|
||||
// EnumDescriptorOf returns the protoreflect.EnumDescriptor for e.
|
||||
// It returns nil if e is nil.
|
||||
func (Export) EnumDescriptorOf(e enum) protoreflect.EnumDescriptor {
|
||||
func (Export) EnumDescriptorOf(e enum) pref.EnumDescriptor {
|
||||
switch e := e.(type) {
|
||||
case nil:
|
||||
return nil
|
||||
case protoreflect.Enum:
|
||||
case pref.Enum:
|
||||
return e.Descriptor()
|
||||
default:
|
||||
return LegacyLoadEnumDesc(reflect.TypeOf(e))
|
||||
@@ -58,11 +58,11 @@ func (Export) EnumDescriptorOf(e enum) protoreflect.EnumDescriptor {
|
||||
|
||||
// EnumTypeOf returns the protoreflect.EnumType for e.
|
||||
// It returns nil if e is nil.
|
||||
func (Export) EnumTypeOf(e enum) protoreflect.EnumType {
|
||||
func (Export) EnumTypeOf(e enum) pref.EnumType {
|
||||
switch e := e.(type) {
|
||||
case nil:
|
||||
return nil
|
||||
case protoreflect.Enum:
|
||||
case pref.Enum:
|
||||
return e.Type()
|
||||
default:
|
||||
return legacyLoadEnumType(reflect.TypeOf(e))
|
||||
@@ -71,7 +71,7 @@ func (Export) EnumTypeOf(e enum) protoreflect.EnumType {
|
||||
|
||||
// EnumStringOf returns the enum value as a string, either as the name if
|
||||
// the number is resolvable, or the number formatted as a string.
|
||||
func (Export) EnumStringOf(ed protoreflect.EnumDescriptor, n protoreflect.EnumNumber) string {
|
||||
func (Export) EnumStringOf(ed pref.EnumDescriptor, n pref.EnumNumber) string {
|
||||
ev := ed.Values().ByNumber(n)
|
||||
if ev != nil {
|
||||
return string(ev.Name())
|
||||
@@ -84,7 +84,7 @@ func (Export) EnumStringOf(ed protoreflect.EnumDescriptor, n protoreflect.EnumNu
|
||||
type message = interface{}
|
||||
|
||||
// legacyMessageWrapper wraps a v2 message as a v1 message.
|
||||
type legacyMessageWrapper struct{ m protoreflect.ProtoMessage }
|
||||
type legacyMessageWrapper struct{ m pref.ProtoMessage }
|
||||
|
||||
func (m legacyMessageWrapper) Reset() { proto.Reset(m.m) }
|
||||
func (m legacyMessageWrapper) String() string { return Export{}.MessageStringOf(m.m) }
|
||||
@@ -92,30 +92,30 @@ func (m legacyMessageWrapper) ProtoMessage() {}
|
||||
|
||||
// ProtoMessageV1Of converts either a v1 or v2 message to a v1 message.
|
||||
// It returns nil if m is nil.
|
||||
func (Export) ProtoMessageV1Of(m message) protoiface.MessageV1 {
|
||||
func (Export) ProtoMessageV1Of(m message) piface.MessageV1 {
|
||||
switch mv := m.(type) {
|
||||
case nil:
|
||||
return nil
|
||||
case protoiface.MessageV1:
|
||||
case piface.MessageV1:
|
||||
return mv
|
||||
case unwrapper:
|
||||
return Export{}.ProtoMessageV1Of(mv.protoUnwrap())
|
||||
case protoreflect.ProtoMessage:
|
||||
case pref.ProtoMessage:
|
||||
return legacyMessageWrapper{mv}
|
||||
default:
|
||||
panic(fmt.Sprintf("message %T is neither a v1 or v2 Message", m))
|
||||
}
|
||||
}
|
||||
|
||||
func (Export) protoMessageV2Of(m message) protoreflect.ProtoMessage {
|
||||
func (Export) protoMessageV2Of(m message) pref.ProtoMessage {
|
||||
switch mv := m.(type) {
|
||||
case nil:
|
||||
return nil
|
||||
case protoreflect.ProtoMessage:
|
||||
case pref.ProtoMessage:
|
||||
return mv
|
||||
case legacyMessageWrapper:
|
||||
return mv.m
|
||||
case protoiface.MessageV1:
|
||||
case piface.MessageV1:
|
||||
return nil
|
||||
default:
|
||||
panic(fmt.Sprintf("message %T is neither a v1 or v2 Message", m))
|
||||
@@ -124,7 +124,7 @@ func (Export) protoMessageV2Of(m message) protoreflect.ProtoMessage {
|
||||
|
||||
// ProtoMessageV2Of converts either a v1 or v2 message to a v2 message.
|
||||
// It returns nil if m is nil.
|
||||
func (Export) ProtoMessageV2Of(m message) protoreflect.ProtoMessage {
|
||||
func (Export) ProtoMessageV2Of(m message) pref.ProtoMessage {
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -136,7 +136,7 @@ func (Export) ProtoMessageV2Of(m message) protoreflect.ProtoMessage {
|
||||
|
||||
// MessageOf returns the protoreflect.Message interface over m.
|
||||
// It returns nil if m is nil.
|
||||
func (Export) MessageOf(m message) protoreflect.Message {
|
||||
func (Export) MessageOf(m message) pref.Message {
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -148,7 +148,7 @@ func (Export) MessageOf(m message) protoreflect.Message {
|
||||
|
||||
// MessageDescriptorOf returns the protoreflect.MessageDescriptor for m.
|
||||
// It returns nil if m is nil.
|
||||
func (Export) MessageDescriptorOf(m message) protoreflect.MessageDescriptor {
|
||||
func (Export) MessageDescriptorOf(m message) pref.MessageDescriptor {
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -160,7 +160,7 @@ func (Export) MessageDescriptorOf(m message) protoreflect.MessageDescriptor {
|
||||
|
||||
// MessageTypeOf returns the protoreflect.MessageType for m.
|
||||
// It returns nil if m is nil.
|
||||
func (Export) MessageTypeOf(m message) protoreflect.MessageType {
|
||||
func (Export) MessageTypeOf(m message) pref.MessageType {
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -172,6 +172,6 @@ func (Export) MessageTypeOf(m message) protoreflect.MessageType {
|
||||
|
||||
// MessageStringOf returns the message value as a string,
|
||||
// which is the message serialized in the protobuf text format.
|
||||
func (Export) MessageStringOf(m protoreflect.ProtoMessage) string {
|
||||
func (Export) MessageStringOf(m pref.ProtoMessage) string {
|
||||
return prototext.MarshalOptions{Multiline: false}.Format(m)
|
||||
}
|
||||
|
||||
12
vendor/google.golang.org/protobuf/internal/impl/checkinit.go
generated
vendored
12
vendor/google.golang.org/protobuf/internal/impl/checkinit.go
generated
vendored
@@ -8,18 +8,18 @@ import (
|
||||
"sync"
|
||||
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/runtime/protoiface"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
piface "google.golang.org/protobuf/runtime/protoiface"
|
||||
)
|
||||
|
||||
func (mi *MessageInfo) checkInitialized(in protoiface.CheckInitializedInput) (protoiface.CheckInitializedOutput, error) {
|
||||
func (mi *MessageInfo) checkInitialized(in piface.CheckInitializedInput) (piface.CheckInitializedOutput, error) {
|
||||
var p pointer
|
||||
if ms, ok := in.Message.(*messageState); ok {
|
||||
p = ms.pointer()
|
||||
} else {
|
||||
p = in.Message.(*messageReflectWrapper).pointer()
|
||||
}
|
||||
return protoiface.CheckInitializedOutput{}, mi.checkInitializedPointer(p)
|
||||
return piface.CheckInitializedOutput{}, mi.checkInitializedPointer(p)
|
||||
}
|
||||
|
||||
func (mi *MessageInfo) checkInitializedPointer(p pointer) error {
|
||||
@@ -90,7 +90,7 @@ var (
|
||||
// needsInitCheck reports whether a message needs to be checked for partial initialization.
|
||||
//
|
||||
// It returns true if the message transitively includes any required or extension fields.
|
||||
func needsInitCheck(md protoreflect.MessageDescriptor) bool {
|
||||
func needsInitCheck(md pref.MessageDescriptor) bool {
|
||||
if v, ok := needsInitCheckMap.Load(md); ok {
|
||||
if has, ok := v.(bool); ok {
|
||||
return has
|
||||
@@ -101,7 +101,7 @@ func needsInitCheck(md protoreflect.MessageDescriptor) bool {
|
||||
return needsInitCheckLocked(md)
|
||||
}
|
||||
|
||||
func needsInitCheckLocked(md protoreflect.MessageDescriptor) (has bool) {
|
||||
func needsInitCheckLocked(md pref.MessageDescriptor) (has bool) {
|
||||
if v, ok := needsInitCheckMap.Load(md); ok {
|
||||
// If has is true, we've previously determined that this message
|
||||
// needs init checks.
|
||||
|
||||
56
vendor/google.golang.org/protobuf/internal/impl/codec_extension.go
generated
vendored
56
vendor/google.golang.org/protobuf/internal/impl/codec_extension.go
generated
vendored
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
type extensionFieldInfo struct {
|
||||
@@ -21,21 +21,29 @@ type extensionFieldInfo struct {
|
||||
validation validationInfo
|
||||
}
|
||||
|
||||
func getExtensionFieldInfo(xt protoreflect.ExtensionType) *extensionFieldInfo {
|
||||
var legacyExtensionFieldInfoCache sync.Map // map[protoreflect.ExtensionType]*extensionFieldInfo
|
||||
|
||||
func getExtensionFieldInfo(xt pref.ExtensionType) *extensionFieldInfo {
|
||||
if xi, ok := xt.(*ExtensionInfo); ok {
|
||||
xi.lazyInit()
|
||||
return xi.info
|
||||
}
|
||||
// Ideally we'd cache the resulting *extensionFieldInfo so we don't have to
|
||||
// recompute this metadata repeatedly. But without support for something like
|
||||
// weak references, such a cache would pin temporary values (like dynamic
|
||||
// extension types, constructed for the duration of a user request) to the
|
||||
// heap forever, causing memory usage of the cache to grow unbounded.
|
||||
// See discussion in https://github.com/golang/protobuf/issues/1521.
|
||||
return makeExtensionFieldInfo(xt.TypeDescriptor())
|
||||
return legacyLoadExtensionFieldInfo(xt)
|
||||
}
|
||||
|
||||
func makeExtensionFieldInfo(xd protoreflect.ExtensionDescriptor) *extensionFieldInfo {
|
||||
// legacyLoadExtensionFieldInfo dynamically loads a *ExtensionInfo for xt.
|
||||
func legacyLoadExtensionFieldInfo(xt pref.ExtensionType) *extensionFieldInfo {
|
||||
if xi, ok := legacyExtensionFieldInfoCache.Load(xt); ok {
|
||||
return xi.(*extensionFieldInfo)
|
||||
}
|
||||
e := makeExtensionFieldInfo(xt.TypeDescriptor())
|
||||
if e, ok := legacyMessageTypeCache.LoadOrStore(xt, e); ok {
|
||||
return e.(*extensionFieldInfo)
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
func makeExtensionFieldInfo(xd pref.ExtensionDescriptor) *extensionFieldInfo {
|
||||
var wiretag uint64
|
||||
if !xd.IsPacked() {
|
||||
wiretag = protowire.EncodeTag(xd.Number(), wireTypes[xd.Kind()])
|
||||
@@ -51,10 +59,10 @@ func makeExtensionFieldInfo(xd protoreflect.ExtensionDescriptor) *extensionField
|
||||
// This is true for composite types, where we pass in a message, list, or map to fill in,
|
||||
// and for enums, where we pass in a prototype value to specify the concrete enum type.
|
||||
switch xd.Kind() {
|
||||
case protoreflect.MessageKind, protoreflect.GroupKind, protoreflect.EnumKind:
|
||||
case pref.MessageKind, pref.GroupKind, pref.EnumKind:
|
||||
e.unmarshalNeedsValue = true
|
||||
default:
|
||||
if xd.Cardinality() == protoreflect.Repeated {
|
||||
if xd.Cardinality() == pref.Repeated {
|
||||
e.unmarshalNeedsValue = true
|
||||
}
|
||||
}
|
||||
@@ -65,21 +73,21 @@ type lazyExtensionValue struct {
|
||||
atomicOnce uint32 // atomically set if value is valid
|
||||
mu sync.Mutex
|
||||
xi *extensionFieldInfo
|
||||
value protoreflect.Value
|
||||
value pref.Value
|
||||
b []byte
|
||||
fn func() protoreflect.Value
|
||||
fn func() pref.Value
|
||||
}
|
||||
|
||||
type ExtensionField struct {
|
||||
typ protoreflect.ExtensionType
|
||||
typ pref.ExtensionType
|
||||
|
||||
// value is either the value of GetValue,
|
||||
// or a *lazyExtensionValue that then returns the value of GetValue.
|
||||
value protoreflect.Value
|
||||
value pref.Value
|
||||
lazy *lazyExtensionValue
|
||||
}
|
||||
|
||||
func (f *ExtensionField) appendLazyBytes(xt protoreflect.ExtensionType, xi *extensionFieldInfo, num protowire.Number, wtyp protowire.Type, b []byte) {
|
||||
func (f *ExtensionField) appendLazyBytes(xt pref.ExtensionType, xi *extensionFieldInfo, num protowire.Number, wtyp protowire.Type, b []byte) {
|
||||
if f.lazy == nil {
|
||||
f.lazy = &lazyExtensionValue{xi: xi}
|
||||
}
|
||||
@@ -89,7 +97,7 @@ func (f *ExtensionField) appendLazyBytes(xt protoreflect.ExtensionType, xi *exte
|
||||
f.lazy.b = append(f.lazy.b, b...)
|
||||
}
|
||||
|
||||
func (f *ExtensionField) canLazy(xt protoreflect.ExtensionType) bool {
|
||||
func (f *ExtensionField) canLazy(xt pref.ExtensionType) bool {
|
||||
if f.typ == nil {
|
||||
return true
|
||||
}
|
||||
@@ -146,7 +154,7 @@ func (f *ExtensionField) lazyInit() {
|
||||
|
||||
// Set sets the type and value of the extension field.
|
||||
// This must not be called concurrently.
|
||||
func (f *ExtensionField) Set(t protoreflect.ExtensionType, v protoreflect.Value) {
|
||||
func (f *ExtensionField) Set(t pref.ExtensionType, v pref.Value) {
|
||||
f.typ = t
|
||||
f.value = v
|
||||
f.lazy = nil
|
||||
@@ -154,14 +162,14 @@ func (f *ExtensionField) Set(t protoreflect.ExtensionType, v protoreflect.Value)
|
||||
|
||||
// SetLazy sets the type and a value that is to be lazily evaluated upon first use.
|
||||
// This must not be called concurrently.
|
||||
func (f *ExtensionField) SetLazy(t protoreflect.ExtensionType, fn func() protoreflect.Value) {
|
||||
func (f *ExtensionField) SetLazy(t pref.ExtensionType, fn func() pref.Value) {
|
||||
f.typ = t
|
||||
f.lazy = &lazyExtensionValue{fn: fn}
|
||||
}
|
||||
|
||||
// Value returns the value of the extension field.
|
||||
// This may be called concurrently.
|
||||
func (f *ExtensionField) Value() protoreflect.Value {
|
||||
func (f *ExtensionField) Value() pref.Value {
|
||||
if f.lazy != nil {
|
||||
if atomic.LoadUint32(&f.lazy.atomicOnce) == 0 {
|
||||
f.lazyInit()
|
||||
@@ -173,7 +181,7 @@ func (f *ExtensionField) Value() protoreflect.Value {
|
||||
|
||||
// Type returns the type of the extension field.
|
||||
// This may be called concurrently.
|
||||
func (f ExtensionField) Type() protoreflect.ExtensionType {
|
||||
func (f ExtensionField) Type() pref.ExtensionType {
|
||||
return f.typ
|
||||
}
|
||||
|
||||
@@ -185,7 +193,7 @@ func (f ExtensionField) IsSet() bool {
|
||||
|
||||
// IsLazy reports whether a field is lazily encoded.
|
||||
// It is exported for testing.
|
||||
func IsLazy(m protoreflect.Message, fd protoreflect.FieldDescriptor) bool {
|
||||
func IsLazy(m pref.Message, fd pref.FieldDescriptor) bool {
|
||||
var mi *MessageInfo
|
||||
var p pointer
|
||||
switch m := m.(type) {
|
||||
@@ -198,7 +206,7 @@ func IsLazy(m protoreflect.Message, fd protoreflect.FieldDescriptor) bool {
|
||||
default:
|
||||
return false
|
||||
}
|
||||
xd, ok := fd.(protoreflect.ExtensionTypeDescriptor)
|
||||
xd, ok := fd.(pref.ExtensionTypeDescriptor)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
90
vendor/google.golang.org/protobuf/internal/impl/codec_field.go
generated
vendored
90
vendor/google.golang.org/protobuf/internal/impl/codec_field.go
generated
vendored
@@ -12,9 +12,9 @@ import (
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
"google.golang.org/protobuf/runtime/protoiface"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
preg "google.golang.org/protobuf/reflect/protoregistry"
|
||||
piface "google.golang.org/protobuf/runtime/protoiface"
|
||||
)
|
||||
|
||||
type errInvalidUTF8 struct{}
|
||||
@@ -30,7 +30,7 @@ func (errInvalidUTF8) Unwrap() error { return errors.Error }
|
||||
// to the appropriate field-specific function as necessary.
|
||||
//
|
||||
// The unmarshal function is set on each field individually as usual.
|
||||
func (mi *MessageInfo) initOneofFieldCoders(od protoreflect.OneofDescriptor, si structInfo) {
|
||||
func (mi *MessageInfo) initOneofFieldCoders(od pref.OneofDescriptor, si structInfo) {
|
||||
fs := si.oneofsByName[od.Name()]
|
||||
ft := fs.Type
|
||||
oneofFields := make(map[reflect.Type]*coderFieldInfo)
|
||||
@@ -118,13 +118,13 @@ func (mi *MessageInfo) initOneofFieldCoders(od protoreflect.OneofDescriptor, si
|
||||
}
|
||||
}
|
||||
|
||||
func makeWeakMessageFieldCoder(fd protoreflect.FieldDescriptor) pointerCoderFuncs {
|
||||
func makeWeakMessageFieldCoder(fd pref.FieldDescriptor) pointerCoderFuncs {
|
||||
var once sync.Once
|
||||
var messageType protoreflect.MessageType
|
||||
var messageType pref.MessageType
|
||||
lazyInit := func() {
|
||||
once.Do(func() {
|
||||
messageName := fd.Message().FullName()
|
||||
messageType, _ = protoregistry.GlobalTypes.FindMessageByName(messageName)
|
||||
messageType, _ = preg.GlobalTypes.FindMessageByName(messageName)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ func makeWeakMessageFieldCoder(fd protoreflect.FieldDescriptor) pointerCoderFunc
|
||||
}
|
||||
}
|
||||
|
||||
func makeMessageFieldCoder(fd protoreflect.FieldDescriptor, ft reflect.Type) pointerCoderFuncs {
|
||||
func makeMessageFieldCoder(fd pref.FieldDescriptor, ft reflect.Type) pointerCoderFuncs {
|
||||
if mi := getMessageInfo(ft); mi != nil {
|
||||
funcs := pointerCoderFuncs{
|
||||
size: sizeMessageInfo,
|
||||
@@ -280,7 +280,7 @@ func consumeMessage(b []byte, m proto.Message, wtyp protowire.Type, opts unmarsh
|
||||
if n < 0 {
|
||||
return out, errDecode
|
||||
}
|
||||
o, err := opts.Options().UnmarshalState(protoiface.UnmarshalInput{
|
||||
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
||||
Buf: v,
|
||||
Message: m.ProtoReflect(),
|
||||
})
|
||||
@@ -288,27 +288,27 @@ func consumeMessage(b []byte, m proto.Message, wtyp protowire.Type, opts unmarsh
|
||||
return out, err
|
||||
}
|
||||
out.n = n
|
||||
out.initialized = o.Flags&protoiface.UnmarshalInitialized != 0
|
||||
out.initialized = o.Flags&piface.UnmarshalInitialized != 0
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func sizeMessageValue(v protoreflect.Value, tagsize int, opts marshalOptions) int {
|
||||
func sizeMessageValue(v pref.Value, tagsize int, opts marshalOptions) int {
|
||||
m := v.Message().Interface()
|
||||
return sizeMessage(m, tagsize, opts)
|
||||
}
|
||||
|
||||
func appendMessageValue(b []byte, v protoreflect.Value, wiretag uint64, opts marshalOptions) ([]byte, error) {
|
||||
func appendMessageValue(b []byte, v pref.Value, wiretag uint64, opts marshalOptions) ([]byte, error) {
|
||||
m := v.Message().Interface()
|
||||
return appendMessage(b, m, wiretag, opts)
|
||||
}
|
||||
|
||||
func consumeMessageValue(b []byte, v protoreflect.Value, _ protowire.Number, wtyp protowire.Type, opts unmarshalOptions) (protoreflect.Value, unmarshalOutput, error) {
|
||||
func consumeMessageValue(b []byte, v pref.Value, _ protowire.Number, wtyp protowire.Type, opts unmarshalOptions) (pref.Value, unmarshalOutput, error) {
|
||||
m := v.Message().Interface()
|
||||
out, err := consumeMessage(b, m, wtyp, opts)
|
||||
return v, out, err
|
||||
}
|
||||
|
||||
func isInitMessageValue(v protoreflect.Value) error {
|
||||
func isInitMessageValue(v pref.Value) error {
|
||||
m := v.Message().Interface()
|
||||
return proto.CheckInitialized(m)
|
||||
}
|
||||
@@ -321,17 +321,17 @@ var coderMessageValue = valueCoderFuncs{
|
||||
merge: mergeMessageValue,
|
||||
}
|
||||
|
||||
func sizeGroupValue(v protoreflect.Value, tagsize int, opts marshalOptions) int {
|
||||
func sizeGroupValue(v pref.Value, tagsize int, opts marshalOptions) int {
|
||||
m := v.Message().Interface()
|
||||
return sizeGroup(m, tagsize, opts)
|
||||
}
|
||||
|
||||
func appendGroupValue(b []byte, v protoreflect.Value, wiretag uint64, opts marshalOptions) ([]byte, error) {
|
||||
func appendGroupValue(b []byte, v pref.Value, wiretag uint64, opts marshalOptions) ([]byte, error) {
|
||||
m := v.Message().Interface()
|
||||
return appendGroup(b, m, wiretag, opts)
|
||||
}
|
||||
|
||||
func consumeGroupValue(b []byte, v protoreflect.Value, num protowire.Number, wtyp protowire.Type, opts unmarshalOptions) (protoreflect.Value, unmarshalOutput, error) {
|
||||
func consumeGroupValue(b []byte, v pref.Value, num protowire.Number, wtyp protowire.Type, opts unmarshalOptions) (pref.Value, unmarshalOutput, error) {
|
||||
m := v.Message().Interface()
|
||||
out, err := consumeGroup(b, m, num, wtyp, opts)
|
||||
return v, out, err
|
||||
@@ -345,7 +345,7 @@ var coderGroupValue = valueCoderFuncs{
|
||||
merge: mergeMessageValue,
|
||||
}
|
||||
|
||||
func makeGroupFieldCoder(fd protoreflect.FieldDescriptor, ft reflect.Type) pointerCoderFuncs {
|
||||
func makeGroupFieldCoder(fd pref.FieldDescriptor, ft reflect.Type) pointerCoderFuncs {
|
||||
num := fd.Number()
|
||||
if mi := getMessageInfo(ft); mi != nil {
|
||||
funcs := pointerCoderFuncs{
|
||||
@@ -424,7 +424,7 @@ func consumeGroup(b []byte, m proto.Message, num protowire.Number, wtyp protowir
|
||||
if n < 0 {
|
||||
return out, errDecode
|
||||
}
|
||||
o, err := opts.Options().UnmarshalState(protoiface.UnmarshalInput{
|
||||
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
||||
Buf: b,
|
||||
Message: m.ProtoReflect(),
|
||||
})
|
||||
@@ -432,11 +432,11 @@ func consumeGroup(b []byte, m proto.Message, num protowire.Number, wtyp protowir
|
||||
return out, err
|
||||
}
|
||||
out.n = n
|
||||
out.initialized = o.Flags&protoiface.UnmarshalInitialized != 0
|
||||
out.initialized = o.Flags&piface.UnmarshalInitialized != 0
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func makeMessageSliceFieldCoder(fd protoreflect.FieldDescriptor, ft reflect.Type) pointerCoderFuncs {
|
||||
func makeMessageSliceFieldCoder(fd pref.FieldDescriptor, ft reflect.Type) pointerCoderFuncs {
|
||||
if mi := getMessageInfo(ft); mi != nil {
|
||||
funcs := pointerCoderFuncs{
|
||||
size: sizeMessageSliceInfo,
|
||||
@@ -555,7 +555,7 @@ func consumeMessageSlice(b []byte, p pointer, goType reflect.Type, wtyp protowir
|
||||
return out, errDecode
|
||||
}
|
||||
mp := reflect.New(goType.Elem())
|
||||
o, err := opts.Options().UnmarshalState(protoiface.UnmarshalInput{
|
||||
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
||||
Buf: v,
|
||||
Message: asMessage(mp).ProtoReflect(),
|
||||
})
|
||||
@@ -564,7 +564,7 @@ func consumeMessageSlice(b []byte, p pointer, goType reflect.Type, wtyp protowir
|
||||
}
|
||||
p.AppendPointerSlice(pointerOfValue(mp))
|
||||
out.n = n
|
||||
out.initialized = o.Flags&protoiface.UnmarshalInitialized != 0
|
||||
out.initialized = o.Flags&piface.UnmarshalInitialized != 0
|
||||
return out, nil
|
||||
}
|
||||
|
||||
@@ -581,7 +581,7 @@ func isInitMessageSlice(p pointer, goType reflect.Type) error {
|
||||
|
||||
// Slices of messages
|
||||
|
||||
func sizeMessageSliceValue(listv protoreflect.Value, tagsize int, opts marshalOptions) int {
|
||||
func sizeMessageSliceValue(listv pref.Value, tagsize int, opts marshalOptions) int {
|
||||
list := listv.List()
|
||||
n := 0
|
||||
for i, llen := 0, list.Len(); i < llen; i++ {
|
||||
@@ -591,7 +591,7 @@ func sizeMessageSliceValue(listv protoreflect.Value, tagsize int, opts marshalOp
|
||||
return n
|
||||
}
|
||||
|
||||
func appendMessageSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, opts marshalOptions) ([]byte, error) {
|
||||
func appendMessageSliceValue(b []byte, listv pref.Value, wiretag uint64, opts marshalOptions) ([]byte, error) {
|
||||
list := listv.List()
|
||||
mopts := opts.Options()
|
||||
for i, llen := 0, list.Len(); i < llen; i++ {
|
||||
@@ -608,30 +608,30 @@ func appendMessageSliceValue(b []byte, listv protoreflect.Value, wiretag uint64,
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func consumeMessageSliceValue(b []byte, listv protoreflect.Value, _ protowire.Number, wtyp protowire.Type, opts unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
|
||||
func consumeMessageSliceValue(b []byte, listv pref.Value, _ protowire.Number, wtyp protowire.Type, opts unmarshalOptions) (_ pref.Value, out unmarshalOutput, err error) {
|
||||
list := listv.List()
|
||||
if wtyp != protowire.BytesType {
|
||||
return protoreflect.Value{}, out, errUnknown
|
||||
return pref.Value{}, out, errUnknown
|
||||
}
|
||||
v, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return protoreflect.Value{}, out, errDecode
|
||||
return pref.Value{}, out, errDecode
|
||||
}
|
||||
m := list.NewElement()
|
||||
o, err := opts.Options().UnmarshalState(protoiface.UnmarshalInput{
|
||||
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
||||
Buf: v,
|
||||
Message: m.Message(),
|
||||
})
|
||||
if err != nil {
|
||||
return protoreflect.Value{}, out, err
|
||||
return pref.Value{}, out, err
|
||||
}
|
||||
list.Append(m)
|
||||
out.n = n
|
||||
out.initialized = o.Flags&protoiface.UnmarshalInitialized != 0
|
||||
out.initialized = o.Flags&piface.UnmarshalInitialized != 0
|
||||
return listv, out, nil
|
||||
}
|
||||
|
||||
func isInitMessageSliceValue(listv protoreflect.Value) error {
|
||||
func isInitMessageSliceValue(listv pref.Value) error {
|
||||
list := listv.List()
|
||||
for i, llen := 0, list.Len(); i < llen; i++ {
|
||||
m := list.Get(i).Message().Interface()
|
||||
@@ -650,7 +650,7 @@ var coderMessageSliceValue = valueCoderFuncs{
|
||||
merge: mergeMessageListValue,
|
||||
}
|
||||
|
||||
func sizeGroupSliceValue(listv protoreflect.Value, tagsize int, opts marshalOptions) int {
|
||||
func sizeGroupSliceValue(listv pref.Value, tagsize int, opts marshalOptions) int {
|
||||
list := listv.List()
|
||||
n := 0
|
||||
for i, llen := 0, list.Len(); i < llen; i++ {
|
||||
@@ -660,7 +660,7 @@ func sizeGroupSliceValue(listv protoreflect.Value, tagsize int, opts marshalOpti
|
||||
return n
|
||||
}
|
||||
|
||||
func appendGroupSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, opts marshalOptions) ([]byte, error) {
|
||||
func appendGroupSliceValue(b []byte, listv pref.Value, wiretag uint64, opts marshalOptions) ([]byte, error) {
|
||||
list := listv.List()
|
||||
mopts := opts.Options()
|
||||
for i, llen := 0, list.Len(); i < llen; i++ {
|
||||
@@ -676,26 +676,26 @@ func appendGroupSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, o
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func consumeGroupSliceValue(b []byte, listv protoreflect.Value, num protowire.Number, wtyp protowire.Type, opts unmarshalOptions) (_ protoreflect.Value, out unmarshalOutput, err error) {
|
||||
func consumeGroupSliceValue(b []byte, listv pref.Value, num protowire.Number, wtyp protowire.Type, opts unmarshalOptions) (_ pref.Value, out unmarshalOutput, err error) {
|
||||
list := listv.List()
|
||||
if wtyp != protowire.StartGroupType {
|
||||
return protoreflect.Value{}, out, errUnknown
|
||||
return pref.Value{}, out, errUnknown
|
||||
}
|
||||
b, n := protowire.ConsumeGroup(num, b)
|
||||
if n < 0 {
|
||||
return protoreflect.Value{}, out, errDecode
|
||||
return pref.Value{}, out, errDecode
|
||||
}
|
||||
m := list.NewElement()
|
||||
o, err := opts.Options().UnmarshalState(protoiface.UnmarshalInput{
|
||||
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
||||
Buf: b,
|
||||
Message: m.Message(),
|
||||
})
|
||||
if err != nil {
|
||||
return protoreflect.Value{}, out, err
|
||||
return pref.Value{}, out, err
|
||||
}
|
||||
list.Append(m)
|
||||
out.n = n
|
||||
out.initialized = o.Flags&protoiface.UnmarshalInitialized != 0
|
||||
out.initialized = o.Flags&piface.UnmarshalInitialized != 0
|
||||
return listv, out, nil
|
||||
}
|
||||
|
||||
@@ -707,7 +707,7 @@ var coderGroupSliceValue = valueCoderFuncs{
|
||||
merge: mergeMessageListValue,
|
||||
}
|
||||
|
||||
func makeGroupSliceFieldCoder(fd protoreflect.FieldDescriptor, ft reflect.Type) pointerCoderFuncs {
|
||||
func makeGroupSliceFieldCoder(fd pref.FieldDescriptor, ft reflect.Type) pointerCoderFuncs {
|
||||
num := fd.Number()
|
||||
if mi := getMessageInfo(ft); mi != nil {
|
||||
funcs := pointerCoderFuncs{
|
||||
@@ -772,7 +772,7 @@ func consumeGroupSlice(b []byte, p pointer, num protowire.Number, wtyp protowire
|
||||
return out, errDecode
|
||||
}
|
||||
mp := reflect.New(goType.Elem())
|
||||
o, err := opts.Options().UnmarshalState(protoiface.UnmarshalInput{
|
||||
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
||||
Buf: b,
|
||||
Message: asMessage(mp).ProtoReflect(),
|
||||
})
|
||||
@@ -781,7 +781,7 @@ func consumeGroupSlice(b []byte, p pointer, num protowire.Number, wtyp protowire
|
||||
}
|
||||
p.AppendPointerSlice(pointerOfValue(mp))
|
||||
out.n = n
|
||||
out.initialized = o.Flags&protoiface.UnmarshalInitialized != 0
|
||||
out.initialized = o.Flags&piface.UnmarshalInitialized != 0
|
||||
return out, nil
|
||||
}
|
||||
|
||||
@@ -822,8 +822,8 @@ func consumeGroupSliceInfo(b []byte, p pointer, wtyp protowire.Type, f *coderFie
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func asMessage(v reflect.Value) protoreflect.ProtoMessage {
|
||||
if m, ok := v.Interface().(protoreflect.ProtoMessage); ok {
|
||||
func asMessage(v reflect.Value) pref.ProtoMessage {
|
||||
if m, ok := v.Interface().(pref.ProtoMessage); ok {
|
||||
return m
|
||||
}
|
||||
return legacyWrapMessage(v).Interface()
|
||||
|
||||
113
vendor/google.golang.org/protobuf/internal/impl/codec_gen.go
generated
vendored
113
vendor/google.golang.org/protobuf/internal/impl/codec_gen.go
generated
vendored
@@ -162,20 +162,11 @@ func appendBoolSlice(b []byte, p pointer, f *coderFieldInfo, opts marshalOptions
|
||||
func consumeBoolSlice(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (out unmarshalOutput, err error) {
|
||||
sp := p.BoolSlice()
|
||||
if wtyp == protowire.BytesType {
|
||||
s := *sp
|
||||
b, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, errDecode
|
||||
}
|
||||
count := 0
|
||||
for _, v := range b {
|
||||
if v < 0x80 {
|
||||
count++
|
||||
}
|
||||
}
|
||||
if count > 0 {
|
||||
p.growBoolSlice(count)
|
||||
}
|
||||
s := *sp
|
||||
for len(b) > 0 {
|
||||
var v uint64
|
||||
var n int
|
||||
@@ -741,20 +732,11 @@ func appendInt32Slice(b []byte, p pointer, f *coderFieldInfo, opts marshalOption
|
||||
func consumeInt32Slice(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (out unmarshalOutput, err error) {
|
||||
sp := p.Int32Slice()
|
||||
if wtyp == protowire.BytesType {
|
||||
s := *sp
|
||||
b, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, errDecode
|
||||
}
|
||||
count := 0
|
||||
for _, v := range b {
|
||||
if v < 0x80 {
|
||||
count++
|
||||
}
|
||||
}
|
||||
if count > 0 {
|
||||
p.growInt32Slice(count)
|
||||
}
|
||||
s := *sp
|
||||
for len(b) > 0 {
|
||||
var v uint64
|
||||
var n int
|
||||
@@ -1156,20 +1138,11 @@ func appendSint32Slice(b []byte, p pointer, f *coderFieldInfo, opts marshalOptio
|
||||
func consumeSint32Slice(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (out unmarshalOutput, err error) {
|
||||
sp := p.Int32Slice()
|
||||
if wtyp == protowire.BytesType {
|
||||
s := *sp
|
||||
b, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, errDecode
|
||||
}
|
||||
count := 0
|
||||
for _, v := range b {
|
||||
if v < 0x80 {
|
||||
count++
|
||||
}
|
||||
}
|
||||
if count > 0 {
|
||||
p.growInt32Slice(count)
|
||||
}
|
||||
s := *sp
|
||||
for len(b) > 0 {
|
||||
var v uint64
|
||||
var n int
|
||||
@@ -1571,20 +1544,11 @@ func appendUint32Slice(b []byte, p pointer, f *coderFieldInfo, opts marshalOptio
|
||||
func consumeUint32Slice(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (out unmarshalOutput, err error) {
|
||||
sp := p.Uint32Slice()
|
||||
if wtyp == protowire.BytesType {
|
||||
s := *sp
|
||||
b, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, errDecode
|
||||
}
|
||||
count := 0
|
||||
for _, v := range b {
|
||||
if v < 0x80 {
|
||||
count++
|
||||
}
|
||||
}
|
||||
if count > 0 {
|
||||
p.growUint32Slice(count)
|
||||
}
|
||||
s := *sp
|
||||
for len(b) > 0 {
|
||||
var v uint64
|
||||
var n int
|
||||
@@ -1986,20 +1950,11 @@ func appendInt64Slice(b []byte, p pointer, f *coderFieldInfo, opts marshalOption
|
||||
func consumeInt64Slice(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (out unmarshalOutput, err error) {
|
||||
sp := p.Int64Slice()
|
||||
if wtyp == protowire.BytesType {
|
||||
s := *sp
|
||||
b, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, errDecode
|
||||
}
|
||||
count := 0
|
||||
for _, v := range b {
|
||||
if v < 0x80 {
|
||||
count++
|
||||
}
|
||||
}
|
||||
if count > 0 {
|
||||
p.growInt64Slice(count)
|
||||
}
|
||||
s := *sp
|
||||
for len(b) > 0 {
|
||||
var v uint64
|
||||
var n int
|
||||
@@ -2401,20 +2356,11 @@ func appendSint64Slice(b []byte, p pointer, f *coderFieldInfo, opts marshalOptio
|
||||
func consumeSint64Slice(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (out unmarshalOutput, err error) {
|
||||
sp := p.Int64Slice()
|
||||
if wtyp == protowire.BytesType {
|
||||
s := *sp
|
||||
b, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, errDecode
|
||||
}
|
||||
count := 0
|
||||
for _, v := range b {
|
||||
if v < 0x80 {
|
||||
count++
|
||||
}
|
||||
}
|
||||
if count > 0 {
|
||||
p.growInt64Slice(count)
|
||||
}
|
||||
s := *sp
|
||||
for len(b) > 0 {
|
||||
var v uint64
|
||||
var n int
|
||||
@@ -2816,20 +2762,11 @@ func appendUint64Slice(b []byte, p pointer, f *coderFieldInfo, opts marshalOptio
|
||||
func consumeUint64Slice(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (out unmarshalOutput, err error) {
|
||||
sp := p.Uint64Slice()
|
||||
if wtyp == protowire.BytesType {
|
||||
s := *sp
|
||||
b, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, errDecode
|
||||
}
|
||||
count := 0
|
||||
for _, v := range b {
|
||||
if v < 0x80 {
|
||||
count++
|
||||
}
|
||||
}
|
||||
if count > 0 {
|
||||
p.growUint64Slice(count)
|
||||
}
|
||||
s := *sp
|
||||
for len(b) > 0 {
|
||||
var v uint64
|
||||
var n int
|
||||
@@ -3208,15 +3145,11 @@ func appendSfixed32Slice(b []byte, p pointer, f *coderFieldInfo, opts marshalOpt
|
||||
func consumeSfixed32Slice(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (out unmarshalOutput, err error) {
|
||||
sp := p.Int32Slice()
|
||||
if wtyp == protowire.BytesType {
|
||||
s := *sp
|
||||
b, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, errDecode
|
||||
}
|
||||
count := len(b) / protowire.SizeFixed32()
|
||||
if count > 0 {
|
||||
p.growInt32Slice(count)
|
||||
}
|
||||
s := *sp
|
||||
for len(b) > 0 {
|
||||
v, n := protowire.ConsumeFixed32(b)
|
||||
if n < 0 {
|
||||
@@ -3528,15 +3461,11 @@ func appendFixed32Slice(b []byte, p pointer, f *coderFieldInfo, opts marshalOpti
|
||||
func consumeFixed32Slice(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (out unmarshalOutput, err error) {
|
||||
sp := p.Uint32Slice()
|
||||
if wtyp == protowire.BytesType {
|
||||
s := *sp
|
||||
b, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, errDecode
|
||||
}
|
||||
count := len(b) / protowire.SizeFixed32()
|
||||
if count > 0 {
|
||||
p.growUint32Slice(count)
|
||||
}
|
||||
s := *sp
|
||||
for len(b) > 0 {
|
||||
v, n := protowire.ConsumeFixed32(b)
|
||||
if n < 0 {
|
||||
@@ -3848,15 +3777,11 @@ func appendFloatSlice(b []byte, p pointer, f *coderFieldInfo, opts marshalOption
|
||||
func consumeFloatSlice(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (out unmarshalOutput, err error) {
|
||||
sp := p.Float32Slice()
|
||||
if wtyp == protowire.BytesType {
|
||||
s := *sp
|
||||
b, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, errDecode
|
||||
}
|
||||
count := len(b) / protowire.SizeFixed32()
|
||||
if count > 0 {
|
||||
p.growFloat32Slice(count)
|
||||
}
|
||||
s := *sp
|
||||
for len(b) > 0 {
|
||||
v, n := protowire.ConsumeFixed32(b)
|
||||
if n < 0 {
|
||||
@@ -4168,15 +4093,11 @@ func appendSfixed64Slice(b []byte, p pointer, f *coderFieldInfo, opts marshalOpt
|
||||
func consumeSfixed64Slice(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (out unmarshalOutput, err error) {
|
||||
sp := p.Int64Slice()
|
||||
if wtyp == protowire.BytesType {
|
||||
s := *sp
|
||||
b, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, errDecode
|
||||
}
|
||||
count := len(b) / protowire.SizeFixed64()
|
||||
if count > 0 {
|
||||
p.growInt64Slice(count)
|
||||
}
|
||||
s := *sp
|
||||
for len(b) > 0 {
|
||||
v, n := protowire.ConsumeFixed64(b)
|
||||
if n < 0 {
|
||||
@@ -4488,15 +4409,11 @@ func appendFixed64Slice(b []byte, p pointer, f *coderFieldInfo, opts marshalOpti
|
||||
func consumeFixed64Slice(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (out unmarshalOutput, err error) {
|
||||
sp := p.Uint64Slice()
|
||||
if wtyp == protowire.BytesType {
|
||||
s := *sp
|
||||
b, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, errDecode
|
||||
}
|
||||
count := len(b) / protowire.SizeFixed64()
|
||||
if count > 0 {
|
||||
p.growUint64Slice(count)
|
||||
}
|
||||
s := *sp
|
||||
for len(b) > 0 {
|
||||
v, n := protowire.ConsumeFixed64(b)
|
||||
if n < 0 {
|
||||
@@ -4808,15 +4725,11 @@ func appendDoubleSlice(b []byte, p pointer, f *coderFieldInfo, opts marshalOptio
|
||||
func consumeDoubleSlice(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (out unmarshalOutput, err error) {
|
||||
sp := p.Float64Slice()
|
||||
if wtyp == protowire.BytesType {
|
||||
s := *sp
|
||||
b, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, errDecode
|
||||
}
|
||||
count := len(b) / protowire.SizeFixed64()
|
||||
if count > 0 {
|
||||
p.growFloat64Slice(count)
|
||||
}
|
||||
s := *sp
|
||||
for len(b) > 0 {
|
||||
v, n := protowire.ConsumeFixed64(b)
|
||||
if n < 0 {
|
||||
|
||||
20
vendor/google.golang.org/protobuf/internal/impl/codec_map.go
generated
vendored
20
vendor/google.golang.org/protobuf/internal/impl/codec_map.go
generated
vendored
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
type mapInfo struct {
|
||||
@@ -19,12 +19,12 @@ type mapInfo struct {
|
||||
valWiretag uint64
|
||||
keyFuncs valueCoderFuncs
|
||||
valFuncs valueCoderFuncs
|
||||
keyZero protoreflect.Value
|
||||
keyKind protoreflect.Kind
|
||||
keyZero pref.Value
|
||||
keyKind pref.Kind
|
||||
conv *mapConverter
|
||||
}
|
||||
|
||||
func encoderFuncsForMap(fd protoreflect.FieldDescriptor, ft reflect.Type) (valueMessage *MessageInfo, funcs pointerCoderFuncs) {
|
||||
func encoderFuncsForMap(fd pref.FieldDescriptor, ft reflect.Type) (valueMessage *MessageInfo, funcs pointerCoderFuncs) {
|
||||
// TODO: Consider generating specialized map coders.
|
||||
keyField := fd.MapKey()
|
||||
valField := fd.MapValue()
|
||||
@@ -44,7 +44,7 @@ func encoderFuncsForMap(fd protoreflect.FieldDescriptor, ft reflect.Type) (value
|
||||
keyKind: keyField.Kind(),
|
||||
conv: conv,
|
||||
}
|
||||
if valField.Kind() == protoreflect.MessageKind {
|
||||
if valField.Kind() == pref.MessageKind {
|
||||
valueMessage = getMessageInfo(ft.Elem())
|
||||
}
|
||||
|
||||
@@ -68,9 +68,9 @@ func encoderFuncsForMap(fd protoreflect.FieldDescriptor, ft reflect.Type) (value
|
||||
},
|
||||
}
|
||||
switch valField.Kind() {
|
||||
case protoreflect.MessageKind:
|
||||
case pref.MessageKind:
|
||||
funcs.merge = mergeMapOfMessage
|
||||
case protoreflect.BytesKind:
|
||||
case pref.BytesKind:
|
||||
funcs.merge = mergeMapOfBytes
|
||||
default:
|
||||
funcs.merge = mergeMap
|
||||
@@ -135,7 +135,7 @@ func consumeMap(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi *mapInfo
|
||||
err := errUnknown
|
||||
switch num {
|
||||
case genid.MapEntry_Key_field_number:
|
||||
var v protoreflect.Value
|
||||
var v pref.Value
|
||||
var o unmarshalOutput
|
||||
v, o, err = mapi.keyFuncs.unmarshal(b, key, num, wtyp, opts)
|
||||
if err != nil {
|
||||
@@ -144,7 +144,7 @@ func consumeMap(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi *mapInfo
|
||||
key = v
|
||||
n = o.n
|
||||
case genid.MapEntry_Value_field_number:
|
||||
var v protoreflect.Value
|
||||
var v pref.Value
|
||||
var o unmarshalOutput
|
||||
v, o, err = mapi.valFuncs.unmarshal(b, val, num, wtyp, opts)
|
||||
if err != nil {
|
||||
@@ -192,7 +192,7 @@ func consumeMapOfMessage(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi
|
||||
err := errUnknown
|
||||
switch num {
|
||||
case 1:
|
||||
var v protoreflect.Value
|
||||
var v pref.Value
|
||||
var o unmarshalOutput
|
||||
v, o, err = mapi.keyFuncs.unmarshal(b, key, num, wtyp, opts)
|
||||
if err != nil {
|
||||
|
||||
1
vendor/google.golang.org/protobuf/internal/impl/codec_map_go111.go
generated
vendored
1
vendor/google.golang.org/protobuf/internal/impl/codec_map_go111.go
generated
vendored
@@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !go1.12
|
||||
// +build !go1.12
|
||||
|
||||
package impl
|
||||
|
||||
1
vendor/google.golang.org/protobuf/internal/impl/codec_map_go112.go
generated
vendored
1
vendor/google.golang.org/protobuf/internal/impl/codec_map_go112.go
generated
vendored
@@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build go1.12
|
||||
// +build go1.12
|
||||
|
||||
package impl
|
||||
|
||||
30
vendor/google.golang.org/protobuf/internal/impl/codec_message.go
generated
vendored
30
vendor/google.golang.org/protobuf/internal/impl/codec_message.go
generated
vendored
@@ -12,15 +12,15 @@ import (
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/encoding/messageset"
|
||||
"google.golang.org/protobuf/internal/order"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/runtime/protoiface"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
piface "google.golang.org/protobuf/runtime/protoiface"
|
||||
)
|
||||
|
||||
// coderMessageInfo contains per-message information used by the fast-path functions.
|
||||
// This is a different type from MessageInfo to keep MessageInfo as general-purpose as
|
||||
// possible.
|
||||
type coderMessageInfo struct {
|
||||
methods protoiface.Methods
|
||||
methods piface.Methods
|
||||
|
||||
orderedCoderFields []*coderFieldInfo
|
||||
denseCoderFields []*coderFieldInfo
|
||||
@@ -38,13 +38,13 @@ type coderFieldInfo struct {
|
||||
funcs pointerCoderFuncs // fast-path per-field functions
|
||||
mi *MessageInfo // field's message
|
||||
ft reflect.Type
|
||||
validation validationInfo // information used by message validation
|
||||
num protoreflect.FieldNumber // field number
|
||||
offset offset // struct field offset
|
||||
wiretag uint64 // field tag (number + wire type)
|
||||
tagsize int // size of the varint-encoded tag
|
||||
isPointer bool // true if IsNil may be called on the struct field
|
||||
isRequired bool // true if field is required
|
||||
validation validationInfo // information used by message validation
|
||||
num pref.FieldNumber // field number
|
||||
offset offset // struct field offset
|
||||
wiretag uint64 // field tag (number + wire type)
|
||||
tagsize int // size of the varint-encoded tag
|
||||
isPointer bool // true if IsNil may be called on the struct field
|
||||
isRequired bool // true if field is required
|
||||
}
|
||||
|
||||
func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
||||
@@ -125,8 +125,8 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
||||
funcs: funcs,
|
||||
mi: childMessage,
|
||||
validation: newFieldValidationInfo(mi, si, fd, ft),
|
||||
isPointer: fd.Cardinality() == protoreflect.Repeated || fd.HasPresence(),
|
||||
isRequired: fd.Cardinality() == protoreflect.Required,
|
||||
isPointer: fd.Cardinality() == pref.Repeated || fd.HasPresence(),
|
||||
isRequired: fd.Cardinality() == pref.Required,
|
||||
}
|
||||
mi.orderedCoderFields = append(mi.orderedCoderFields, cf)
|
||||
mi.coderFields[cf.num] = cf
|
||||
@@ -149,7 +149,7 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
||||
return mi.orderedCoderFields[i].num < mi.orderedCoderFields[j].num
|
||||
})
|
||||
|
||||
var maxDense protoreflect.FieldNumber
|
||||
var maxDense pref.FieldNumber
|
||||
for _, cf := range mi.orderedCoderFields {
|
||||
if cf.num >= 16 && cf.num >= 2*maxDense {
|
||||
break
|
||||
@@ -175,12 +175,12 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
||||
|
||||
mi.needsInitCheck = needsInitCheck(mi.Desc)
|
||||
if mi.methods.Marshal == nil && mi.methods.Size == nil {
|
||||
mi.methods.Flags |= protoiface.SupportMarshalDeterministic
|
||||
mi.methods.Flags |= piface.SupportMarshalDeterministic
|
||||
mi.methods.Marshal = mi.marshal
|
||||
mi.methods.Size = mi.size
|
||||
}
|
||||
if mi.methods.Unmarshal == nil {
|
||||
mi.methods.Flags |= protoiface.SupportUnmarshalDiscardUnknown
|
||||
mi.methods.Flags |= piface.SupportUnmarshalDiscardUnknown
|
||||
mi.methods.Unmarshal = mi.unmarshal
|
||||
}
|
||||
if mi.methods.CheckInitialized == nil {
|
||||
|
||||
1
vendor/google.golang.org/protobuf/internal/impl/codec_reflect.go
generated
vendored
1
vendor/google.golang.org/protobuf/internal/impl/codec_reflect.go
generated
vendored
@@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build purego || appengine
|
||||
// +build purego appengine
|
||||
|
||||
package impl
|
||||
|
||||
290
vendor/google.golang.org/protobuf/internal/impl/codec_tables.go
generated
vendored
290
vendor/google.golang.org/protobuf/internal/impl/codec_tables.go
generated
vendored
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/strs"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
// pointerCoderFuncs is a set of pointer encoding functions.
|
||||
@@ -25,83 +25,83 @@ type pointerCoderFuncs struct {
|
||||
|
||||
// valueCoderFuncs is a set of protoreflect.Value encoding functions.
|
||||
type valueCoderFuncs struct {
|
||||
size func(v protoreflect.Value, tagsize int, opts marshalOptions) int
|
||||
marshal func(b []byte, v protoreflect.Value, wiretag uint64, opts marshalOptions) ([]byte, error)
|
||||
unmarshal func(b []byte, v protoreflect.Value, num protowire.Number, wtyp protowire.Type, opts unmarshalOptions) (protoreflect.Value, unmarshalOutput, error)
|
||||
isInit func(v protoreflect.Value) error
|
||||
merge func(dst, src protoreflect.Value, opts mergeOptions) protoreflect.Value
|
||||
size func(v pref.Value, tagsize int, opts marshalOptions) int
|
||||
marshal func(b []byte, v pref.Value, wiretag uint64, opts marshalOptions) ([]byte, error)
|
||||
unmarshal func(b []byte, v pref.Value, num protowire.Number, wtyp protowire.Type, opts unmarshalOptions) (pref.Value, unmarshalOutput, error)
|
||||
isInit func(v pref.Value) error
|
||||
merge func(dst, src pref.Value, opts mergeOptions) pref.Value
|
||||
}
|
||||
|
||||
// fieldCoder returns pointer functions for a field, used for operating on
|
||||
// struct fields.
|
||||
func fieldCoder(fd protoreflect.FieldDescriptor, ft reflect.Type) (*MessageInfo, pointerCoderFuncs) {
|
||||
func fieldCoder(fd pref.FieldDescriptor, ft reflect.Type) (*MessageInfo, pointerCoderFuncs) {
|
||||
switch {
|
||||
case fd.IsMap():
|
||||
return encoderFuncsForMap(fd, ft)
|
||||
case fd.Cardinality() == protoreflect.Repeated && !fd.IsPacked():
|
||||
case fd.Cardinality() == pref.Repeated && !fd.IsPacked():
|
||||
// Repeated fields (not packed).
|
||||
if ft.Kind() != reflect.Slice {
|
||||
break
|
||||
}
|
||||
ft := ft.Elem()
|
||||
switch fd.Kind() {
|
||||
case protoreflect.BoolKind:
|
||||
case pref.BoolKind:
|
||||
if ft.Kind() == reflect.Bool {
|
||||
return nil, coderBoolSlice
|
||||
}
|
||||
case protoreflect.EnumKind:
|
||||
case pref.EnumKind:
|
||||
if ft.Kind() == reflect.Int32 {
|
||||
return nil, coderEnumSlice
|
||||
}
|
||||
case protoreflect.Int32Kind:
|
||||
case pref.Int32Kind:
|
||||
if ft.Kind() == reflect.Int32 {
|
||||
return nil, coderInt32Slice
|
||||
}
|
||||
case protoreflect.Sint32Kind:
|
||||
case pref.Sint32Kind:
|
||||
if ft.Kind() == reflect.Int32 {
|
||||
return nil, coderSint32Slice
|
||||
}
|
||||
case protoreflect.Uint32Kind:
|
||||
case pref.Uint32Kind:
|
||||
if ft.Kind() == reflect.Uint32 {
|
||||
return nil, coderUint32Slice
|
||||
}
|
||||
case protoreflect.Int64Kind:
|
||||
case pref.Int64Kind:
|
||||
if ft.Kind() == reflect.Int64 {
|
||||
return nil, coderInt64Slice
|
||||
}
|
||||
case protoreflect.Sint64Kind:
|
||||
case pref.Sint64Kind:
|
||||
if ft.Kind() == reflect.Int64 {
|
||||
return nil, coderSint64Slice
|
||||
}
|
||||
case protoreflect.Uint64Kind:
|
||||
case pref.Uint64Kind:
|
||||
if ft.Kind() == reflect.Uint64 {
|
||||
return nil, coderUint64Slice
|
||||
}
|
||||
case protoreflect.Sfixed32Kind:
|
||||
case pref.Sfixed32Kind:
|
||||
if ft.Kind() == reflect.Int32 {
|
||||
return nil, coderSfixed32Slice
|
||||
}
|
||||
case protoreflect.Fixed32Kind:
|
||||
case pref.Fixed32Kind:
|
||||
if ft.Kind() == reflect.Uint32 {
|
||||
return nil, coderFixed32Slice
|
||||
}
|
||||
case protoreflect.FloatKind:
|
||||
case pref.FloatKind:
|
||||
if ft.Kind() == reflect.Float32 {
|
||||
return nil, coderFloatSlice
|
||||
}
|
||||
case protoreflect.Sfixed64Kind:
|
||||
case pref.Sfixed64Kind:
|
||||
if ft.Kind() == reflect.Int64 {
|
||||
return nil, coderSfixed64Slice
|
||||
}
|
||||
case protoreflect.Fixed64Kind:
|
||||
case pref.Fixed64Kind:
|
||||
if ft.Kind() == reflect.Uint64 {
|
||||
return nil, coderFixed64Slice
|
||||
}
|
||||
case protoreflect.DoubleKind:
|
||||
case pref.DoubleKind:
|
||||
if ft.Kind() == reflect.Float64 {
|
||||
return nil, coderDoubleSlice
|
||||
}
|
||||
case protoreflect.StringKind:
|
||||
case pref.StringKind:
|
||||
if ft.Kind() == reflect.String && strs.EnforceUTF8(fd) {
|
||||
return nil, coderStringSliceValidateUTF8
|
||||
}
|
||||
@@ -114,19 +114,19 @@ func fieldCoder(fd protoreflect.FieldDescriptor, ft reflect.Type) (*MessageInfo,
|
||||
if ft.Kind() == reflect.Slice && ft.Elem().Kind() == reflect.Uint8 {
|
||||
return nil, coderBytesSlice
|
||||
}
|
||||
case protoreflect.BytesKind:
|
||||
case pref.BytesKind:
|
||||
if ft.Kind() == reflect.String {
|
||||
return nil, coderStringSlice
|
||||
}
|
||||
if ft.Kind() == reflect.Slice && ft.Elem().Kind() == reflect.Uint8 {
|
||||
return nil, coderBytesSlice
|
||||
}
|
||||
case protoreflect.MessageKind:
|
||||
case pref.MessageKind:
|
||||
return getMessageInfo(ft), makeMessageSliceFieldCoder(fd, ft)
|
||||
case protoreflect.GroupKind:
|
||||
case pref.GroupKind:
|
||||
return getMessageInfo(ft), makeGroupSliceFieldCoder(fd, ft)
|
||||
}
|
||||
case fd.Cardinality() == protoreflect.Repeated && fd.IsPacked():
|
||||
case fd.Cardinality() == pref.Repeated && fd.IsPacked():
|
||||
// Packed repeated fields.
|
||||
//
|
||||
// Only repeated fields of primitive numeric types
|
||||
@@ -136,128 +136,128 @@ func fieldCoder(fd protoreflect.FieldDescriptor, ft reflect.Type) (*MessageInfo,
|
||||
}
|
||||
ft := ft.Elem()
|
||||
switch fd.Kind() {
|
||||
case protoreflect.BoolKind:
|
||||
case pref.BoolKind:
|
||||
if ft.Kind() == reflect.Bool {
|
||||
return nil, coderBoolPackedSlice
|
||||
}
|
||||
case protoreflect.EnumKind:
|
||||
case pref.EnumKind:
|
||||
if ft.Kind() == reflect.Int32 {
|
||||
return nil, coderEnumPackedSlice
|
||||
}
|
||||
case protoreflect.Int32Kind:
|
||||
case pref.Int32Kind:
|
||||
if ft.Kind() == reflect.Int32 {
|
||||
return nil, coderInt32PackedSlice
|
||||
}
|
||||
case protoreflect.Sint32Kind:
|
||||
case pref.Sint32Kind:
|
||||
if ft.Kind() == reflect.Int32 {
|
||||
return nil, coderSint32PackedSlice
|
||||
}
|
||||
case protoreflect.Uint32Kind:
|
||||
case pref.Uint32Kind:
|
||||
if ft.Kind() == reflect.Uint32 {
|
||||
return nil, coderUint32PackedSlice
|
||||
}
|
||||
case protoreflect.Int64Kind:
|
||||
case pref.Int64Kind:
|
||||
if ft.Kind() == reflect.Int64 {
|
||||
return nil, coderInt64PackedSlice
|
||||
}
|
||||
case protoreflect.Sint64Kind:
|
||||
case pref.Sint64Kind:
|
||||
if ft.Kind() == reflect.Int64 {
|
||||
return nil, coderSint64PackedSlice
|
||||
}
|
||||
case protoreflect.Uint64Kind:
|
||||
case pref.Uint64Kind:
|
||||
if ft.Kind() == reflect.Uint64 {
|
||||
return nil, coderUint64PackedSlice
|
||||
}
|
||||
case protoreflect.Sfixed32Kind:
|
||||
case pref.Sfixed32Kind:
|
||||
if ft.Kind() == reflect.Int32 {
|
||||
return nil, coderSfixed32PackedSlice
|
||||
}
|
||||
case protoreflect.Fixed32Kind:
|
||||
case pref.Fixed32Kind:
|
||||
if ft.Kind() == reflect.Uint32 {
|
||||
return nil, coderFixed32PackedSlice
|
||||
}
|
||||
case protoreflect.FloatKind:
|
||||
case pref.FloatKind:
|
||||
if ft.Kind() == reflect.Float32 {
|
||||
return nil, coderFloatPackedSlice
|
||||
}
|
||||
case protoreflect.Sfixed64Kind:
|
||||
case pref.Sfixed64Kind:
|
||||
if ft.Kind() == reflect.Int64 {
|
||||
return nil, coderSfixed64PackedSlice
|
||||
}
|
||||
case protoreflect.Fixed64Kind:
|
||||
case pref.Fixed64Kind:
|
||||
if ft.Kind() == reflect.Uint64 {
|
||||
return nil, coderFixed64PackedSlice
|
||||
}
|
||||
case protoreflect.DoubleKind:
|
||||
case pref.DoubleKind:
|
||||
if ft.Kind() == reflect.Float64 {
|
||||
return nil, coderDoublePackedSlice
|
||||
}
|
||||
}
|
||||
case fd.Kind() == protoreflect.MessageKind:
|
||||
case fd.Kind() == pref.MessageKind:
|
||||
return getMessageInfo(ft), makeMessageFieldCoder(fd, ft)
|
||||
case fd.Kind() == protoreflect.GroupKind:
|
||||
case fd.Kind() == pref.GroupKind:
|
||||
return getMessageInfo(ft), makeGroupFieldCoder(fd, ft)
|
||||
case !fd.HasPresence() && fd.ContainingOneof() == nil:
|
||||
case fd.Syntax() == pref.Proto3 && fd.ContainingOneof() == nil:
|
||||
// Populated oneof fields always encode even if set to the zero value,
|
||||
// which normally are not encoded in proto3.
|
||||
switch fd.Kind() {
|
||||
case protoreflect.BoolKind:
|
||||
case pref.BoolKind:
|
||||
if ft.Kind() == reflect.Bool {
|
||||
return nil, coderBoolNoZero
|
||||
}
|
||||
case protoreflect.EnumKind:
|
||||
case pref.EnumKind:
|
||||
if ft.Kind() == reflect.Int32 {
|
||||
return nil, coderEnumNoZero
|
||||
}
|
||||
case protoreflect.Int32Kind:
|
||||
case pref.Int32Kind:
|
||||
if ft.Kind() == reflect.Int32 {
|
||||
return nil, coderInt32NoZero
|
||||
}
|
||||
case protoreflect.Sint32Kind:
|
||||
case pref.Sint32Kind:
|
||||
if ft.Kind() == reflect.Int32 {
|
||||
return nil, coderSint32NoZero
|
||||
}
|
||||
case protoreflect.Uint32Kind:
|
||||
case pref.Uint32Kind:
|
||||
if ft.Kind() == reflect.Uint32 {
|
||||
return nil, coderUint32NoZero
|
||||
}
|
||||
case protoreflect.Int64Kind:
|
||||
case pref.Int64Kind:
|
||||
if ft.Kind() == reflect.Int64 {
|
||||
return nil, coderInt64NoZero
|
||||
}
|
||||
case protoreflect.Sint64Kind:
|
||||
case pref.Sint64Kind:
|
||||
if ft.Kind() == reflect.Int64 {
|
||||
return nil, coderSint64NoZero
|
||||
}
|
||||
case protoreflect.Uint64Kind:
|
||||
case pref.Uint64Kind:
|
||||
if ft.Kind() == reflect.Uint64 {
|
||||
return nil, coderUint64NoZero
|
||||
}
|
||||
case protoreflect.Sfixed32Kind:
|
||||
case pref.Sfixed32Kind:
|
||||
if ft.Kind() == reflect.Int32 {
|
||||
return nil, coderSfixed32NoZero
|
||||
}
|
||||
case protoreflect.Fixed32Kind:
|
||||
case pref.Fixed32Kind:
|
||||
if ft.Kind() == reflect.Uint32 {
|
||||
return nil, coderFixed32NoZero
|
||||
}
|
||||
case protoreflect.FloatKind:
|
||||
case pref.FloatKind:
|
||||
if ft.Kind() == reflect.Float32 {
|
||||
return nil, coderFloatNoZero
|
||||
}
|
||||
case protoreflect.Sfixed64Kind:
|
||||
case pref.Sfixed64Kind:
|
||||
if ft.Kind() == reflect.Int64 {
|
||||
return nil, coderSfixed64NoZero
|
||||
}
|
||||
case protoreflect.Fixed64Kind:
|
||||
case pref.Fixed64Kind:
|
||||
if ft.Kind() == reflect.Uint64 {
|
||||
return nil, coderFixed64NoZero
|
||||
}
|
||||
case protoreflect.DoubleKind:
|
||||
case pref.DoubleKind:
|
||||
if ft.Kind() == reflect.Float64 {
|
||||
return nil, coderDoubleNoZero
|
||||
}
|
||||
case protoreflect.StringKind:
|
||||
case pref.StringKind:
|
||||
if ft.Kind() == reflect.String && strs.EnforceUTF8(fd) {
|
||||
return nil, coderStringNoZeroValidateUTF8
|
||||
}
|
||||
@@ -270,7 +270,7 @@ func fieldCoder(fd protoreflect.FieldDescriptor, ft reflect.Type) (*MessageInfo,
|
||||
if ft.Kind() == reflect.Slice && ft.Elem().Kind() == reflect.Uint8 {
|
||||
return nil, coderBytesNoZero
|
||||
}
|
||||
case protoreflect.BytesKind:
|
||||
case pref.BytesKind:
|
||||
if ft.Kind() == reflect.String {
|
||||
return nil, coderStringNoZero
|
||||
}
|
||||
@@ -281,133 +281,133 @@ func fieldCoder(fd protoreflect.FieldDescriptor, ft reflect.Type) (*MessageInfo,
|
||||
case ft.Kind() == reflect.Ptr:
|
||||
ft := ft.Elem()
|
||||
switch fd.Kind() {
|
||||
case protoreflect.BoolKind:
|
||||
case pref.BoolKind:
|
||||
if ft.Kind() == reflect.Bool {
|
||||
return nil, coderBoolPtr
|
||||
}
|
||||
case protoreflect.EnumKind:
|
||||
case pref.EnumKind:
|
||||
if ft.Kind() == reflect.Int32 {
|
||||
return nil, coderEnumPtr
|
||||
}
|
||||
case protoreflect.Int32Kind:
|
||||
case pref.Int32Kind:
|
||||
if ft.Kind() == reflect.Int32 {
|
||||
return nil, coderInt32Ptr
|
||||
}
|
||||
case protoreflect.Sint32Kind:
|
||||
case pref.Sint32Kind:
|
||||
if ft.Kind() == reflect.Int32 {
|
||||
return nil, coderSint32Ptr
|
||||
}
|
||||
case protoreflect.Uint32Kind:
|
||||
case pref.Uint32Kind:
|
||||
if ft.Kind() == reflect.Uint32 {
|
||||
return nil, coderUint32Ptr
|
||||
}
|
||||
case protoreflect.Int64Kind:
|
||||
case pref.Int64Kind:
|
||||
if ft.Kind() == reflect.Int64 {
|
||||
return nil, coderInt64Ptr
|
||||
}
|
||||
case protoreflect.Sint64Kind:
|
||||
case pref.Sint64Kind:
|
||||
if ft.Kind() == reflect.Int64 {
|
||||
return nil, coderSint64Ptr
|
||||
}
|
||||
case protoreflect.Uint64Kind:
|
||||
case pref.Uint64Kind:
|
||||
if ft.Kind() == reflect.Uint64 {
|
||||
return nil, coderUint64Ptr
|
||||
}
|
||||
case protoreflect.Sfixed32Kind:
|
||||
case pref.Sfixed32Kind:
|
||||
if ft.Kind() == reflect.Int32 {
|
||||
return nil, coderSfixed32Ptr
|
||||
}
|
||||
case protoreflect.Fixed32Kind:
|
||||
case pref.Fixed32Kind:
|
||||
if ft.Kind() == reflect.Uint32 {
|
||||
return nil, coderFixed32Ptr
|
||||
}
|
||||
case protoreflect.FloatKind:
|
||||
case pref.FloatKind:
|
||||
if ft.Kind() == reflect.Float32 {
|
||||
return nil, coderFloatPtr
|
||||
}
|
||||
case protoreflect.Sfixed64Kind:
|
||||
case pref.Sfixed64Kind:
|
||||
if ft.Kind() == reflect.Int64 {
|
||||
return nil, coderSfixed64Ptr
|
||||
}
|
||||
case protoreflect.Fixed64Kind:
|
||||
case pref.Fixed64Kind:
|
||||
if ft.Kind() == reflect.Uint64 {
|
||||
return nil, coderFixed64Ptr
|
||||
}
|
||||
case protoreflect.DoubleKind:
|
||||
case pref.DoubleKind:
|
||||
if ft.Kind() == reflect.Float64 {
|
||||
return nil, coderDoublePtr
|
||||
}
|
||||
case protoreflect.StringKind:
|
||||
case pref.StringKind:
|
||||
if ft.Kind() == reflect.String && strs.EnforceUTF8(fd) {
|
||||
return nil, coderStringPtrValidateUTF8
|
||||
}
|
||||
if ft.Kind() == reflect.String {
|
||||
return nil, coderStringPtr
|
||||
}
|
||||
case protoreflect.BytesKind:
|
||||
case pref.BytesKind:
|
||||
if ft.Kind() == reflect.String {
|
||||
return nil, coderStringPtr
|
||||
}
|
||||
}
|
||||
default:
|
||||
switch fd.Kind() {
|
||||
case protoreflect.BoolKind:
|
||||
case pref.BoolKind:
|
||||
if ft.Kind() == reflect.Bool {
|
||||
return nil, coderBool
|
||||
}
|
||||
case protoreflect.EnumKind:
|
||||
case pref.EnumKind:
|
||||
if ft.Kind() == reflect.Int32 {
|
||||
return nil, coderEnum
|
||||
}
|
||||
case protoreflect.Int32Kind:
|
||||
case pref.Int32Kind:
|
||||
if ft.Kind() == reflect.Int32 {
|
||||
return nil, coderInt32
|
||||
}
|
||||
case protoreflect.Sint32Kind:
|
||||
case pref.Sint32Kind:
|
||||
if ft.Kind() == reflect.Int32 {
|
||||
return nil, coderSint32
|
||||
}
|
||||
case protoreflect.Uint32Kind:
|
||||
case pref.Uint32Kind:
|
||||
if ft.Kind() == reflect.Uint32 {
|
||||
return nil, coderUint32
|
||||
}
|
||||
case protoreflect.Int64Kind:
|
||||
case pref.Int64Kind:
|
||||
if ft.Kind() == reflect.Int64 {
|
||||
return nil, coderInt64
|
||||
}
|
||||
case protoreflect.Sint64Kind:
|
||||
case pref.Sint64Kind:
|
||||
if ft.Kind() == reflect.Int64 {
|
||||
return nil, coderSint64
|
||||
}
|
||||
case protoreflect.Uint64Kind:
|
||||
case pref.Uint64Kind:
|
||||
if ft.Kind() == reflect.Uint64 {
|
||||
return nil, coderUint64
|
||||
}
|
||||
case protoreflect.Sfixed32Kind:
|
||||
case pref.Sfixed32Kind:
|
||||
if ft.Kind() == reflect.Int32 {
|
||||
return nil, coderSfixed32
|
||||
}
|
||||
case protoreflect.Fixed32Kind:
|
||||
case pref.Fixed32Kind:
|
||||
if ft.Kind() == reflect.Uint32 {
|
||||
return nil, coderFixed32
|
||||
}
|
||||
case protoreflect.FloatKind:
|
||||
case pref.FloatKind:
|
||||
if ft.Kind() == reflect.Float32 {
|
||||
return nil, coderFloat
|
||||
}
|
||||
case protoreflect.Sfixed64Kind:
|
||||
case pref.Sfixed64Kind:
|
||||
if ft.Kind() == reflect.Int64 {
|
||||
return nil, coderSfixed64
|
||||
}
|
||||
case protoreflect.Fixed64Kind:
|
||||
case pref.Fixed64Kind:
|
||||
if ft.Kind() == reflect.Uint64 {
|
||||
return nil, coderFixed64
|
||||
}
|
||||
case protoreflect.DoubleKind:
|
||||
case pref.DoubleKind:
|
||||
if ft.Kind() == reflect.Float64 {
|
||||
return nil, coderDouble
|
||||
}
|
||||
case protoreflect.StringKind:
|
||||
case pref.StringKind:
|
||||
if ft.Kind() == reflect.String && strs.EnforceUTF8(fd) {
|
||||
return nil, coderStringValidateUTF8
|
||||
}
|
||||
@@ -420,7 +420,7 @@ func fieldCoder(fd protoreflect.FieldDescriptor, ft reflect.Type) (*MessageInfo,
|
||||
if ft.Kind() == reflect.Slice && ft.Elem().Kind() == reflect.Uint8 {
|
||||
return nil, coderBytes
|
||||
}
|
||||
case protoreflect.BytesKind:
|
||||
case pref.BytesKind:
|
||||
if ft.Kind() == reflect.String {
|
||||
return nil, coderString
|
||||
}
|
||||
@@ -434,122 +434,122 @@ func fieldCoder(fd protoreflect.FieldDescriptor, ft reflect.Type) (*MessageInfo,
|
||||
|
||||
// encoderFuncsForValue returns value functions for a field, used for
|
||||
// extension values and map encoding.
|
||||
func encoderFuncsForValue(fd protoreflect.FieldDescriptor) valueCoderFuncs {
|
||||
func encoderFuncsForValue(fd pref.FieldDescriptor) valueCoderFuncs {
|
||||
switch {
|
||||
case fd.Cardinality() == protoreflect.Repeated && !fd.IsPacked():
|
||||
case fd.Cardinality() == pref.Repeated && !fd.IsPacked():
|
||||
switch fd.Kind() {
|
||||
case protoreflect.BoolKind:
|
||||
case pref.BoolKind:
|
||||
return coderBoolSliceValue
|
||||
case protoreflect.EnumKind:
|
||||
case pref.EnumKind:
|
||||
return coderEnumSliceValue
|
||||
case protoreflect.Int32Kind:
|
||||
case pref.Int32Kind:
|
||||
return coderInt32SliceValue
|
||||
case protoreflect.Sint32Kind:
|
||||
case pref.Sint32Kind:
|
||||
return coderSint32SliceValue
|
||||
case protoreflect.Uint32Kind:
|
||||
case pref.Uint32Kind:
|
||||
return coderUint32SliceValue
|
||||
case protoreflect.Int64Kind:
|
||||
case pref.Int64Kind:
|
||||
return coderInt64SliceValue
|
||||
case protoreflect.Sint64Kind:
|
||||
case pref.Sint64Kind:
|
||||
return coderSint64SliceValue
|
||||
case protoreflect.Uint64Kind:
|
||||
case pref.Uint64Kind:
|
||||
return coderUint64SliceValue
|
||||
case protoreflect.Sfixed32Kind:
|
||||
case pref.Sfixed32Kind:
|
||||
return coderSfixed32SliceValue
|
||||
case protoreflect.Fixed32Kind:
|
||||
case pref.Fixed32Kind:
|
||||
return coderFixed32SliceValue
|
||||
case protoreflect.FloatKind:
|
||||
case pref.FloatKind:
|
||||
return coderFloatSliceValue
|
||||
case protoreflect.Sfixed64Kind:
|
||||
case pref.Sfixed64Kind:
|
||||
return coderSfixed64SliceValue
|
||||
case protoreflect.Fixed64Kind:
|
||||
case pref.Fixed64Kind:
|
||||
return coderFixed64SliceValue
|
||||
case protoreflect.DoubleKind:
|
||||
case pref.DoubleKind:
|
||||
return coderDoubleSliceValue
|
||||
case protoreflect.StringKind:
|
||||
case pref.StringKind:
|
||||
// We don't have a UTF-8 validating coder for repeated string fields.
|
||||
// Value coders are used for extensions and maps.
|
||||
// Extensions are never proto3, and maps never contain lists.
|
||||
return coderStringSliceValue
|
||||
case protoreflect.BytesKind:
|
||||
case pref.BytesKind:
|
||||
return coderBytesSliceValue
|
||||
case protoreflect.MessageKind:
|
||||
case pref.MessageKind:
|
||||
return coderMessageSliceValue
|
||||
case protoreflect.GroupKind:
|
||||
case pref.GroupKind:
|
||||
return coderGroupSliceValue
|
||||
}
|
||||
case fd.Cardinality() == protoreflect.Repeated && fd.IsPacked():
|
||||
case fd.Cardinality() == pref.Repeated && fd.IsPacked():
|
||||
switch fd.Kind() {
|
||||
case protoreflect.BoolKind:
|
||||
case pref.BoolKind:
|
||||
return coderBoolPackedSliceValue
|
||||
case protoreflect.EnumKind:
|
||||
case pref.EnumKind:
|
||||
return coderEnumPackedSliceValue
|
||||
case protoreflect.Int32Kind:
|
||||
case pref.Int32Kind:
|
||||
return coderInt32PackedSliceValue
|
||||
case protoreflect.Sint32Kind:
|
||||
case pref.Sint32Kind:
|
||||
return coderSint32PackedSliceValue
|
||||
case protoreflect.Uint32Kind:
|
||||
case pref.Uint32Kind:
|
||||
return coderUint32PackedSliceValue
|
||||
case protoreflect.Int64Kind:
|
||||
case pref.Int64Kind:
|
||||
return coderInt64PackedSliceValue
|
||||
case protoreflect.Sint64Kind:
|
||||
case pref.Sint64Kind:
|
||||
return coderSint64PackedSliceValue
|
||||
case protoreflect.Uint64Kind:
|
||||
case pref.Uint64Kind:
|
||||
return coderUint64PackedSliceValue
|
||||
case protoreflect.Sfixed32Kind:
|
||||
case pref.Sfixed32Kind:
|
||||
return coderSfixed32PackedSliceValue
|
||||
case protoreflect.Fixed32Kind:
|
||||
case pref.Fixed32Kind:
|
||||
return coderFixed32PackedSliceValue
|
||||
case protoreflect.FloatKind:
|
||||
case pref.FloatKind:
|
||||
return coderFloatPackedSliceValue
|
||||
case protoreflect.Sfixed64Kind:
|
||||
case pref.Sfixed64Kind:
|
||||
return coderSfixed64PackedSliceValue
|
||||
case protoreflect.Fixed64Kind:
|
||||
case pref.Fixed64Kind:
|
||||
return coderFixed64PackedSliceValue
|
||||
case protoreflect.DoubleKind:
|
||||
case pref.DoubleKind:
|
||||
return coderDoublePackedSliceValue
|
||||
}
|
||||
default:
|
||||
switch fd.Kind() {
|
||||
default:
|
||||
case protoreflect.BoolKind:
|
||||
case pref.BoolKind:
|
||||
return coderBoolValue
|
||||
case protoreflect.EnumKind:
|
||||
case pref.EnumKind:
|
||||
return coderEnumValue
|
||||
case protoreflect.Int32Kind:
|
||||
case pref.Int32Kind:
|
||||
return coderInt32Value
|
||||
case protoreflect.Sint32Kind:
|
||||
case pref.Sint32Kind:
|
||||
return coderSint32Value
|
||||
case protoreflect.Uint32Kind:
|
||||
case pref.Uint32Kind:
|
||||
return coderUint32Value
|
||||
case protoreflect.Int64Kind:
|
||||
case pref.Int64Kind:
|
||||
return coderInt64Value
|
||||
case protoreflect.Sint64Kind:
|
||||
case pref.Sint64Kind:
|
||||
return coderSint64Value
|
||||
case protoreflect.Uint64Kind:
|
||||
case pref.Uint64Kind:
|
||||
return coderUint64Value
|
||||
case protoreflect.Sfixed32Kind:
|
||||
case pref.Sfixed32Kind:
|
||||
return coderSfixed32Value
|
||||
case protoreflect.Fixed32Kind:
|
||||
case pref.Fixed32Kind:
|
||||
return coderFixed32Value
|
||||
case protoreflect.FloatKind:
|
||||
case pref.FloatKind:
|
||||
return coderFloatValue
|
||||
case protoreflect.Sfixed64Kind:
|
||||
case pref.Sfixed64Kind:
|
||||
return coderSfixed64Value
|
||||
case protoreflect.Fixed64Kind:
|
||||
case pref.Fixed64Kind:
|
||||
return coderFixed64Value
|
||||
case protoreflect.DoubleKind:
|
||||
case pref.DoubleKind:
|
||||
return coderDoubleValue
|
||||
case protoreflect.StringKind:
|
||||
case pref.StringKind:
|
||||
if strs.EnforceUTF8(fd) {
|
||||
return coderStringValueValidateUTF8
|
||||
}
|
||||
return coderStringValue
|
||||
case protoreflect.BytesKind:
|
||||
case pref.BytesKind:
|
||||
return coderBytesValue
|
||||
case protoreflect.MessageKind:
|
||||
case pref.MessageKind:
|
||||
return coderMessageValue
|
||||
case protoreflect.GroupKind:
|
||||
case pref.GroupKind:
|
||||
return coderGroupValue
|
||||
}
|
||||
}
|
||||
|
||||
1
vendor/google.golang.org/protobuf/internal/impl/codec_unsafe.go
generated
vendored
1
vendor/google.golang.org/protobuf/internal/impl/codec_unsafe.go
generated
vendored
@@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !purego && !appengine
|
||||
// +build !purego,!appengine
|
||||
|
||||
package impl
|
||||
|
||||
229
vendor/google.golang.org/protobuf/internal/impl/convert.go
generated
vendored
229
vendor/google.golang.org/protobuf/internal/impl/convert.go
generated
vendored
@@ -8,7 +8,7 @@ import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
// unwrapper unwraps the value to the underlying value.
|
||||
@@ -20,13 +20,13 @@ type unwrapper interface {
|
||||
// A Converter coverts to/from Go reflect.Value types and protobuf protoreflect.Value types.
|
||||
type Converter interface {
|
||||
// PBValueOf converts a reflect.Value to a protoreflect.Value.
|
||||
PBValueOf(reflect.Value) protoreflect.Value
|
||||
PBValueOf(reflect.Value) pref.Value
|
||||
|
||||
// GoValueOf converts a protoreflect.Value to a reflect.Value.
|
||||
GoValueOf(protoreflect.Value) reflect.Value
|
||||
GoValueOf(pref.Value) reflect.Value
|
||||
|
||||
// IsValidPB returns whether a protoreflect.Value is compatible with this type.
|
||||
IsValidPB(protoreflect.Value) bool
|
||||
IsValidPB(pref.Value) bool
|
||||
|
||||
// IsValidGo returns whether a reflect.Value is compatible with this type.
|
||||
IsValidGo(reflect.Value) bool
|
||||
@@ -34,12 +34,12 @@ type Converter interface {
|
||||
// New returns a new field value.
|
||||
// For scalars, it returns the default value of the field.
|
||||
// For composite types, it returns a new mutable value.
|
||||
New() protoreflect.Value
|
||||
New() pref.Value
|
||||
|
||||
// Zero returns a new field value.
|
||||
// For scalars, it returns the default value of the field.
|
||||
// For composite types, it returns an immutable, empty value.
|
||||
Zero() protoreflect.Value
|
||||
Zero() pref.Value
|
||||
}
|
||||
|
||||
// NewConverter matches a Go type with a protobuf field and returns a Converter
|
||||
@@ -50,7 +50,7 @@ type Converter interface {
|
||||
// This matcher deliberately supports a wider range of Go types than what
|
||||
// protoc-gen-go historically generated to be able to automatically wrap some
|
||||
// v1 messages generated by other forks of protoc-gen-go.
|
||||
func NewConverter(t reflect.Type, fd protoreflect.FieldDescriptor) Converter {
|
||||
func NewConverter(t reflect.Type, fd pref.FieldDescriptor) Converter {
|
||||
switch {
|
||||
case fd.IsList():
|
||||
return newListConverter(t, fd)
|
||||
@@ -59,6 +59,7 @@ func NewConverter(t reflect.Type, fd protoreflect.FieldDescriptor) Converter {
|
||||
default:
|
||||
return newSingularConverter(t, fd)
|
||||
}
|
||||
panic(fmt.Sprintf("invalid Go type %v for field %v", t, fd.FullName()))
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -75,68 +76,68 @@ var (
|
||||
)
|
||||
|
||||
var (
|
||||
boolZero = protoreflect.ValueOfBool(false)
|
||||
int32Zero = protoreflect.ValueOfInt32(0)
|
||||
int64Zero = protoreflect.ValueOfInt64(0)
|
||||
uint32Zero = protoreflect.ValueOfUint32(0)
|
||||
uint64Zero = protoreflect.ValueOfUint64(0)
|
||||
float32Zero = protoreflect.ValueOfFloat32(0)
|
||||
float64Zero = protoreflect.ValueOfFloat64(0)
|
||||
stringZero = protoreflect.ValueOfString("")
|
||||
bytesZero = protoreflect.ValueOfBytes(nil)
|
||||
boolZero = pref.ValueOfBool(false)
|
||||
int32Zero = pref.ValueOfInt32(0)
|
||||
int64Zero = pref.ValueOfInt64(0)
|
||||
uint32Zero = pref.ValueOfUint32(0)
|
||||
uint64Zero = pref.ValueOfUint64(0)
|
||||
float32Zero = pref.ValueOfFloat32(0)
|
||||
float64Zero = pref.ValueOfFloat64(0)
|
||||
stringZero = pref.ValueOfString("")
|
||||
bytesZero = pref.ValueOfBytes(nil)
|
||||
)
|
||||
|
||||
func newSingularConverter(t reflect.Type, fd protoreflect.FieldDescriptor) Converter {
|
||||
defVal := func(fd protoreflect.FieldDescriptor, zero protoreflect.Value) protoreflect.Value {
|
||||
if fd.Cardinality() == protoreflect.Repeated {
|
||||
func newSingularConverter(t reflect.Type, fd pref.FieldDescriptor) Converter {
|
||||
defVal := func(fd pref.FieldDescriptor, zero pref.Value) pref.Value {
|
||||
if fd.Cardinality() == pref.Repeated {
|
||||
// Default isn't defined for repeated fields.
|
||||
return zero
|
||||
}
|
||||
return fd.Default()
|
||||
}
|
||||
switch fd.Kind() {
|
||||
case protoreflect.BoolKind:
|
||||
case pref.BoolKind:
|
||||
if t.Kind() == reflect.Bool {
|
||||
return &boolConverter{t, defVal(fd, boolZero)}
|
||||
}
|
||||
case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind:
|
||||
case pref.Int32Kind, pref.Sint32Kind, pref.Sfixed32Kind:
|
||||
if t.Kind() == reflect.Int32 {
|
||||
return &int32Converter{t, defVal(fd, int32Zero)}
|
||||
}
|
||||
case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind:
|
||||
case pref.Int64Kind, pref.Sint64Kind, pref.Sfixed64Kind:
|
||||
if t.Kind() == reflect.Int64 {
|
||||
return &int64Converter{t, defVal(fd, int64Zero)}
|
||||
}
|
||||
case protoreflect.Uint32Kind, protoreflect.Fixed32Kind:
|
||||
case pref.Uint32Kind, pref.Fixed32Kind:
|
||||
if t.Kind() == reflect.Uint32 {
|
||||
return &uint32Converter{t, defVal(fd, uint32Zero)}
|
||||
}
|
||||
case protoreflect.Uint64Kind, protoreflect.Fixed64Kind:
|
||||
case pref.Uint64Kind, pref.Fixed64Kind:
|
||||
if t.Kind() == reflect.Uint64 {
|
||||
return &uint64Converter{t, defVal(fd, uint64Zero)}
|
||||
}
|
||||
case protoreflect.FloatKind:
|
||||
case pref.FloatKind:
|
||||
if t.Kind() == reflect.Float32 {
|
||||
return &float32Converter{t, defVal(fd, float32Zero)}
|
||||
}
|
||||
case protoreflect.DoubleKind:
|
||||
case pref.DoubleKind:
|
||||
if t.Kind() == reflect.Float64 {
|
||||
return &float64Converter{t, defVal(fd, float64Zero)}
|
||||
}
|
||||
case protoreflect.StringKind:
|
||||
case pref.StringKind:
|
||||
if t.Kind() == reflect.String || (t.Kind() == reflect.Slice && t.Elem() == byteType) {
|
||||
return &stringConverter{t, defVal(fd, stringZero)}
|
||||
}
|
||||
case protoreflect.BytesKind:
|
||||
case pref.BytesKind:
|
||||
if t.Kind() == reflect.String || (t.Kind() == reflect.Slice && t.Elem() == byteType) {
|
||||
return &bytesConverter{t, defVal(fd, bytesZero)}
|
||||
}
|
||||
case protoreflect.EnumKind:
|
||||
case pref.EnumKind:
|
||||
// Handle enums, which must be a named int32 type.
|
||||
if t.Kind() == reflect.Int32 {
|
||||
return newEnumConverter(t, fd)
|
||||
}
|
||||
case protoreflect.MessageKind, protoreflect.GroupKind:
|
||||
case pref.MessageKind, pref.GroupKind:
|
||||
return newMessageConverter(t)
|
||||
}
|
||||
panic(fmt.Sprintf("invalid Go type %v for field %v", t, fd.FullName()))
|
||||
@@ -144,184 +145,184 @@ func newSingularConverter(t reflect.Type, fd protoreflect.FieldDescriptor) Conve
|
||||
|
||||
type boolConverter struct {
|
||||
goType reflect.Type
|
||||
def protoreflect.Value
|
||||
def pref.Value
|
||||
}
|
||||
|
||||
func (c *boolConverter) PBValueOf(v reflect.Value) protoreflect.Value {
|
||||
func (c *boolConverter) PBValueOf(v reflect.Value) pref.Value {
|
||||
if v.Type() != c.goType {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want %v", v.Type(), c.goType))
|
||||
}
|
||||
return protoreflect.ValueOfBool(v.Bool())
|
||||
return pref.ValueOfBool(v.Bool())
|
||||
}
|
||||
func (c *boolConverter) GoValueOf(v protoreflect.Value) reflect.Value {
|
||||
func (c *boolConverter) GoValueOf(v pref.Value) reflect.Value {
|
||||
return reflect.ValueOf(v.Bool()).Convert(c.goType)
|
||||
}
|
||||
func (c *boolConverter) IsValidPB(v protoreflect.Value) bool {
|
||||
func (c *boolConverter) IsValidPB(v pref.Value) bool {
|
||||
_, ok := v.Interface().(bool)
|
||||
return ok
|
||||
}
|
||||
func (c *boolConverter) IsValidGo(v reflect.Value) bool {
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
func (c *boolConverter) New() protoreflect.Value { return c.def }
|
||||
func (c *boolConverter) Zero() protoreflect.Value { return c.def }
|
||||
func (c *boolConverter) New() pref.Value { return c.def }
|
||||
func (c *boolConverter) Zero() pref.Value { return c.def }
|
||||
|
||||
type int32Converter struct {
|
||||
goType reflect.Type
|
||||
def protoreflect.Value
|
||||
def pref.Value
|
||||
}
|
||||
|
||||
func (c *int32Converter) PBValueOf(v reflect.Value) protoreflect.Value {
|
||||
func (c *int32Converter) PBValueOf(v reflect.Value) pref.Value {
|
||||
if v.Type() != c.goType {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want %v", v.Type(), c.goType))
|
||||
}
|
||||
return protoreflect.ValueOfInt32(int32(v.Int()))
|
||||
return pref.ValueOfInt32(int32(v.Int()))
|
||||
}
|
||||
func (c *int32Converter) GoValueOf(v protoreflect.Value) reflect.Value {
|
||||
func (c *int32Converter) GoValueOf(v pref.Value) reflect.Value {
|
||||
return reflect.ValueOf(int32(v.Int())).Convert(c.goType)
|
||||
}
|
||||
func (c *int32Converter) IsValidPB(v protoreflect.Value) bool {
|
||||
func (c *int32Converter) IsValidPB(v pref.Value) bool {
|
||||
_, ok := v.Interface().(int32)
|
||||
return ok
|
||||
}
|
||||
func (c *int32Converter) IsValidGo(v reflect.Value) bool {
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
func (c *int32Converter) New() protoreflect.Value { return c.def }
|
||||
func (c *int32Converter) Zero() protoreflect.Value { return c.def }
|
||||
func (c *int32Converter) New() pref.Value { return c.def }
|
||||
func (c *int32Converter) Zero() pref.Value { return c.def }
|
||||
|
||||
type int64Converter struct {
|
||||
goType reflect.Type
|
||||
def protoreflect.Value
|
||||
def pref.Value
|
||||
}
|
||||
|
||||
func (c *int64Converter) PBValueOf(v reflect.Value) protoreflect.Value {
|
||||
func (c *int64Converter) PBValueOf(v reflect.Value) pref.Value {
|
||||
if v.Type() != c.goType {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want %v", v.Type(), c.goType))
|
||||
}
|
||||
return protoreflect.ValueOfInt64(int64(v.Int()))
|
||||
return pref.ValueOfInt64(int64(v.Int()))
|
||||
}
|
||||
func (c *int64Converter) GoValueOf(v protoreflect.Value) reflect.Value {
|
||||
func (c *int64Converter) GoValueOf(v pref.Value) reflect.Value {
|
||||
return reflect.ValueOf(int64(v.Int())).Convert(c.goType)
|
||||
}
|
||||
func (c *int64Converter) IsValidPB(v protoreflect.Value) bool {
|
||||
func (c *int64Converter) IsValidPB(v pref.Value) bool {
|
||||
_, ok := v.Interface().(int64)
|
||||
return ok
|
||||
}
|
||||
func (c *int64Converter) IsValidGo(v reflect.Value) bool {
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
func (c *int64Converter) New() protoreflect.Value { return c.def }
|
||||
func (c *int64Converter) Zero() protoreflect.Value { return c.def }
|
||||
func (c *int64Converter) New() pref.Value { return c.def }
|
||||
func (c *int64Converter) Zero() pref.Value { return c.def }
|
||||
|
||||
type uint32Converter struct {
|
||||
goType reflect.Type
|
||||
def protoreflect.Value
|
||||
def pref.Value
|
||||
}
|
||||
|
||||
func (c *uint32Converter) PBValueOf(v reflect.Value) protoreflect.Value {
|
||||
func (c *uint32Converter) PBValueOf(v reflect.Value) pref.Value {
|
||||
if v.Type() != c.goType {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want %v", v.Type(), c.goType))
|
||||
}
|
||||
return protoreflect.ValueOfUint32(uint32(v.Uint()))
|
||||
return pref.ValueOfUint32(uint32(v.Uint()))
|
||||
}
|
||||
func (c *uint32Converter) GoValueOf(v protoreflect.Value) reflect.Value {
|
||||
func (c *uint32Converter) GoValueOf(v pref.Value) reflect.Value {
|
||||
return reflect.ValueOf(uint32(v.Uint())).Convert(c.goType)
|
||||
}
|
||||
func (c *uint32Converter) IsValidPB(v protoreflect.Value) bool {
|
||||
func (c *uint32Converter) IsValidPB(v pref.Value) bool {
|
||||
_, ok := v.Interface().(uint32)
|
||||
return ok
|
||||
}
|
||||
func (c *uint32Converter) IsValidGo(v reflect.Value) bool {
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
func (c *uint32Converter) New() protoreflect.Value { return c.def }
|
||||
func (c *uint32Converter) Zero() protoreflect.Value { return c.def }
|
||||
func (c *uint32Converter) New() pref.Value { return c.def }
|
||||
func (c *uint32Converter) Zero() pref.Value { return c.def }
|
||||
|
||||
type uint64Converter struct {
|
||||
goType reflect.Type
|
||||
def protoreflect.Value
|
||||
def pref.Value
|
||||
}
|
||||
|
||||
func (c *uint64Converter) PBValueOf(v reflect.Value) protoreflect.Value {
|
||||
func (c *uint64Converter) PBValueOf(v reflect.Value) pref.Value {
|
||||
if v.Type() != c.goType {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want %v", v.Type(), c.goType))
|
||||
}
|
||||
return protoreflect.ValueOfUint64(uint64(v.Uint()))
|
||||
return pref.ValueOfUint64(uint64(v.Uint()))
|
||||
}
|
||||
func (c *uint64Converter) GoValueOf(v protoreflect.Value) reflect.Value {
|
||||
func (c *uint64Converter) GoValueOf(v pref.Value) reflect.Value {
|
||||
return reflect.ValueOf(uint64(v.Uint())).Convert(c.goType)
|
||||
}
|
||||
func (c *uint64Converter) IsValidPB(v protoreflect.Value) bool {
|
||||
func (c *uint64Converter) IsValidPB(v pref.Value) bool {
|
||||
_, ok := v.Interface().(uint64)
|
||||
return ok
|
||||
}
|
||||
func (c *uint64Converter) IsValidGo(v reflect.Value) bool {
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
func (c *uint64Converter) New() protoreflect.Value { return c.def }
|
||||
func (c *uint64Converter) Zero() protoreflect.Value { return c.def }
|
||||
func (c *uint64Converter) New() pref.Value { return c.def }
|
||||
func (c *uint64Converter) Zero() pref.Value { return c.def }
|
||||
|
||||
type float32Converter struct {
|
||||
goType reflect.Type
|
||||
def protoreflect.Value
|
||||
def pref.Value
|
||||
}
|
||||
|
||||
func (c *float32Converter) PBValueOf(v reflect.Value) protoreflect.Value {
|
||||
func (c *float32Converter) PBValueOf(v reflect.Value) pref.Value {
|
||||
if v.Type() != c.goType {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want %v", v.Type(), c.goType))
|
||||
}
|
||||
return protoreflect.ValueOfFloat32(float32(v.Float()))
|
||||
return pref.ValueOfFloat32(float32(v.Float()))
|
||||
}
|
||||
func (c *float32Converter) GoValueOf(v protoreflect.Value) reflect.Value {
|
||||
func (c *float32Converter) GoValueOf(v pref.Value) reflect.Value {
|
||||
return reflect.ValueOf(float32(v.Float())).Convert(c.goType)
|
||||
}
|
||||
func (c *float32Converter) IsValidPB(v protoreflect.Value) bool {
|
||||
func (c *float32Converter) IsValidPB(v pref.Value) bool {
|
||||
_, ok := v.Interface().(float32)
|
||||
return ok
|
||||
}
|
||||
func (c *float32Converter) IsValidGo(v reflect.Value) bool {
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
func (c *float32Converter) New() protoreflect.Value { return c.def }
|
||||
func (c *float32Converter) Zero() protoreflect.Value { return c.def }
|
||||
func (c *float32Converter) New() pref.Value { return c.def }
|
||||
func (c *float32Converter) Zero() pref.Value { return c.def }
|
||||
|
||||
type float64Converter struct {
|
||||
goType reflect.Type
|
||||
def protoreflect.Value
|
||||
def pref.Value
|
||||
}
|
||||
|
||||
func (c *float64Converter) PBValueOf(v reflect.Value) protoreflect.Value {
|
||||
func (c *float64Converter) PBValueOf(v reflect.Value) pref.Value {
|
||||
if v.Type() != c.goType {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want %v", v.Type(), c.goType))
|
||||
}
|
||||
return protoreflect.ValueOfFloat64(float64(v.Float()))
|
||||
return pref.ValueOfFloat64(float64(v.Float()))
|
||||
}
|
||||
func (c *float64Converter) GoValueOf(v protoreflect.Value) reflect.Value {
|
||||
func (c *float64Converter) GoValueOf(v pref.Value) reflect.Value {
|
||||
return reflect.ValueOf(float64(v.Float())).Convert(c.goType)
|
||||
}
|
||||
func (c *float64Converter) IsValidPB(v protoreflect.Value) bool {
|
||||
func (c *float64Converter) IsValidPB(v pref.Value) bool {
|
||||
_, ok := v.Interface().(float64)
|
||||
return ok
|
||||
}
|
||||
func (c *float64Converter) IsValidGo(v reflect.Value) bool {
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
func (c *float64Converter) New() protoreflect.Value { return c.def }
|
||||
func (c *float64Converter) Zero() protoreflect.Value { return c.def }
|
||||
func (c *float64Converter) New() pref.Value { return c.def }
|
||||
func (c *float64Converter) Zero() pref.Value { return c.def }
|
||||
|
||||
type stringConverter struct {
|
||||
goType reflect.Type
|
||||
def protoreflect.Value
|
||||
def pref.Value
|
||||
}
|
||||
|
||||
func (c *stringConverter) PBValueOf(v reflect.Value) protoreflect.Value {
|
||||
func (c *stringConverter) PBValueOf(v reflect.Value) pref.Value {
|
||||
if v.Type() != c.goType {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want %v", v.Type(), c.goType))
|
||||
}
|
||||
return protoreflect.ValueOfString(v.Convert(stringType).String())
|
||||
return pref.ValueOfString(v.Convert(stringType).String())
|
||||
}
|
||||
func (c *stringConverter) GoValueOf(v protoreflect.Value) reflect.Value {
|
||||
func (c *stringConverter) GoValueOf(v pref.Value) reflect.Value {
|
||||
// pref.Value.String never panics, so we go through an interface
|
||||
// conversion here to check the type.
|
||||
s := v.Interface().(string)
|
||||
@@ -330,71 +331,71 @@ func (c *stringConverter) GoValueOf(v protoreflect.Value) reflect.Value {
|
||||
}
|
||||
return reflect.ValueOf(s).Convert(c.goType)
|
||||
}
|
||||
func (c *stringConverter) IsValidPB(v protoreflect.Value) bool {
|
||||
func (c *stringConverter) IsValidPB(v pref.Value) bool {
|
||||
_, ok := v.Interface().(string)
|
||||
return ok
|
||||
}
|
||||
func (c *stringConverter) IsValidGo(v reflect.Value) bool {
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
func (c *stringConverter) New() protoreflect.Value { return c.def }
|
||||
func (c *stringConverter) Zero() protoreflect.Value { return c.def }
|
||||
func (c *stringConverter) New() pref.Value { return c.def }
|
||||
func (c *stringConverter) Zero() pref.Value { return c.def }
|
||||
|
||||
type bytesConverter struct {
|
||||
goType reflect.Type
|
||||
def protoreflect.Value
|
||||
def pref.Value
|
||||
}
|
||||
|
||||
func (c *bytesConverter) PBValueOf(v reflect.Value) protoreflect.Value {
|
||||
func (c *bytesConverter) PBValueOf(v reflect.Value) pref.Value {
|
||||
if v.Type() != c.goType {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want %v", v.Type(), c.goType))
|
||||
}
|
||||
if c.goType.Kind() == reflect.String && v.Len() == 0 {
|
||||
return protoreflect.ValueOfBytes(nil) // ensure empty string is []byte(nil)
|
||||
return pref.ValueOfBytes(nil) // ensure empty string is []byte(nil)
|
||||
}
|
||||
return protoreflect.ValueOfBytes(v.Convert(bytesType).Bytes())
|
||||
return pref.ValueOfBytes(v.Convert(bytesType).Bytes())
|
||||
}
|
||||
func (c *bytesConverter) GoValueOf(v protoreflect.Value) reflect.Value {
|
||||
func (c *bytesConverter) GoValueOf(v pref.Value) reflect.Value {
|
||||
return reflect.ValueOf(v.Bytes()).Convert(c.goType)
|
||||
}
|
||||
func (c *bytesConverter) IsValidPB(v protoreflect.Value) bool {
|
||||
func (c *bytesConverter) IsValidPB(v pref.Value) bool {
|
||||
_, ok := v.Interface().([]byte)
|
||||
return ok
|
||||
}
|
||||
func (c *bytesConverter) IsValidGo(v reflect.Value) bool {
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
func (c *bytesConverter) New() protoreflect.Value { return c.def }
|
||||
func (c *bytesConverter) Zero() protoreflect.Value { return c.def }
|
||||
func (c *bytesConverter) New() pref.Value { return c.def }
|
||||
func (c *bytesConverter) Zero() pref.Value { return c.def }
|
||||
|
||||
type enumConverter struct {
|
||||
goType reflect.Type
|
||||
def protoreflect.Value
|
||||
def pref.Value
|
||||
}
|
||||
|
||||
func newEnumConverter(goType reflect.Type, fd protoreflect.FieldDescriptor) Converter {
|
||||
var def protoreflect.Value
|
||||
if fd.Cardinality() == protoreflect.Repeated {
|
||||
def = protoreflect.ValueOfEnum(fd.Enum().Values().Get(0).Number())
|
||||
func newEnumConverter(goType reflect.Type, fd pref.FieldDescriptor) Converter {
|
||||
var def pref.Value
|
||||
if fd.Cardinality() == pref.Repeated {
|
||||
def = pref.ValueOfEnum(fd.Enum().Values().Get(0).Number())
|
||||
} else {
|
||||
def = fd.Default()
|
||||
}
|
||||
return &enumConverter{goType, def}
|
||||
}
|
||||
|
||||
func (c *enumConverter) PBValueOf(v reflect.Value) protoreflect.Value {
|
||||
func (c *enumConverter) PBValueOf(v reflect.Value) pref.Value {
|
||||
if v.Type() != c.goType {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want %v", v.Type(), c.goType))
|
||||
}
|
||||
return protoreflect.ValueOfEnum(protoreflect.EnumNumber(v.Int()))
|
||||
return pref.ValueOfEnum(pref.EnumNumber(v.Int()))
|
||||
}
|
||||
|
||||
func (c *enumConverter) GoValueOf(v protoreflect.Value) reflect.Value {
|
||||
func (c *enumConverter) GoValueOf(v pref.Value) reflect.Value {
|
||||
return reflect.ValueOf(v.Enum()).Convert(c.goType)
|
||||
}
|
||||
|
||||
func (c *enumConverter) IsValidPB(v protoreflect.Value) bool {
|
||||
_, ok := v.Interface().(protoreflect.EnumNumber)
|
||||
func (c *enumConverter) IsValidPB(v pref.Value) bool {
|
||||
_, ok := v.Interface().(pref.EnumNumber)
|
||||
return ok
|
||||
}
|
||||
|
||||
@@ -402,11 +403,11 @@ func (c *enumConverter) IsValidGo(v reflect.Value) bool {
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
|
||||
func (c *enumConverter) New() protoreflect.Value {
|
||||
func (c *enumConverter) New() pref.Value {
|
||||
return c.def
|
||||
}
|
||||
|
||||
func (c *enumConverter) Zero() protoreflect.Value {
|
||||
func (c *enumConverter) Zero() pref.Value {
|
||||
return c.def
|
||||
}
|
||||
|
||||
@@ -418,7 +419,7 @@ func newMessageConverter(goType reflect.Type) Converter {
|
||||
return &messageConverter{goType}
|
||||
}
|
||||
|
||||
func (c *messageConverter) PBValueOf(v reflect.Value) protoreflect.Value {
|
||||
func (c *messageConverter) PBValueOf(v reflect.Value) pref.Value {
|
||||
if v.Type() != c.goType {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want %v", v.Type(), c.goType))
|
||||
}
|
||||
@@ -429,13 +430,13 @@ func (c *messageConverter) PBValueOf(v reflect.Value) protoreflect.Value {
|
||||
v = reflect.Zero(reflect.PtrTo(v.Type()))
|
||||
}
|
||||
}
|
||||
if m, ok := v.Interface().(protoreflect.ProtoMessage); ok {
|
||||
return protoreflect.ValueOfMessage(m.ProtoReflect())
|
||||
if m, ok := v.Interface().(pref.ProtoMessage); ok {
|
||||
return pref.ValueOfMessage(m.ProtoReflect())
|
||||
}
|
||||
return protoreflect.ValueOfMessage(legacyWrapMessage(v))
|
||||
return pref.ValueOfMessage(legacyWrapMessage(v))
|
||||
}
|
||||
|
||||
func (c *messageConverter) GoValueOf(v protoreflect.Value) reflect.Value {
|
||||
func (c *messageConverter) GoValueOf(v pref.Value) reflect.Value {
|
||||
m := v.Message()
|
||||
var rv reflect.Value
|
||||
if u, ok := m.(unwrapper); ok {
|
||||
@@ -459,7 +460,7 @@ func (c *messageConverter) GoValueOf(v protoreflect.Value) reflect.Value {
|
||||
return rv
|
||||
}
|
||||
|
||||
func (c *messageConverter) IsValidPB(v protoreflect.Value) bool {
|
||||
func (c *messageConverter) IsValidPB(v pref.Value) bool {
|
||||
m := v.Message()
|
||||
var rv reflect.Value
|
||||
if u, ok := m.(unwrapper); ok {
|
||||
@@ -477,14 +478,14 @@ func (c *messageConverter) IsValidGo(v reflect.Value) bool {
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
|
||||
func (c *messageConverter) New() protoreflect.Value {
|
||||
func (c *messageConverter) New() pref.Value {
|
||||
if c.isNonPointer() {
|
||||
return c.PBValueOf(reflect.New(c.goType).Elem())
|
||||
}
|
||||
return c.PBValueOf(reflect.New(c.goType.Elem()))
|
||||
}
|
||||
|
||||
func (c *messageConverter) Zero() protoreflect.Value {
|
||||
func (c *messageConverter) Zero() pref.Value {
|
||||
return c.PBValueOf(reflect.Zero(c.goType))
|
||||
}
|
||||
|
||||
|
||||
42
vendor/google.golang.org/protobuf/internal/impl/convert_list.go
generated
vendored
42
vendor/google.golang.org/protobuf/internal/impl/convert_list.go
generated
vendored
@@ -8,10 +8,10 @@ import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
func newListConverter(t reflect.Type, fd protoreflect.FieldDescriptor) Converter {
|
||||
func newListConverter(t reflect.Type, fd pref.FieldDescriptor) Converter {
|
||||
switch {
|
||||
case t.Kind() == reflect.Ptr && t.Elem().Kind() == reflect.Slice:
|
||||
return &listPtrConverter{t, newSingularConverter(t.Elem().Elem(), fd)}
|
||||
@@ -26,16 +26,16 @@ type listConverter struct {
|
||||
c Converter
|
||||
}
|
||||
|
||||
func (c *listConverter) PBValueOf(v reflect.Value) protoreflect.Value {
|
||||
func (c *listConverter) PBValueOf(v reflect.Value) pref.Value {
|
||||
if v.Type() != c.goType {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want %v", v.Type(), c.goType))
|
||||
}
|
||||
pv := reflect.New(c.goType)
|
||||
pv.Elem().Set(v)
|
||||
return protoreflect.ValueOfList(&listReflect{pv, c.c})
|
||||
return pref.ValueOfList(&listReflect{pv, c.c})
|
||||
}
|
||||
|
||||
func (c *listConverter) GoValueOf(v protoreflect.Value) reflect.Value {
|
||||
func (c *listConverter) GoValueOf(v pref.Value) reflect.Value {
|
||||
rv := v.List().(*listReflect).v
|
||||
if rv.IsNil() {
|
||||
return reflect.Zero(c.goType)
|
||||
@@ -43,7 +43,7 @@ func (c *listConverter) GoValueOf(v protoreflect.Value) reflect.Value {
|
||||
return rv.Elem()
|
||||
}
|
||||
|
||||
func (c *listConverter) IsValidPB(v protoreflect.Value) bool {
|
||||
func (c *listConverter) IsValidPB(v pref.Value) bool {
|
||||
list, ok := v.Interface().(*listReflect)
|
||||
if !ok {
|
||||
return false
|
||||
@@ -55,12 +55,12 @@ func (c *listConverter) IsValidGo(v reflect.Value) bool {
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
|
||||
func (c *listConverter) New() protoreflect.Value {
|
||||
return protoreflect.ValueOfList(&listReflect{reflect.New(c.goType), c.c})
|
||||
func (c *listConverter) New() pref.Value {
|
||||
return pref.ValueOfList(&listReflect{reflect.New(c.goType), c.c})
|
||||
}
|
||||
|
||||
func (c *listConverter) Zero() protoreflect.Value {
|
||||
return protoreflect.ValueOfList(&listReflect{reflect.Zero(reflect.PtrTo(c.goType)), c.c})
|
||||
func (c *listConverter) Zero() pref.Value {
|
||||
return pref.ValueOfList(&listReflect{reflect.Zero(reflect.PtrTo(c.goType)), c.c})
|
||||
}
|
||||
|
||||
type listPtrConverter struct {
|
||||
@@ -68,18 +68,18 @@ type listPtrConverter struct {
|
||||
c Converter
|
||||
}
|
||||
|
||||
func (c *listPtrConverter) PBValueOf(v reflect.Value) protoreflect.Value {
|
||||
func (c *listPtrConverter) PBValueOf(v reflect.Value) pref.Value {
|
||||
if v.Type() != c.goType {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want %v", v.Type(), c.goType))
|
||||
}
|
||||
return protoreflect.ValueOfList(&listReflect{v, c.c})
|
||||
return pref.ValueOfList(&listReflect{v, c.c})
|
||||
}
|
||||
|
||||
func (c *listPtrConverter) GoValueOf(v protoreflect.Value) reflect.Value {
|
||||
func (c *listPtrConverter) GoValueOf(v pref.Value) reflect.Value {
|
||||
return v.List().(*listReflect).v
|
||||
}
|
||||
|
||||
func (c *listPtrConverter) IsValidPB(v protoreflect.Value) bool {
|
||||
func (c *listPtrConverter) IsValidPB(v pref.Value) bool {
|
||||
list, ok := v.Interface().(*listReflect)
|
||||
if !ok {
|
||||
return false
|
||||
@@ -91,11 +91,11 @@ func (c *listPtrConverter) IsValidGo(v reflect.Value) bool {
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
|
||||
func (c *listPtrConverter) New() protoreflect.Value {
|
||||
func (c *listPtrConverter) New() pref.Value {
|
||||
return c.PBValueOf(reflect.New(c.goType.Elem()))
|
||||
}
|
||||
|
||||
func (c *listPtrConverter) Zero() protoreflect.Value {
|
||||
func (c *listPtrConverter) Zero() pref.Value {
|
||||
return c.PBValueOf(reflect.Zero(c.goType))
|
||||
}
|
||||
|
||||
@@ -110,16 +110,16 @@ func (ls *listReflect) Len() int {
|
||||
}
|
||||
return ls.v.Elem().Len()
|
||||
}
|
||||
func (ls *listReflect) Get(i int) protoreflect.Value {
|
||||
func (ls *listReflect) Get(i int) pref.Value {
|
||||
return ls.conv.PBValueOf(ls.v.Elem().Index(i))
|
||||
}
|
||||
func (ls *listReflect) Set(i int, v protoreflect.Value) {
|
||||
func (ls *listReflect) Set(i int, v pref.Value) {
|
||||
ls.v.Elem().Index(i).Set(ls.conv.GoValueOf(v))
|
||||
}
|
||||
func (ls *listReflect) Append(v protoreflect.Value) {
|
||||
func (ls *listReflect) Append(v pref.Value) {
|
||||
ls.v.Elem().Set(reflect.Append(ls.v.Elem(), ls.conv.GoValueOf(v)))
|
||||
}
|
||||
func (ls *listReflect) AppendMutable() protoreflect.Value {
|
||||
func (ls *listReflect) AppendMutable() pref.Value {
|
||||
if _, ok := ls.conv.(*messageConverter); !ok {
|
||||
panic("invalid AppendMutable on list with non-message type")
|
||||
}
|
||||
@@ -130,7 +130,7 @@ func (ls *listReflect) AppendMutable() protoreflect.Value {
|
||||
func (ls *listReflect) Truncate(i int) {
|
||||
ls.v.Elem().Set(ls.v.Elem().Slice(0, i))
|
||||
}
|
||||
func (ls *listReflect) NewElement() protoreflect.Value {
|
||||
func (ls *listReflect) NewElement() pref.Value {
|
||||
return ls.conv.New()
|
||||
}
|
||||
func (ls *listReflect) IsValid() bool {
|
||||
|
||||
32
vendor/google.golang.org/protobuf/internal/impl/convert_map.go
generated
vendored
32
vendor/google.golang.org/protobuf/internal/impl/convert_map.go
generated
vendored
@@ -8,7 +8,7 @@ import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
type mapConverter struct {
|
||||
@@ -16,7 +16,7 @@ type mapConverter struct {
|
||||
keyConv, valConv Converter
|
||||
}
|
||||
|
||||
func newMapConverter(t reflect.Type, fd protoreflect.FieldDescriptor) *mapConverter {
|
||||
func newMapConverter(t reflect.Type, fd pref.FieldDescriptor) *mapConverter {
|
||||
if t.Kind() != reflect.Map {
|
||||
panic(fmt.Sprintf("invalid Go type %v for field %v", t, fd.FullName()))
|
||||
}
|
||||
@@ -27,18 +27,18 @@ func newMapConverter(t reflect.Type, fd protoreflect.FieldDescriptor) *mapConver
|
||||
}
|
||||
}
|
||||
|
||||
func (c *mapConverter) PBValueOf(v reflect.Value) protoreflect.Value {
|
||||
func (c *mapConverter) PBValueOf(v reflect.Value) pref.Value {
|
||||
if v.Type() != c.goType {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want %v", v.Type(), c.goType))
|
||||
}
|
||||
return protoreflect.ValueOfMap(&mapReflect{v, c.keyConv, c.valConv})
|
||||
return pref.ValueOfMap(&mapReflect{v, c.keyConv, c.valConv})
|
||||
}
|
||||
|
||||
func (c *mapConverter) GoValueOf(v protoreflect.Value) reflect.Value {
|
||||
func (c *mapConverter) GoValueOf(v pref.Value) reflect.Value {
|
||||
return v.Map().(*mapReflect).v
|
||||
}
|
||||
|
||||
func (c *mapConverter) IsValidPB(v protoreflect.Value) bool {
|
||||
func (c *mapConverter) IsValidPB(v pref.Value) bool {
|
||||
mapv, ok := v.Interface().(*mapReflect)
|
||||
if !ok {
|
||||
return false
|
||||
@@ -50,11 +50,11 @@ func (c *mapConverter) IsValidGo(v reflect.Value) bool {
|
||||
return v.IsValid() && v.Type() == c.goType
|
||||
}
|
||||
|
||||
func (c *mapConverter) New() protoreflect.Value {
|
||||
func (c *mapConverter) New() pref.Value {
|
||||
return c.PBValueOf(reflect.MakeMap(c.goType))
|
||||
}
|
||||
|
||||
func (c *mapConverter) Zero() protoreflect.Value {
|
||||
func (c *mapConverter) Zero() pref.Value {
|
||||
return c.PBValueOf(reflect.Zero(c.goType))
|
||||
}
|
||||
|
||||
@@ -67,29 +67,29 @@ type mapReflect struct {
|
||||
func (ms *mapReflect) Len() int {
|
||||
return ms.v.Len()
|
||||
}
|
||||
func (ms *mapReflect) Has(k protoreflect.MapKey) bool {
|
||||
func (ms *mapReflect) Has(k pref.MapKey) bool {
|
||||
rk := ms.keyConv.GoValueOf(k.Value())
|
||||
rv := ms.v.MapIndex(rk)
|
||||
return rv.IsValid()
|
||||
}
|
||||
func (ms *mapReflect) Get(k protoreflect.MapKey) protoreflect.Value {
|
||||
func (ms *mapReflect) Get(k pref.MapKey) pref.Value {
|
||||
rk := ms.keyConv.GoValueOf(k.Value())
|
||||
rv := ms.v.MapIndex(rk)
|
||||
if !rv.IsValid() {
|
||||
return protoreflect.Value{}
|
||||
return pref.Value{}
|
||||
}
|
||||
return ms.valConv.PBValueOf(rv)
|
||||
}
|
||||
func (ms *mapReflect) Set(k protoreflect.MapKey, v protoreflect.Value) {
|
||||
func (ms *mapReflect) Set(k pref.MapKey, v pref.Value) {
|
||||
rk := ms.keyConv.GoValueOf(k.Value())
|
||||
rv := ms.valConv.GoValueOf(v)
|
||||
ms.v.SetMapIndex(rk, rv)
|
||||
}
|
||||
func (ms *mapReflect) Clear(k protoreflect.MapKey) {
|
||||
func (ms *mapReflect) Clear(k pref.MapKey) {
|
||||
rk := ms.keyConv.GoValueOf(k.Value())
|
||||
ms.v.SetMapIndex(rk, reflect.Value{})
|
||||
}
|
||||
func (ms *mapReflect) Mutable(k protoreflect.MapKey) protoreflect.Value {
|
||||
func (ms *mapReflect) Mutable(k pref.MapKey) pref.Value {
|
||||
if _, ok := ms.valConv.(*messageConverter); !ok {
|
||||
panic("invalid Mutable on map with non-message value type")
|
||||
}
|
||||
@@ -100,7 +100,7 @@ func (ms *mapReflect) Mutable(k protoreflect.MapKey) protoreflect.Value {
|
||||
}
|
||||
return v
|
||||
}
|
||||
func (ms *mapReflect) Range(f func(protoreflect.MapKey, protoreflect.Value) bool) {
|
||||
func (ms *mapReflect) Range(f func(pref.MapKey, pref.Value) bool) {
|
||||
iter := mapRange(ms.v)
|
||||
for iter.Next() {
|
||||
k := ms.keyConv.PBValueOf(iter.Key()).MapKey()
|
||||
@@ -110,7 +110,7 @@ func (ms *mapReflect) Range(f func(protoreflect.MapKey, protoreflect.Value) bool
|
||||
}
|
||||
}
|
||||
}
|
||||
func (ms *mapReflect) NewValue() protoreflect.Value {
|
||||
func (ms *mapReflect) NewValue() pref.Value {
|
||||
return ms.valConv.New()
|
||||
}
|
||||
func (ms *mapReflect) IsValid() bool {
|
||||
|
||||
29
vendor/google.golang.org/protobuf/internal/impl/decode.go
generated
vendored
29
vendor/google.golang.org/protobuf/internal/impl/decode.go
generated
vendored
@@ -12,12 +12,12 @@ import (
|
||||
"google.golang.org/protobuf/internal/flags"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
preg "google.golang.org/protobuf/reflect/protoregistry"
|
||||
"google.golang.org/protobuf/runtime/protoiface"
|
||||
piface "google.golang.org/protobuf/runtime/protoiface"
|
||||
)
|
||||
|
||||
var errDecode = errors.New("cannot parse invalid wire-format data")
|
||||
var errRecursionDepth = errors.New("exceeded maximum recursion depth")
|
||||
|
||||
type unmarshalOptions struct {
|
||||
flags protoiface.UnmarshalInputFlags
|
||||
@@ -25,7 +25,6 @@ type unmarshalOptions struct {
|
||||
FindExtensionByName(field protoreflect.FullName) (protoreflect.ExtensionType, error)
|
||||
FindExtensionByNumber(message protoreflect.FullName, field protoreflect.FieldNumber) (protoreflect.ExtensionType, error)
|
||||
}
|
||||
depth int
|
||||
}
|
||||
|
||||
func (o unmarshalOptions) Options() proto.UnmarshalOptions {
|
||||
@@ -37,17 +36,14 @@ func (o unmarshalOptions) Options() proto.UnmarshalOptions {
|
||||
}
|
||||
}
|
||||
|
||||
func (o unmarshalOptions) DiscardUnknown() bool {
|
||||
return o.flags&protoiface.UnmarshalDiscardUnknown != 0
|
||||
}
|
||||
func (o unmarshalOptions) DiscardUnknown() bool { return o.flags&piface.UnmarshalDiscardUnknown != 0 }
|
||||
|
||||
func (o unmarshalOptions) IsDefault() bool {
|
||||
return o.flags == 0 && o.resolver == protoregistry.GlobalTypes
|
||||
return o.flags == 0 && o.resolver == preg.GlobalTypes
|
||||
}
|
||||
|
||||
var lazyUnmarshalOptions = unmarshalOptions{
|
||||
resolver: protoregistry.GlobalTypes,
|
||||
depth: protowire.DefaultRecursionLimit,
|
||||
resolver: preg.GlobalTypes,
|
||||
}
|
||||
|
||||
type unmarshalOutput struct {
|
||||
@@ -56,7 +52,7 @@ type unmarshalOutput struct {
|
||||
}
|
||||
|
||||
// unmarshal is protoreflect.Methods.Unmarshal.
|
||||
func (mi *MessageInfo) unmarshal(in protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) {
|
||||
func (mi *MessageInfo) unmarshal(in piface.UnmarshalInput) (piface.UnmarshalOutput, error) {
|
||||
var p pointer
|
||||
if ms, ok := in.Message.(*messageState); ok {
|
||||
p = ms.pointer()
|
||||
@@ -66,13 +62,12 @@ func (mi *MessageInfo) unmarshal(in protoiface.UnmarshalInput) (protoiface.Unmar
|
||||
out, err := mi.unmarshalPointer(in.Buf, p, 0, unmarshalOptions{
|
||||
flags: in.Flags,
|
||||
resolver: in.Resolver,
|
||||
depth: in.Depth,
|
||||
})
|
||||
var flags protoiface.UnmarshalOutputFlags
|
||||
var flags piface.UnmarshalOutputFlags
|
||||
if out.initialized {
|
||||
flags |= protoiface.UnmarshalInitialized
|
||||
flags |= piface.UnmarshalInitialized
|
||||
}
|
||||
return protoiface.UnmarshalOutput{
|
||||
return piface.UnmarshalOutput{
|
||||
Flags: flags,
|
||||
}, err
|
||||
}
|
||||
@@ -87,10 +82,6 @@ var errUnknown = errors.New("unknown")
|
||||
|
||||
func (mi *MessageInfo) unmarshalPointer(b []byte, p pointer, groupTag protowire.Number, opts unmarshalOptions) (out unmarshalOutput, err error) {
|
||||
mi.init()
|
||||
opts.depth--
|
||||
if opts.depth < 0 {
|
||||
return out, errRecursionDepth
|
||||
}
|
||||
if flags.ProtoLegacy && mi.isMessageSet {
|
||||
return unmarshalMessageSet(mi, b, p, opts)
|
||||
}
|
||||
@@ -211,7 +202,7 @@ func (mi *MessageInfo) unmarshalExtension(b []byte, num protowire.Number, wtyp p
|
||||
var err error
|
||||
xt, err = opts.resolver.FindExtensionByNumber(mi.Desc.FullName(), num)
|
||||
if err != nil {
|
||||
if err == protoregistry.NotFound {
|
||||
if err == preg.NotFound {
|
||||
return out, errUnknown
|
||||
}
|
||||
return out, errors.New("%v: unable to resolve extension %v: %v", mi.Desc.FullName(), num, err)
|
||||
|
||||
10
vendor/google.golang.org/protobuf/internal/impl/enum.go
generated
vendored
10
vendor/google.golang.org/protobuf/internal/impl/enum.go
generated
vendored
@@ -7,15 +7,15 @@ package impl
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
type EnumInfo struct {
|
||||
GoReflectType reflect.Type // int32 kind
|
||||
Desc protoreflect.EnumDescriptor
|
||||
Desc pref.EnumDescriptor
|
||||
}
|
||||
|
||||
func (t *EnumInfo) New(n protoreflect.EnumNumber) protoreflect.Enum {
|
||||
return reflect.ValueOf(n).Convert(t.GoReflectType).Interface().(protoreflect.Enum)
|
||||
func (t *EnumInfo) New(n pref.EnumNumber) pref.Enum {
|
||||
return reflect.ValueOf(n).Convert(t.GoReflectType).Interface().(pref.Enum)
|
||||
}
|
||||
func (t *EnumInfo) Descriptor() protoreflect.EnumDescriptor { return t.Desc }
|
||||
func (t *EnumInfo) Descriptor() pref.EnumDescriptor { return t.Desc }
|
||||
|
||||
26
vendor/google.golang.org/protobuf/internal/impl/extension.go
generated
vendored
26
vendor/google.golang.org/protobuf/internal/impl/extension.go
generated
vendored
@@ -9,8 +9,8 @@ import (
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/runtime/protoiface"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
piface "google.golang.org/protobuf/runtime/protoiface"
|
||||
)
|
||||
|
||||
// ExtensionInfo implements ExtensionType.
|
||||
@@ -45,7 +45,7 @@ type ExtensionInfo struct {
|
||||
// since the message may no longer implement the MessageV1 interface.
|
||||
//
|
||||
// Deprecated: Use the ExtendedType method instead.
|
||||
ExtendedType protoiface.MessageV1
|
||||
ExtendedType piface.MessageV1
|
||||
|
||||
// ExtensionType is the zero value of the extension type.
|
||||
//
|
||||
@@ -83,31 +83,31 @@ const (
|
||||
extensionInfoFullInit = 2
|
||||
)
|
||||
|
||||
func InitExtensionInfo(xi *ExtensionInfo, xd protoreflect.ExtensionDescriptor, goType reflect.Type) {
|
||||
func InitExtensionInfo(xi *ExtensionInfo, xd pref.ExtensionDescriptor, goType reflect.Type) {
|
||||
xi.goType = goType
|
||||
xi.desc = extensionTypeDescriptor{xd, xi}
|
||||
xi.init = extensionInfoDescInit
|
||||
}
|
||||
|
||||
func (xi *ExtensionInfo) New() protoreflect.Value {
|
||||
func (xi *ExtensionInfo) New() pref.Value {
|
||||
return xi.lazyInit().New()
|
||||
}
|
||||
func (xi *ExtensionInfo) Zero() protoreflect.Value {
|
||||
func (xi *ExtensionInfo) Zero() pref.Value {
|
||||
return xi.lazyInit().Zero()
|
||||
}
|
||||
func (xi *ExtensionInfo) ValueOf(v interface{}) protoreflect.Value {
|
||||
func (xi *ExtensionInfo) ValueOf(v interface{}) pref.Value {
|
||||
return xi.lazyInit().PBValueOf(reflect.ValueOf(v))
|
||||
}
|
||||
func (xi *ExtensionInfo) InterfaceOf(v protoreflect.Value) interface{} {
|
||||
func (xi *ExtensionInfo) InterfaceOf(v pref.Value) interface{} {
|
||||
return xi.lazyInit().GoValueOf(v).Interface()
|
||||
}
|
||||
func (xi *ExtensionInfo) IsValidValue(v protoreflect.Value) bool {
|
||||
func (xi *ExtensionInfo) IsValidValue(v pref.Value) bool {
|
||||
return xi.lazyInit().IsValidPB(v)
|
||||
}
|
||||
func (xi *ExtensionInfo) IsValidInterface(v interface{}) bool {
|
||||
return xi.lazyInit().IsValidGo(reflect.ValueOf(v))
|
||||
}
|
||||
func (xi *ExtensionInfo) TypeDescriptor() protoreflect.ExtensionTypeDescriptor {
|
||||
func (xi *ExtensionInfo) TypeDescriptor() pref.ExtensionTypeDescriptor {
|
||||
if atomic.LoadUint32(&xi.init) < extensionInfoDescInit {
|
||||
xi.lazyInitSlow()
|
||||
}
|
||||
@@ -144,13 +144,13 @@ func (xi *ExtensionInfo) lazyInitSlow() {
|
||||
}
|
||||
|
||||
type extensionTypeDescriptor struct {
|
||||
protoreflect.ExtensionDescriptor
|
||||
pref.ExtensionDescriptor
|
||||
xi *ExtensionInfo
|
||||
}
|
||||
|
||||
func (xtd *extensionTypeDescriptor) Type() protoreflect.ExtensionType {
|
||||
func (xtd *extensionTypeDescriptor) Type() pref.ExtensionType {
|
||||
return xtd.xi
|
||||
}
|
||||
func (xtd *extensionTypeDescriptor) Descriptor() protoreflect.ExtensionDescriptor {
|
||||
func (xtd *extensionTypeDescriptor) Descriptor() pref.ExtensionDescriptor {
|
||||
return xtd.ExtensionDescriptor
|
||||
}
|
||||
|
||||
57
vendor/google.golang.org/protobuf/internal/impl/legacy_enum.go
generated
vendored
57
vendor/google.golang.org/protobuf/internal/impl/legacy_enum.go
generated
vendored
@@ -13,12 +13,13 @@ import (
|
||||
"google.golang.org/protobuf/internal/filedesc"
|
||||
"google.golang.org/protobuf/internal/strs"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
// legacyEnumName returns the name of enums used in legacy code.
|
||||
// It is neither the protobuf full name nor the qualified Go name,
|
||||
// but rather an odd hybrid of both.
|
||||
func legacyEnumName(ed protoreflect.EnumDescriptor) string {
|
||||
func legacyEnumName(ed pref.EnumDescriptor) string {
|
||||
var protoPkg string
|
||||
enumName := string(ed.FullName())
|
||||
if fd := ed.ParentFile(); fd != nil {
|
||||
@@ -33,68 +34,68 @@ func legacyEnumName(ed protoreflect.EnumDescriptor) string {
|
||||
|
||||
// legacyWrapEnum wraps v as a protoreflect.Enum,
|
||||
// where v must be a int32 kind and not implement the v2 API already.
|
||||
func legacyWrapEnum(v reflect.Value) protoreflect.Enum {
|
||||
func legacyWrapEnum(v reflect.Value) pref.Enum {
|
||||
et := legacyLoadEnumType(v.Type())
|
||||
return et.New(protoreflect.EnumNumber(v.Int()))
|
||||
return et.New(pref.EnumNumber(v.Int()))
|
||||
}
|
||||
|
||||
var legacyEnumTypeCache sync.Map // map[reflect.Type]protoreflect.EnumType
|
||||
|
||||
// legacyLoadEnumType dynamically loads a protoreflect.EnumType for t,
|
||||
// where t must be an int32 kind and not implement the v2 API already.
|
||||
func legacyLoadEnumType(t reflect.Type) protoreflect.EnumType {
|
||||
func legacyLoadEnumType(t reflect.Type) pref.EnumType {
|
||||
// Fast-path: check if a EnumType is cached for this concrete type.
|
||||
if et, ok := legacyEnumTypeCache.Load(t); ok {
|
||||
return et.(protoreflect.EnumType)
|
||||
return et.(pref.EnumType)
|
||||
}
|
||||
|
||||
// Slow-path: derive enum descriptor and initialize EnumType.
|
||||
var et protoreflect.EnumType
|
||||
var et pref.EnumType
|
||||
ed := LegacyLoadEnumDesc(t)
|
||||
et = &legacyEnumType{
|
||||
desc: ed,
|
||||
goType: t,
|
||||
}
|
||||
if et, ok := legacyEnumTypeCache.LoadOrStore(t, et); ok {
|
||||
return et.(protoreflect.EnumType)
|
||||
return et.(pref.EnumType)
|
||||
}
|
||||
return et
|
||||
}
|
||||
|
||||
type legacyEnumType struct {
|
||||
desc protoreflect.EnumDescriptor
|
||||
desc pref.EnumDescriptor
|
||||
goType reflect.Type
|
||||
m sync.Map // map[protoreflect.EnumNumber]proto.Enum
|
||||
}
|
||||
|
||||
func (t *legacyEnumType) New(n protoreflect.EnumNumber) protoreflect.Enum {
|
||||
func (t *legacyEnumType) New(n pref.EnumNumber) pref.Enum {
|
||||
if e, ok := t.m.Load(n); ok {
|
||||
return e.(protoreflect.Enum)
|
||||
return e.(pref.Enum)
|
||||
}
|
||||
e := &legacyEnumWrapper{num: n, pbTyp: t, goTyp: t.goType}
|
||||
t.m.Store(n, e)
|
||||
return e
|
||||
}
|
||||
func (t *legacyEnumType) Descriptor() protoreflect.EnumDescriptor {
|
||||
func (t *legacyEnumType) Descriptor() pref.EnumDescriptor {
|
||||
return t.desc
|
||||
}
|
||||
|
||||
type legacyEnumWrapper struct {
|
||||
num protoreflect.EnumNumber
|
||||
pbTyp protoreflect.EnumType
|
||||
num pref.EnumNumber
|
||||
pbTyp pref.EnumType
|
||||
goTyp reflect.Type
|
||||
}
|
||||
|
||||
func (e *legacyEnumWrapper) Descriptor() protoreflect.EnumDescriptor {
|
||||
func (e *legacyEnumWrapper) Descriptor() pref.EnumDescriptor {
|
||||
return e.pbTyp.Descriptor()
|
||||
}
|
||||
func (e *legacyEnumWrapper) Type() protoreflect.EnumType {
|
||||
func (e *legacyEnumWrapper) Type() pref.EnumType {
|
||||
return e.pbTyp
|
||||
}
|
||||
func (e *legacyEnumWrapper) Number() protoreflect.EnumNumber {
|
||||
func (e *legacyEnumWrapper) Number() pref.EnumNumber {
|
||||
return e.num
|
||||
}
|
||||
func (e *legacyEnumWrapper) ProtoReflect() protoreflect.Enum {
|
||||
func (e *legacyEnumWrapper) ProtoReflect() pref.Enum {
|
||||
return e
|
||||
}
|
||||
func (e *legacyEnumWrapper) protoUnwrap() interface{} {
|
||||
@@ -104,8 +105,8 @@ func (e *legacyEnumWrapper) protoUnwrap() interface{} {
|
||||
}
|
||||
|
||||
var (
|
||||
_ protoreflect.Enum = (*legacyEnumWrapper)(nil)
|
||||
_ unwrapper = (*legacyEnumWrapper)(nil)
|
||||
_ pref.Enum = (*legacyEnumWrapper)(nil)
|
||||
_ unwrapper = (*legacyEnumWrapper)(nil)
|
||||
)
|
||||
|
||||
var legacyEnumDescCache sync.Map // map[reflect.Type]protoreflect.EnumDescriptor
|
||||
@@ -114,15 +115,15 @@ var legacyEnumDescCache sync.Map // map[reflect.Type]protoreflect.EnumDescriptor
|
||||
// which must be an int32 kind and not implement the v2 API already.
|
||||
//
|
||||
// This is exported for testing purposes.
|
||||
func LegacyLoadEnumDesc(t reflect.Type) protoreflect.EnumDescriptor {
|
||||
func LegacyLoadEnumDesc(t reflect.Type) pref.EnumDescriptor {
|
||||
// Fast-path: check if an EnumDescriptor is cached for this concrete type.
|
||||
if ed, ok := legacyEnumDescCache.Load(t); ok {
|
||||
return ed.(protoreflect.EnumDescriptor)
|
||||
return ed.(pref.EnumDescriptor)
|
||||
}
|
||||
|
||||
// Slow-path: initialize EnumDescriptor from the raw descriptor.
|
||||
ev := reflect.Zero(t).Interface()
|
||||
if _, ok := ev.(protoreflect.Enum); ok {
|
||||
if _, ok := ev.(pref.Enum); ok {
|
||||
panic(fmt.Sprintf("%v already implements proto.Enum", t))
|
||||
}
|
||||
edV1, ok := ev.(enumV1)
|
||||
@@ -131,7 +132,7 @@ func LegacyLoadEnumDesc(t reflect.Type) protoreflect.EnumDescriptor {
|
||||
}
|
||||
b, idxs := edV1.EnumDescriptor()
|
||||
|
||||
var ed protoreflect.EnumDescriptor
|
||||
var ed pref.EnumDescriptor
|
||||
if len(idxs) == 1 {
|
||||
ed = legacyLoadFileDesc(b).Enums().Get(idxs[0])
|
||||
} else {
|
||||
@@ -157,10 +158,10 @@ var aberrantEnumDescCache sync.Map // map[reflect.Type]protoreflect.EnumDescript
|
||||
// We are unable to use the global enum registry since it is
|
||||
// unfortunately keyed by the protobuf full name, which we also do not know.
|
||||
// Thus, this produces some bogus enum descriptor based on the Go type name.
|
||||
func aberrantLoadEnumDesc(t reflect.Type) protoreflect.EnumDescriptor {
|
||||
func aberrantLoadEnumDesc(t reflect.Type) pref.EnumDescriptor {
|
||||
// Fast-path: check if an EnumDescriptor is cached for this concrete type.
|
||||
if ed, ok := aberrantEnumDescCache.Load(t); ok {
|
||||
return ed.(protoreflect.EnumDescriptor)
|
||||
return ed.(pref.EnumDescriptor)
|
||||
}
|
||||
|
||||
// Slow-path: construct a bogus, but unique EnumDescriptor.
|
||||
@@ -181,7 +182,7 @@ func aberrantLoadEnumDesc(t reflect.Type) protoreflect.EnumDescriptor {
|
||||
// An exhaustive query is clearly impractical, but can be best-effort.
|
||||
|
||||
if ed, ok := aberrantEnumDescCache.LoadOrStore(t, ed); ok {
|
||||
return ed.(protoreflect.EnumDescriptor)
|
||||
return ed.(pref.EnumDescriptor)
|
||||
}
|
||||
return ed
|
||||
}
|
||||
@@ -191,7 +192,7 @@ func aberrantLoadEnumDesc(t reflect.Type) protoreflect.EnumDescriptor {
|
||||
// It should be sufficiently unique within a program.
|
||||
//
|
||||
// This is exported for testing purposes.
|
||||
func AberrantDeriveFullName(t reflect.Type) protoreflect.FullName {
|
||||
func AberrantDeriveFullName(t reflect.Type) pref.FullName {
|
||||
sanitize := func(r rune) rune {
|
||||
switch {
|
||||
case r == '/':
|
||||
@@ -214,5 +215,5 @@ func AberrantDeriveFullName(t reflect.Type) protoreflect.FullName {
|
||||
ss[i] = "x" + s
|
||||
}
|
||||
}
|
||||
return protoreflect.FullName(strings.Join(ss, "."))
|
||||
return pref.FullName(strings.Join(ss, "."))
|
||||
}
|
||||
|
||||
18
vendor/google.golang.org/protobuf/internal/impl/legacy_export.go
generated
vendored
18
vendor/google.golang.org/protobuf/internal/impl/legacy_export.go
generated
vendored
@@ -12,21 +12,21 @@ import (
|
||||
"reflect"
|
||||
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/runtime/protoiface"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
piface "google.golang.org/protobuf/runtime/protoiface"
|
||||
)
|
||||
|
||||
// These functions exist to support exported APIs in generated protobufs.
|
||||
// While these are deprecated, they cannot be removed for compatibility reasons.
|
||||
|
||||
// LegacyEnumName returns the name of enums used in legacy code.
|
||||
func (Export) LegacyEnumName(ed protoreflect.EnumDescriptor) string {
|
||||
func (Export) LegacyEnumName(ed pref.EnumDescriptor) string {
|
||||
return legacyEnumName(ed)
|
||||
}
|
||||
|
||||
// LegacyMessageTypeOf returns the protoreflect.MessageType for m,
|
||||
// with name used as the message name if necessary.
|
||||
func (Export) LegacyMessageTypeOf(m protoiface.MessageV1, name protoreflect.FullName) protoreflect.MessageType {
|
||||
func (Export) LegacyMessageTypeOf(m piface.MessageV1, name pref.FullName) pref.MessageType {
|
||||
if mv := (Export{}).protoMessageV2Of(m); mv != nil {
|
||||
return mv.ProtoReflect().Type()
|
||||
}
|
||||
@@ -36,9 +36,9 @@ func (Export) LegacyMessageTypeOf(m protoiface.MessageV1, name protoreflect.Full
|
||||
// UnmarshalJSONEnum unmarshals an enum from a JSON-encoded input.
|
||||
// The input can either be a string representing the enum value by name,
|
||||
// or a number representing the enum number itself.
|
||||
func (Export) UnmarshalJSONEnum(ed protoreflect.EnumDescriptor, b []byte) (protoreflect.EnumNumber, error) {
|
||||
func (Export) UnmarshalJSONEnum(ed pref.EnumDescriptor, b []byte) (pref.EnumNumber, error) {
|
||||
if b[0] == '"' {
|
||||
var name protoreflect.Name
|
||||
var name pref.Name
|
||||
if err := json.Unmarshal(b, &name); err != nil {
|
||||
return 0, errors.New("invalid input for enum %v: %s", ed.FullName(), b)
|
||||
}
|
||||
@@ -48,7 +48,7 @@ func (Export) UnmarshalJSONEnum(ed protoreflect.EnumDescriptor, b []byte) (proto
|
||||
}
|
||||
return ev.Number(), nil
|
||||
} else {
|
||||
var num protoreflect.EnumNumber
|
||||
var num pref.EnumNumber
|
||||
if err := json.Unmarshal(b, &num); err != nil {
|
||||
return 0, errors.New("invalid input for enum %v: %s", ed.FullName(), b)
|
||||
}
|
||||
@@ -81,8 +81,8 @@ func (Export) CompressGZIP(in []byte) (out []byte) {
|
||||
blockHeader[0] = 0x01 // final bit per RFC 1951, section 3.2.3.
|
||||
blockSize = len(in)
|
||||
}
|
||||
binary.LittleEndian.PutUint16(blockHeader[1:3], uint16(blockSize))
|
||||
binary.LittleEndian.PutUint16(blockHeader[3:5], ^uint16(blockSize))
|
||||
binary.LittleEndian.PutUint16(blockHeader[1:3], uint16(blockSize)^0x0000)
|
||||
binary.LittleEndian.PutUint16(blockHeader[3:5], uint16(blockSize)^0xffff)
|
||||
out = append(out, blockHeader[:]...)
|
||||
out = append(out, in[:blockSize]...)
|
||||
in = in[blockSize:]
|
||||
|
||||
100
vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go
generated
vendored
100
vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go
generated
vendored
@@ -12,16 +12,16 @@ import (
|
||||
ptag "google.golang.org/protobuf/internal/encoding/tag"
|
||||
"google.golang.org/protobuf/internal/filedesc"
|
||||
"google.golang.org/protobuf/internal/pragma"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
"google.golang.org/protobuf/runtime/protoiface"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
preg "google.golang.org/protobuf/reflect/protoregistry"
|
||||
piface "google.golang.org/protobuf/runtime/protoiface"
|
||||
)
|
||||
|
||||
func (xi *ExtensionInfo) initToLegacy() {
|
||||
xd := xi.desc
|
||||
var parent protoiface.MessageV1
|
||||
var parent piface.MessageV1
|
||||
messageName := xd.ContainingMessage().FullName()
|
||||
if mt, _ := protoregistry.GlobalTypes.FindMessageByName(messageName); mt != nil {
|
||||
if mt, _ := preg.GlobalTypes.FindMessageByName(messageName); mt != nil {
|
||||
// Create a new parent message and unwrap it if possible.
|
||||
mv := mt.New().Interface()
|
||||
t := reflect.TypeOf(mv)
|
||||
@@ -31,7 +31,7 @@ func (xi *ExtensionInfo) initToLegacy() {
|
||||
|
||||
// Check whether the message implements the legacy v1 Message interface.
|
||||
mz := reflect.Zero(t).Interface()
|
||||
if mz, ok := mz.(protoiface.MessageV1); ok {
|
||||
if mz, ok := mz.(piface.MessageV1); ok {
|
||||
parent = mz
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ func (xi *ExtensionInfo) initToLegacy() {
|
||||
|
||||
// Reconstruct the legacy enum full name.
|
||||
var enumName string
|
||||
if xd.Kind() == protoreflect.EnumKind {
|
||||
if xd.Kind() == pref.EnumKind {
|
||||
enumName = legacyEnumName(xd.Enum())
|
||||
}
|
||||
|
||||
@@ -77,16 +77,16 @@ func (xi *ExtensionInfo) initFromLegacy() {
|
||||
// field number is specified. In such a case, use a placeholder.
|
||||
if xi.ExtendedType == nil || xi.ExtensionType == nil {
|
||||
xd := placeholderExtension{
|
||||
name: protoreflect.FullName(xi.Name),
|
||||
number: protoreflect.FieldNumber(xi.Field),
|
||||
name: pref.FullName(xi.Name),
|
||||
number: pref.FieldNumber(xi.Field),
|
||||
}
|
||||
xi.desc = extensionTypeDescriptor{xd, xi}
|
||||
return
|
||||
}
|
||||
|
||||
// Resolve enum or message dependencies.
|
||||
var ed protoreflect.EnumDescriptor
|
||||
var md protoreflect.MessageDescriptor
|
||||
var ed pref.EnumDescriptor
|
||||
var md pref.MessageDescriptor
|
||||
t := reflect.TypeOf(xi.ExtensionType)
|
||||
isOptional := t.Kind() == reflect.Ptr && t.Elem().Kind() != reflect.Struct
|
||||
isRepeated := t.Kind() == reflect.Slice && t.Elem().Kind() != reflect.Uint8
|
||||
@@ -94,18 +94,18 @@ func (xi *ExtensionInfo) initFromLegacy() {
|
||||
t = t.Elem()
|
||||
}
|
||||
switch v := reflect.Zero(t).Interface().(type) {
|
||||
case protoreflect.Enum:
|
||||
case pref.Enum:
|
||||
ed = v.Descriptor()
|
||||
case enumV1:
|
||||
ed = LegacyLoadEnumDesc(t)
|
||||
case protoreflect.ProtoMessage:
|
||||
case pref.ProtoMessage:
|
||||
md = v.ProtoReflect().Descriptor()
|
||||
case messageV1:
|
||||
md = LegacyLoadMessageDesc(t)
|
||||
}
|
||||
|
||||
// Derive basic field information from the struct tag.
|
||||
var evs protoreflect.EnumValueDescriptors
|
||||
var evs pref.EnumValueDescriptors
|
||||
if ed != nil {
|
||||
evs = ed.Values()
|
||||
}
|
||||
@@ -114,8 +114,8 @@ func (xi *ExtensionInfo) initFromLegacy() {
|
||||
// Construct a v2 ExtensionType.
|
||||
xd := &filedesc.Extension{L2: new(filedesc.ExtensionL2)}
|
||||
xd.L0.ParentFile = filedesc.SurrogateProto2
|
||||
xd.L0.FullName = protoreflect.FullName(xi.Name)
|
||||
xd.L1.Number = protoreflect.FieldNumber(xi.Field)
|
||||
xd.L0.FullName = pref.FullName(xi.Name)
|
||||
xd.L1.Number = pref.FieldNumber(xi.Field)
|
||||
xd.L1.Cardinality = fd.L1.Cardinality
|
||||
xd.L1.Kind = fd.L1.Kind
|
||||
xd.L2.IsPacked = fd.L1.IsPacked
|
||||
@@ -138,39 +138,39 @@ func (xi *ExtensionInfo) initFromLegacy() {
|
||||
}
|
||||
|
||||
type placeholderExtension struct {
|
||||
name protoreflect.FullName
|
||||
number protoreflect.FieldNumber
|
||||
name pref.FullName
|
||||
number pref.FieldNumber
|
||||
}
|
||||
|
||||
func (x placeholderExtension) ParentFile() protoreflect.FileDescriptor { return nil }
|
||||
func (x placeholderExtension) Parent() protoreflect.Descriptor { return nil }
|
||||
func (x placeholderExtension) Index() int { return 0 }
|
||||
func (x placeholderExtension) Syntax() protoreflect.Syntax { return 0 }
|
||||
func (x placeholderExtension) Name() protoreflect.Name { return x.name.Name() }
|
||||
func (x placeholderExtension) FullName() protoreflect.FullName { return x.name }
|
||||
func (x placeholderExtension) IsPlaceholder() bool { return true }
|
||||
func (x placeholderExtension) Options() protoreflect.ProtoMessage { return descopts.Field }
|
||||
func (x placeholderExtension) Number() protoreflect.FieldNumber { return x.number }
|
||||
func (x placeholderExtension) Cardinality() protoreflect.Cardinality { return 0 }
|
||||
func (x placeholderExtension) Kind() protoreflect.Kind { return 0 }
|
||||
func (x placeholderExtension) HasJSONName() bool { return false }
|
||||
func (x placeholderExtension) JSONName() string { return "[" + string(x.name) + "]" }
|
||||
func (x placeholderExtension) TextName() string { return "[" + string(x.name) + "]" }
|
||||
func (x placeholderExtension) HasPresence() bool { return false }
|
||||
func (x placeholderExtension) HasOptionalKeyword() bool { return false }
|
||||
func (x placeholderExtension) IsExtension() bool { return true }
|
||||
func (x placeholderExtension) IsWeak() bool { return false }
|
||||
func (x placeholderExtension) IsPacked() bool { return false }
|
||||
func (x placeholderExtension) IsList() bool { return false }
|
||||
func (x placeholderExtension) IsMap() bool { return false }
|
||||
func (x placeholderExtension) MapKey() protoreflect.FieldDescriptor { return nil }
|
||||
func (x placeholderExtension) MapValue() protoreflect.FieldDescriptor { return nil }
|
||||
func (x placeholderExtension) HasDefault() bool { return false }
|
||||
func (x placeholderExtension) Default() protoreflect.Value { return protoreflect.Value{} }
|
||||
func (x placeholderExtension) DefaultEnumValue() protoreflect.EnumValueDescriptor { return nil }
|
||||
func (x placeholderExtension) ContainingOneof() protoreflect.OneofDescriptor { return nil }
|
||||
func (x placeholderExtension) ContainingMessage() protoreflect.MessageDescriptor { return nil }
|
||||
func (x placeholderExtension) Enum() protoreflect.EnumDescriptor { return nil }
|
||||
func (x placeholderExtension) Message() protoreflect.MessageDescriptor { return nil }
|
||||
func (x placeholderExtension) ProtoType(protoreflect.FieldDescriptor) { return }
|
||||
func (x placeholderExtension) ProtoInternal(pragma.DoNotImplement) { return }
|
||||
func (x placeholderExtension) ParentFile() pref.FileDescriptor { return nil }
|
||||
func (x placeholderExtension) Parent() pref.Descriptor { return nil }
|
||||
func (x placeholderExtension) Index() int { return 0 }
|
||||
func (x placeholderExtension) Syntax() pref.Syntax { return 0 }
|
||||
func (x placeholderExtension) Name() pref.Name { return x.name.Name() }
|
||||
func (x placeholderExtension) FullName() pref.FullName { return x.name }
|
||||
func (x placeholderExtension) IsPlaceholder() bool { return true }
|
||||
func (x placeholderExtension) Options() pref.ProtoMessage { return descopts.Field }
|
||||
func (x placeholderExtension) Number() pref.FieldNumber { return x.number }
|
||||
func (x placeholderExtension) Cardinality() pref.Cardinality { return 0 }
|
||||
func (x placeholderExtension) Kind() pref.Kind { return 0 }
|
||||
func (x placeholderExtension) HasJSONName() bool { return false }
|
||||
func (x placeholderExtension) JSONName() string { return "[" + string(x.name) + "]" }
|
||||
func (x placeholderExtension) TextName() string { return "[" + string(x.name) + "]" }
|
||||
func (x placeholderExtension) HasPresence() bool { return false }
|
||||
func (x placeholderExtension) HasOptionalKeyword() bool { return false }
|
||||
func (x placeholderExtension) IsExtension() bool { return true }
|
||||
func (x placeholderExtension) IsWeak() bool { return false }
|
||||
func (x placeholderExtension) IsPacked() bool { return false }
|
||||
func (x placeholderExtension) IsList() bool { return false }
|
||||
func (x placeholderExtension) IsMap() bool { return false }
|
||||
func (x placeholderExtension) MapKey() pref.FieldDescriptor { return nil }
|
||||
func (x placeholderExtension) MapValue() pref.FieldDescriptor { return nil }
|
||||
func (x placeholderExtension) HasDefault() bool { return false }
|
||||
func (x placeholderExtension) Default() pref.Value { return pref.Value{} }
|
||||
func (x placeholderExtension) DefaultEnumValue() pref.EnumValueDescriptor { return nil }
|
||||
func (x placeholderExtension) ContainingOneof() pref.OneofDescriptor { return nil }
|
||||
func (x placeholderExtension) ContainingMessage() pref.MessageDescriptor { return nil }
|
||||
func (x placeholderExtension) Enum() pref.EnumDescriptor { return nil }
|
||||
func (x placeholderExtension) Message() pref.MessageDescriptor { return nil }
|
||||
func (x placeholderExtension) ProtoType(pref.FieldDescriptor) { return }
|
||||
func (x placeholderExtension) ProtoInternal(pragma.DoNotImplement) { return }
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user