added vendor
This commit is contained in:
parent
012b1f8eb3
commit
99fb9507dc
4761 changed files with 1358158 additions and 0 deletions
|
|
@ -0,0 +1,201 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2023-2025 Buf Technologies, Inc.
|
||||
|
||||
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.
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
2
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/.gitattributes
vendored
Normal file
2
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/.gitattributes
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
*.go text eol=lf
|
||||
internal/gen/**/* linguist-generated=true
|
||||
5
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/.gitignore
vendored
Normal file
5
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
/.tmp/
|
||||
*.pprof
|
||||
*.svg
|
||||
cover.out
|
||||
*.test
|
||||
117
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/.golangci.yml
vendored
Normal file
117
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/.golangci.yml
vendored
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
version: "2"
|
||||
linters:
|
||||
default: all
|
||||
disable:
|
||||
- cyclop # covered by gocyclo
|
||||
- depguard # we can manage dependencies strictly if the need arises in the future
|
||||
- err113 # internal error causes may be dynamic
|
||||
- embeddedstructfieldcheck # over-generous whitespace violates house style
|
||||
- exhaustive # don't _always_ need to exhaustively test all enum values
|
||||
- exhaustruct # don't _always_ need to exhaustively create struct
|
||||
- funcorder # consider enabling in the future
|
||||
- funlen # rely on code review to limit function length
|
||||
- gocognit # dubious "cognitive overhead" quantification
|
||||
- gomoddirectives # we use go modules replacements intentionally
|
||||
- gomodguard # not compatible with go workspaces
|
||||
- ireturn # "accept interfaces, return structs" isn't ironclad
|
||||
- lll # don't want hard limits for line length
|
||||
- maintidx # covered by gocyclo
|
||||
- mnd # some unnamed constants are okay
|
||||
- nlreturn # generous whitespace violates house style
|
||||
- noinlineerr # inline is fine
|
||||
- nonamedreturns # usage of named returns should be selective
|
||||
- testpackage # internal tests are fine
|
||||
- thelper # overzealous breaking of stack traces
|
||||
- wrapcheck # don't _always_ need to wrap errors
|
||||
- wsl # over-generous whitespace violates house style
|
||||
- wsl_v5 # over-generous whitespace violates house style
|
||||
settings:
|
||||
errcheck:
|
||||
check-type-assertions: true
|
||||
forbidigo:
|
||||
forbid:
|
||||
- pattern: ^fmt\.Print
|
||||
- pattern: ^log\.
|
||||
- pattern: ^print$
|
||||
- pattern: ^println$
|
||||
- pattern: ^panic$
|
||||
godox:
|
||||
# TODO, OPT, etc. comments are fine to commit. Use FIXME comments for
|
||||
# temporary hacks, and use godox to prevent committing them.
|
||||
keywords:
|
||||
- FIXME
|
||||
varnamelen:
|
||||
ignore-decls:
|
||||
- T any
|
||||
- i int
|
||||
- wg sync.WaitGroup
|
||||
- ok bool
|
||||
- w io.Writer
|
||||
exclusions:
|
||||
generated: lax
|
||||
presets:
|
||||
- comments
|
||||
- common-false-positives
|
||||
- legacy
|
||||
- std-error-handling
|
||||
rules:
|
||||
# Loosen requirements on conformance executor
|
||||
- linters:
|
||||
- errorlint
|
||||
- forbidigo
|
||||
path: internal/cmd/
|
||||
# Loosen requirements on tests
|
||||
- linters:
|
||||
- funlen
|
||||
- gosec
|
||||
- gosmopolitan
|
||||
- unparam
|
||||
- varnamelen
|
||||
path: _test.go
|
||||
- linters:
|
||||
# setting up custom functions/overloads appears duplicative (false positive)
|
||||
- dupl
|
||||
# Types are checked internally within CEL. There are bigger issues if its
|
||||
# type analysis is wrong
|
||||
- forcetypeassert
|
||||
path: cel/library.go
|
||||
# static unexported lookup tables
|
||||
- linters:
|
||||
- gochecknoglobals
|
||||
path: lookups.go
|
||||
- linters:
|
||||
# uses deprecated fields on protoimpl.ExtensionInfo but its the only way
|
||||
- staticcheck
|
||||
path: resolver/resolver.go
|
||||
# We allow a global validator.
|
||||
- linters:
|
||||
- gochecknoglobals
|
||||
path: validator.go
|
||||
# Library code uses for loops to implement parsing that often don't have bodies.
|
||||
# Unfortunately, revive doesn't detect comments within these empty for loops.
|
||||
- linters:
|
||||
- revive
|
||||
text: "empty-block"
|
||||
path: cel/library.go
|
||||
### BEGIN Temporary exclusions from golangci-lint upgrade.
|
||||
# Will remove in a future PR.
|
||||
- linters:
|
||||
- staticcheck
|
||||
text: "QF1001:" # could apply De Morgan's law
|
||||
### END Temporary exclusions
|
||||
paths:
|
||||
- third_party$
|
||||
- builtin$
|
||||
- examples$
|
||||
issues:
|
||||
max-same-issues: 0
|
||||
formatters:
|
||||
enable:
|
||||
- gci
|
||||
- gofmt
|
||||
exclusions:
|
||||
generated: lax
|
||||
paths:
|
||||
- third_party$
|
||||
- builtin$
|
||||
- examples$
|
||||
201
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/LICENSE
vendored
Normal file
201
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/LICENSE
vendored
Normal file
|
|
@ -0,0 +1,201 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2023-2025 Buf Technologies, Inc.
|
||||
|
||||
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.
|
||||
139
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/Makefile
vendored
Normal file
139
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/Makefile
vendored
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
# See https://tech.davis-hansson.com/p/make/
|
||||
SHELL := bash
|
||||
.DELETE_ON_ERROR:
|
||||
.SHELLFLAGS := -eu -o pipefail -c
|
||||
.DEFAULT_GOAL := all
|
||||
MAKEFLAGS += --warn-undefined-variables
|
||||
MAKEFLAGS += --no-builtin-rules
|
||||
MAKEFLAGS += --no-print-directory
|
||||
TMP := .tmp
|
||||
BIN := $(TMP)/bin
|
||||
BENCH_TMP := $(TMP)/bench
|
||||
COPYRIGHT_YEARS := 2023-2025
|
||||
LICENSE_IGNORE := -e internal/testdata/
|
||||
# Set to use a different compiler. For example, `GO=go1.18rc1 make test`.
|
||||
GO ?= go
|
||||
ARGS ?= --strict_message --strict_error
|
||||
GOLANGCI_LINT_VERSION ?= v2.4.0
|
||||
# Set to use a different version of protovalidate-conformance.
|
||||
# Should be kept in sync with the version referenced in buf.yaml and
|
||||
# 'buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go' in go.mod.
|
||||
CONFORMANCE_VERSION ?= v1.1.0
|
||||
|
||||
.PHONY: help
|
||||
help: ## Describe useful make targets
|
||||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "%-15s %s\n", $$1, $$2}'
|
||||
|
||||
.PHONY: all
|
||||
all: generate test conformance lint ## Generate and run all tests and lint (default)
|
||||
|
||||
.PHONY: clean
|
||||
clean: ## Delete intermediate build artifacts
|
||||
@# -X only removes untracked files, -d recurses into directories, -f actually removes files/dirs
|
||||
git clean -Xdf
|
||||
|
||||
.PHONY: test
|
||||
test: ## Run all unit tests
|
||||
$(GO) test -race -cover ./...
|
||||
|
||||
.PHONY: test-opaque
|
||||
test-opaque: ## Test proto opaque API support
|
||||
$(GO) test --tags=protoopaque ./...
|
||||
|
||||
.PHONY: lint
|
||||
lint: lint-proto lint-go ## Lint code and protos
|
||||
|
||||
.PHONY: lint-go
|
||||
lint-go: $(BIN)/golangci-lint
|
||||
$(BIN)/golangci-lint run --modules-download-mode=readonly --timeout=3m0s ./...
|
||||
$(BIN)/golangci-lint fmt --diff
|
||||
|
||||
.PHONY: lint-proto
|
||||
lint-proto: $(BIN)/buf
|
||||
$(BIN)/buf lint
|
||||
|
||||
.PHONY: lint-fix
|
||||
lint-fix:
|
||||
$(BIN)/golangci-lint run --fix --modules-download-mode=readonly --timeout=3m0s ./...
|
||||
$(BIN)/golangci-lint fmt
|
||||
|
||||
.PHONY: conformance
|
||||
conformance: $(BIN)/protovalidate-conformance protovalidate-conformance-go ## Run conformance tests
|
||||
$(BIN)/protovalidate-conformance $(ARGS) $(BIN)/protovalidate-conformance-go --expected_failures=conformance/expected_failures.yaml
|
||||
|
||||
.PHONY: conformance-hyperpb
|
||||
conformance-hyperpb: ## Run conformance tests against hyperpb
|
||||
HYPERPB=true $(MAKE) conformance
|
||||
|
||||
.PHONY: generate
|
||||
generate: generate-proto generate-license ## Regenerate code and license headers
|
||||
$(GO) mod tidy
|
||||
|
||||
.PHONY: generate-proto
|
||||
generate-proto: $(BIN)/buf
|
||||
rm -rf internal/gen/*/
|
||||
$(BIN)/buf generate buf.build/bufbuild/protovalidate-testing:$(CONFORMANCE_VERSION)
|
||||
$(BIN)/buf generate
|
||||
|
||||
.PHONY: generate-license
|
||||
generate-license: $(BIN)/license-header
|
||||
@# We want to operate on a list of modified and new files, excluding
|
||||
@# deleted and ignored files. git-ls-files can't do this alone. comm -23 takes
|
||||
@# two files and prints the union, dropping lines common to both (-3) and
|
||||
@# those only in the second file (-2). We make one git-ls-files call for
|
||||
@# the modified, cached, and new (--others) files, and a second for the
|
||||
@# deleted files.
|
||||
comm -23 \
|
||||
<(git ls-files --cached --modified --others --no-empty-directory --exclude-standard | sort -u | grep -v $(LICENSE_IGNORE) ) \
|
||||
<(git ls-files --deleted | sort -u) | \
|
||||
xargs $(BIN)/license-header \
|
||||
--license-type apache \
|
||||
--copyright-holder "Buf Technologies, Inc." \
|
||||
--year-range "$(COPYRIGHT_YEARS)"
|
||||
|
||||
.PHONY: checkgenerate
|
||||
checkgenerate: generate
|
||||
@# Used in CI to verify that `make generate` doesn't produce a diff.
|
||||
test -z "$$(git status --porcelain | tee /dev/stderr)"
|
||||
|
||||
|
||||
BENCH ?= .
|
||||
BENCH_COUNT ?= 10
|
||||
BENCH_NAME ?= $(shell date +%F:%T)
|
||||
.PHONY: bench
|
||||
bench: $(BENCH_TMP)
|
||||
go test -bench="$(BENCH)" -benchmem \
|
||||
-memprofile "$(BENCH_TMP)/$(BENCH_NAME).mem.profile" \
|
||||
-cpuprofile "$(BENCH_TMP)/$(BENCH_NAME).cpu.profile" \
|
||||
-count $(BENCH_COUNT) \
|
||||
| tee "$(BENCH_TMP)/$(BENCH_NAME).bench.txt"
|
||||
|
||||
|
||||
.PHONY: upgrade-go
|
||||
upgrade-go:
|
||||
$(GO) get -u -t ./... && $(GO) mod tidy -v
|
||||
|
||||
$(BENCH_TMP):
|
||||
@mkdir -p $(BENCH_TMP)
|
||||
|
||||
$(BIN):
|
||||
@mkdir -p $(BIN)
|
||||
|
||||
$(BIN)/buf: $(BIN) Makefile
|
||||
GOBIN=$(abspath $(@D)) $(GO) install github.com/bufbuild/buf/cmd/buf@latest
|
||||
|
||||
$(BIN)/license-header: $(BIN) Makefile
|
||||
GOBIN=$(abspath $(@D)) $(GO) install \
|
||||
github.com/bufbuild/buf/private/pkg/licenseheader/cmd/license-header@latest
|
||||
|
||||
$(BIN)/golangci-lint: $(BIN) Makefile
|
||||
GOBIN=$(abspath $(@D)) $(GO) install \
|
||||
github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
|
||||
|
||||
$(BIN)/protovalidate-conformance: $(BIN) Makefile
|
||||
GOBIN=$(abspath $(BIN)) $(GO) install \
|
||||
github.com/bufbuild/protovalidate/tools/protovalidate-conformance@$(CONFORMANCE_VERSION)
|
||||
|
||||
.PHONY: protovalidate-conformance-go
|
||||
protovalidate-conformance-go: $(BIN)
|
||||
GOBIN=$(abspath $(BIN)) $(GO) install ./internal/cmd/protovalidate-conformance-go
|
||||
122
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/README.md
vendored
Normal file
122
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/README.md
vendored
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
[][buf]
|
||||
|
||||
# protovalidate-go
|
||||
|
||||
[](https://github.com/bufbuild/protovalidate-go/actions/workflows/ci.yaml)
|
||||
[](https://github.com/bufbuild/protovalidate-go/actions/workflows/conformance.yaml)
|
||||
[](https://goreportcard.com/report/buf.build/go/protovalidate)
|
||||
[](https://pkg.go.dev/buf.build/go/protovalidate)
|
||||
[][buf-mod]
|
||||
|
||||
[Protovalidate][protovalidate] is the semantic validation library for Protobuf. It provides standard annotations to validate common rules on messages and fields, as well as the ability to use [CEL][cel] to write custom rules. It's the next generation of [protoc-gen-validate][protoc-gen-validate].
|
||||
|
||||
With Protovalidate, you can annotate your Protobuf messages with both standard and custom validation rules:
|
||||
|
||||
```protobuf
|
||||
syntax = "proto3";
|
||||
|
||||
package acme.user.v1;
|
||||
|
||||
import "buf/validate/validate.proto";
|
||||
|
||||
message User {
|
||||
string id = 1 [(buf.validate.field).string.uuid = true];
|
||||
uint32 age = 2 [(buf.validate.field).uint32.lte = 150]; // We can only hope.
|
||||
string email = 3 [(buf.validate.field).string.email = true];
|
||||
string first_name = 4 [(buf.validate.field).string.max_len = 64];
|
||||
string last_name = 5 [(buf.validate.field).string.max_len = 64];
|
||||
|
||||
option (buf.validate.message).cel = {
|
||||
id: "first_name_requires_last_name"
|
||||
message: "last_name must be present if first_name is present"
|
||||
expression: "!has(this.first_name) || has(this.last_name)"
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
Once you've added `protovalidate-go` to your project, validation is idiomatic Go:
|
||||
|
||||
```go
|
||||
if err = protovalidate.Validate(moneyTransfer); err != nil {
|
||||
// Handle failure.
|
||||
}
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
> [!TIP]
|
||||
> The easiest way to get started with Protovalidate for RPC APIs are the quickstarts in Buf's documentation. They're available for both [Connect][connect-go] and [gRPC][grpc-go].
|
||||
|
||||
To install the package, use `go get` from within your Go module:
|
||||
|
||||
```shell
|
||||
go get buf.build/go/protovalidate
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
Comprehensive documentation for Protovalidate is available at [protovalidate.com][protovalidate].
|
||||
|
||||
Highlights for Go developers include:
|
||||
|
||||
* The [developer quickstart][quickstart]
|
||||
* Comprehensive RPC quickstarts for [Connect][connect-go] and [gRPC][grpc-go]
|
||||
* A [migration guide for protoc-gen-validate][migration-guide] users
|
||||
|
||||
API documentation for Go is available on [pkg.go.dev][pkg-go].
|
||||
|
||||
## Additional languages and repositories
|
||||
|
||||
Protovalidate isn't just for Go! You might be interested in sibling repositories for other languages:
|
||||
|
||||
- [`protovalidate-java`][pv-java] (Java)
|
||||
- [`protovalidate-python`][pv-python] (Python)
|
||||
- [`protovalidate-cc`][pv-cc] (C++)
|
||||
- [`protovalidate-es`][pv-es] (TypeScript and JavaScript)
|
||||
|
||||
Additionally, [protovalidate's core repository](https://github.com/bufbuild/protovalidate) provides:
|
||||
|
||||
- [Protovalidate's Protobuf API][validate-proto]
|
||||
- [Conformance testing utilities][conformance] for acceptance testing of `protovalidate` implementations
|
||||
|
||||
## Contributing
|
||||
|
||||
We genuinely appreciate any help! If you'd like to contribute, check out these resources:
|
||||
|
||||
- [Contributing Guidelines][contributing]: Guidelines to make your contribution process straightforward and meaningful
|
||||
- [Conformance testing utilities](https://github.com/bufbuild/protovalidate/tree/main/docs/conformance.md): Utilities providing acceptance testing of `protovalidate` implementations
|
||||
- [Go conformance executor][conformance-executable]: Conformance testing executor for `protovalidate-go`
|
||||
|
||||
## Legal
|
||||
|
||||
Offered under the [Apache 2 license][license].
|
||||
|
||||
[buf]: https://buf.build
|
||||
[cel]: https://cel.dev
|
||||
|
||||
[pv-go]: https://github.com/bufbuild/protovalidate-go
|
||||
[pv-java]: https://github.com/bufbuild/protovalidate-java
|
||||
[pv-python]: https://github.com/bufbuild/protovalidate-python
|
||||
[pv-cc]: https://github.com/bufbuild/protovalidate-cc
|
||||
[pv-es]: https://github.com/bufbuild/protovalidate-es
|
||||
|
||||
[buf-mod]: https://buf.build/bufbuild/protovalidate
|
||||
[license]: LICENSE
|
||||
[contributing]: .github/CONTRIBUTING.md
|
||||
|
||||
[protoc-gen-validate]: https://github.com/bufbuild/protoc-gen-validate
|
||||
|
||||
[protovalidate]: https://protovalidate.com/
|
||||
[quickstart]: https://protovalidate.com/quickstart/
|
||||
[connect-go]: https://protovalidate.com/quickstart/connect-go/
|
||||
[grpc-go]: https://protovalidate.com/quickstart/grpc-go/
|
||||
[grpc-java]: https://protovalidate.com/quickstart/grpc-java/
|
||||
[grpc-python]: https://protovalidate.com/quickstart/grpc-python/
|
||||
[migration-guide]: https://protovalidate.com/migration-guides/migrate-from-protoc-gen-validate/
|
||||
[conformance-executable]: ./internal/cmd/protovalidate-conformance-go/README.md
|
||||
[pkg-go]: https://pkg.go.dev/buf.build/go/protovalidate
|
||||
|
||||
[validate-proto]: https://buf.build/bufbuild/protovalidate/docs/main:buf.validate
|
||||
[conformance]: https://github.com/bufbuild/protovalidate/blob/main/docs/conformance.md
|
||||
[examples]: https://github.com/bufbuild/protovalidate/tree/main/examples
|
||||
[migrate]: https://protovalidate.com/migration-guides/migrate-from-protoc-gen-validate/
|
||||
123
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/any.go
vendored
Normal file
123
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/any.go
vendored
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
//nolint:gochecknoglobals
|
||||
var (
|
||||
anyRuleDescriptor = (&validate.FieldRules{}).ProtoReflect().Descriptor().Fields().ByName("any")
|
||||
anyInRuleDescriptor = (&validate.AnyRules{}).ProtoReflect().Descriptor().Fields().ByName("in")
|
||||
anyInRulePath = validate.FieldPath_builder{
|
||||
Elements: []*validate.FieldPathElement{
|
||||
fieldPathElement(anyRuleDescriptor),
|
||||
fieldPathElement(anyInRuleDescriptor),
|
||||
},
|
||||
}.Build()
|
||||
anyNotInDescriptor = (&validate.AnyRules{}).ProtoReflect().Descriptor().Fields().ByName("not_in")
|
||||
anyNotInRulePath = validate.FieldPath_builder{
|
||||
Elements: []*validate.FieldPathElement{
|
||||
fieldPathElement(anyRuleDescriptor),
|
||||
fieldPathElement(anyNotInDescriptor),
|
||||
},
|
||||
}.Build()
|
||||
)
|
||||
|
||||
// anyPB is a specialized evaluator for applying validate.AnyRules to an
|
||||
// anypb.Any message. This is handled outside CEL which attempts to
|
||||
// hydrate anyPB's within an expression, breaking evaluation if the type is
|
||||
// unknown at runtime.
|
||||
type anyPB struct {
|
||||
base base
|
||||
|
||||
// TypeURLDescriptor is the descriptor for the TypeURL field
|
||||
TypeURLDescriptor protoreflect.FieldDescriptor
|
||||
// In specifies which type URLs the value may possess
|
||||
In map[string]struct{}
|
||||
// NotIn specifies which type URLs the value may not possess
|
||||
NotIn map[string]struct{}
|
||||
// InValue contains the original `in` rule value.
|
||||
InValue protoreflect.Value
|
||||
// NotInValue contains the original `not_in` rule value.
|
||||
NotInValue protoreflect.Value
|
||||
}
|
||||
|
||||
func (a anyPB) Evaluate(_ protoreflect.Message, val protoreflect.Value, cfg *validationConfig) error {
|
||||
typeURL := val.Message().Get(a.TypeURLDescriptor).String()
|
||||
|
||||
err := &ValidationError{}
|
||||
if len(a.In) > 0 {
|
||||
if _, ok := a.In[typeURL]; !ok {
|
||||
err.Violations = append(err.Violations, &Violation{
|
||||
Proto: validate.Violation_builder{
|
||||
Field: a.base.fieldPath(),
|
||||
Rule: a.base.rulePath(anyInRulePath),
|
||||
RuleId: proto.String("any.in"),
|
||||
Message: proto.String("type URL must be in the allow list"),
|
||||
}.Build(),
|
||||
FieldValue: val,
|
||||
FieldDescriptor: a.base.Descriptor,
|
||||
RuleValue: a.InValue,
|
||||
RuleDescriptor: anyInRuleDescriptor,
|
||||
})
|
||||
if cfg.failFast {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(a.NotIn) > 0 {
|
||||
if _, ok := a.NotIn[typeURL]; ok {
|
||||
err.Violations = append(err.Violations, &Violation{
|
||||
Proto: validate.Violation_builder{
|
||||
Field: a.base.fieldPath(),
|
||||
Rule: a.base.rulePath(anyNotInRulePath),
|
||||
RuleId: proto.String("any.not_in"),
|
||||
Message: proto.String("type URL must not be in the block list"),
|
||||
}.Build(),
|
||||
FieldValue: val,
|
||||
FieldDescriptor: a.base.Descriptor,
|
||||
RuleValue: a.NotInValue,
|
||||
RuleDescriptor: anyNotInDescriptor,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if len(err.Violations) > 0 {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a anyPB) Tautology() bool {
|
||||
return len(a.In) == 0 && len(a.NotIn) == 0
|
||||
}
|
||||
|
||||
func stringsToSet(ss []string) map[string]struct{} {
|
||||
if len(ss) == 0 {
|
||||
return nil
|
||||
}
|
||||
set := make(map[string]struct{}, len(ss))
|
||||
for _, s := range ss {
|
||||
set[s] = struct{}{}
|
||||
}
|
||||
return set
|
||||
}
|
||||
|
||||
var _ evaluator = anyPB{}
|
||||
157
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/ast.go
vendored
Normal file
157
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/ast.go
vendored
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
"buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
|
||||
"github.com/google/cel-go/cel"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
// astSet represents a collection of compiledAST and their associated cel.Env.
|
||||
type astSet []compiledAST
|
||||
|
||||
// Merge combines a set with another, producing a new ASTSet.
|
||||
func (set astSet) Merge(other astSet) astSet {
|
||||
out := make([]compiledAST, 0, len(set)+len(other))
|
||||
out = append(out, set...)
|
||||
out = append(out, other...)
|
||||
return out
|
||||
}
|
||||
|
||||
// ReduceResiduals generates a ProgramSet, performing a partial evaluation of
|
||||
// the ASTSet to optimize the expression. If the expression is optimized to
|
||||
// either a true or empty string constant result, no compiledProgram is
|
||||
// generated for it. The main usage of this is to elide tautological expressions
|
||||
// from the final result.
|
||||
func (set astSet) ReduceResiduals(rules protoreflect.Message, opts ...cel.ProgramOption) (programSet, error) {
|
||||
residuals := make(astSet, 0, len(set))
|
||||
options := append([]cel.ProgramOption{
|
||||
cel.EvalOptions(
|
||||
cel.OptTrackState,
|
||||
cel.OptExhaustiveEval,
|
||||
cel.OptOptimize,
|
||||
cel.OptPartialEval,
|
||||
),
|
||||
}, opts...)
|
||||
|
||||
baseActivation := &variable{
|
||||
Name: "rules",
|
||||
Val: rules.Interface(),
|
||||
}
|
||||
|
||||
for _, ast := range set {
|
||||
activation := baseActivation
|
||||
if ast.Value.IsValid() {
|
||||
activation = &variable{
|
||||
Name: "rule",
|
||||
Val: ast.Value.Interface(),
|
||||
Next: activation,
|
||||
}
|
||||
}
|
||||
program, err := ast.toProgram(ast.Env, options...)
|
||||
if err != nil {
|
||||
residuals = append(residuals, ast)
|
||||
continue
|
||||
}
|
||||
val, details, _ := program.Program.Eval(activation)
|
||||
if val != nil {
|
||||
switch value := val.Value().(type) {
|
||||
case bool:
|
||||
if value {
|
||||
continue
|
||||
}
|
||||
case string:
|
||||
if value == "" {
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
residual, err := ast.Env.ResidualAst(ast.AST, details)
|
||||
if err != nil {
|
||||
residuals = append(residuals, ast)
|
||||
} else {
|
||||
residuals = append(residuals, compiledAST{
|
||||
AST: residual,
|
||||
Env: ast.Env,
|
||||
Rules: ast.Rules,
|
||||
Source: ast.Source,
|
||||
Path: ast.Path,
|
||||
Value: ast.Value,
|
||||
Descriptor: ast.Descriptor,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return residuals.ToProgramSet(opts...)
|
||||
}
|
||||
|
||||
// ToProgramSet generates a ProgramSet from the specified ASTs.
|
||||
func (set astSet) ToProgramSet(opts ...cel.ProgramOption) (out programSet, err error) {
|
||||
if l := len(set); l == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
out = make(programSet, len(set))
|
||||
for i, ast := range set {
|
||||
out[i], err = ast.toProgram(ast.Env, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// SetRuleValue sets the rule and rules value for the programs in the ASTSet.
|
||||
func (set astSet) WithRuleValues(
|
||||
rules protoreflect.Message,
|
||||
ruleValue protoreflect.Value,
|
||||
ruleDescriptor protoreflect.FieldDescriptor,
|
||||
) (out astSet, err error) {
|
||||
out = slices.Clone(set)
|
||||
for i := range set {
|
||||
out[i].Rules = rules
|
||||
out[i].Value = ruleValue
|
||||
out[i].Descriptor = ruleDescriptor
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
type compiledAST struct {
|
||||
AST *cel.Ast
|
||||
Env *cel.Env
|
||||
Rules protoreflect.Message
|
||||
Source *validate.Rule
|
||||
Path []*validate.FieldPathElement
|
||||
Value protoreflect.Value
|
||||
Descriptor protoreflect.FieldDescriptor
|
||||
}
|
||||
|
||||
func (ast compiledAST) toProgram(env *cel.Env, opts ...cel.ProgramOption) (out compiledProgram, err error) {
|
||||
prog, err := env.Program(ast.AST, opts...)
|
||||
if err != nil {
|
||||
return out, &CompilationError{cause: fmt.Errorf("failed to compile program %s: %w", ast.Source.GetId(), err)}
|
||||
}
|
||||
return compiledProgram{
|
||||
Program: prog,
|
||||
Rules: ast.Rules,
|
||||
Source: ast.Source,
|
||||
Path: ast.Path,
|
||||
Value: ast.Value,
|
||||
Descriptor: ast.Descriptor,
|
||||
}, nil
|
||||
}
|
||||
70
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/base.go
vendored
Normal file
70
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/base.go
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"slices"
|
||||
|
||||
"buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
// base is a common struct used by all field evaluators. It holds
|
||||
// some common information used across all field evaluators.
|
||||
type base struct {
|
||||
// Descriptor is the FieldDescriptor targeted by this evaluator, nor nil if
|
||||
// there is none.
|
||||
Descriptor protoreflect.FieldDescriptor
|
||||
|
||||
// FieldPatht is the field path element that pertains to this evaluator, or
|
||||
// nil if there is none.
|
||||
FieldPathElement *validate.FieldPathElement
|
||||
|
||||
// RulePrefix is a static prefix this evaluator should add to the rule path
|
||||
// of violations.
|
||||
RulePrefix *validate.FieldPath
|
||||
}
|
||||
|
||||
func newBase(valEval *value) base {
|
||||
return base{
|
||||
Descriptor: valEval.Descriptor,
|
||||
FieldPathElement: fieldPathElement(valEval.Descriptor),
|
||||
RulePrefix: valEval.NestedRule,
|
||||
}
|
||||
}
|
||||
|
||||
func (b *base) fieldPath() *validate.FieldPath {
|
||||
if b.FieldPathElement == nil {
|
||||
return nil
|
||||
}
|
||||
return validate.FieldPath_builder{
|
||||
Elements: []*validate.FieldPathElement{
|
||||
b.FieldPathElement,
|
||||
},
|
||||
}.Build()
|
||||
}
|
||||
|
||||
func (b *base) rulePath(suffix *validate.FieldPath) *validate.FieldPath {
|
||||
return prefixRulePath(b.RulePrefix, suffix)
|
||||
}
|
||||
|
||||
func prefixRulePath(prefix *validate.FieldPath, suffix *validate.FieldPath) *validate.FieldPath {
|
||||
if len(prefix.GetElements()) > 0 {
|
||||
return validate.FieldPath_builder{
|
||||
Elements: slices.Concat(prefix.GetElements(), suffix.GetElements()),
|
||||
}.Build()
|
||||
}
|
||||
return suffix
|
||||
}
|
||||
17
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/buf.gen.yaml
vendored
Normal file
17
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/buf.gen.yaml
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
version: v2
|
||||
managed:
|
||||
enabled: true
|
||||
disable:
|
||||
- file_option: go_package
|
||||
module: buf.build/bufbuild/protovalidate
|
||||
- file_option: go_package
|
||||
module: buf.build/rodaine/protogofakeit
|
||||
override:
|
||||
- file_option: go_package_prefix
|
||||
value: buf.build/go/protovalidate/internal/gen
|
||||
plugins:
|
||||
- remote: buf.build/protocolbuffers/go:v1.36.6
|
||||
out: internal/gen
|
||||
opt:
|
||||
- paths=source_relative
|
||||
- default_api_level=API_HYBRID
|
||||
9
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/buf.lock
vendored
Normal file
9
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/buf.lock
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Generated by buf. DO NOT EDIT.
|
||||
version: v2
|
||||
deps:
|
||||
- name: buf.build/bufbuild/protovalidate
|
||||
commit: 2a1774d888024a9b93ce7eb4b59f6a83
|
||||
digest: b5:6b7f9bc919b65e5b79d7b726ffc03d6f815a412d6b792970fa6f065cae162107bd0a9d47272c8ab1a2c9514e87b13d3fbf71df614374d62d2183afb64be2d30a
|
||||
- name: buf.build/rodaine/protogofakeit
|
||||
commit: 9caf0fc578d3413590962a1764b81b94
|
||||
digest: b5:eeead7373f2f598ebc8f91aa3a68d6b50630076341d875b22dc6760126bc56c82cf1e98f5a2eff9815ba55fa48ab81745c93a5aeefd5e4697bf43c9ea4694735
|
||||
17
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/buf.yaml
vendored
Normal file
17
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/buf.yaml
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
version: v2
|
||||
modules:
|
||||
- path: proto
|
||||
deps:
|
||||
- buf.build/bufbuild/protovalidate:v1.1.0
|
||||
- buf.build/rodaine/protogofakeit
|
||||
lint:
|
||||
use:
|
||||
- STANDARD
|
||||
ignore_only:
|
||||
PROTOVALIDATE:
|
||||
- proto/tests/example/v1/validations.proto
|
||||
- proto/tests/example/v1/filter.proto
|
||||
- proto/tests/example/v1/compile.proto
|
||||
breaking:
|
||||
use:
|
||||
- FILE
|
||||
648
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/builder.go
vendored
Normal file
648
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/builder.go
vendored
Normal file
|
|
@ -0,0 +1,648 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"maps"
|
||||
"slices"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
|
||||
pvcel "buf.build/go/protovalidate/cel"
|
||||
"github.com/google/cel-go/cel"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
"google.golang.org/protobuf/types/dynamicpb"
|
||||
)
|
||||
|
||||
//nolint:gochecknoglobals
|
||||
var (
|
||||
celExpressionDescriptor = (&validate.FieldRules{}).ProtoReflect().Descriptor().Fields().ByName("cel_expression")
|
||||
celExpressionField = fieldPathElement(celExpressionDescriptor)
|
||||
celRuleDescriptor = (&validate.FieldRules{}).ProtoReflect().Descriptor().Fields().ByName("cel")
|
||||
celRuleField = fieldPathElement(celRuleDescriptor)
|
||||
)
|
||||
|
||||
// builder is a build-through cache of message evaluators keyed off the provided
|
||||
// descriptor.
|
||||
type builder struct {
|
||||
mtx sync.Mutex // serializes cache writes.
|
||||
cache atomic.Pointer[messageCache] // copy-on-write cache.
|
||||
env *cel.Env
|
||||
rules cache
|
||||
extensionTypeResolver protoregistry.ExtensionTypeResolver
|
||||
allowUnknownFields bool
|
||||
Load func(desc protoreflect.MessageDescriptor) messageEvaluator
|
||||
}
|
||||
|
||||
// newBuilder initializes a new Builder.
|
||||
func newBuilder(
|
||||
env *cel.Env,
|
||||
disableLazy bool,
|
||||
extensionTypeResolver protoregistry.ExtensionTypeResolver,
|
||||
allowUnknownFields bool,
|
||||
seedDesc ...protoreflect.MessageDescriptor,
|
||||
) *builder {
|
||||
bldr := &builder{
|
||||
env: env,
|
||||
rules: newCache(),
|
||||
extensionTypeResolver: extensionTypeResolver,
|
||||
allowUnknownFields: allowUnknownFields,
|
||||
}
|
||||
|
||||
if disableLazy {
|
||||
bldr.Load = bldr.load
|
||||
} else {
|
||||
bldr.Load = bldr.loadOrBuild
|
||||
}
|
||||
|
||||
cache := make(messageCache, len(seedDesc))
|
||||
for _, desc := range seedDesc {
|
||||
bldr.build(desc, cache)
|
||||
}
|
||||
bldr.cache.Store(&cache)
|
||||
return bldr
|
||||
}
|
||||
|
||||
// load returns a pre-cached MessageEvaluator for the given descriptor or, if
|
||||
// the descriptor is unknown, returns an evaluator that always resolves to a
|
||||
// errors.CompilationError.
|
||||
func (bldr *builder) load(desc protoreflect.MessageDescriptor) messageEvaluator {
|
||||
if eval, ok := (*bldr.cache.Load())[desc]; ok {
|
||||
return eval
|
||||
}
|
||||
return unknownMessage{desc: desc}
|
||||
}
|
||||
|
||||
// loadOrBuild either returns a memoized MessageEvaluator for the given
|
||||
// descriptor or lazily constructs a new one. This method is thread-safe via
|
||||
// locking.
|
||||
func (bldr *builder) loadOrBuild(desc protoreflect.MessageDescriptor) messageEvaluator {
|
||||
if eval, ok := (*bldr.cache.Load())[desc]; ok {
|
||||
return eval
|
||||
}
|
||||
bldr.mtx.Lock()
|
||||
defer bldr.mtx.Unlock()
|
||||
cache := *bldr.cache.Load()
|
||||
if eval, ok := cache[desc]; ok {
|
||||
return eval
|
||||
}
|
||||
newCache := cache.Clone()
|
||||
msgEval := bldr.build(desc, newCache)
|
||||
bldr.cache.Store(&newCache)
|
||||
return msgEval
|
||||
}
|
||||
|
||||
func (bldr *builder) build(
|
||||
desc protoreflect.MessageDescriptor,
|
||||
cache messageCache,
|
||||
) *message {
|
||||
if eval, ok := cache[desc]; ok {
|
||||
return eval
|
||||
}
|
||||
msgEval := &message{}
|
||||
cache[desc] = msgEval
|
||||
bldr.buildMessage(desc, msgEval, cache)
|
||||
return msgEval
|
||||
}
|
||||
|
||||
func (bldr *builder) buildMessage(
|
||||
desc protoreflect.MessageDescriptor, msgEval *message,
|
||||
cache messageCache,
|
||||
) {
|
||||
msgRules, _ := ResolveMessageRules(desc)
|
||||
|
||||
steps := []func(
|
||||
desc protoreflect.MessageDescriptor,
|
||||
msgRules *validate.MessageRules,
|
||||
msg *message,
|
||||
cache messageCache,
|
||||
){
|
||||
bldr.processMessageExpressions,
|
||||
bldr.processMessageOneofRules,
|
||||
bldr.processOneofRules,
|
||||
bldr.processFields,
|
||||
}
|
||||
|
||||
for _, step := range steps {
|
||||
step(desc, msgRules, msgEval, cache)
|
||||
}
|
||||
}
|
||||
|
||||
func (bldr *builder) processMessageExpressions(
|
||||
desc protoreflect.MessageDescriptor,
|
||||
msgRules *validate.MessageRules,
|
||||
msgEval *message,
|
||||
_ messageCache,
|
||||
) {
|
||||
exprs := expressions{
|
||||
Rules: append(expressionsToRules(msgRules.GetCelExpression()), msgRules.GetCel()...),
|
||||
}
|
||||
compiledExprs, err := compile(
|
||||
exprs,
|
||||
bldr.env,
|
||||
cel.Types(dynamicpb.NewMessage(desc)),
|
||||
cel.Variable("this", cel.ObjectType(string(desc.FullName()))),
|
||||
)
|
||||
if err != nil {
|
||||
msgEval.Err = err
|
||||
return
|
||||
}
|
||||
|
||||
msgEval.Append(celPrograms{
|
||||
programSet: compiledExprs,
|
||||
})
|
||||
}
|
||||
|
||||
func (bldr *builder) processMessageOneofRules(
|
||||
desc protoreflect.MessageDescriptor,
|
||||
msgRules *validate.MessageRules,
|
||||
msgEval *message,
|
||||
_ messageCache,
|
||||
) {
|
||||
oneofRules := msgRules.GetOneof()
|
||||
for _, rule := range oneofRules {
|
||||
fields := rule.GetFields()
|
||||
if len(fields) == 0 {
|
||||
msgEval.Err = &CompilationError{
|
||||
cause: fmt.Errorf("at least one field must be specified in oneof rule for the message %s", desc.FullName()),
|
||||
}
|
||||
return
|
||||
}
|
||||
seen := make(map[string]struct{}, len(fields))
|
||||
fdescs := make([]protoreflect.FieldDescriptor, 0, len(fields))
|
||||
for _, name := range fields {
|
||||
if _, ok := seen[name]; ok {
|
||||
msgEval.Err = &CompilationError{
|
||||
cause: fmt.Errorf("duplicate %s in oneof rule for the message %s", name, desc.FullName()),
|
||||
}
|
||||
return
|
||||
}
|
||||
seen[name] = struct{}{}
|
||||
fdesc := desc.Fields().ByName(protoreflect.Name(name))
|
||||
if fdesc == nil {
|
||||
msgEval.Err = &CompilationError{
|
||||
cause: fmt.Errorf("field %s not found in message %s", name, desc.FullName()),
|
||||
}
|
||||
return
|
||||
}
|
||||
fdescs = append(fdescs, fdesc)
|
||||
}
|
||||
oneofEval := &messageOneof{
|
||||
Fields: fdescs,
|
||||
Required: rule.GetRequired(),
|
||||
}
|
||||
msgEval.AppendNested(oneofEval)
|
||||
}
|
||||
}
|
||||
|
||||
func (bldr *builder) processOneofRules(
|
||||
desc protoreflect.MessageDescriptor,
|
||||
_ *validate.MessageRules,
|
||||
msgEval *message,
|
||||
_ messageCache,
|
||||
) {
|
||||
oneofs := desc.Oneofs()
|
||||
for i := range oneofs.Len() {
|
||||
oneofDesc := oneofs.Get(i)
|
||||
oneofRules, _ := ResolveOneofRules(oneofDesc)
|
||||
oneofEval := oneof{
|
||||
Descriptor: oneofDesc,
|
||||
Required: oneofRules.GetRequired(),
|
||||
}
|
||||
msgEval.AppendNested(oneofEval)
|
||||
}
|
||||
}
|
||||
|
||||
func (bldr *builder) processFields(
|
||||
desc protoreflect.MessageDescriptor,
|
||||
msgRules *validate.MessageRules,
|
||||
msgEval *message,
|
||||
cache messageCache,
|
||||
) {
|
||||
fields := desc.Fields()
|
||||
for i := range fields.Len() {
|
||||
fdesc := fields.Get(i)
|
||||
fieldRules, _ := ResolveFieldRules(fdesc)
|
||||
fldEval, err := bldr.buildField(fdesc, fieldRules, msgRules, cache)
|
||||
if err != nil {
|
||||
fldEval.Err = err
|
||||
}
|
||||
msgEval.AppendNested(fldEval)
|
||||
}
|
||||
}
|
||||
|
||||
func (bldr *builder) buildField(
|
||||
fieldDescriptor protoreflect.FieldDescriptor,
|
||||
fieldRules *validate.FieldRules,
|
||||
msgRules *validate.MessageRules,
|
||||
cache messageCache,
|
||||
) (field, error) {
|
||||
if fieldRules != nil && !fieldRules.HasIgnore() && isPartOfMessageOneof(msgRules, fieldDescriptor) {
|
||||
fieldRules = proto.CloneOf(fieldRules)
|
||||
fieldRules.SetIgnore(validate.Ignore_IGNORE_IF_ZERO_VALUE)
|
||||
}
|
||||
fld := field{
|
||||
Value: value{
|
||||
Descriptor: fieldDescriptor,
|
||||
},
|
||||
HasPresence: fieldDescriptor.HasPresence(),
|
||||
Required: fieldRules.GetRequired(),
|
||||
Ignore: fieldRules.GetIgnore(),
|
||||
}
|
||||
err := bldr.buildValue(fieldDescriptor, fieldRules, &fld.Value, cache)
|
||||
return fld, err
|
||||
}
|
||||
|
||||
func (bldr *builder) buildValue(
|
||||
fdesc protoreflect.FieldDescriptor,
|
||||
rules *validate.FieldRules,
|
||||
valEval *value,
|
||||
cache messageCache,
|
||||
) (err error) {
|
||||
if bldr.shouldIgnoreAlways(rules) {
|
||||
return nil
|
||||
}
|
||||
|
||||
steps := []func(
|
||||
fdesc protoreflect.FieldDescriptor,
|
||||
fieldRules *validate.FieldRules,
|
||||
valEval *value,
|
||||
cache messageCache,
|
||||
) error{
|
||||
bldr.processIgnoreEmpty,
|
||||
bldr.processFieldExpressions,
|
||||
bldr.processEmbeddedMessage,
|
||||
bldr.processWrapperRules,
|
||||
bldr.processStandardRules,
|
||||
bldr.processAnyRules,
|
||||
bldr.processEnumRules,
|
||||
bldr.processMapRules,
|
||||
bldr.processRepeatedRules,
|
||||
}
|
||||
|
||||
for _, step := range steps {
|
||||
if err = step(fdesc, rules, valEval, cache); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bldr *builder) processIgnoreEmpty(
|
||||
fdesc protoreflect.FieldDescriptor,
|
||||
rules *validate.FieldRules,
|
||||
val *value,
|
||||
_ messageCache,
|
||||
) error {
|
||||
// the only time we need to ignore empty on a value is if it's evaluating a
|
||||
// field item (repeated element or map key/value).
|
||||
val.IgnoreEmpty = val.NestedRule != nil && bldr.shouldIgnoreEmpty(rules)
|
||||
if val.IgnoreEmpty {
|
||||
val.Zero = bldr.zeroValue(fdesc, val.NestedRule != nil)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bldr *builder) processFieldExpressions(
|
||||
fieldDesc protoreflect.FieldDescriptor,
|
||||
fieldRules *validate.FieldRules,
|
||||
eval *value,
|
||||
_ messageCache,
|
||||
) error {
|
||||
celTyp := pvcel.ProtoFieldToType(fieldDesc, false, eval.NestedRule != nil)
|
||||
opts := append(
|
||||
pvcel.RequiredEnvOptions(fieldDesc),
|
||||
cel.Variable("this", celTyp),
|
||||
)
|
||||
compileWithPath := func(exprs expressions, fieldPathElement *validate.FieldPathElement, descriptor protoreflect.FieldDescriptor) (programSet, error) {
|
||||
compiledExpressions, err := compile(exprs, bldr.env, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := range compiledExpressions {
|
||||
compiledExpressions[i].Path = []*validate.FieldPathElement{
|
||||
validate.FieldPathElement_builder{
|
||||
FieldNumber: proto.Int32(fieldPathElement.GetFieldNumber()),
|
||||
FieldType: fieldPathElement.GetFieldType().Enum(),
|
||||
FieldName: proto.String(fieldPathElement.GetFieldName()),
|
||||
Index: proto.Uint64(uint64(i)), //nolint:gosec // indices are guaranteed to be non-negative
|
||||
}.Build(),
|
||||
}
|
||||
compiledExpressions[i].Descriptor = descriptor
|
||||
}
|
||||
return compiledExpressions, nil
|
||||
}
|
||||
compiledExpressions, err := compileWithPath(
|
||||
expressions{
|
||||
Rules: expressionsToRules(fieldRules.GetCelExpression()),
|
||||
},
|
||||
celExpressionField,
|
||||
celExpressionDescriptor,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
celRuleCompiledExpressions, err := compileWithPath(
|
||||
expressions{
|
||||
Rules: fieldRules.GetCel(),
|
||||
},
|
||||
celRuleField,
|
||||
celRuleDescriptor,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
compiledExpressions = append(compiledExpressions, celRuleCompiledExpressions...)
|
||||
if len(compiledExpressions) > 0 {
|
||||
eval.Rules = append(eval.Rules,
|
||||
celPrograms{
|
||||
base: newBase(eval),
|
||||
programSet: compiledExpressions,
|
||||
},
|
||||
)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bldr *builder) processEmbeddedMessage(
|
||||
fdesc protoreflect.FieldDescriptor,
|
||||
_ *validate.FieldRules,
|
||||
valEval *value,
|
||||
cache messageCache,
|
||||
) error {
|
||||
if !isMessageField(fdesc) ||
|
||||
fdesc.IsMap() ||
|
||||
(fdesc.IsList() && valEval.NestedRule == nil) {
|
||||
return nil
|
||||
}
|
||||
|
||||
embedEval := bldr.build(fdesc.Message(), cache)
|
||||
if err := embedEval.Err; err != nil {
|
||||
return &CompilationError{cause: fmt.Errorf(
|
||||
"failed to compile embedded type %s for %s: %w",
|
||||
fdesc.Message().FullName(), fdesc.FullName(), err)}
|
||||
}
|
||||
valEval.AppendNested(&embeddedMessage{
|
||||
base: newBase(valEval),
|
||||
message: embedEval,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bldr *builder) processWrapperRules(
|
||||
fdesc protoreflect.FieldDescriptor,
|
||||
rules *validate.FieldRules,
|
||||
valEval *value,
|
||||
cache messageCache,
|
||||
) error {
|
||||
if !isMessageField(fdesc) ||
|
||||
fdesc.IsMap() ||
|
||||
(fdesc.IsList() && valEval.NestedRule == nil) {
|
||||
return nil
|
||||
}
|
||||
refRules := rules.ProtoReflect()
|
||||
setOneof := refRules.WhichOneof(fieldRulesOneofDesc)
|
||||
if setOneof == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
expectedWrapperDescriptor, ok := expectedWrapperRules(fdesc.Message().FullName())
|
||||
if ok && setOneof.FullName() != expectedWrapperDescriptor.FullName() {
|
||||
return &CompilationError{cause: fmt.Errorf(
|
||||
"expected rule %q, got %q on field %q",
|
||||
expectedWrapperDescriptor.FullName(),
|
||||
setOneof.FullName(),
|
||||
fdesc.FullName(),
|
||||
)}
|
||||
}
|
||||
|
||||
if !ok || !rules.ProtoReflect().Has(expectedWrapperDescriptor) {
|
||||
return nil
|
||||
}
|
||||
unwrapped := value{
|
||||
Descriptor: valEval.Descriptor,
|
||||
NestedRule: valEval.NestedRule,
|
||||
}
|
||||
err := bldr.buildValue(fdesc.Message().Fields().ByName("value"), rules, &unwrapped, cache)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
valEval.Append(unwrapped.Rules)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bldr *builder) processStandardRules(
|
||||
fdesc protoreflect.FieldDescriptor,
|
||||
rules *validate.FieldRules,
|
||||
valEval *value,
|
||||
_ messageCache,
|
||||
) error {
|
||||
// If this is a wrapper field, just return. Wrapper fields are handled by
|
||||
// processWrapperRules and their wrapped values are passed through the process gauntlet.
|
||||
if isMessageField(fdesc) {
|
||||
if _, ok := expectedWrapperRules(fdesc.Message().FullName()); ok {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
stdRules, err := bldr.rules.Build(
|
||||
bldr.env,
|
||||
fdesc,
|
||||
rules,
|
||||
bldr.extensionTypeResolver,
|
||||
bldr.allowUnknownFields,
|
||||
valEval.NestedRule != nil,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
valEval.Append(celPrograms{
|
||||
base: newBase(valEval),
|
||||
programSet: stdRules,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bldr *builder) processAnyRules(
|
||||
fdesc protoreflect.FieldDescriptor,
|
||||
fieldRules *validate.FieldRules,
|
||||
valEval *value,
|
||||
_ messageCache,
|
||||
) error {
|
||||
if (fdesc.IsList() && valEval.NestedRule == nil) ||
|
||||
!isMessageField(fdesc) ||
|
||||
fdesc.Message().FullName() != "google.protobuf.Any" {
|
||||
return nil
|
||||
}
|
||||
|
||||
typeURLDesc := fdesc.Message().Fields().ByName("type_url")
|
||||
anyPbDesc := (&validate.AnyRules{}).ProtoReflect().Descriptor()
|
||||
inField := anyPbDesc.Fields().ByName("in")
|
||||
notInField := anyPbDesc.Fields().ByName("not_in")
|
||||
anyEval := anyPB{
|
||||
base: newBase(valEval),
|
||||
TypeURLDescriptor: typeURLDesc,
|
||||
In: stringsToSet(fieldRules.GetAny().GetIn()),
|
||||
NotIn: stringsToSet(fieldRules.GetAny().GetNotIn()),
|
||||
InValue: fieldRules.GetAny().ProtoReflect().Get(inField),
|
||||
NotInValue: fieldRules.GetAny().ProtoReflect().Get(notInField),
|
||||
}
|
||||
valEval.Append(anyEval)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bldr *builder) processEnumRules(
|
||||
fdesc protoreflect.FieldDescriptor,
|
||||
fieldRules *validate.FieldRules,
|
||||
valEval *value,
|
||||
_ messageCache,
|
||||
) error {
|
||||
if fdesc.Kind() != protoreflect.EnumKind {
|
||||
return nil
|
||||
}
|
||||
if fieldRules.GetEnum().GetDefinedOnly() {
|
||||
valEval.Append(definedEnum{
|
||||
base: newBase(valEval),
|
||||
ValueDescriptors: fdesc.Enum().Values(),
|
||||
})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bldr *builder) processMapRules(
|
||||
fieldDesc protoreflect.FieldDescriptor,
|
||||
rules *validate.FieldRules,
|
||||
valEval *value,
|
||||
cache messageCache,
|
||||
) error {
|
||||
if !fieldDesc.IsMap() {
|
||||
return nil
|
||||
}
|
||||
|
||||
mapEval := newKVPairs(valEval)
|
||||
|
||||
err := bldr.buildValue(
|
||||
fieldDesc.MapKey(),
|
||||
rules.GetMap().GetKeys(),
|
||||
&mapEval.KeyRules,
|
||||
cache)
|
||||
if err != nil {
|
||||
return &CompilationError{cause: fmt.Errorf(
|
||||
"failed to compile key rules for map %s: %w",
|
||||
fieldDesc.FullName(), err)}
|
||||
}
|
||||
|
||||
err = bldr.buildValue(
|
||||
fieldDesc.MapValue(),
|
||||
rules.GetMap().GetValues(),
|
||||
&mapEval.ValueRules,
|
||||
cache)
|
||||
if err != nil {
|
||||
return &CompilationError{cause: fmt.Errorf(
|
||||
"failed to compile value rules for map %s: %w",
|
||||
fieldDesc.FullName(), err)}
|
||||
}
|
||||
|
||||
valEval.Append(mapEval)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bldr *builder) processRepeatedRules(
|
||||
fdesc protoreflect.FieldDescriptor,
|
||||
fieldRules *validate.FieldRules,
|
||||
valEval *value,
|
||||
cache messageCache,
|
||||
) error {
|
||||
if !fdesc.IsList() || valEval.NestedRule != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
listEval := newListItems(valEval)
|
||||
|
||||
err := bldr.buildValue(fdesc, fieldRules.GetRepeated().GetItems(), &listEval.ItemRules, cache)
|
||||
if err != nil {
|
||||
return &CompilationError{cause: fmt.Errorf(
|
||||
"failed to compile items rules for repeated %v: %w", fdesc.FullName(), err)}
|
||||
}
|
||||
|
||||
valEval.Append(listEval)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bldr *builder) shouldIgnoreAlways(rules *validate.FieldRules) bool {
|
||||
return rules.GetIgnore() == validate.Ignore_IGNORE_ALWAYS
|
||||
}
|
||||
|
||||
func (bldr *builder) shouldIgnoreEmpty(rules *validate.FieldRules) bool {
|
||||
return rules.GetIgnore() == validate.Ignore_IGNORE_IF_ZERO_VALUE
|
||||
}
|
||||
|
||||
func (bldr *builder) zeroValue(fdesc protoreflect.FieldDescriptor, forItems bool) protoreflect.Value {
|
||||
switch {
|
||||
case forItems && fdesc.IsList():
|
||||
msg := dynamicpb.NewMessage(fdesc.ContainingMessage())
|
||||
return msg.Get(fdesc).List().NewElement()
|
||||
case isMessageField(fdesc) &&
|
||||
fdesc.Cardinality() != protoreflect.Repeated:
|
||||
msg := dynamicpb.NewMessage(fdesc.Message())
|
||||
return protoreflect.ValueOfMessage(msg)
|
||||
default:
|
||||
return fdesc.Default()
|
||||
}
|
||||
}
|
||||
|
||||
type messageCache map[protoreflect.MessageDescriptor]*message
|
||||
|
||||
func (c messageCache) Clone() messageCache {
|
||||
newCache := make(messageCache, len(c)+1)
|
||||
c.SyncTo(newCache)
|
||||
return newCache
|
||||
}
|
||||
func (c messageCache) SyncTo(other messageCache) {
|
||||
maps.Copy(other, c)
|
||||
}
|
||||
|
||||
// isMessageField returns true if the field descriptor fdesc describes a field
|
||||
// containing a submessage. Although they are represented differently on the
|
||||
// wire, group fields are treated like message fields in protoreflect and have
|
||||
// similar properties. In the 2023 edition of protobuf, message fields with the
|
||||
// delimited encoding feature will be detected as groups, but should otherwise
|
||||
// be treated the same.
|
||||
func isMessageField(fdesc protoreflect.FieldDescriptor) bool {
|
||||
return fdesc.Kind() == protoreflect.MessageKind ||
|
||||
fdesc.Kind() == protoreflect.GroupKind
|
||||
}
|
||||
|
||||
func isPartOfMessageOneof(msgRules *validate.MessageRules, field protoreflect.FieldDescriptor) bool {
|
||||
return slices.ContainsFunc(msgRules.GetOneof(), func(oneof *validate.MessageOneofRule) bool {
|
||||
return slices.Contains(oneof.GetFields(), string(field.Name()))
|
||||
})
|
||||
}
|
||||
|
||||
func expressionsToRules(expressions []string) []*validate.Rule {
|
||||
rules := make([]*validate.Rule, 0, len(expressions))
|
||||
for _, expr := range expressions {
|
||||
rules = append(rules, validate.Rule_builder{
|
||||
Id: proto.String(expr),
|
||||
Expression: proto.String(expr),
|
||||
}.Build())
|
||||
}
|
||||
return rules
|
||||
}
|
||||
241
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/cache.go
vendored
Normal file
241
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/cache.go
vendored
Normal file
|
|
@ -0,0 +1,241 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
|
||||
pvcel "buf.build/go/protovalidate/cel"
|
||||
"github.com/google/cel-go/cel"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
)
|
||||
|
||||
// cache is a build-through cache to computed standard rules.
|
||||
type cache struct {
|
||||
cache map[protoreflect.FieldDescriptor]astSet
|
||||
}
|
||||
|
||||
// newCache constructs a new build-through cache for the standard rules.
|
||||
func newCache() cache {
|
||||
return cache{
|
||||
cache: map[protoreflect.FieldDescriptor]astSet{},
|
||||
}
|
||||
}
|
||||
|
||||
// Build creates the standard rules for the given field. If forItems is
|
||||
// true, the rules for repeated list items are built instead of the
|
||||
// rules on the list itself.
|
||||
func (c *cache) Build(
|
||||
env *cel.Env,
|
||||
fieldDesc protoreflect.FieldDescriptor,
|
||||
fieldRules *validate.FieldRules,
|
||||
extensionTypeResolver protoregistry.ExtensionTypeResolver,
|
||||
allowUnknownFields bool,
|
||||
forItems bool,
|
||||
) (set programSet, err error) {
|
||||
rules, setOneof, done, err := c.resolveRules(
|
||||
fieldDesc,
|
||||
fieldRules,
|
||||
forItems,
|
||||
)
|
||||
if done {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = reparseUnrecognized(extensionTypeResolver, rules); err != nil {
|
||||
return nil, &CompilationError{cause: fmt.Errorf("error reparsing message: %w", err)}
|
||||
}
|
||||
if !allowUnknownFields && len(rules.GetUnknown()) > 0 {
|
||||
return nil, &CompilationError{cause: fmt.Errorf("unknown rules in %s; see protovalidate.WithExtensionTypeResolver", rules.Descriptor().FullName())}
|
||||
}
|
||||
|
||||
env, err = c.prepareEnvironment(env, fieldDesc, rules, forItems)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var asts astSet
|
||||
rules.Range(func(desc protoreflect.FieldDescriptor, rule protoreflect.Value) bool {
|
||||
// Try compiling without the rule variable first. Extending a cel
|
||||
// environment is expensive.
|
||||
precomputedASTs, compileErr := c.loadOrCompileStandardRule(env, setOneof, desc)
|
||||
if compileErr != nil {
|
||||
fieldEnv, compileErr := env.Extend(
|
||||
cel.Variable("rule", pvcel.ProtoFieldToType(desc, true, false)),
|
||||
)
|
||||
if compileErr != nil {
|
||||
err = compileErr
|
||||
return false
|
||||
}
|
||||
precomputedASTs, compileErr = c.loadOrCompileStandardRule(fieldEnv, setOneof, desc)
|
||||
if compileErr != nil {
|
||||
err = compileErr
|
||||
return false
|
||||
}
|
||||
}
|
||||
precomputedASTs, compileErr = precomputedASTs.WithRuleValues(rules, rule, desc)
|
||||
if compileErr != nil {
|
||||
err = compileErr
|
||||
return false
|
||||
}
|
||||
asts = asts.Merge(precomputedASTs)
|
||||
return true
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
set, err = asts.ReduceResiduals(rules)
|
||||
return set, err
|
||||
}
|
||||
|
||||
// resolveRules extracts the standard rules for the specified field. An
|
||||
// error is returned if the wrong rules are applied to a field (typically
|
||||
// if there is a type-mismatch). The done result is true if an error is returned
|
||||
// or if there are now standard rules to apply to this field.
|
||||
func (c *cache) resolveRules(
|
||||
fieldDesc protoreflect.FieldDescriptor,
|
||||
fieldRules *validate.FieldRules,
|
||||
forItems bool,
|
||||
) (rules protoreflect.Message, fieldRule protoreflect.FieldDescriptor, done bool, err error) {
|
||||
refRules := fieldRules.ProtoReflect()
|
||||
setOneof := refRules.WhichOneof(fieldRulesOneofDesc)
|
||||
if setOneof == nil {
|
||||
return nil, nil, true, nil
|
||||
}
|
||||
expected, ok := c.getExpectedRuleDescriptor(fieldDesc, forItems)
|
||||
if ok && setOneof.FullName() != expected.FullName() {
|
||||
return nil, nil, true, &CompilationError{cause: fmt.Errorf(
|
||||
"expected rule %q, got %q on field %q",
|
||||
expected.FullName(),
|
||||
setOneof.FullName(),
|
||||
fieldDesc.FullName(),
|
||||
)}
|
||||
}
|
||||
|
||||
if !ok {
|
||||
// The only expected rule descriptor for message fields is for well known types.
|
||||
// If we didn't find a descriptor and this is a message, there must be a mismatch.
|
||||
if fieldDesc.Kind() == protoreflect.MessageKind {
|
||||
return nil, nil, true, &CompilationError{cause: fmt.Errorf(
|
||||
"mismatched message rules, %q is not a valid rule for field %q",
|
||||
setOneof.FullName(),
|
||||
fieldDesc.FullName(),
|
||||
)}
|
||||
}
|
||||
if !refRules.Has(setOneof) {
|
||||
return nil, nil, true, nil
|
||||
}
|
||||
}
|
||||
|
||||
rules = refRules.Get(setOneof).Message()
|
||||
return rules, setOneof, false, nil
|
||||
}
|
||||
|
||||
// prepareEnvironment prepares the environment for compiling standard rule
|
||||
// expressions.
|
||||
func (c *cache) prepareEnvironment(
|
||||
env *cel.Env,
|
||||
fieldDesc protoreflect.FieldDescriptor,
|
||||
rules protoreflect.Message,
|
||||
forItems bool,
|
||||
) (*cel.Env, error) {
|
||||
env, err := env.Extend(
|
||||
cel.Types(rules.Interface()),
|
||||
cel.Variable("this", pvcel.ProtoFieldToType(fieldDesc, true, forItems)),
|
||||
cel.Variable("rules",
|
||||
cel.ObjectType(string(rules.Descriptor().FullName()))),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, &CompilationError{cause: fmt.Errorf(
|
||||
"failed to extend base environment: %w", err)}
|
||||
}
|
||||
return env, nil
|
||||
}
|
||||
|
||||
// loadOrCompileStandardRule loads the precompiled ASTs for the
|
||||
// specified rule field from the Cache if present or precomputes them
|
||||
// otherwise. The result may be empty if the rule does not have associated
|
||||
// CEL expressions.
|
||||
func (c *cache) loadOrCompileStandardRule(
|
||||
env *cel.Env,
|
||||
setOneOf protoreflect.FieldDescriptor,
|
||||
ruleFieldDesc protoreflect.FieldDescriptor,
|
||||
) (set astSet, err error) {
|
||||
if cachedRule, ok := c.cache[ruleFieldDesc]; ok {
|
||||
return cachedRule, nil
|
||||
}
|
||||
predefinedRules, _ := ResolvePredefinedRules(
|
||||
ruleFieldDesc,
|
||||
)
|
||||
exprs := expressions{
|
||||
Rules: predefinedRules.GetCel(),
|
||||
RulePath: []*validate.FieldPathElement{
|
||||
fieldPathElement(setOneOf),
|
||||
fieldPathElement(ruleFieldDesc),
|
||||
},
|
||||
}
|
||||
set, err = compileASTs(exprs, env)
|
||||
if err != nil {
|
||||
return set, &CompilationError{cause: fmt.Errorf(
|
||||
"failed to compile standard rule %q: %w",
|
||||
ruleFieldDesc.FullName(), err)}
|
||||
}
|
||||
c.cache[ruleFieldDesc] = set
|
||||
return set, nil
|
||||
}
|
||||
|
||||
// getExpectedRuleDescriptor produces the field descriptor from the
|
||||
// validate.FieldRules 'type' oneof that matches the provided target
|
||||
// field descriptor. If ok is false, the field does not expect any standard
|
||||
// rules.
|
||||
func (c *cache) getExpectedRuleDescriptor(
|
||||
targetFieldDesc protoreflect.FieldDescriptor,
|
||||
forItems bool,
|
||||
) (expected protoreflect.FieldDescriptor, ok bool) {
|
||||
switch {
|
||||
case targetFieldDesc.IsMap():
|
||||
return mapFieldRulesDesc, true
|
||||
case targetFieldDesc.IsList() && !forItems:
|
||||
return repeatedFieldRulesDesc, true
|
||||
case targetFieldDesc.Kind() == protoreflect.MessageKind,
|
||||
targetFieldDesc.Kind() == protoreflect.GroupKind:
|
||||
expected, ok = expectedWKTRules[targetFieldDesc.Message().FullName()]
|
||||
return expected, ok
|
||||
default:
|
||||
expected, ok = expectedStandardRules[targetFieldDesc.Kind()]
|
||||
return expected, ok
|
||||
}
|
||||
}
|
||||
|
||||
func reparseUnrecognized(
|
||||
extensionTypeResolver protoregistry.ExtensionTypeResolver,
|
||||
reflectMessage protoreflect.Message,
|
||||
) error {
|
||||
if unknown := reflectMessage.GetUnknown(); len(unknown) > 0 {
|
||||
reflectMessage.SetUnknown(nil)
|
||||
options := proto.UnmarshalOptions{
|
||||
Resolver: extensionTypeResolver,
|
||||
Merge: true,
|
||||
}
|
||||
if err := options.Unmarshal(unknown, reflectMessage.Interface()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
56
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/cel.go
vendored
Normal file
56
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/cel.go
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
// celPrograms is an evaluator that executes an expression.ProgramSet.
|
||||
type celPrograms struct {
|
||||
base
|
||||
programSet
|
||||
}
|
||||
|
||||
func (c celPrograms) Evaluate(_ protoreflect.Message, val protoreflect.Value, cfg *validationConfig) error {
|
||||
err := c.Eval(val, cfg)
|
||||
if err != nil {
|
||||
var valErr *ValidationError
|
||||
if errors.As(err, &valErr) {
|
||||
for _, violation := range valErr.Violations {
|
||||
violation.Proto.SetField(c.fieldPath())
|
||||
violation.Proto.SetRule(c.rulePath(violation.Proto.GetRule()))
|
||||
violation.FieldValue = val
|
||||
violation.FieldDescriptor = c.Descriptor
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c celPrograms) EvaluateMessage(msg protoreflect.Message, cfg *validationConfig) error {
|
||||
return c.Eval(protoreflect.ValueOfMessage(msg), cfg)
|
||||
}
|
||||
|
||||
func (c celPrograms) Tautology() bool {
|
||||
return len(c.programSet) == 0
|
||||
}
|
||||
|
||||
var (
|
||||
_ evaluator = celPrograms{}
|
||||
_ messageEvaluator = celPrograms{}
|
||||
)
|
||||
1767
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/cel/library.go
vendored
Normal file
1767
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/cel/library.go
vendored
Normal file
File diff suppressed because it is too large
Load diff
107
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/cel/lookups.go
vendored
Normal file
107
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/cel/lookups.go
vendored
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 cel
|
||||
|
||||
import (
|
||||
"github.com/google/cel-go/cel"
|
||||
"github.com/google/cel-go/common/types"
|
||||
"github.com/google/cel-go/common/types/ref"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
// ProtoFieldToType resolves the CEL value type for the provided
|
||||
// FieldDescriptor. If generic is true, the specific subtypes of map and
|
||||
// repeated fields will be replaced with cel.DynType. If forItems is true, the
|
||||
// type for the repeated list items is returned instead of the list type itself.
|
||||
func ProtoFieldToType(fieldDesc protoreflect.FieldDescriptor, generic, forItems bool) *cel.Type {
|
||||
if !forItems {
|
||||
switch {
|
||||
case fieldDesc.IsMap():
|
||||
if generic {
|
||||
return cel.MapType(cel.DynType, cel.DynType)
|
||||
}
|
||||
keyType := ProtoFieldToType(fieldDesc.MapKey(), false, true)
|
||||
valType := ProtoFieldToType(fieldDesc.MapValue(), false, true)
|
||||
return cel.MapType(keyType, valType)
|
||||
case fieldDesc.IsList():
|
||||
if generic {
|
||||
return cel.ListType(cel.DynType)
|
||||
}
|
||||
itemType := ProtoFieldToType(fieldDesc, false, true)
|
||||
return cel.ListType(itemType)
|
||||
}
|
||||
}
|
||||
|
||||
if fieldDesc.Kind() == protoreflect.MessageKind ||
|
||||
fieldDesc.Kind() == protoreflect.GroupKind {
|
||||
switch fqn := fieldDesc.Message().FullName(); fqn {
|
||||
case "google.protobuf.Any":
|
||||
return cel.AnyType
|
||||
case "google.protobuf.Duration":
|
||||
return cel.DurationType
|
||||
case "google.protobuf.Timestamp":
|
||||
return cel.TimestampType
|
||||
default:
|
||||
return cel.ObjectType(string(fqn))
|
||||
}
|
||||
}
|
||||
return protoKindToType(fieldDesc.Kind())
|
||||
}
|
||||
|
||||
func ProtoFieldToValue(fieldDesc protoreflect.FieldDescriptor, value protoreflect.Value, forItems bool) ref.Val {
|
||||
switch {
|
||||
case fieldDesc.IsList() && !forItems:
|
||||
return types.NewProtoList(types.DefaultTypeAdapter, value.List())
|
||||
default:
|
||||
return types.DefaultTypeAdapter.NativeToValue(value.Interface())
|
||||
}
|
||||
}
|
||||
|
||||
// protoKindToType maps a protoreflect.Kind to a compatible cel.Type.
|
||||
func protoKindToType(kind protoreflect.Kind) *cel.Type {
|
||||
switch kind {
|
||||
case
|
||||
protoreflect.FloatKind,
|
||||
protoreflect.DoubleKind:
|
||||
return cel.DoubleType
|
||||
case
|
||||
protoreflect.Int32Kind,
|
||||
protoreflect.Int64Kind,
|
||||
protoreflect.Sint32Kind,
|
||||
protoreflect.Sint64Kind,
|
||||
protoreflect.Sfixed32Kind,
|
||||
protoreflect.Sfixed64Kind,
|
||||
protoreflect.EnumKind:
|
||||
return cel.IntType
|
||||
case
|
||||
protoreflect.Uint32Kind,
|
||||
protoreflect.Uint64Kind,
|
||||
protoreflect.Fixed32Kind,
|
||||
protoreflect.Fixed64Kind:
|
||||
return cel.UintType
|
||||
case protoreflect.BoolKind:
|
||||
return cel.BoolType
|
||||
case protoreflect.StringKind:
|
||||
return cel.StringType
|
||||
case protoreflect.BytesKind:
|
||||
return cel.BytesType
|
||||
case
|
||||
protoreflect.MessageKind,
|
||||
protoreflect.GroupKind:
|
||||
return cel.DynType
|
||||
default:
|
||||
return cel.DynType
|
||||
}
|
||||
}
|
||||
43
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/compilation_error.go
vendored
Normal file
43
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/compilation_error.go
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import "strings"
|
||||
|
||||
// A CompilationError is returned if a CEL expression cannot be compiled &
|
||||
// type-checked or if invalid standard rules are applied.
|
||||
type CompilationError struct {
|
||||
cause error
|
||||
}
|
||||
|
||||
func (err *CompilationError) Error() string {
|
||||
if err == nil {
|
||||
return ""
|
||||
}
|
||||
var builder strings.Builder
|
||||
_, _ = builder.WriteString("compilation error")
|
||||
if err.cause != nil {
|
||||
_, _ = builder.WriteString(": ")
|
||||
_, _ = builder.WriteString(err.cause.Error())
|
||||
}
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
func (err *CompilationError) Unwrap() error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
return err.cause
|
||||
}
|
||||
123
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/compile.go
vendored
Normal file
123
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/compile.go
vendored
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
|
||||
"github.com/google/cel-go/cel"
|
||||
)
|
||||
|
||||
// An expressions instance is a container for the information needed to compile
|
||||
// and evaluate a list of CEL-based expressions, originating from a
|
||||
// validate.Rule.
|
||||
type expressions struct {
|
||||
Rules []*validate.Rule
|
||||
RulePath []*validate.FieldPathElement
|
||||
}
|
||||
|
||||
// compile produces a ProgramSet from the provided expressions in the given
|
||||
// environment. If the generated cel.Program require cel.ProgramOption params,
|
||||
// use CompileASTs instead with a subsequent call to ASTSet.ToProgramSet.
|
||||
func compile(
|
||||
expressions expressions,
|
||||
env *cel.Env,
|
||||
envOpts ...cel.EnvOption,
|
||||
) (set programSet, err error) {
|
||||
if len(expressions.Rules) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if len(envOpts) > 0 {
|
||||
env, err = env.Extend(envOpts...)
|
||||
if err != nil {
|
||||
return nil, &CompilationError{cause: fmt.Errorf(
|
||||
"failed to extend environment: %w", err)}
|
||||
}
|
||||
}
|
||||
|
||||
set = make(programSet, len(expressions.Rules))
|
||||
for i, rule := range expressions.Rules {
|
||||
set[i].Source = rule
|
||||
set[i].Path = expressions.RulePath
|
||||
|
||||
ast, err := compileAST(env, rule, expressions.RulePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
set[i], err = ast.toProgram(env)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return set, nil
|
||||
}
|
||||
|
||||
// compileASTs parses and type checks a set of expressions, producing a resulting
|
||||
// ASTSet. The value can then be converted to a ProgramSet via
|
||||
// ASTSet.ToProgramSet or ASTSet.ReduceResiduals. Use Compile instead if no
|
||||
// cel.ProgramOption args need to be provided or residuals do not need to be
|
||||
// computed.
|
||||
func compileASTs(
|
||||
expressions expressions,
|
||||
env *cel.Env,
|
||||
envOpts ...cel.EnvOption,
|
||||
) (set astSet, err error) {
|
||||
if len(expressions.Rules) == 0 {
|
||||
return set, nil
|
||||
}
|
||||
|
||||
set = make([]compiledAST, len(expressions.Rules))
|
||||
for i, rule := range expressions.Rules {
|
||||
set[i].Env = env
|
||||
if len(envOpts) > 0 {
|
||||
set[i].Env, err = env.Extend(envOpts...)
|
||||
if err != nil {
|
||||
return set, &CompilationError{cause: fmt.Errorf(
|
||||
"failed to extend environment: %w", err)}
|
||||
}
|
||||
}
|
||||
set[i], err = compileAST(set[i].Env, rule, expressions.RulePath)
|
||||
if err != nil {
|
||||
return set, err
|
||||
}
|
||||
}
|
||||
|
||||
return set, nil
|
||||
}
|
||||
|
||||
func compileAST(env *cel.Env, rule *validate.Rule, rulePath []*validate.FieldPathElement) (out compiledAST, err error) {
|
||||
ast, issues := env.Compile(rule.GetExpression())
|
||||
if err := issues.Err(); err != nil {
|
||||
return out, &CompilationError{cause: fmt.Errorf(
|
||||
"failed to compile expression %s: %w", rule.GetId(), err)}
|
||||
}
|
||||
|
||||
outType := ast.OutputType()
|
||||
if !(outType.IsAssignableType(cel.BoolType) || outType.IsAssignableType(cel.StringType)) {
|
||||
return out, &CompilationError{cause: fmt.Errorf(
|
||||
"expression %s outputs %s, wanted either bool or string",
|
||||
rule.GetId(), outType.String())}
|
||||
}
|
||||
|
||||
return compiledAST{
|
||||
AST: ast,
|
||||
Env: env,
|
||||
Source: rule,
|
||||
Path: rulePath,
|
||||
}, nil
|
||||
}
|
||||
67
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/enum.go
vendored
Normal file
67
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/enum.go
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
//nolint:gochecknoglobals
|
||||
var (
|
||||
enumRuleDescriptor = (&validate.FieldRules{}).ProtoReflect().Descriptor().Fields().ByName("enum")
|
||||
enumDefinedOnlyRuleDescriptor = (&validate.EnumRules{}).ProtoReflect().Descriptor().Fields().ByName("defined_only")
|
||||
enumDefinedOnlyRulePath = validate.FieldPath_builder{
|
||||
Elements: []*validate.FieldPathElement{
|
||||
fieldPathElement(enumRuleDescriptor),
|
||||
fieldPathElement(enumDefinedOnlyRuleDescriptor),
|
||||
},
|
||||
}.Build()
|
||||
)
|
||||
|
||||
// definedEnum is an evaluator that checks an enum value being a member of
|
||||
// the defined values exclusively. This check is handled outside CEL as enums
|
||||
// are completely type erased to integers.
|
||||
type definedEnum struct {
|
||||
base
|
||||
|
||||
// ValueDescriptors captures all the defined values for this enum
|
||||
ValueDescriptors protoreflect.EnumValueDescriptors
|
||||
}
|
||||
|
||||
func (d definedEnum) Evaluate(_ protoreflect.Message, val protoreflect.Value, _ *validationConfig) error {
|
||||
if d.ValueDescriptors.ByNumber(val.Enum()) == nil {
|
||||
return &ValidationError{Violations: []*Violation{{
|
||||
Proto: validate.Violation_builder{
|
||||
Field: d.fieldPath(),
|
||||
Rule: d.rulePath(enumDefinedOnlyRulePath),
|
||||
RuleId: proto.String("enum.defined_only"),
|
||||
Message: proto.String("value must be one of the defined enum values"),
|
||||
}.Build(),
|
||||
FieldValue: val,
|
||||
FieldDescriptor: d.Descriptor,
|
||||
RuleValue: protoreflect.ValueOfBool(true),
|
||||
RuleDescriptor: enumDefinedOnlyRuleDescriptor,
|
||||
}}}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d definedEnum) Tautology() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
var _ evaluator = definedEnum{}
|
||||
181
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/error_utils.go
vendored
Normal file
181
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/error_utils.go
vendored
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/types/descriptorpb"
|
||||
)
|
||||
|
||||
// mergeViolations is a utility to resolve and combine errors resulting from
|
||||
// evaluation. If ok is false, execution of validation should stop (either due
|
||||
// to failFast or the result is not a ValidationError).
|
||||
//
|
||||
//nolint:errorlint
|
||||
func mergeViolations(dst, src error, cfg *validationConfig) (ok bool, err error) {
|
||||
if src == nil {
|
||||
return true, dst
|
||||
}
|
||||
|
||||
srcValErrs, ok := src.(*ValidationError)
|
||||
if !ok {
|
||||
return false, src
|
||||
}
|
||||
|
||||
if dst == nil {
|
||||
return !(cfg.failFast && len(srcValErrs.Violations) > 0), src
|
||||
}
|
||||
|
||||
dstValErrs, ok := dst.(*ValidationError)
|
||||
if !ok {
|
||||
// what should we do here?
|
||||
return false, dst
|
||||
}
|
||||
|
||||
dstValErrs.Violations = append(dstValErrs.Violations, srcValErrs.Violations...)
|
||||
return !(cfg.failFast && len(dstValErrs.Violations) > 0), dst
|
||||
}
|
||||
|
||||
// fieldPathElement returns a buf.validate.FieldPathElement that corresponds to
|
||||
// a provided FieldDescriptor. If the provided FieldDescriptor is nil, nil is
|
||||
// returned.
|
||||
func fieldPathElement(field protoreflect.FieldDescriptor) *validate.FieldPathElement {
|
||||
if field == nil {
|
||||
return nil
|
||||
}
|
||||
element := validate.FieldPathElement_builder{
|
||||
FieldNumber: proto.Int32(int32(field.Number())),
|
||||
FieldType: descriptorpb.FieldDescriptorProto_Type(field.Kind()).Enum(),
|
||||
}
|
||||
if field.IsExtension() {
|
||||
element.FieldName = proto.String(field.TextName())
|
||||
} else {
|
||||
element.FieldName = proto.String(string(field.Name()))
|
||||
}
|
||||
return element.Build()
|
||||
}
|
||||
|
||||
// fieldPath returns a single-element buf.validate.fieldPath corresponding to
|
||||
// the provided FieldDescriptor, or nil if the provided FieldDescriptor is nil.
|
||||
func fieldPath(field protoreflect.FieldDescriptor) *validate.FieldPath {
|
||||
if field == nil {
|
||||
return nil
|
||||
}
|
||||
return validate.FieldPath_builder{
|
||||
Elements: []*validate.FieldPathElement{
|
||||
fieldPathElement(field),
|
||||
},
|
||||
}.Build()
|
||||
}
|
||||
|
||||
// updateViolationPaths modifies the field and rule paths of an error, appending
|
||||
// an element to the end of each field path (if provided) and prepending a list
|
||||
// of elements to the beginning of each rule path (if provided.)
|
||||
//
|
||||
// Note that this function is ordinarily used to append field paths in reverse
|
||||
// order, as the stack bubbles up through the evaluators. Then, at the end, the
|
||||
// path is reversed. Rule paths are generally static, so this optimization isn't
|
||||
// applied for rule paths.
|
||||
func updateViolationPaths(err error, fieldSuffix *validate.FieldPathElement, rulePrefix []*validate.FieldPathElement) {
|
||||
if err == nil || (fieldSuffix == nil && len(rulePrefix) == 0) {
|
||||
return
|
||||
}
|
||||
var valErr *ValidationError
|
||||
if errors.As(err, &valErr) {
|
||||
for _, violation := range valErr.Violations {
|
||||
if fieldSuffix != nil {
|
||||
if violation.Proto.GetField() == nil {
|
||||
violation.Proto.SetField(&validate.FieldPath{})
|
||||
}
|
||||
violation.Proto.GetField().SetElements(
|
||||
append(violation.Proto.GetField().GetElements(), fieldSuffix),
|
||||
)
|
||||
}
|
||||
if len(rulePrefix) != 0 {
|
||||
violation.Proto.GetRule().SetElements(
|
||||
slices.Concat(rulePrefix, violation.Proto.GetRule().GetElements()),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// finalizeViolationPaths reverses all field paths in the error and populates
|
||||
// the deprecated string-based field path.
|
||||
func finalizeViolationPaths(err error) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
var valErr *ValidationError
|
||||
if errors.As(err, &valErr) {
|
||||
for _, violation := range valErr.Violations {
|
||||
if violation.Proto.GetField() != nil {
|
||||
slices.Reverse(violation.Proto.GetField().GetElements())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FieldPathString takes a FieldPath and encodes it to a string-based dotted
|
||||
// field path.
|
||||
func FieldPathString(path *validate.FieldPath) string {
|
||||
var result strings.Builder
|
||||
for i, element := range path.GetElements() {
|
||||
if i > 0 {
|
||||
result.WriteByte('.')
|
||||
}
|
||||
result.WriteString(element.GetFieldName())
|
||||
subscript := element.WhichSubscript()
|
||||
if subscript == validate.FieldPathElement_Subscript_not_set_case {
|
||||
continue
|
||||
}
|
||||
result.WriteByte('[')
|
||||
switch subscript {
|
||||
case validate.FieldPathElement_Index_case:
|
||||
result.WriteString(strconv.FormatUint(element.GetIndex(), 10))
|
||||
case validate.FieldPathElement_BoolKey_case:
|
||||
result.WriteString(strconv.FormatBool(element.GetBoolKey()))
|
||||
case validate.FieldPathElement_IntKey_case:
|
||||
result.WriteString(strconv.FormatInt(element.GetIntKey(), 10))
|
||||
case validate.FieldPathElement_UintKey_case:
|
||||
result.WriteString(strconv.FormatUint(element.GetUintKey(), 10))
|
||||
case validate.FieldPathElement_StringKey_case:
|
||||
result.WriteString(strconv.Quote(element.GetStringKey()))
|
||||
}
|
||||
result.WriteByte(']')
|
||||
}
|
||||
return result.String()
|
||||
}
|
||||
|
||||
// markViolationForKey marks the provided error as being for a map key, by
|
||||
// setting the `for_key` flag on each violation within the validation error.
|
||||
func markViolationForKey(err error) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
var valErr *ValidationError
|
||||
if errors.As(err, &valErr) {
|
||||
for _, violation := range valErr.Violations {
|
||||
violation.Proto.SetForKey(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
102
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/evaluator.go
vendored
Normal file
102
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/evaluator.go
vendored
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
// evaluator defines a validation evaluator. evaluator implementations may elide
|
||||
// type checking of the passed in value, as the types have been guaranteed
|
||||
// during the build phase.
|
||||
type evaluator interface {
|
||||
// Tautology returns true if the evaluator always succeeds.
|
||||
Tautology() bool
|
||||
|
||||
// Evaluate checks that the provided val is valid. Unless failFast is true,
|
||||
// evaluation attempts to find all violations present in val instead of
|
||||
// returning an error on the first violation. The returned error will be one
|
||||
// of the following expected types:
|
||||
//
|
||||
// - errors.ValidationError: val is invalid.
|
||||
// - errors.RuntimeError: error evaluating val determined at runtime.
|
||||
// - errors.CompilationError: this evaluator (or child evaluator) failed to
|
||||
// build. This error is not recoverable.
|
||||
//
|
||||
Evaluate(msg protoreflect.Message, val protoreflect.Value, cfg *validationConfig) error
|
||||
}
|
||||
|
||||
// messageEvaluator is essentially the same as evaluator, but specialized for
|
||||
// messages as an optimization. See evaluator for behavior.
|
||||
type messageEvaluator interface {
|
||||
evaluator
|
||||
|
||||
// EvaluateMessage checks that the provided msg is valid. See
|
||||
// evaluator.Evaluate for behavior
|
||||
EvaluateMessage(msg protoreflect.Message, cfg *validationConfig) error
|
||||
}
|
||||
|
||||
// evaluators are a set of evaluator applied together to a value. Evaluation
|
||||
// merges all errors.ValidationError violations or short-circuits if failFast is
|
||||
// true or a different error is returned.
|
||||
type evaluators []evaluator
|
||||
|
||||
func (e evaluators) Evaluate(msg protoreflect.Message, val protoreflect.Value, cfg *validationConfig) (err error) {
|
||||
var ok bool
|
||||
for _, eval := range e {
|
||||
evalErr := eval.Evaluate(msg, val, cfg)
|
||||
if ok, err = mergeViolations(err, evalErr, cfg); !ok {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (e evaluators) Tautology() bool {
|
||||
for _, eval := range e {
|
||||
if !eval.Tautology() {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// messageEvaluators are a specialization of evaluators. See evaluators for
|
||||
// behavior details.
|
||||
type messageEvaluators []messageEvaluator
|
||||
|
||||
func (m messageEvaluators) Evaluate(val protoreflect.Value, cfg *validationConfig) error {
|
||||
return m.EvaluateMessage(val.Message(), cfg)
|
||||
}
|
||||
|
||||
func (m messageEvaluators) EvaluateMessage(msg protoreflect.Message, cfg *validationConfig) (err error) {
|
||||
var ok bool
|
||||
for _, eval := range m {
|
||||
evalErr := eval.EvaluateMessage(msg, cfg)
|
||||
if ok, err = mergeViolations(err, evalErr, cfg); !ok {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (m messageEvaluators) Tautology() bool {
|
||||
for _, eval := range m {
|
||||
if !eval.Tautology() {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
105
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/field.go
vendored
Normal file
105
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/field.go
vendored
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
//nolint:gochecknoglobals
|
||||
var (
|
||||
requiredRuleDescriptor = (&validate.FieldRules{}).ProtoReflect().Descriptor().Fields().ByName("required")
|
||||
requiredRulePath = validate.FieldPath_builder{
|
||||
Elements: []*validate.FieldPathElement{
|
||||
fieldPathElement(requiredRuleDescriptor),
|
||||
},
|
||||
}.Build()
|
||||
)
|
||||
|
||||
// field performs validation on a single message field, defined by its
|
||||
// descriptor.
|
||||
type field struct {
|
||||
// Value is the evaluator to apply to the field's value
|
||||
Value value
|
||||
// Required indicates that the field must have a set value.
|
||||
Required bool
|
||||
// HasPresence reports whether the field distinguishes between unpopulated
|
||||
// and default values.
|
||||
HasPresence bool
|
||||
// Whether validation should be ignored for certain conditions.
|
||||
Ignore validate.Ignore
|
||||
// Err stores if there was a compilation error constructing this evaluator. It is stored
|
||||
// here so that it can be returned as part of validating this specific field.
|
||||
Err error
|
||||
}
|
||||
|
||||
// shouldIgnoreAlways returns whether this field should always skip validation.
|
||||
// If true, this will take precedence and all checks are skipped.
|
||||
func (f field) shouldIgnoreAlways() bool {
|
||||
return f.Ignore == validate.Ignore_IGNORE_ALWAYS
|
||||
}
|
||||
|
||||
// shouldIgnoreEmpty returns whether this field should skip validation on its zero value.
|
||||
// This field is generally true for nullable fields or fields with the
|
||||
// ignore_empty rule explicitly set.
|
||||
func (f field) shouldIgnoreEmpty() bool {
|
||||
return f.HasPresence || f.Ignore == validate.Ignore_IGNORE_IF_ZERO_VALUE
|
||||
}
|
||||
|
||||
func (f field) Evaluate(_ protoreflect.Message, val protoreflect.Value, cfg *validationConfig) error {
|
||||
return f.EvaluateMessage(val.Message(), cfg)
|
||||
}
|
||||
|
||||
func (f field) EvaluateMessage(msg protoreflect.Message, cfg *validationConfig) (err error) {
|
||||
if f.shouldIgnoreAlways() {
|
||||
return nil
|
||||
}
|
||||
if !cfg.filter.ShouldValidate(msg, f.Value.Descriptor) {
|
||||
return nil
|
||||
}
|
||||
|
||||
if f.Err != nil {
|
||||
return f.Err
|
||||
}
|
||||
|
||||
if f.Required && !msg.Has(f.Value.Descriptor) {
|
||||
return &ValidationError{Violations: []*Violation{{
|
||||
Proto: validate.Violation_builder{
|
||||
Field: fieldPath(f.Value.Descriptor),
|
||||
Rule: prefixRulePath(f.Value.NestedRule, requiredRulePath),
|
||||
RuleId: proto.String("required"),
|
||||
Message: proto.String("value is required"),
|
||||
}.Build(),
|
||||
FieldValue: protoreflect.Value{},
|
||||
FieldDescriptor: f.Value.Descriptor,
|
||||
RuleValue: protoreflect.ValueOfBool(true),
|
||||
RuleDescriptor: requiredRuleDescriptor,
|
||||
}}}
|
||||
}
|
||||
|
||||
if f.shouldIgnoreEmpty() && !msg.Has(f.Value.Descriptor) {
|
||||
return nil
|
||||
}
|
||||
|
||||
return f.Value.EvaluateField(msg, msg.Get(f.Value.Descriptor), cfg, true)
|
||||
}
|
||||
|
||||
func (f field) Tautology() bool {
|
||||
return !f.Required && f.Value.Tautology() && f.Err == nil
|
||||
}
|
||||
|
||||
var _ messageEvaluator = field{}
|
||||
50
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/filter.go
vendored
Normal file
50
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/filter.go
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import "google.golang.org/protobuf/reflect/protoreflect"
|
||||
|
||||
// The Filter interface determines which rules should be validated.
|
||||
type Filter interface {
|
||||
// ShouldValidate returns whether rules for a given message, field, or
|
||||
// oneof should be evaluated. For a message or oneof, this only determines
|
||||
// whether message-level or oneof-level rules should be evaluated, and
|
||||
// ShouldValidate will still be called for each field in the message. If
|
||||
// ShouldValidate returns false for a specific field, all rules nested
|
||||
// in submessages of that field will be skipped as well.
|
||||
// For a message, the message argument provides the message itself. For a
|
||||
// field or oneof, the message argument provides the containing message.
|
||||
ShouldValidate(message protoreflect.Message, descriptor protoreflect.Descriptor) bool
|
||||
}
|
||||
|
||||
// FilterFunc is a function type that implements the Filter interface, as a
|
||||
// convenience for simple filters. A FilterFunc should follow the same semantics
|
||||
// as the ShouldValidate method of Filter.
|
||||
type FilterFunc func(protoreflect.Message, protoreflect.Descriptor) bool
|
||||
|
||||
func (f FilterFunc) ShouldValidate(
|
||||
message protoreflect.Message,
|
||||
descriptor protoreflect.Descriptor,
|
||||
) bool {
|
||||
return f(message, descriptor)
|
||||
}
|
||||
|
||||
type nopFilter struct{}
|
||||
|
||||
func (nopFilter) ShouldValidate(_ protoreflect.Message, _ protoreflect.Descriptor) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
var _ Filter = nopFilter{}
|
||||
93
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/lookups.go
vendored
Normal file
93
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/lookups.go
vendored
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
var (
|
||||
// fieldRulesDesc provides a Descriptor for validate.FieldRules.
|
||||
fieldRulesDesc = (*validate.FieldRules)(nil).ProtoReflect().Descriptor()
|
||||
|
||||
// fieldRulesOneofDesc provides the OneofDescriptor for the type union
|
||||
// in FieldRules.
|
||||
fieldRulesOneofDesc = fieldRulesDesc.Oneofs().ByName("type")
|
||||
|
||||
// mapFieldRulesDesc provides the FieldDescriptor for the map standard
|
||||
// rules.
|
||||
mapFieldRulesDesc = fieldRulesDesc.Fields().ByName("map")
|
||||
|
||||
// repeatedFieldRulesDesc provides the FieldDescriptor for the repeated
|
||||
// standard rules.
|
||||
repeatedFieldRulesDesc = fieldRulesDesc.Fields().ByName("repeated")
|
||||
)
|
||||
|
||||
// expectedStandardRules maps protocol buffer field kinds to their
|
||||
// expected field rules.
|
||||
var expectedStandardRules = map[protoreflect.Kind]protoreflect.FieldDescriptor{
|
||||
protoreflect.FloatKind: fieldRulesDesc.Fields().ByName("float"),
|
||||
protoreflect.DoubleKind: fieldRulesDesc.Fields().ByName("double"),
|
||||
protoreflect.Int32Kind: fieldRulesDesc.Fields().ByName("int32"),
|
||||
protoreflect.Int64Kind: fieldRulesDesc.Fields().ByName("int64"),
|
||||
protoreflect.Uint32Kind: fieldRulesDesc.Fields().ByName("uint32"),
|
||||
protoreflect.Uint64Kind: fieldRulesDesc.Fields().ByName("uint64"),
|
||||
protoreflect.Sint32Kind: fieldRulesDesc.Fields().ByName("sint32"),
|
||||
protoreflect.Sint64Kind: fieldRulesDesc.Fields().ByName("sint64"),
|
||||
protoreflect.Fixed32Kind: fieldRulesDesc.Fields().ByName("fixed32"),
|
||||
protoreflect.Fixed64Kind: fieldRulesDesc.Fields().ByName("fixed64"),
|
||||
protoreflect.Sfixed32Kind: fieldRulesDesc.Fields().ByName("sfixed32"),
|
||||
protoreflect.Sfixed64Kind: fieldRulesDesc.Fields().ByName("sfixed64"),
|
||||
protoreflect.BoolKind: fieldRulesDesc.Fields().ByName("bool"),
|
||||
protoreflect.StringKind: fieldRulesDesc.Fields().ByName("string"),
|
||||
protoreflect.BytesKind: fieldRulesDesc.Fields().ByName("bytes"),
|
||||
protoreflect.EnumKind: fieldRulesDesc.Fields().ByName("enum"),
|
||||
}
|
||||
|
||||
var expectedWKTRules = map[protoreflect.FullName]protoreflect.FieldDescriptor{
|
||||
"google.protobuf.Any": fieldRulesDesc.Fields().ByName("any"),
|
||||
"google.protobuf.Duration": fieldRulesDesc.Fields().ByName("duration"),
|
||||
"google.protobuf.FieldMask": fieldRulesDesc.Fields().ByName("field_mask"),
|
||||
"google.protobuf.Timestamp": fieldRulesDesc.Fields().ByName("timestamp"),
|
||||
}
|
||||
|
||||
// expectedWrapperRules returns the validate.FieldRules field that
|
||||
// is expected for the given wrapper well-known type's full name. If ok is
|
||||
// false, no standard rules exist for that type.
|
||||
func expectedWrapperRules(fqn protoreflect.FullName) (desc protoreflect.FieldDescriptor, ok bool) {
|
||||
switch fqn {
|
||||
case "google.protobuf.BoolValue":
|
||||
return expectedStandardRules[protoreflect.BoolKind], true
|
||||
case "google.protobuf.BytesValue":
|
||||
return expectedStandardRules[protoreflect.BytesKind], true
|
||||
case "google.protobuf.DoubleValue":
|
||||
return expectedStandardRules[protoreflect.DoubleKind], true
|
||||
case "google.protobuf.FloatValue":
|
||||
return expectedStandardRules[protoreflect.FloatKind], true
|
||||
case "google.protobuf.Int32Value":
|
||||
return expectedStandardRules[protoreflect.Int32Kind], true
|
||||
case "google.protobuf.Int64Value":
|
||||
return expectedStandardRules[protoreflect.Int64Kind], true
|
||||
case "google.protobuf.StringValue":
|
||||
return expectedStandardRules[protoreflect.StringKind], true
|
||||
case "google.protobuf.UInt32Value":
|
||||
return expectedStandardRules[protoreflect.Uint32Kind], true
|
||||
case "google.protobuf.UInt64Value":
|
||||
return expectedStandardRules[protoreflect.Uint64Kind], true
|
||||
default:
|
||||
return nil, false
|
||||
}
|
||||
}
|
||||
132
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/map.go
vendored
Normal file
132
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/map.go
vendored
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/types/descriptorpb"
|
||||
)
|
||||
|
||||
//nolint:gochecknoglobals
|
||||
var (
|
||||
mapRuleDescriptor = (&validate.FieldRules{}).ProtoReflect().Descriptor().Fields().ByName("map")
|
||||
mapKeysRuleDescriptor = (&validate.MapRules{}).ProtoReflect().Descriptor().Fields().ByName("keys")
|
||||
mapKeysRulePath = validate.FieldPath_builder{
|
||||
Elements: []*validate.FieldPathElement{
|
||||
fieldPathElement(mapRuleDescriptor),
|
||||
fieldPathElement(mapKeysRuleDescriptor),
|
||||
},
|
||||
}.Build()
|
||||
mapValuesDescriptor = (&validate.MapRules{}).ProtoReflect().Descriptor().Fields().ByName("values")
|
||||
mapValuesRulePath = validate.FieldPath_builder{
|
||||
Elements: []*validate.FieldPathElement{
|
||||
fieldPathElement(mapRuleDescriptor),
|
||||
fieldPathElement(mapValuesDescriptor),
|
||||
},
|
||||
}.Build()
|
||||
)
|
||||
|
||||
// kvPairs performs validation on a map field's KV Pairs.
|
||||
type kvPairs struct {
|
||||
base
|
||||
|
||||
// KeyRules are checked on the map keys
|
||||
KeyRules value
|
||||
// ValueRules are checked on the map values
|
||||
ValueRules value
|
||||
}
|
||||
|
||||
func newKVPairs(valEval *value) kvPairs {
|
||||
return kvPairs{
|
||||
base: newBase(valEval),
|
||||
KeyRules: value{NestedRule: mapKeysRulePath},
|
||||
ValueRules: value{NestedRule: mapValuesRulePath},
|
||||
}
|
||||
}
|
||||
|
||||
func (m kvPairs) Evaluate(msg protoreflect.Message, val protoreflect.Value, cfg *validationConfig) (err error) {
|
||||
var ok bool
|
||||
val.Map().Range(func(key protoreflect.MapKey, value protoreflect.Value) bool {
|
||||
evalErr := m.evalPairs(msg, key, value, cfg)
|
||||
if evalErr != nil {
|
||||
element := validate.FieldPathElement_builder{
|
||||
FieldNumber: proto.Int32(m.FieldPathElement.GetFieldNumber()),
|
||||
FieldType: m.base.FieldPathElement.GetFieldType().Enum(),
|
||||
FieldName: proto.String(m.FieldPathElement.GetFieldName()),
|
||||
}
|
||||
element.KeyType = descriptorpb.FieldDescriptorProto_Type(m.base.Descriptor.MapKey().Kind()).Enum()
|
||||
element.ValueType = descriptorpb.FieldDescriptorProto_Type(m.base.Descriptor.MapValue().Kind()).Enum()
|
||||
switch m.base.Descriptor.MapKey().Kind() {
|
||||
case protoreflect.BoolKind:
|
||||
element.BoolKey = proto.Bool(key.Bool())
|
||||
case protoreflect.Int32Kind, protoreflect.Int64Kind,
|
||||
protoreflect.Sfixed32Kind, protoreflect.Sfixed64Kind,
|
||||
protoreflect.Sint32Kind, protoreflect.Sint64Kind:
|
||||
element.IntKey = proto.Int64(key.Int())
|
||||
case protoreflect.Uint32Kind, protoreflect.Uint64Kind,
|
||||
protoreflect.Fixed32Kind, protoreflect.Fixed64Kind:
|
||||
element.UintKey = proto.Uint64(key.Uint())
|
||||
case protoreflect.StringKind:
|
||||
element.StringKey = proto.String(key.String())
|
||||
case protoreflect.EnumKind, protoreflect.FloatKind, protoreflect.DoubleKind,
|
||||
protoreflect.BytesKind, protoreflect.MessageKind, protoreflect.GroupKind:
|
||||
fallthrough
|
||||
default:
|
||||
err = &CompilationError{cause: fmt.Errorf(
|
||||
"unexpected map key type %s",
|
||||
m.base.Descriptor.MapKey().Kind())}
|
||||
return false
|
||||
}
|
||||
updateViolationPaths(evalErr, element.Build(), m.RulePrefix.GetElements())
|
||||
}
|
||||
ok, err = mergeViolations(err, evalErr, cfg)
|
||||
return ok
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func (m kvPairs) evalPairs(msg protoreflect.Message, key protoreflect.MapKey, value protoreflect.Value, cfg *validationConfig) (err error) {
|
||||
evalErr := m.KeyRules.EvaluateField(msg, key.Value(), cfg, true)
|
||||
markViolationForKey(evalErr)
|
||||
ok, err := mergeViolations(err, evalErr, cfg)
|
||||
if !ok {
|
||||
return err
|
||||
}
|
||||
|
||||
evalErr = m.ValueRules.EvaluateField(msg, value, cfg, true)
|
||||
_, err = mergeViolations(err, evalErr, cfg)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m kvPairs) Tautology() bool {
|
||||
return m.KeyRules.Tautology() &&
|
||||
m.ValueRules.Tautology()
|
||||
}
|
||||
|
||||
func (m kvPairs) formatKey(key any) string {
|
||||
switch k := key.(type) {
|
||||
case string:
|
||||
return strconv.Quote(k)
|
||||
default:
|
||||
return fmt.Sprintf("%v", key)
|
||||
}
|
||||
}
|
||||
|
||||
var _ evaluator = kvPairs{}
|
||||
124
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/message.go
vendored
Normal file
124
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/message.go
vendored
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
// message performs validation on a protoreflect.Message.
|
||||
type message struct {
|
||||
// Err stores if there was a compilation error constructing this evaluator.
|
||||
// It is cached here so that it can be stored in the registry's lookup table.
|
||||
Err error
|
||||
|
||||
// evaluators are the individual evaluators that are applied to a message.
|
||||
evaluators messageEvaluators
|
||||
|
||||
// nestedEvaluators are the evaluators that are applied to nested fields and
|
||||
// oneofs.
|
||||
nestedEvaluators messageEvaluators
|
||||
}
|
||||
|
||||
func (m *message) Evaluate(_ protoreflect.Message, val protoreflect.Value, cfg *validationConfig) error {
|
||||
return m.EvaluateMessage(val.Message(), cfg)
|
||||
}
|
||||
|
||||
func (m *message) EvaluateMessage(msg protoreflect.Message, cfg *validationConfig) error {
|
||||
var (
|
||||
err error
|
||||
ok bool
|
||||
)
|
||||
if cfg.filter.ShouldValidate(msg, msg.Descriptor()) {
|
||||
if m.Err != nil {
|
||||
return m.Err
|
||||
}
|
||||
if ok, err = mergeViolations(err, m.evaluators.EvaluateMessage(msg, cfg), cfg); !ok {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_, err = mergeViolations(err, m.nestedEvaluators.EvaluateMessage(msg, cfg), cfg)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *message) Tautology() bool {
|
||||
// returning false for now to avoid recursive messages causing false positives
|
||||
// on tautology detection.
|
||||
//
|
||||
// TODO: use a more sophisticated method to detect recursions so we can
|
||||
// continue to detect tautologies on message evaluators.
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *message) Append(eval messageEvaluator) {
|
||||
if eval != nil && !eval.Tautology() {
|
||||
m.evaluators = append(m.evaluators, eval)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *message) AppendNested(eval messageEvaluator) {
|
||||
if eval != nil && !eval.Tautology() {
|
||||
m.nestedEvaluators = append(m.nestedEvaluators, eval)
|
||||
}
|
||||
}
|
||||
|
||||
// unknownMessage is a MessageEvaluator for an unknown descriptor. This is
|
||||
// returned only if lazy-building of evaluators has been disabled and an unknown
|
||||
// descriptor is encountered.
|
||||
type unknownMessage struct {
|
||||
desc protoreflect.MessageDescriptor
|
||||
}
|
||||
|
||||
func (u unknownMessage) Err() error {
|
||||
return &CompilationError{cause: fmt.Errorf(
|
||||
"no evaluator available for %s",
|
||||
u.desc.FullName())}
|
||||
}
|
||||
|
||||
func (u unknownMessage) Tautology() bool { return false }
|
||||
|
||||
func (u unknownMessage) Evaluate(_ protoreflect.Message, _ protoreflect.Value, _ *validationConfig) error {
|
||||
return u.Err()
|
||||
}
|
||||
|
||||
func (u unknownMessage) EvaluateMessage(_ protoreflect.Message, _ *validationConfig) error {
|
||||
return u.Err()
|
||||
}
|
||||
|
||||
// embeddedMessage is a wrapper for fields containing messages. It contains data that
|
||||
// may differ per embeddedMessage message so that it is not cached.
|
||||
type embeddedMessage struct {
|
||||
base
|
||||
|
||||
message *message
|
||||
}
|
||||
|
||||
func (m *embeddedMessage) Evaluate(_ protoreflect.Message, val protoreflect.Value, cfg *validationConfig) error {
|
||||
err := m.message.EvaluateMessage(val.Message(), cfg)
|
||||
updateViolationPaths(err, m.FieldPathElement, nil)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *embeddedMessage) Tautology() bool {
|
||||
return m.message.Tautology()
|
||||
}
|
||||
|
||||
var (
|
||||
_ messageEvaluator = (*message)(nil)
|
||||
_ messageEvaluator = (*unknownMessage)(nil)
|
||||
_ evaluator = (*embeddedMessage)(nil)
|
||||
)
|
||||
84
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/message_oneof.go
vendored
Normal file
84
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/message_oneof.go
vendored
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
// messageOneof is a message evaluator that performs validation on the specified
|
||||
// fields, ensuring that only one is set. If `required` is true, it enforces that one of
|
||||
// the fields _must_ be set.
|
||||
type messageOneof struct {
|
||||
Fields []protoreflect.FieldDescriptor
|
||||
Required bool
|
||||
}
|
||||
|
||||
func (o messageOneof) formatFields() string {
|
||||
names := make([]string, len(o.Fields))
|
||||
for idx, fdesc := range o.Fields {
|
||||
names[idx] = string(fdesc.Name())
|
||||
}
|
||||
return strings.Join(names, ", ")
|
||||
}
|
||||
|
||||
func (o messageOneof) Evaluate(_ protoreflect.Message, val protoreflect.Value, cfg *validationConfig) error {
|
||||
return o.EvaluateMessage(val.Message(), cfg)
|
||||
}
|
||||
|
||||
func (o messageOneof) EvaluateMessage(msg protoreflect.Message, cfg *validationConfig) error {
|
||||
if !cfg.filter.ShouldValidate(msg, msg.Descriptor()) {
|
||||
return nil
|
||||
}
|
||||
err := &ValidationError{}
|
||||
if len(o.Fields) > 0 {
|
||||
count := 0
|
||||
for _, fdesc := range o.Fields {
|
||||
if msg.Has(fdesc) {
|
||||
count++
|
||||
}
|
||||
}
|
||||
if count > 1 {
|
||||
err.Violations = append(err.Violations, &Violation{
|
||||
Proto: validate.Violation_builder{
|
||||
RuleId: proto.String("message.oneof"),
|
||||
Message: proto.String(fmt.Sprintf("only one of %s can be set", o.formatFields())),
|
||||
}.Build(),
|
||||
})
|
||||
return err
|
||||
}
|
||||
if o.Required && count != 1 {
|
||||
err.Violations = append(err.Violations, &Violation{
|
||||
Proto: validate.Violation_builder{
|
||||
RuleId: proto.String("message.oneof"),
|
||||
Message: proto.String(fmt.Sprintf("one of %s must be set", o.formatFields())),
|
||||
}.Build(),
|
||||
})
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o messageOneof) Tautology() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
var _ messageEvaluator = messageOneof{}
|
||||
59
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/oneof.go
vendored
Normal file
59
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/oneof.go
vendored
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
// oneof performs validation on a oneof union.
|
||||
type oneof struct {
|
||||
// Descriptor is the OneofDescriptor targeted by this evaluator
|
||||
Descriptor protoreflect.OneofDescriptor
|
||||
// Required indicates that a member of the oneof must be set
|
||||
Required bool
|
||||
}
|
||||
|
||||
func (o oneof) Evaluate(_ protoreflect.Message, val protoreflect.Value, cfg *validationConfig) error {
|
||||
return o.EvaluateMessage(val.Message(), cfg)
|
||||
}
|
||||
|
||||
func (o oneof) EvaluateMessage(msg protoreflect.Message, cfg *validationConfig) error {
|
||||
if !cfg.filter.ShouldValidate(msg, o.Descriptor) ||
|
||||
!o.Required || msg.WhichOneof(o.Descriptor) != nil {
|
||||
return nil
|
||||
}
|
||||
return &ValidationError{Violations: []*Violation{{
|
||||
Proto: validate.Violation_builder{
|
||||
Field: validate.FieldPath_builder{
|
||||
Elements: []*validate.FieldPathElement{
|
||||
validate.FieldPathElement_builder{
|
||||
FieldName: proto.String(string(o.Descriptor.Name())),
|
||||
}.Build(),
|
||||
},
|
||||
}.Build(),
|
||||
RuleId: proto.String("required"),
|
||||
Message: proto.String("exactly one field is required in oneof"),
|
||||
}.Build(),
|
||||
}}}
|
||||
}
|
||||
|
||||
func (o oneof) Tautology() bool {
|
||||
return !o.Required
|
||||
}
|
||||
|
||||
var _ messageEvaluator = oneof{}
|
||||
170
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/option.go
vendored
Normal file
170
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/option.go
vendored
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
// A ValidatorOption modifies the default configuration of a Validator. See the
|
||||
// individual options for their defaults and affects on the fallibility of
|
||||
// configuring a Validator.
|
||||
type ValidatorOption interface {
|
||||
applyToValidator(cfg *config)
|
||||
}
|
||||
|
||||
// WithMessages allows warming up the Validator with messages that are
|
||||
// expected to be validated. Messages included transitively (i.e., fields with
|
||||
// message values) are automatically handled.
|
||||
func WithMessages(messages ...proto.Message) ValidatorOption {
|
||||
desc := make([]protoreflect.MessageDescriptor, len(messages))
|
||||
for i, msg := range messages {
|
||||
desc[i] = msg.ProtoReflect().Descriptor()
|
||||
}
|
||||
return WithMessageDescriptors(desc...)
|
||||
}
|
||||
|
||||
// WithMessageDescriptors allows warming up the Validator with message
|
||||
// descriptors that are expected to be validated. Messages included transitively
|
||||
// (i.e., fields with message values) are automatically handled.
|
||||
func WithMessageDescriptors(descriptors ...protoreflect.MessageDescriptor) ValidatorOption {
|
||||
return &messageDescriptorsOption{descriptors}
|
||||
}
|
||||
|
||||
// WithDisableLazy prevents the Validator from lazily building validation logic
|
||||
// for a message it has not encountered before. Disabling lazy logic
|
||||
// additionally eliminates any internal locking as the validator becomes
|
||||
// read-only.
|
||||
//
|
||||
// Note: All expected messages must be provided by WithMessages or
|
||||
// WithMessageDescriptors during initialization.
|
||||
func WithDisableLazy() ValidatorOption {
|
||||
return &disableLazyOption{}
|
||||
}
|
||||
|
||||
// WithExtensionTypeResolver specifies a resolver to use when reparsing unknown
|
||||
// extension types. When dealing with dynamic file descriptor sets, passing this
|
||||
// option will allow extensions to be resolved using a custom resolver.
|
||||
//
|
||||
// To ignore unknown extension fields, use the [WithAllowUnknownFields] option.
|
||||
// Note that this may result in messages being treated as valid even though not
|
||||
// all rules are being applied.
|
||||
func WithExtensionTypeResolver(extensionTypeResolver protoregistry.ExtensionTypeResolver) ValidatorOption {
|
||||
return &extensionTypeResolverOption{extensionTypeResolver}
|
||||
}
|
||||
|
||||
// WithAllowUnknownFields specifies if the presence of unknown field rules
|
||||
// should cause compilation to fail with an error. When set to false, an unknown
|
||||
// field will simply be ignored, which will cause rules to silently not be
|
||||
// applied. This condition may occur if a predefined rule definition isn't
|
||||
// present in the extension type resolver, or when passing dynamic messages with
|
||||
// standard rules defined in a newer version of protovalidate. The default
|
||||
// value is false, to prevent silently-incorrect validation from occurring.
|
||||
func WithAllowUnknownFields() ValidatorOption {
|
||||
return &allowUnknownFieldsOption{}
|
||||
}
|
||||
|
||||
// A ValidationOption specifies per-validation configuration. See the individual
|
||||
// options for their defaults and effects.
|
||||
type ValidationOption interface {
|
||||
applyToValidation(cfg *validationConfig)
|
||||
}
|
||||
|
||||
// WithFilter specifies a filter to use for this validation. A filter can
|
||||
// control which fields are evaluated by the validator.
|
||||
func WithFilter(filter Filter) ValidationOption {
|
||||
return &filterOption{filter}
|
||||
}
|
||||
|
||||
// Option implements both [ValidatorOption] and [ValidationOption], so it can be
|
||||
// applied both to validator instances as well as individual validations.
|
||||
type Option interface {
|
||||
ValidatorOption
|
||||
ValidationOption
|
||||
}
|
||||
|
||||
// WithFailFast specifies whether validation should fail on the first rule
|
||||
// violation encountered or if all violations should be accumulated. By default,
|
||||
// all violations are accumulated.
|
||||
func WithFailFast() Option {
|
||||
return &failFastOption{}
|
||||
}
|
||||
|
||||
// WithNowFunc specifies the function used to derive the `now` variable in CEL
|
||||
// expressions. By default, [timestamppb.Now] is used.
|
||||
func WithNowFunc(fn func() *timestamppb.Timestamp) Option {
|
||||
return nowFuncOption(fn)
|
||||
}
|
||||
|
||||
type messageDescriptorsOption struct {
|
||||
descriptors []protoreflect.MessageDescriptor
|
||||
}
|
||||
|
||||
func (o *messageDescriptorsOption) applyToValidator(cfg *config) {
|
||||
cfg.desc = append(cfg.desc, o.descriptors...)
|
||||
}
|
||||
|
||||
type disableLazyOption struct{}
|
||||
|
||||
func (o *disableLazyOption) applyToValidator(cfg *config) {
|
||||
cfg.disableLazy = true
|
||||
}
|
||||
|
||||
type extensionTypeResolverOption struct {
|
||||
extensionTypeResolver protoregistry.ExtensionTypeResolver
|
||||
}
|
||||
|
||||
func (o *extensionTypeResolverOption) applyToValidator(cfg *config) {
|
||||
cfg.extensionTypeResolver = o.extensionTypeResolver
|
||||
}
|
||||
|
||||
type allowUnknownFieldsOption struct{}
|
||||
|
||||
func (o *allowUnknownFieldsOption) applyToValidator(cfg *config) {
|
||||
cfg.allowUnknownFields = true
|
||||
}
|
||||
|
||||
type filterOption struct{ filter Filter }
|
||||
|
||||
func (o *filterOption) applyToValidation(cfg *validationConfig) {
|
||||
if o.filter == nil {
|
||||
cfg.filter = nopFilter{}
|
||||
} else {
|
||||
cfg.filter = o.filter
|
||||
}
|
||||
}
|
||||
|
||||
type failFastOption struct{}
|
||||
|
||||
func (o *failFastOption) applyToValidator(cfg *config) {
|
||||
cfg.failFast = true
|
||||
}
|
||||
|
||||
func (o *failFastOption) applyToValidation(cfg *validationConfig) {
|
||||
cfg.failFast = true
|
||||
}
|
||||
|
||||
type nowFuncOption func() *timestamppb.Timestamp
|
||||
|
||||
func (o nowFuncOption) applyToValidator(cfg *config) {
|
||||
cfg.nowFn = o
|
||||
}
|
||||
|
||||
func (o nowFuncOption) applyToValidation(cfg *validationConfig) {
|
||||
cfg.nowFn = o
|
||||
}
|
||||
167
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/program.go
vendored
Normal file
167
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/program.go
vendored
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
|
||||
"github.com/google/cel-go/cel"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
//nolint:gochecknoglobals // amortized, eliminates allocations for all CEL programs
|
||||
var globalVarPool = &variablePool{New: func() any { return &variable{} }}
|
||||
|
||||
//nolint:gochecknoglobals // amortized, eliminates allocations for all CEL programs
|
||||
var globalNowPool = &nowPool{New: func() any { return &now{} }}
|
||||
|
||||
// programSet is a list of compiledProgram expressions that are evaluated
|
||||
// together with the same input value. All expressions in a programSet may refer
|
||||
// to a `this` variable.
|
||||
type programSet []compiledProgram
|
||||
|
||||
// Eval applies the contained expressions to the provided `this` val, returning
|
||||
// either *errors.ValidationError if the input is invalid or errors.RuntimeError
|
||||
// if there is a type or range error. If failFast is true, execution stops at
|
||||
// the first failed expression.
|
||||
func (s programSet) Eval(val protoreflect.Value, cfg *validationConfig) error {
|
||||
binding := s.bindThis(val.Interface())
|
||||
defer globalVarPool.Put(binding)
|
||||
|
||||
var violations []*Violation
|
||||
for _, expr := range s {
|
||||
violation, err := expr.eval(binding, cfg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if violation != nil {
|
||||
violations = append(violations, violation)
|
||||
if cfg.failFast {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(violations) > 0 {
|
||||
return &ValidationError{Violations: violations}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s programSet) bindThis(val any) *variable {
|
||||
binding := globalVarPool.Get()
|
||||
binding.Name = "this"
|
||||
|
||||
switch value := val.(type) {
|
||||
case protoreflect.Message:
|
||||
binding.Val = value.Interface()
|
||||
case protoreflect.Map:
|
||||
// TODO: expensive to create this copy, but getting this into a ref.Val with
|
||||
// traits.Mapper is not terribly feasible from this type.
|
||||
bindingVal := make(map[any]any, value.Len())
|
||||
value.Range(func(key protoreflect.MapKey, value protoreflect.Value) bool {
|
||||
// Cel operates on 64-bit integers, so if our map type is 32-bit, we
|
||||
// need to widen to a 64-bit type in the binding due to our usage of
|
||||
// a map[any]any.
|
||||
switch key.Interface().(type) {
|
||||
case int32:
|
||||
bindingVal[key.Int()] = value.Interface()
|
||||
case uint32:
|
||||
bindingVal[key.Uint()] = value.Interface()
|
||||
default:
|
||||
bindingVal[key.Interface()] = value.Interface()
|
||||
}
|
||||
return true
|
||||
})
|
||||
binding.Val = bindingVal
|
||||
default:
|
||||
binding.Val = value
|
||||
}
|
||||
|
||||
return binding
|
||||
}
|
||||
|
||||
// compiledProgram is a parsed and type-checked cel.Program along with the
|
||||
// source Expression.
|
||||
type compiledProgram struct {
|
||||
Program cel.Program
|
||||
Rules protoreflect.Message
|
||||
Source *validate.Rule
|
||||
Path []*validate.FieldPathElement
|
||||
Value protoreflect.Value
|
||||
Descriptor protoreflect.FieldDescriptor
|
||||
}
|
||||
|
||||
//nolint:nilnil // non-existence of violations is intentional
|
||||
func (expr compiledProgram) eval(bindings *variable, cfg *validationConfig) (*Violation, error) {
|
||||
now := globalNowPool.Get(cfg.nowFn)
|
||||
defer globalNowPool.Put(now)
|
||||
bindings.Next = &variable{
|
||||
Next: now,
|
||||
Name: "rules",
|
||||
Val: expr.Rules,
|
||||
}
|
||||
|
||||
value, _, err := expr.Program.Eval(bindings)
|
||||
if err != nil {
|
||||
return nil, &RuntimeError{cause: fmt.Errorf(
|
||||
"error evaluating %s: %w", expr.Source.GetId(), err)}
|
||||
}
|
||||
switch val := value.Value().(type) {
|
||||
case string:
|
||||
if val == "" {
|
||||
return nil, nil
|
||||
}
|
||||
return &Violation{
|
||||
Proto: validate.Violation_builder{
|
||||
Rule: expr.rulePath(),
|
||||
RuleId: proto.String(expr.Source.GetId()),
|
||||
Message: proto.String(val),
|
||||
}.Build(),
|
||||
RuleValue: expr.Value,
|
||||
RuleDescriptor: expr.Descriptor,
|
||||
}, nil
|
||||
case bool:
|
||||
if val {
|
||||
return nil, nil
|
||||
}
|
||||
message := expr.Source.GetMessage()
|
||||
if message == "" {
|
||||
message = fmt.Sprintf("%q returned false", expr.Source.GetExpression())
|
||||
}
|
||||
return &Violation{
|
||||
Proto: validate.Violation_builder{
|
||||
Rule: expr.rulePath(),
|
||||
RuleId: proto.String(expr.Source.GetId()),
|
||||
Message: proto.String(message),
|
||||
}.Build(),
|
||||
RuleValue: expr.Value,
|
||||
RuleDescriptor: expr.Descriptor,
|
||||
}, nil
|
||||
default:
|
||||
return nil, &RuntimeError{cause: fmt.Errorf(
|
||||
"resolved to an unexpected type %T", val)}
|
||||
}
|
||||
}
|
||||
|
||||
func (expr compiledProgram) rulePath() *validate.FieldPath {
|
||||
if len(expr.Path) > 0 {
|
||||
return validate.FieldPath_builder{Elements: expr.Path}.Build()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
75
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/repeated.go
vendored
Normal file
75
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/repeated.go
vendored
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
//nolint:gochecknoglobals
|
||||
var (
|
||||
repeatedRuleDescriptor = (&validate.FieldRules{}).ProtoReflect().Descriptor().Fields().ByName("repeated")
|
||||
repeatedItemsRuleDescriptor = (&validate.RepeatedRules{}).ProtoReflect().Descriptor().Fields().ByName("items")
|
||||
repeatedItemsRulePath = validate.FieldPath_builder{
|
||||
Elements: []*validate.FieldPathElement{
|
||||
fieldPathElement(repeatedRuleDescriptor),
|
||||
fieldPathElement(repeatedItemsRuleDescriptor),
|
||||
},
|
||||
}.Build()
|
||||
)
|
||||
|
||||
// listItems performs validation on the elements of a repeated field.
|
||||
type listItems struct {
|
||||
base
|
||||
|
||||
// ItemRules are checked on every item of the list
|
||||
ItemRules value
|
||||
}
|
||||
|
||||
func newListItems(valEval *value) listItems {
|
||||
return listItems{
|
||||
base: newBase(valEval),
|
||||
ItemRules: value{NestedRule: repeatedItemsRulePath},
|
||||
}
|
||||
}
|
||||
|
||||
func (r listItems) Evaluate(msg protoreflect.Message, val protoreflect.Value, cfg *validationConfig) error {
|
||||
list := val.List()
|
||||
var ok bool
|
||||
var err error
|
||||
for i := range list.Len() {
|
||||
itemErr := r.ItemRules.EvaluateField(msg, list.Get(i), cfg, true)
|
||||
if itemErr != nil {
|
||||
updateViolationPaths(itemErr, validate.FieldPathElement_builder{
|
||||
FieldNumber: proto.Int32(r.FieldPathElement.GetFieldNumber()),
|
||||
FieldType: r.base.FieldPathElement.GetFieldType().Enum(),
|
||||
FieldName: proto.String(r.FieldPathElement.GetFieldName()),
|
||||
Index: proto.Uint64(uint64(i)), //nolint:gosec // indices are guaranteed to be non-negative
|
||||
}.Build(), r.RulePrefix.GetElements())
|
||||
}
|
||||
if ok, err = mergeViolations(err, itemErr, cfg); !ok {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (r listItems) Tautology() bool {
|
||||
return r.ItemRules.Tautology()
|
||||
}
|
||||
|
||||
var _ evaluator = listItems{}
|
||||
153
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/resolve.go
vendored
Normal file
153
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/resolve.go
vendored
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
)
|
||||
|
||||
//nolint:gochecknoglobals // static data, only want single instance
|
||||
var resolver = newExtensionResolver()
|
||||
|
||||
// ResolveMessageRules returns the ResolveMessageRules option set for the MessageDescriptor.
|
||||
func ResolveMessageRules(desc protoreflect.MessageDescriptor) (*validate.MessageRules, error) {
|
||||
return resolve[*validate.MessageRules](desc.Options(), validate.E_Message)
|
||||
}
|
||||
|
||||
// ResolveOneofRules returns the ResolveOneofRules option set for the OneofDescriptor.
|
||||
func ResolveOneofRules(desc protoreflect.OneofDescriptor) (*validate.OneofRules, error) {
|
||||
return resolve[*validate.OneofRules](desc.Options(), validate.E_Oneof)
|
||||
}
|
||||
|
||||
// ResolveFieldRules returns the ResolveFieldRules option set for the FieldDescriptor.
|
||||
func ResolveFieldRules(desc protoreflect.FieldDescriptor) (*validate.FieldRules, error) {
|
||||
return resolve[*validate.FieldRules](desc.Options(), validate.E_Field)
|
||||
}
|
||||
|
||||
// ResolvePredefinedRules returns the ResolvePredefinedRules option set for the
|
||||
// FieldDescriptor. Note that this value is only meaningful if it is set on a
|
||||
// field or extension of a field rule message. This method is provided for
|
||||
// convenience.
|
||||
func ResolvePredefinedRules(desc protoreflect.FieldDescriptor) (*validate.PredefinedRules, error) {
|
||||
return resolve[*validate.PredefinedRules](desc.Options(), validate.E_Predefined)
|
||||
}
|
||||
|
||||
// resolve resolves extensions without using [proto.GetExtension], in case the
|
||||
// underlying type of the extension is not the concrete type expected by the
|
||||
// library. In some cases, particularly when using a dynamic descriptor set, the
|
||||
// underlying extension value's type will be a dynamicpb.Message. In some cases,
|
||||
// the extension may not be resolved at all. This function handles reparsing the
|
||||
// fields as needed to get it into the right concrete message. Resolve does not
|
||||
// modify the input protobuf message, so it can be used concurrently.
|
||||
func resolve[C proto.Message](
|
||||
options proto.Message,
|
||||
extensionType protoreflect.ExtensionType,
|
||||
) (typedMessage C, err error) {
|
||||
var nilMessage C
|
||||
message, err := resolver.resolve(options, extensionType)
|
||||
if err != nil {
|
||||
return nilMessage, err
|
||||
}
|
||||
if message == nil {
|
||||
return nilMessage, nil
|
||||
} else if typedMessage, ok := message.(C); ok {
|
||||
return typedMessage, nil
|
||||
}
|
||||
typedMessage, _ = typedMessage.ProtoReflect().New().Interface().(C)
|
||||
b, err := proto.Marshal(message)
|
||||
if err != nil {
|
||||
return nilMessage, err
|
||||
}
|
||||
err = proto.Unmarshal(b, typedMessage)
|
||||
if err != nil {
|
||||
return nilMessage, err
|
||||
}
|
||||
return typedMessage, nil
|
||||
}
|
||||
|
||||
// extensionResolver implements most of the logic of resolving protovalidate
|
||||
// extensions.
|
||||
type extensionResolver struct {
|
||||
// types is a types that just contains the protovalidate extensions.
|
||||
types *protoregistry.Types
|
||||
}
|
||||
|
||||
// newExtensionResolver creates a new extension resolver. This is only called at
|
||||
// init and will panic if it fails.
|
||||
func newExtensionResolver() extensionResolver {
|
||||
resolver := extensionResolver{
|
||||
types: &protoregistry.Types{},
|
||||
}
|
||||
resolver.register(validate.E_Field)
|
||||
resolver.register(validate.E_Message)
|
||||
resolver.register(validate.E_Oneof)
|
||||
resolver.register(validate.E_Predefined)
|
||||
return resolver
|
||||
}
|
||||
|
||||
// register registers an extension into the resolver's registry. This is only
|
||||
// called at init and will panic if it fails.
|
||||
func (resolver extensionResolver) register(extension protoreflect.ExtensionType) {
|
||||
if err := resolver.types.RegisterExtension(extension); err != nil {
|
||||
//nolint:forbidigo // this needs to be a fatal at init
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// resolve handles the majority of extension resolution logic. This will return
|
||||
// a proto.Message for the given extension if the message has the tag number of
|
||||
// the provided extension. If there was no such tag number present in the known
|
||||
// or unknown fields, this method will return nil. Note that the returned
|
||||
// message may be dynamicpb.Message or another type, and thus may need to still
|
||||
// be reparsed if needed.
|
||||
func (resolver extensionResolver) resolve(
|
||||
options proto.Message,
|
||||
extensionType protoreflect.ExtensionType,
|
||||
) (msg proto.Message, err error) {
|
||||
msg = resolver.getExtension(options, extensionType)
|
||||
if msg == nil {
|
||||
if unknown := options.ProtoReflect().GetUnknown(); len(unknown) > 0 {
|
||||
reparsedOptions := options.ProtoReflect().Type().New().Interface()
|
||||
if err = (proto.UnmarshalOptions{
|
||||
Resolver: resolver.types,
|
||||
}).Unmarshal(unknown, reparsedOptions); err == nil {
|
||||
msg = resolver.getExtension(reparsedOptions, extensionType)
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return msg, nil
|
||||
}
|
||||
|
||||
// getExtension gets the extension extensionType on message, or if it is not
|
||||
// found, nil. Unlike proto.GetExtension, this method will not panic if the
|
||||
// runtime type of the extension is unexpected and returns nil if the extension
|
||||
// is not present.
|
||||
func (resolver extensionResolver) getExtension(
|
||||
message proto.Message,
|
||||
extensionType protoreflect.ExtensionType,
|
||||
) proto.Message {
|
||||
reflect := message.ProtoReflect()
|
||||
if reflect.Has(extensionType.TypeDescriptor()) {
|
||||
extension, _ := reflect.Get(extensionType.TypeDescriptor()).Interface().(protoreflect.Message)
|
||||
return extension.Interface()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
45
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/runtime_error.go
vendored
Normal file
45
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/runtime_error.go
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import "strings"
|
||||
|
||||
// A RuntimeError is returned if a valid CEL expression evaluation is terminated.
|
||||
// The two built-in reasons are 'no_matching_overload' when a CEL function has
|
||||
// no overload for the types of the arguments or 'no_such_field' when a map or
|
||||
// message does not contain the desired field.
|
||||
type RuntimeError struct {
|
||||
cause error
|
||||
}
|
||||
|
||||
func (err *RuntimeError) Error() string {
|
||||
if err == nil {
|
||||
return ""
|
||||
}
|
||||
var builder strings.Builder
|
||||
_, _ = builder.WriteString("runtime error")
|
||||
if err.cause != nil {
|
||||
_, _ = builder.WriteString(": ")
|
||||
_, _ = builder.WriteString(err.cause.Error())
|
||||
}
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
func (err *RuntimeError) Unwrap() error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
return err.cause
|
||||
}
|
||||
58
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/validation_error.go
vendored
Normal file
58
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/validation_error.go
vendored
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
|
||||
)
|
||||
|
||||
// A ValidationError is returned if one or more rule violations were
|
||||
// detected.
|
||||
type ValidationError struct {
|
||||
Violations []*Violation
|
||||
}
|
||||
|
||||
func (err *ValidationError) Error() string {
|
||||
if err == nil {
|
||||
return ""
|
||||
}
|
||||
switch len(err.Violations) {
|
||||
case 0:
|
||||
return ""
|
||||
case 1:
|
||||
return "validation error: " + err.Violations[0].String()
|
||||
default:
|
||||
bldr := &strings.Builder{}
|
||||
bldr.WriteString("validation errors:")
|
||||
for _, violation := range err.Violations {
|
||||
bldr.WriteString("\n - ")
|
||||
bldr.WriteString(violation.String())
|
||||
}
|
||||
return bldr.String()
|
||||
}
|
||||
}
|
||||
|
||||
// ToProto converts this error into its proto.Message form.
|
||||
func (err *ValidationError) ToProto() *validate.Violations {
|
||||
violations := &validate.Violations_builder{
|
||||
Violations: make([]*validate.Violation, len(err.Violations)),
|
||||
}
|
||||
for i, violation := range err.Violations {
|
||||
violations.Violations[i] = violation.Proto
|
||||
}
|
||||
return violations.Build()
|
||||
}
|
||||
153
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/validator.go
vendored
Normal file
153
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/validator.go
vendored
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
pvcel "buf.build/go/protovalidate/cel"
|
||||
"github.com/google/cel-go/cel"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
var (
|
||||
getGlobalValidator = sync.OnceValues(func() (Validator, error) { return New() })
|
||||
|
||||
// GlobalValidator provides access to the global Validator instance that is
|
||||
// used by the [Validate] function. This is intended to be used by libraries
|
||||
// that use protovalidate. This Validator can be used as a default when the
|
||||
// user does not specify a Validator instance to use.
|
||||
//
|
||||
// Using the global Validator instance (either through [Validator] or via
|
||||
// GlobalValidator) will result in lower memory usage than using multiple
|
||||
// Validator instances, because each Validator instance has its own caches.
|
||||
GlobalValidator Validator = globalValidator{}
|
||||
)
|
||||
|
||||
// Validator performs validation on any proto.Message values. The Validator is
|
||||
// safe for concurrent use.
|
||||
type Validator interface {
|
||||
// Validate checks that message satisfies its rules. Rules are
|
||||
// defined within the Protobuf file as options from the buf.validate
|
||||
// package. An error is returned if the rules are violated
|
||||
// (ValidationError), the evaluation logic for the message cannot be built
|
||||
// (CompilationError), or there is a type error when attempting to evaluate
|
||||
// a CEL expression associated with the message (RuntimeError).
|
||||
Validate(msg proto.Message, options ...ValidationOption) error
|
||||
}
|
||||
|
||||
// New creates a Validator with the given options. An error may occur in setting
|
||||
// up the CEL execution environment if the configuration is invalid. See the
|
||||
// individual ValidatorOption for how they impact the fallibility of New.
|
||||
func New(options ...ValidatorOption) (Validator, error) {
|
||||
cfg := config{
|
||||
extensionTypeResolver: protoregistry.GlobalTypes,
|
||||
nowFn: timestamppb.Now,
|
||||
}
|
||||
for _, opt := range options {
|
||||
opt.applyToValidator(&cfg)
|
||||
}
|
||||
|
||||
env, err := cel.NewEnv(cel.Lib(pvcel.NewLibrary()))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(
|
||||
"failed to construct CEL environment: %w", err)
|
||||
}
|
||||
|
||||
bldr := newBuilder(
|
||||
env,
|
||||
cfg.disableLazy,
|
||||
cfg.extensionTypeResolver,
|
||||
cfg.allowUnknownFields,
|
||||
cfg.desc...,
|
||||
)
|
||||
|
||||
return &validator{
|
||||
builder: bldr,
|
||||
cfg: &validationConfig{
|
||||
failFast: cfg.failFast,
|
||||
filter: nopFilter{},
|
||||
nowFn: cfg.nowFn,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
type validator struct {
|
||||
builder *builder
|
||||
cfg *validationConfig
|
||||
}
|
||||
|
||||
func (v *validator) Validate(
|
||||
msg proto.Message,
|
||||
options ...ValidationOption,
|
||||
) error {
|
||||
if msg == nil {
|
||||
return nil
|
||||
}
|
||||
cfg := v.cfg
|
||||
if len(options) > 0 {
|
||||
cfg = cfg.clone()
|
||||
for _, opt := range options {
|
||||
opt.applyToValidation(cfg)
|
||||
}
|
||||
}
|
||||
refl := msg.ProtoReflect()
|
||||
eval := v.builder.Load(refl.Descriptor())
|
||||
err := eval.EvaluateMessage(refl, cfg)
|
||||
finalizeViolationPaths(err)
|
||||
return err
|
||||
}
|
||||
|
||||
// Validate uses a global instance of Validator constructed with no ValidatorOptions and
|
||||
// calls its Validate function. For the vast majority of validation cases, using this global
|
||||
// function is safe and acceptable. If you need to provide i.e. a custom
|
||||
// ExtensionTypeResolver, you'll need to construct a Validator.
|
||||
func Validate(msg proto.Message, options ...ValidationOption) error {
|
||||
globalValidator, err := getGlobalValidator()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return globalValidator.Validate(msg, options...)
|
||||
}
|
||||
|
||||
type config struct {
|
||||
failFast bool
|
||||
disableLazy bool
|
||||
desc []protoreflect.MessageDescriptor
|
||||
extensionTypeResolver protoregistry.ExtensionTypeResolver
|
||||
allowUnknownFields bool
|
||||
nowFn func() *timestamppb.Timestamp
|
||||
}
|
||||
|
||||
type validationConfig struct {
|
||||
failFast bool
|
||||
filter Filter
|
||||
nowFn func() *timestamppb.Timestamp
|
||||
}
|
||||
|
||||
func (cfg *validationConfig) clone() *validationConfig {
|
||||
clonedCfg := *cfg
|
||||
return &clonedCfg
|
||||
}
|
||||
|
||||
type globalValidator struct{}
|
||||
|
||||
func (globalValidator) Validate(msg proto.Message, options ...ValidationOption) error {
|
||||
return Validate(msg, options...)
|
||||
}
|
||||
84
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/value.go
vendored
Normal file
84
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/value.go
vendored
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
// value performs validation on any concrete value contained within a singular
|
||||
// field, repeated elements, or the keys/values of a map.
|
||||
type value struct {
|
||||
// Descriptor is the FieldDescriptor targeted by this evaluator
|
||||
Descriptor protoreflect.FieldDescriptor
|
||||
// Rules are the individual evaluators applied to a value
|
||||
Rules evaluators
|
||||
// NestedRules are rules applied to messages nested under a
|
||||
// value.
|
||||
NestedRules evaluators
|
||||
// Zero is the default or zero-value for this value's type
|
||||
Zero protoreflect.Value
|
||||
// NestedRule specifies the nested rule type the value is for.
|
||||
NestedRule *validate.FieldPath
|
||||
// IgnoreEmpty indicates that the Rules should not be applied if the
|
||||
// value is unset or the default (typically zero) value. This only applies to
|
||||
// repeated elements or map keys/values with an ignore_empty rule.
|
||||
IgnoreEmpty bool
|
||||
}
|
||||
|
||||
func (v *value) Evaluate(msg protoreflect.Message, val protoreflect.Value, cfg *validationConfig) error {
|
||||
return v.EvaluateField(msg, val, cfg, cfg.filter.ShouldValidate(msg, v.Descriptor))
|
||||
}
|
||||
|
||||
func (v *value) EvaluateField(
|
||||
msg protoreflect.Message,
|
||||
val protoreflect.Value,
|
||||
cfg *validationConfig,
|
||||
shouldValidate bool,
|
||||
) error {
|
||||
var (
|
||||
err error
|
||||
ok bool
|
||||
)
|
||||
if shouldValidate {
|
||||
if v.IgnoreEmpty && val.Equal(v.Zero) {
|
||||
return nil
|
||||
}
|
||||
if ok, err = mergeViolations(err, v.Rules.Evaluate(msg, val, cfg), cfg); !ok {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_, err = mergeViolations(err, v.NestedRules.Evaluate(msg, val, cfg), cfg)
|
||||
return err
|
||||
}
|
||||
|
||||
func (v *value) Tautology() bool {
|
||||
return v.Rules.Tautology() && v.NestedRules.Tautology()
|
||||
}
|
||||
|
||||
func (v *value) Append(eval evaluator) {
|
||||
if !eval.Tautology() {
|
||||
v.Rules = append(v.Rules, eval)
|
||||
}
|
||||
}
|
||||
|
||||
func (v *value) AppendNested(eval evaluator) {
|
||||
if !eval.Tautology() {
|
||||
v.NestedRules = append(v.NestedRules, eval)
|
||||
}
|
||||
}
|
||||
|
||||
var _ evaluator = (*value)(nil)
|
||||
91
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/variable.go
vendored
Normal file
91
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/variable.go
vendored
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/google/cel-go/interpreter"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
// variable implements interpreter.Activation, providing a lightweight named
|
||||
// variable to cel.Program executions.
|
||||
type variable struct {
|
||||
// Next is the parent activation
|
||||
Next interpreter.Activation
|
||||
// Name is the variable's name
|
||||
Name string
|
||||
// Val is the value for this variable
|
||||
Val any
|
||||
}
|
||||
|
||||
func (v *variable) ResolveName(name string) (any, bool) {
|
||||
switch {
|
||||
case name == v.Name:
|
||||
return v.Val, true
|
||||
case v.Next != nil:
|
||||
return v.Next.ResolveName(name)
|
||||
default:
|
||||
return nil, false
|
||||
}
|
||||
}
|
||||
|
||||
func (v *variable) Parent() interpreter.Activation { return nil }
|
||||
|
||||
type variablePool sync.Pool
|
||||
|
||||
func (p *variablePool) Put(v *variable) {
|
||||
(*sync.Pool)(p).Put(v)
|
||||
}
|
||||
|
||||
func (p *variablePool) Get() *variable {
|
||||
v := (*sync.Pool)(p).Get().(*variable) //nolint:errcheck,forcetypeassert
|
||||
v.Next = nil
|
||||
return v
|
||||
}
|
||||
|
||||
// now implements interpreter.Activation, providing a lazily produced timestamp
|
||||
// for accessing the variable `now` that's constant within an evaluation.
|
||||
type now struct {
|
||||
// TS is the already resolved timestamp. If unset, the field is populated with
|
||||
// the output of nowFn.
|
||||
TS *timestamppb.Timestamp
|
||||
nowFn func() *timestamppb.Timestamp
|
||||
}
|
||||
|
||||
func (n *now) ResolveName(name string) (any, bool) {
|
||||
if name != "now" {
|
||||
return nil, false
|
||||
} else if n.TS == nil {
|
||||
n.TS = n.nowFn()
|
||||
}
|
||||
return n.TS, true
|
||||
}
|
||||
|
||||
func (n *now) Parent() interpreter.Activation { return nil }
|
||||
|
||||
type nowPool sync.Pool
|
||||
|
||||
func (p *nowPool) Put(v *now) {
|
||||
(*sync.Pool)(p).Put(v)
|
||||
}
|
||||
|
||||
func (p *nowPool) Get(nowFn func() *timestamppb.Timestamp) *now {
|
||||
n := (*sync.Pool)(p).Get().(*now) //nolint:errcheck,forcetypeassert
|
||||
n.nowFn = nowFn
|
||||
n.TS = nil
|
||||
return n
|
||||
}
|
||||
76
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/violation.go
vendored
Normal file
76
.gear/predownloaded-development/vendor/buf.build/go/protovalidate/violation.go
vendored
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
// Copyright 2023-2025 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protovalidate
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
// Violation represents a single instance where a validation rule was not met.
|
||||
// It provides information about the field that caused the violation, the
|
||||
// specific unfulfilled rule, and a human-readable error message.
|
||||
type Violation struct {
|
||||
// Proto contains the violation's proto.Message form.
|
||||
Proto *validate.Violation
|
||||
|
||||
// FieldValue contains the value of the specific field that failed
|
||||
// validation. If there was no value, this will contain an invalid value.
|
||||
FieldValue protoreflect.Value
|
||||
|
||||
// FieldDescriptor contains the field descriptor corresponding to the
|
||||
// field that failed validation.
|
||||
FieldDescriptor protoreflect.FieldDescriptor
|
||||
|
||||
// RuleValue contains the value of the rule that specified the failed
|
||||
// rule. Not all rules have a value; only standard and
|
||||
// predefined rules have rule values. In violations caused by other
|
||||
// kinds of rules, like custom contraints, this will contain an
|
||||
// invalid value.
|
||||
RuleValue protoreflect.Value
|
||||
|
||||
// RuleDescriptor contains the field descriptor corresponding to the
|
||||
// rule that failed validation.
|
||||
RuleDescriptor protoreflect.FieldDescriptor
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (v *Violation) String() string {
|
||||
if v == nil {
|
||||
return ""
|
||||
}
|
||||
if v.Proto == nil {
|
||||
// default case so that we don't have an empty string
|
||||
return "[unknown]"
|
||||
}
|
||||
bldr := &strings.Builder{}
|
||||
if fieldPath := FieldPathString(v.Proto.GetField()); fieldPath != "" {
|
||||
bldr.WriteString(fieldPath)
|
||||
bldr.WriteString(": ")
|
||||
}
|
||||
if message := v.Proto.GetMessage(); message != "" {
|
||||
bldr.WriteString(message)
|
||||
} else if ruleID := v.Proto.GetRuleId(); ruleID != "" {
|
||||
bldr.WriteString("[")
|
||||
bldr.WriteString(ruleID)
|
||||
bldr.WriteString("]")
|
||||
} else {
|
||||
// default case
|
||||
bldr.WriteString("[unknown]")
|
||||
}
|
||||
return bldr.String()
|
||||
}
|
||||
1
.gear/predownloaded-development/vendor/buf.build/go/protoyaml/.gitattributes
vendored
Normal file
1
.gear/predownloaded-development/vendor/buf.build/go/protoyaml/.gitattributes
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
internal/gen/**/* linguist-generated=true
|
||||
3
.gear/predownloaded-development/vendor/buf.build/go/protoyaml/.gitignore
vendored
Normal file
3
.gear/predownloaded-development/vendor/buf.build/go/protoyaml/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
/.idea/
|
||||
/.tmp/
|
||||
/internal/cmd/generate-txt-testdata/generate-txt-testdata
|
||||
84
.gear/predownloaded-development/vendor/buf.build/go/protoyaml/.golangci.yml
vendored
Normal file
84
.gear/predownloaded-development/vendor/buf.build/go/protoyaml/.golangci.yml
vendored
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
version: "2"
|
||||
linters:
|
||||
default: all
|
||||
disable:
|
||||
- cyclop # covered by gocyclo
|
||||
- exhaustive
|
||||
- exhaustruct
|
||||
- funlen # rely on code review to limit function length
|
||||
- gochecknoglobals
|
||||
- gocognit # dubious "cognitive overhead" quantification
|
||||
- ireturn # "accept interfaces, return structs" isn't ironclad
|
||||
- lll # don't want hard limits for line length
|
||||
- maintidx # covered by gocyclo
|
||||
- mnd
|
||||
- nlreturn # generous whitespace violates house style
|
||||
- nonamedreturns
|
||||
- testpackage # internal tests are fine
|
||||
- wrapcheck # don't _always_ need to wrap errors
|
||||
- wsl # generous whitespace violates house style
|
||||
settings:
|
||||
depguard:
|
||||
rules:
|
||||
Main:
|
||||
files:
|
||||
- $all
|
||||
- '!$test'
|
||||
allow:
|
||||
- $gostd
|
||||
- github.com/bufbuild/protoyaml-go/decode
|
||||
- buf.build/gen/go/bufbuild/protovalidate
|
||||
- buf.build/go/protovalidate
|
||||
- google.golang.org/protobuf
|
||||
- gopkg.in/yaml.v3
|
||||
errcheck:
|
||||
check-type-assertions: true
|
||||
forbidigo:
|
||||
forbid:
|
||||
- pattern: ^fmt\.Print
|
||||
- pattern: ^log\.
|
||||
- pattern: ^print$
|
||||
- pattern: ^println$
|
||||
- pattern: ^panic$
|
||||
gocyclo:
|
||||
min-complexity: 15
|
||||
godox:
|
||||
keywords:
|
||||
- FIXME
|
||||
varnamelen:
|
||||
ignore-decls:
|
||||
- ok bool
|
||||
- T any
|
||||
- i int
|
||||
- wg sync.WaitGroup
|
||||
exclusions:
|
||||
generated: lax
|
||||
presets:
|
||||
- comments
|
||||
- common-false-positives
|
||||
- legacy
|
||||
- std-error-handling
|
||||
rules:
|
||||
- linters:
|
||||
- nestif
|
||||
path: _test.go
|
||||
- linters:
|
||||
- depguard
|
||||
- forbidigo
|
||||
- revive
|
||||
path: internal/*
|
||||
- linters:
|
||||
- gosec
|
||||
- gosmopolitan
|
||||
- prealloc
|
||||
path: internal/protoyamltest/*
|
||||
- path: (.+)\.go$
|
||||
text: do not define dynamic errors.*
|
||||
issues:
|
||||
max-same-issues: 0
|
||||
formatters:
|
||||
enable:
|
||||
- gci
|
||||
- gofmt
|
||||
exclusions:
|
||||
generated: lax
|
||||
201
.gear/predownloaded-development/vendor/buf.build/go/protoyaml/LICENSE
vendored
Normal file
201
.gear/predownloaded-development/vendor/buf.build/go/protoyaml/LICENSE
vendored
Normal file
|
|
@ -0,0 +1,201 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2023 Buf Technologies, Inc.
|
||||
|
||||
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.
|
||||
91
.gear/predownloaded-development/vendor/buf.build/go/protoyaml/Makefile
vendored
Normal file
91
.gear/predownloaded-development/vendor/buf.build/go/protoyaml/Makefile
vendored
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
# See https://tech.davis-hansson.com/p/make/
|
||||
SHELL := bash
|
||||
.DELETE_ON_ERROR:
|
||||
.SHELLFLAGS := -eu -o pipefail -c
|
||||
.DEFAULT_GOAL := all
|
||||
MAKEFLAGS += --warn-undefined-variables
|
||||
MAKEFLAGS += --no-builtin-rules
|
||||
MAKEFLAGS += --no-print-directory
|
||||
BIN := .tmp/bin
|
||||
export PATH := $(BIN):$(PATH)
|
||||
export GOBIN := $(abspath $(BIN))
|
||||
COPYRIGHT_YEARS := 2023-2024
|
||||
LICENSE_IGNORE := --ignore testdata/
|
||||
|
||||
.PHONY: help
|
||||
help: ## Describe useful make targets
|
||||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "%-30s %s\n", $$1, $$2}'
|
||||
|
||||
.PHONY: all
|
||||
all: ## Build, test, and lint (default)
|
||||
$(MAKE) test
|
||||
$(MAKE) lint
|
||||
|
||||
.PHONY: clean
|
||||
clean: ## Delete intermediate build artifacts
|
||||
@# -X only removes untracked files, -d recurses into directories, -f actually removes files/dirs
|
||||
git clean -Xdf
|
||||
|
||||
.PHONY: test
|
||||
test: build ## Run unit tests
|
||||
go test -vet=off -race -cover ./...
|
||||
|
||||
.PHONY: build
|
||||
build: generate ## Build all packages
|
||||
go build ./...
|
||||
|
||||
.PHONY: lint
|
||||
lint: $(BIN)/golangci-lint $(BIN)/buf ## Lint
|
||||
go vet ./...
|
||||
$(BIN)/golangci-lint fmt --diff
|
||||
$(BIN)/golangci-lint run
|
||||
buf lint
|
||||
buf format -d --exit-code
|
||||
|
||||
.PHONY: lintfix
|
||||
lintfix: $(BIN)/golangci-lint ## Automatically fix some lint errors
|
||||
$(BIN)/golangci-lint fmt
|
||||
$(BIN)/golangci-lint run --fix
|
||||
buf format -w
|
||||
|
||||
.PHONY: install
|
||||
install: ## Install all binaries
|
||||
go install ./...
|
||||
|
||||
.PHONY: generate
|
||||
generate: $(BIN)/license-header $(BIN)/buf ## Regenerate code and licenses
|
||||
rm -rf internal/gen
|
||||
buf generate
|
||||
license-header \
|
||||
--license-type apache \
|
||||
--copyright-holder "Buf Technologies, Inc." \
|
||||
--year-range "$(COPYRIGHT_YEARS)" $(LICENSE_IGNORE)
|
||||
|
||||
.PHONY: golden
|
||||
golden:
|
||||
find internal/testdata -name "*.txt" -type f -delete
|
||||
go run internal/cmd/generate-txt-testdata/main.go internal/testdata
|
||||
|
||||
.PHONY: upgrade
|
||||
upgrade: ## Upgrade dependencies
|
||||
go get -u -t ./...
|
||||
go mod tidy -v
|
||||
buf mod update internal/proto
|
||||
|
||||
.PHONY: checkgenerate
|
||||
checkgenerate:
|
||||
@# Used in CI to verify that `make generate` doesn't produce a diff.
|
||||
test -z "$$(git status --porcelain | tee /dev/stderr)"
|
||||
|
||||
$(BIN):
|
||||
@mkdir -p $(BIN)
|
||||
|
||||
$(BIN)/buf: $(BIN) Makefile
|
||||
go install github.com/bufbuild/buf/cmd/buf@v1.51.0
|
||||
|
||||
$(BIN)/license-header: $(BIN) Makefile
|
||||
go install \
|
||||
github.com/bufbuild/buf/private/pkg/licenseheader/cmd/license-header@v1.51.0
|
||||
|
||||
$(BIN)/golangci-lint: $(BIN) Makefile
|
||||
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.0.2
|
||||
150
.gear/predownloaded-development/vendor/buf.build/go/protoyaml/README.md
vendored
Normal file
150
.gear/predownloaded-development/vendor/buf.build/go/protoyaml/README.md
vendored
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
# ProtoYAML
|
||||
|
||||
[](https://github.com/bufbuild/protoyaml-go/actions/workflows/ci.yaml)
|
||||
[](https://goreportcard.com/report/buf.build/go/protoyaml)
|
||||
[](https://pkg.go.dev/buf.build/go/protoyaml)
|
||||
|
||||
Marshal and unmarshal Protocol Buffers as YAML. Provides fine-grained error details with file, line, column and snippet information.
|
||||
|
||||
Fully compatible with [protojson](https://github.com/protocolbuffers/protobuf-go/tree/master/encoding/protojson).
|
||||
|
||||
## Usage
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"buf.build/go/protoyaml"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Marshal a proto message to YAML.
|
||||
yamlBytes, err := protoyaml.Marshal(
|
||||
&pb.MyMessage{
|
||||
MyField: "hello world",
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Unmarshal a proto message from YAML.
|
||||
options := protoyaml.UnmarshalOptions{
|
||||
Path: "testdata/basic.proto3test.yaml",
|
||||
}
|
||||
var myMessage pb.MyMessage
|
||||
if err := options.Unmarshal(yamlBytes, &myMessage); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
ProtoYAML returns either `nil` or an error with a detailed message. For every error found in the file, the error
|
||||
message includes the file name (if `Path` is set on `UnmarshalOptions`), line number, column number, and snippet
|
||||
of the YAML that caused the error. For example, when unmarshalling the following YAML file:
|
||||
|
||||
```yaml
|
||||
values:
|
||||
- single_bool: true
|
||||
- single_bool: false
|
||||
- single_bool: 1
|
||||
- single_bool: 0
|
||||
- single_bool: "true"
|
||||
- single_bool: "false"
|
||||
- single_bool: True
|
||||
- single_bool: False
|
||||
- single_bool: TRUE
|
||||
- single_bool: FALSE
|
||||
- single_bool: yes
|
||||
- single_bool: no
|
||||
```
|
||||
|
||||
The following errors are returned:
|
||||
|
||||
```
|
||||
testdata/basic.proto3test.yaml:5:18: expected bool, got "1"
|
||||
5 | - single_bool: 1
|
||||
| .................^
|
||||
testdata/basic.proto3test.yaml:6:18: expected bool, got "0"
|
||||
6 | - single_bool: 0
|
||||
| .................^
|
||||
testdata/basic.proto3test.yaml:7:18: expected tag !!bool, got !!str
|
||||
7 | - single_bool: "true"
|
||||
| .................^
|
||||
testdata/basic.proto3test.yaml:8:18: expected tag !!bool, got !!str
|
||||
8 | - single_bool: "false"
|
||||
| .................^
|
||||
testdata/basic.proto3test.yaml:9:18: expected bool, got "True"
|
||||
9 | - single_bool: True
|
||||
| .................^
|
||||
testdata/basic.proto3test.yaml:10:18: expected bool, got "False"
|
||||
10 | - single_bool: False
|
||||
| .................^
|
||||
testdata/basic.proto3test.yaml:11:18: expected bool, got "TRUE"
|
||||
11 | - single_bool: TRUE
|
||||
| .................^
|
||||
testdata/basic.proto3test.yaml:12:18: expected bool, got "FALSE"
|
||||
12 | - single_bool: FALSE
|
||||
| .................^
|
||||
testdata/basic.proto3test.yaml:13:18: expected bool, got "yes"
|
||||
13 | - single_bool: yes
|
||||
| .................^
|
||||
testdata/basic.proto3test.yaml:14:18: expected bool, got "no"
|
||||
14 | - single_bool: no
|
||||
| .................^
|
||||
```
|
||||
|
||||
Only `true` and `false` are valid values for the `single_bool` field.
|
||||
|
||||
For more examples, see the [internal/testdata](internal/testdata) directory.
|
||||
|
||||
## Validation
|
||||
|
||||
ProtoYAML can integrate with external validation libraries such as
|
||||
[Protovalidate](https://github.com/bufbuild/protovalidate-go) to provide additional rich error
|
||||
information. Simply provide a `Validator` to the `UnmarshalOptions`:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"buf.build/go/protoyaml"
|
||||
"buf.build/go/protovalidate"
|
||||
)
|
||||
|
||||
func main() {
|
||||
validator, err := protovalidate.NewValidator()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
var myMessage pb.MyMessage
|
||||
options := protoyaml.UnmarshalOptions{
|
||||
Path: "testdata/basic.proto3test.yaml",
|
||||
Validator: validator,
|
||||
}
|
||||
if err := options.Unmarshal(yamlBytes, &myMessage); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The errors produced by the `Validator` will show up along side the ProtoYAML errors. For example:
|
||||
|
||||
```
|
||||
testdata/validate.validate.yaml:4:18 cases[2].float_gt_lt: value must be greater than 0 and less than 10 (float.gt_lt)
|
||||
4 | - float_gt_lt: 10.5
|
||||
| .................^
|
||||
```
|
||||
|
||||
## Status: Beta
|
||||
|
||||
ProtoYAML is not yet stable. However, the final shape is unlikely to change drastically—future edits will be somewhat minor.
|
||||
|
||||
## Legal
|
||||
|
||||
Offered under the [Apache 2 license](https://github.com/bufbuild/protoyaml-go/blob/main/LICENSE)
|
||||
13
.gear/predownloaded-development/vendor/buf.build/go/protoyaml/buf.gen.yaml
vendored
Normal file
13
.gear/predownloaded-development/vendor/buf.build/go/protoyaml/buf.gen.yaml
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
version: v2
|
||||
managed:
|
||||
enabled: true
|
||||
disable:
|
||||
- file_option: go_package
|
||||
module: buf.build/bufbuild/protovalidate
|
||||
override:
|
||||
- file_option: go_package_prefix
|
||||
value: buf.build/go/protoyaml/internal/gen/proto
|
||||
plugins:
|
||||
- remote: buf.build/protocolbuffers/go:v1.36.6
|
||||
out: internal/gen/proto
|
||||
opt: paths=source_relative
|
||||
6
.gear/predownloaded-development/vendor/buf.build/go/protoyaml/buf.lock
vendored
Normal file
6
.gear/predownloaded-development/vendor/buf.build/go/protoyaml/buf.lock
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# Generated by buf. DO NOT EDIT.
|
||||
version: v2
|
||||
deps:
|
||||
- name: buf.build/bufbuild/protovalidate
|
||||
commit: 7712fb530c574b95bc1d57c0877543c3
|
||||
digest: b5:b3e9c9428384357e3b73e4d5a4614328b0a4b1595b10163bbe9483fa16204749274c41797bd49b0d716479c855aa35c1172a94f471fa120ba8369637fd138829
|
||||
10
.gear/predownloaded-development/vendor/buf.build/go/protoyaml/buf.yaml
vendored
Normal file
10
.gear/predownloaded-development/vendor/buf.build/go/protoyaml/buf.yaml
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
version: v2
|
||||
modules:
|
||||
- path: internal/proto
|
||||
deps:
|
||||
- buf.build/bufbuild/protovalidate
|
||||
lint:
|
||||
except:
|
||||
- FIELD_NOT_REQUIRED
|
||||
ignore:
|
||||
- internal/proto/bufext
|
||||
1488
.gear/predownloaded-development/vendor/buf.build/go/protoyaml/decode.go
vendored
Normal file
1488
.gear/predownloaded-development/vendor/buf.build/go/protoyaml/decode.go
vendored
Normal file
File diff suppressed because it is too large
Load diff
115
.gear/predownloaded-development/vendor/buf.build/go/protoyaml/encode.go
vendored
Normal file
115
.gear/predownloaded-development/vendor/buf.build/go/protoyaml/encode.go
vendored
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
// Copyright 2023-2024 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protoyaml
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
// Marshal marshals the given message to YAML.
|
||||
func Marshal(message proto.Message) ([]byte, error) {
|
||||
return MarshalOptions{}.Marshal(message)
|
||||
}
|
||||
|
||||
// MarshalOptions is a configurable YAML format marshaller.
|
||||
//
|
||||
// It uses similar options to protojson.MarshalOptions.
|
||||
type MarshalOptions struct {
|
||||
// The number of spaces to indent. Passed to yaml.Encoder.SetIndent.
|
||||
// If 0, uses the default indent of yaml.v3.
|
||||
Indent int
|
||||
// AllowPartial allows messages that have missing required fields to marshal
|
||||
// without returning an error.
|
||||
AllowPartial bool
|
||||
// UseProtoNames uses proto field name instead of lowerCamelCase name in YAML
|
||||
// field names.
|
||||
UseProtoNames bool
|
||||
// UseEnumNumbers emits enum values as numbers.
|
||||
UseEnumNumbers bool
|
||||
// EmitUnpopulated specifies whether to emit unpopulated fields.
|
||||
EmitUnpopulated bool
|
||||
// Resolver is used for looking up types when expanding google.protobuf.Any
|
||||
// messages. If nil, this defaults to using protoregistry.GlobalTypes.
|
||||
Resolver interface {
|
||||
protoregistry.ExtensionTypeResolver
|
||||
protoregistry.MessageTypeResolver
|
||||
}
|
||||
}
|
||||
|
||||
// Marshal marshals the given message to YAML using the options in MarshalOptions.
|
||||
// Do not depend on the output to be stable across different versions.
|
||||
func (o MarshalOptions) Marshal(message proto.Message) ([]byte, error) {
|
||||
data, err := protojson.MarshalOptions{
|
||||
AllowPartial: o.AllowPartial,
|
||||
UseProtoNames: o.UseProtoNames,
|
||||
UseEnumNumbers: o.UseEnumNumbers,
|
||||
EmitUnpopulated: o.EmitUnpopulated,
|
||||
Resolver: o.Resolver,
|
||||
}.Marshal(message)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
yamlVal, err := jsonDataToYAML(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Write the JSON back out as YAML
|
||||
buffer := &bytes.Buffer{}
|
||||
encoder := yaml.NewEncoder(buffer)
|
||||
encoder.SetIndent(o.Indent)
|
||||
if err := encoder.Encode(yamlVal); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return buffer.Bytes(), nil
|
||||
}
|
||||
|
||||
func jsonDataToYAML(data []byte) (interface{}, error) {
|
||||
// YAML unmarshal preserves the order of fields, but is more restrictive than JSON.
|
||||
// Prefer it if the data is valid YAML.
|
||||
jsonNode := &yaml.Node{}
|
||||
if err := yaml.Unmarshal(data, jsonNode); err == nil {
|
||||
if jsonNode.Kind == yaml.DocumentNode {
|
||||
jsonNode = jsonNode.Content[0]
|
||||
}
|
||||
clearStyle(jsonNode)
|
||||
return jsonNode, nil
|
||||
}
|
||||
|
||||
// If the data is not valid YAML (e.g. a string contains control characters),
|
||||
// fall back to JSON unmarshal, which loses field order, but is more permissive.
|
||||
var jsonValue interface{}
|
||||
if err := json.Unmarshal(data, &jsonValue); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return jsonValue, nil
|
||||
}
|
||||
|
||||
// clearStyle removes all style information from the node and its children.
|
||||
//
|
||||
// Without this, the returned YAML will look exactly like the JSON input.
|
||||
// TODO: Allow yaml style information to be specified in proto.
|
||||
func clearStyle(node *yaml.Node) {
|
||||
node.Style = 0
|
||||
for _, child := range node.Content {
|
||||
clearStyle(child)
|
||||
}
|
||||
}
|
||||
60
.gear/predownloaded-development/vendor/buf.build/go/protoyaml/errors.go
vendored
Normal file
60
.gear/predownloaded-development/vendor/buf.build/go/protoyaml/errors.go
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
// Copyright 2023-2024 Buf Technologies, Inc.
|
||||
//
|
||||
// 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 protoyaml
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
|
||||
"buf.build/go/protovalidate"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
// nodeError is an error that occurred while processing a specific yaml.Node.
|
||||
type nodeError struct {
|
||||
Node *yaml.Node
|
||||
Path string
|
||||
line string
|
||||
cause error
|
||||
}
|
||||
|
||||
func (n *nodeError) Unwrap() error {
|
||||
return n.cause
|
||||
}
|
||||
|
||||
// DetailedError returns an error message that includes the path and a code snippet, if
|
||||
// the lines of the source code are provided.
|
||||
func (n *nodeError) Error() string {
|
||||
var result strings.Builder
|
||||
result.WriteString(fmt.Sprintf("%s:%d:%d %s\n", n.Path, n.Node.Line, n.Node.Column, n.Unwrap().Error()))
|
||||
if n.line != "" {
|
||||
lineNum := fmt.Sprintf("%4d", n.Node.Line)
|
||||
result.WriteString(fmt.Sprintf("%s | %s\n", lineNum, n.line))
|
||||
marker := strings.Repeat(".", n.Node.Column-1) + "^"
|
||||
result.WriteString(fmt.Sprintf("%s | %s\n", lineNum, marker))
|
||||
}
|
||||
return result.String()
|
||||
}
|
||||
|
||||
// violationError is singe validation violation.
|
||||
type violationError struct {
|
||||
Violation *validate.Violation
|
||||
}
|
||||
|
||||
// Error prints the field path, message, and constraint ID.
|
||||
func (v *violationError) Error() string {
|
||||
return protovalidate.FieldPathString(v.Violation.GetField()) + ": " + v.Violation.GetMessage() + " (" + v.Violation.GetRuleId() + ")"
|
||||
}
|
||||
2
.gear/predownloaded-development/vendor/cel.dev/expr/.bazelversion
vendored
Normal file
2
.gear/predownloaded-development/vendor/cel.dev/expr/.bazelversion
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
7.3.2
|
||||
# Keep this pinned version in parity with cel-go
|
||||
2
.gear/predownloaded-development/vendor/cel.dev/expr/.gitattributes
vendored
Normal file
2
.gear/predownloaded-development/vendor/cel.dev/expr/.gitattributes
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
*.pb.go linguist-generated=true
|
||||
*.pb.go -diff -merge
|
||||
2
.gear/predownloaded-development/vendor/cel.dev/expr/.gitignore
vendored
Normal file
2
.gear/predownloaded-development/vendor/cel.dev/expr/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
bazel-*
|
||||
MODULE.bazel.lock
|
||||
33
.gear/predownloaded-development/vendor/cel.dev/expr/BUILD.bazel
vendored
Normal file
33
.gear/predownloaded-development/vendor/cel.dev/expr/BUILD.bazel
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["notice"]) # Apache 2.0
|
||||
|
||||
go_library(
|
||||
name = "expr",
|
||||
srcs = [
|
||||
"checked.pb.go",
|
||||
"eval.pb.go",
|
||||
"explain.pb.go",
|
||||
"syntax.pb.go",
|
||||
"value.pb.go",
|
||||
],
|
||||
importpath = "cel.dev/expr",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"@org_golang_google_protobuf//reflect/protoreflect",
|
||||
"@org_golang_google_protobuf//runtime/protoimpl",
|
||||
"@org_golang_google_protobuf//types/known/anypb",
|
||||
"@org_golang_google_protobuf//types/known/durationpb",
|
||||
"@org_golang_google_protobuf//types/known/emptypb",
|
||||
"@org_golang_google_protobuf//types/known/structpb",
|
||||
"@org_golang_google_protobuf//types/known/timestamppb",
|
||||
],
|
||||
)
|
||||
|
||||
alias(
|
||||
name = "go_default_library",
|
||||
actual = ":expr",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
25
.gear/predownloaded-development/vendor/cel.dev/expr/CODE_OF_CONDUCT.md
vendored
Normal file
25
.gear/predownloaded-development/vendor/cel.dev/expr/CODE_OF_CONDUCT.md
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# Contributor Code of Conduct
|
||||
## Version 0.1.1 (adapted from 0.3b-angular)
|
||||
|
||||
As contributors and maintainers of the Common Expression Language
|
||||
(CEL) project, we pledge to respect everyone who contributes by
|
||||
posting issues, updating documentation, submitting pull requests,
|
||||
providing feedback in comments, and any other activities.
|
||||
|
||||
Communication through any of CEL's channels (GitHub, Gitter, IRC,
|
||||
mailing lists, Google+, Twitter, etc.) must be constructive and never
|
||||
resort to personal attacks, trolling, public or private harassment,
|
||||
insults, or other unprofessional conduct.
|
||||
|
||||
We promise to extend courtesy and respect to everyone involved in this
|
||||
project regardless of gender, gender identity, sexual orientation,
|
||||
disability, age, race, ethnicity, religion, or level of experience. We
|
||||
expect anyone contributing to the project to do the same.
|
||||
|
||||
If any member of the community violates this code of conduct, the
|
||||
maintainers of the CEL project may take action, removing issues,
|
||||
comments, and PRs or blocking accounts as deemed appropriate.
|
||||
|
||||
If you are subject to or witness unacceptable behavior, or have any
|
||||
other concerns, please email us at
|
||||
[cel-conduct@google.com](mailto:cel-conduct@google.com).
|
||||
32
.gear/predownloaded-development/vendor/cel.dev/expr/CONTRIBUTING.md
vendored
Normal file
32
.gear/predownloaded-development/vendor/cel.dev/expr/CONTRIBUTING.md
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# How to Contribute
|
||||
|
||||
We'd love to accept your patches and contributions to this project. There are a
|
||||
few guidelines you need to follow.
|
||||
|
||||
## Contributor License Agreement
|
||||
|
||||
Contributions to this project must be accompanied by a Contributor License
|
||||
Agreement. You (or your employer) retain the copyright to your contribution,
|
||||
this simply gives us permission to use and redistribute your contributions as
|
||||
part of the project. Head over to <https://cla.developers.google.com/> to see
|
||||
your current agreements on file or to sign a new one.
|
||||
|
||||
You generally only need to submit a CLA once, so if you've already submitted one
|
||||
(even if it was for a different project), you probably don't need to do it
|
||||
again.
|
||||
|
||||
## Code reviews
|
||||
|
||||
All submissions, including submissions by project members, require review. We
|
||||
use GitHub pull requests for this purpose. Consult
|
||||
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
|
||||
information on using pull requests.
|
||||
|
||||
## What to expect from maintainers
|
||||
|
||||
Expect maintainers to respond to new issues or pull requests within a week.
|
||||
For outstanding and ongoing issues and particularly for long-running
|
||||
pull requests, expect the maintainers to review within a week of a
|
||||
contributor asking for a new review. There is no commitment to resolution --
|
||||
merging or closing a pull request, or fixing or closing an issue -- because some
|
||||
issues will require more discussion than others.
|
||||
43
.gear/predownloaded-development/vendor/cel.dev/expr/GOVERNANCE.md
vendored
Normal file
43
.gear/predownloaded-development/vendor/cel.dev/expr/GOVERNANCE.md
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# Project Governance
|
||||
|
||||
This document defines the governance process for the CEL language. CEL is
|
||||
Google-developed, but openly governed. Major contributors to the CEL
|
||||
specification and its corresponding implementations constitute the CEL
|
||||
Language Council. New members may be added by a unanimous vote of the
|
||||
Council.
|
||||
|
||||
The MAINTAINERS.md file lists the members of the CEL Language Council, and
|
||||
unofficially indicates the "areas of expertise" of each member with respect
|
||||
to the publicly available CEL repos.
|
||||
|
||||
## Code Changes
|
||||
|
||||
Code changes must follow the standard pull request (PR) model documented in the
|
||||
CONTRIBUTING.md for each CEL repo. All fixes and features must be reviewed by a
|
||||
maintainer. The maintainer reserves the right to request that any feature
|
||||
request (FR) or PR be reviewed by the language council.
|
||||
|
||||
## Syntax and Semantic Changes
|
||||
|
||||
Syntactic and semantic changes must be reviewed by the CEL Language Council.
|
||||
Maintainers may also request language council review at their discretion.
|
||||
|
||||
The review process is as follows:
|
||||
|
||||
- Create a Feature Request in the CEL-Spec repo. The feature description will
|
||||
serve as an abstract for the detailed design document.
|
||||
- Co-develop a design document with the Language Council.
|
||||
- Once the proposer gives the design document approval, the document will be
|
||||
linked to the FR in the CEL-Spec repo and opened for comments to members of
|
||||
the cel-lang-discuss@googlegroups.com.
|
||||
- The Language Council will review the design doc at the next council meeting
|
||||
(once every three weeks) and the council decision included in the document.
|
||||
|
||||
If the proposal is approved, the spec will be updated by a maintainer (if
|
||||
applicable) and a rationale will be included in the CEL-Spec wiki to ensure
|
||||
future developers may follow CEL's growth and direction over time.
|
||||
|
||||
Approved proposals may be implemented by the proposer or by the maintainers as
|
||||
the parties see fit. At the discretion of the maintainer, changes from the
|
||||
approved design are permitted during implementation if they improve the user
|
||||
experience and clarity of the feature.
|
||||
202
.gear/predownloaded-development/vendor/cel.dev/expr/LICENSE
vendored
Normal file
202
.gear/predownloaded-development/vendor/cel.dev/expr/LICENSE
vendored
Normal file
|
|
@ -0,0 +1,202 @@
|
|||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
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.
|
||||
13
.gear/predownloaded-development/vendor/cel.dev/expr/MAINTAINERS.md
vendored
Normal file
13
.gear/predownloaded-development/vendor/cel.dev/expr/MAINTAINERS.md
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# CEL Language Council
|
||||
|
||||
| Name | Company | Area of Expertise |
|
||||
|-----------------|--------------|-------------------|
|
||||
| Alfred Fuller | Facebook | cel-cpp, cel-spec |
|
||||
| Jim Larson | Google | cel-go, cel-spec |
|
||||
| Matthais Blume | Google | cel-spec |
|
||||
| Tristan Swadell | Google | cel-go, cel-spec |
|
||||
|
||||
## Emeritus
|
||||
|
||||
* Sanjay Ghemawat (Google)
|
||||
* Wolfgang Grieskamp (Facebook)
|
||||
56
.gear/predownloaded-development/vendor/cel.dev/expr/MODULE.bazel
vendored
Normal file
56
.gear/predownloaded-development/vendor/cel.dev/expr/MODULE.bazel
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
module(
|
||||
name = "cel-spec",
|
||||
)
|
||||
|
||||
bazel_dep(
|
||||
name = "bazel_skylib",
|
||||
version = "1.7.1",
|
||||
)
|
||||
bazel_dep(
|
||||
name = "gazelle",
|
||||
version = "0.39.1",
|
||||
repo_name = "bazel_gazelle",
|
||||
)
|
||||
bazel_dep(
|
||||
name = "protobuf",
|
||||
version = "27.1",
|
||||
repo_name = "com_google_protobuf",
|
||||
)
|
||||
bazel_dep(
|
||||
name = "rules_cc",
|
||||
version = "0.0.17",
|
||||
)
|
||||
bazel_dep(
|
||||
name = "rules_go",
|
||||
version = "0.53.0",
|
||||
repo_name = "io_bazel_rules_go",
|
||||
)
|
||||
bazel_dep(
|
||||
name = "rules_java",
|
||||
version = "7.6.5",
|
||||
)
|
||||
bazel_dep(
|
||||
name = "rules_proto",
|
||||
version = "7.0.2",
|
||||
)
|
||||
bazel_dep(
|
||||
name = "rules_python",
|
||||
version = "0.35.0",
|
||||
)
|
||||
|
||||
### PYTHON ###
|
||||
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
|
||||
python.toolchain(
|
||||
ignore_root_user_error = True,
|
||||
python_version = "3.11",
|
||||
)
|
||||
|
||||
go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
|
||||
go_sdk.download(version = "1.23.0")
|
||||
|
||||
go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
|
||||
go_deps.from_file(go_mod = "//:go.mod")
|
||||
use_repo(
|
||||
go_deps,
|
||||
"org_golang_google_protobuf",
|
||||
)
|
||||
71
.gear/predownloaded-development/vendor/cel.dev/expr/README.md
vendored
Normal file
71
.gear/predownloaded-development/vendor/cel.dev/expr/README.md
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
# Common Expression Language
|
||||
|
||||
The Common Expression Language (CEL) implements common semantics for expression
|
||||
evaluation, enabling different applications to more easily interoperate.
|
||||
|
||||
Key Applications
|
||||
|
||||
* Security policy: organizations have complex infrastructure and need common
|
||||
tooling to reason about the system as a whole
|
||||
* Protocols: expressions are a useful data type and require interoperability
|
||||
across programming languages and platforms.
|
||||
|
||||
|
||||
Guiding philosophy:
|
||||
|
||||
1. Keep it small & fast.
|
||||
* CEL evaluates in linear time, is mutation free, and not Turing-complete.
|
||||
This limitation is a feature of the language design, which allows the
|
||||
implementation to evaluate orders of magnitude faster than equivalently
|
||||
sandboxed JavaScript.
|
||||
2. Make it extensible.
|
||||
* CEL is designed to be embedded in applications, and allows for
|
||||
extensibility via its context which allows for functions and data to be
|
||||
provided by the software that embeds it.
|
||||
3. Developer-friendly.
|
||||
* The language is approachable to developers. The initial spec was based
|
||||
on the experience of developing Firebase Rules and usability testing
|
||||
many prior iterations.
|
||||
* The library itself and accompanying toolings should be easy to adopt by
|
||||
teams that seek to integrate CEL into their platforms.
|
||||
|
||||
The required components of a system that supports CEL are:
|
||||
|
||||
* The textual representation of an expression as written by a developer. It is
|
||||
of similar syntax to expressions in C/C++/Java/JavaScript
|
||||
* A representation of the program's abstract syntax tree (AST).
|
||||
* A compiler library that converts the textual representation to the binary
|
||||
representation. This can be done ahead of time (in the control plane) or
|
||||
just before evaluation (in the data plane).
|
||||
* A context containing one or more typed variables, often protobuf messages.
|
||||
Most use-cases will use `attribute_context.proto`
|
||||
* An evaluator library that takes the binary format in the context and
|
||||
produces a result, usually a Boolean.
|
||||
|
||||
For use cases which require persistence or cross-process communcation, it is
|
||||
highly recommended to serialize the type-checked expression as a protocol
|
||||
buffer. The CEL team will maintains canonical protocol buffers for ASTs and
|
||||
will keep these versions identical and wire-compatible in perpetuity:
|
||||
|
||||
* [CEL canonical](https://github.com/google/cel-spec/tree/master/proto/cel/expr)
|
||||
* [CEL v1alpha1](https://github.com/googleapis/googleapis/tree/master/google/api/expr/v1alpha1)
|
||||
|
||||
|
||||
Example of boolean conditions and object construction:
|
||||
|
||||
``` c
|
||||
// Condition
|
||||
account.balance >= transaction.withdrawal
|
||||
|| (account.overdraftProtection
|
||||
&& account.overdraftLimit >= transaction.withdrawal - account.balance)
|
||||
|
||||
// Object construction
|
||||
common.GeoPoint{ latitude: 10.0, longitude: -5.5 }
|
||||
```
|
||||
|
||||
For more detail, see:
|
||||
|
||||
* [Introduction](doc/intro.md)
|
||||
* [Language Definition](doc/langdef.md)
|
||||
|
||||
Released under the [Apache License](LICENSE).
|
||||
145
.gear/predownloaded-development/vendor/cel.dev/expr/WORKSPACE
vendored
Normal file
145
.gear/predownloaded-development/vendor/cel.dev/expr/WORKSPACE
vendored
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
|
||||
http_archive(
|
||||
name = "io_bazel_rules_go",
|
||||
sha256 = "099a9fb96a376ccbbb7d291ed4ecbdfd42f6bc822ab77ae6f1b5cb9e914e94fa",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
|
||||
"https://github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
|
||||
],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "bazel_gazelle",
|
||||
sha256 = "ecba0f04f96b4960a5b250c8e8eeec42281035970aa8852dda73098274d14a1d",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz",
|
||||
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "rules_proto",
|
||||
sha256 = "e017528fd1c91c5a33f15493e3a398181a9e821a804eb7ff5acdd1d2d6c2b18d",
|
||||
strip_prefix = "rules_proto-4.0.0-3.20.0",
|
||||
urls = [
|
||||
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0-3.20.0.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
# googleapis as of 09/16/2024
|
||||
http_archive(
|
||||
name = "com_google_googleapis",
|
||||
strip_prefix = "googleapis-4082d5e51e8481f6ccc384cacd896f4e78f19dee",
|
||||
sha256 = "57319889d47578b3c89bf1b3f34888d796a8913d63b32d750a4cd12ed303c4e8",
|
||||
urls = [
|
||||
"https://github.com/googleapis/googleapis/archive/4082d5e51e8481f6ccc384cacd896f4e78f19dee.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
# protobuf
|
||||
http_archive(
|
||||
name = "com_google_protobuf",
|
||||
sha256 = "8242327e5df8c80ba49e4165250b8f79a76bd11765facefaaecfca7747dc8da2",
|
||||
strip_prefix = "protobuf-3.21.5",
|
||||
urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.21.5.zip"],
|
||||
)
|
||||
|
||||
# googletest
|
||||
http_archive(
|
||||
name = "com_google_googletest",
|
||||
urls = ["https://github.com/google/googletest/archive/master.zip"],
|
||||
strip_prefix = "googletest-master",
|
||||
)
|
||||
|
||||
# gflags
|
||||
http_archive(
|
||||
name = "com_github_gflags_gflags",
|
||||
sha256 = "6e16c8bc91b1310a44f3965e616383dbda48f83e8c1eaa2370a215057b00cabe",
|
||||
strip_prefix = "gflags-77592648e3f3be87d6c7123eb81cbad75f9aef5a",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/gflags/gflags/archive/77592648e3f3be87d6c7123eb81cbad75f9aef5a.tar.gz",
|
||||
"https://github.com/gflags/gflags/archive/77592648e3f3be87d6c7123eb81cbad75f9aef5a.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
# glog
|
||||
http_archive(
|
||||
name = "com_google_glog",
|
||||
sha256 = "1ee310e5d0a19b9d584a855000434bb724aa744745d5b8ab1855c85bff8a8e21",
|
||||
strip_prefix = "glog-028d37889a1e80e8a07da1b8945ac706259e5fd8",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/google/glog/archive/028d37889a1e80e8a07da1b8945ac706259e5fd8.tar.gz",
|
||||
"https://github.com/google/glog/archive/028d37889a1e80e8a07da1b8945ac706259e5fd8.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
# absl
|
||||
http_archive(
|
||||
name = "com_google_absl",
|
||||
strip_prefix = "abseil-cpp-master",
|
||||
urls = ["https://github.com/abseil/abseil-cpp/archive/master.zip"],
|
||||
)
|
||||
|
||||
load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains")
|
||||
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
|
||||
load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")
|
||||
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
|
||||
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
|
||||
|
||||
switched_rules_by_language(
|
||||
name = "com_google_googleapis_imports",
|
||||
cc = True,
|
||||
)
|
||||
|
||||
# Do *not* call *_dependencies(), etc, yet. See comment at the end.
|
||||
|
||||
# Generated Google APIs protos for Golang
|
||||
# Generated Google APIs protos for Golang 08/26/2024
|
||||
go_repository(
|
||||
name = "org_golang_google_genproto_googleapis_api",
|
||||
build_file_proto_mode = "disable_global",
|
||||
importpath = "google.golang.org/genproto/googleapis/api",
|
||||
sum = "h1:YcyjlL1PRr2Q17/I0dPk2JmYS5CDXfcdb2Z3YRioEbw=",
|
||||
version = "v0.0.0-20240826202546-f6391c0de4c7",
|
||||
)
|
||||
|
||||
# Generated Google APIs protos for Golang 08/26/2024
|
||||
go_repository(
|
||||
name = "org_golang_google_genproto_googleapis_rpc",
|
||||
build_file_proto_mode = "disable_global",
|
||||
importpath = "google.golang.org/genproto/googleapis/rpc",
|
||||
sum = "h1:2035KHhUv+EpyB+hWgJnaWKJOdX1E95w2S8Rr4uWKTs=",
|
||||
version = "v0.0.0-20240826202546-f6391c0de4c7",
|
||||
)
|
||||
|
||||
# gRPC deps
|
||||
go_repository(
|
||||
name = "org_golang_google_grpc",
|
||||
build_file_proto_mode = "disable_global",
|
||||
importpath = "google.golang.org/grpc",
|
||||
tag = "v1.49.0",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "org_golang_x_net",
|
||||
importpath = "golang.org/x/net",
|
||||
sum = "h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=",
|
||||
version = "v0.0.0-20190311183353-d8887717615a",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "org_golang_x_text",
|
||||
importpath = "golang.org/x/text",
|
||||
sum = "h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=",
|
||||
version = "v0.3.2",
|
||||
)
|
||||
|
||||
# Run the dependencies at the end. These will silently try to import some
|
||||
# of the above repositories but at different versions, so ours must come first.
|
||||
go_rules_dependencies()
|
||||
go_register_toolchains(version = "1.19.1")
|
||||
gazelle_dependencies()
|
||||
rules_proto_dependencies()
|
||||
rules_proto_toolchains()
|
||||
protobuf_deps()
|
||||
0
.gear/predownloaded-development/vendor/cel.dev/expr/WORKSPACE.bzlmod
vendored
Normal file
0
.gear/predownloaded-development/vendor/cel.dev/expr/WORKSPACE.bzlmod
vendored
Normal file
1231
.gear/predownloaded-development/vendor/cel.dev/expr/checked.pb.go
generated
vendored
Normal file
1231
.gear/predownloaded-development/vendor/cel.dev/expr/checked.pb.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
9
.gear/predownloaded-development/vendor/cel.dev/expr/cloudbuild.yaml
vendored
Normal file
9
.gear/predownloaded-development/vendor/cel.dev/expr/cloudbuild.yaml
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
steps:
|
||||
- name: 'gcr.io/cloud-builders/bazel:7.3.2'
|
||||
entrypoint: bazel
|
||||
args: ['build', '...']
|
||||
id: bazel-build
|
||||
waitFor: ['-']
|
||||
timeout: 15m
|
||||
options:
|
||||
machineType: 'N1_HIGHCPU_32'
|
||||
468
.gear/predownloaded-development/vendor/cel.dev/expr/eval.pb.go
generated
vendored
Normal file
468
.gear/predownloaded-development/vendor/cel.dev/expr/eval.pb.go
generated
vendored
Normal file
|
|
@ -0,0 +1,468 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.10
|
||||
// protoc v5.27.1
|
||||
// source: cel/expr/eval.proto
|
||||
|
||||
package expr
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
anypb "google.golang.org/protobuf/types/known/anypb"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type EvalState struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Values []*ExprValue `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"`
|
||||
Results []*EvalState_Result `protobuf:"bytes,3,rep,name=results,proto3" json:"results,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *EvalState) Reset() {
|
||||
*x = EvalState{}
|
||||
mi := &file_cel_expr_eval_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *EvalState) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*EvalState) ProtoMessage() {}
|
||||
|
||||
func (x *EvalState) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_cel_expr_eval_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use EvalState.ProtoReflect.Descriptor instead.
|
||||
func (*EvalState) Descriptor() ([]byte, []int) {
|
||||
return file_cel_expr_eval_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *EvalState) GetValues() []*ExprValue {
|
||||
if x != nil {
|
||||
return x.Values
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *EvalState) GetResults() []*EvalState_Result {
|
||||
if x != nil {
|
||||
return x.Results
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ExprValue struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Types that are valid to be assigned to Kind:
|
||||
//
|
||||
// *ExprValue_Value
|
||||
// *ExprValue_Error
|
||||
// *ExprValue_Unknown
|
||||
Kind isExprValue_Kind `protobuf_oneof:"kind"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ExprValue) Reset() {
|
||||
*x = ExprValue{}
|
||||
mi := &file_cel_expr_eval_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ExprValue) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ExprValue) ProtoMessage() {}
|
||||
|
||||
func (x *ExprValue) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_cel_expr_eval_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ExprValue.ProtoReflect.Descriptor instead.
|
||||
func (*ExprValue) Descriptor() ([]byte, []int) {
|
||||
return file_cel_expr_eval_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *ExprValue) GetKind() isExprValue_Kind {
|
||||
if x != nil {
|
||||
return x.Kind
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ExprValue) GetValue() *Value {
|
||||
if x != nil {
|
||||
if x, ok := x.Kind.(*ExprValue_Value); ok {
|
||||
return x.Value
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ExprValue) GetError() *ErrorSet {
|
||||
if x != nil {
|
||||
if x, ok := x.Kind.(*ExprValue_Error); ok {
|
||||
return x.Error
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ExprValue) GetUnknown() *UnknownSet {
|
||||
if x != nil {
|
||||
if x, ok := x.Kind.(*ExprValue_Unknown); ok {
|
||||
return x.Unknown
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type isExprValue_Kind interface {
|
||||
isExprValue_Kind()
|
||||
}
|
||||
|
||||
type ExprValue_Value struct {
|
||||
Value *Value `protobuf:"bytes,1,opt,name=value,proto3,oneof"`
|
||||
}
|
||||
|
||||
type ExprValue_Error struct {
|
||||
Error *ErrorSet `protobuf:"bytes,2,opt,name=error,proto3,oneof"`
|
||||
}
|
||||
|
||||
type ExprValue_Unknown struct {
|
||||
Unknown *UnknownSet `protobuf:"bytes,3,opt,name=unknown,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*ExprValue_Value) isExprValue_Kind() {}
|
||||
|
||||
func (*ExprValue_Error) isExprValue_Kind() {}
|
||||
|
||||
func (*ExprValue_Unknown) isExprValue_Kind() {}
|
||||
|
||||
type ErrorSet struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Errors []*Status `protobuf:"bytes,1,rep,name=errors,proto3" json:"errors,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ErrorSet) Reset() {
|
||||
*x = ErrorSet{}
|
||||
mi := &file_cel_expr_eval_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ErrorSet) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ErrorSet) ProtoMessage() {}
|
||||
|
||||
func (x *ErrorSet) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_cel_expr_eval_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ErrorSet.ProtoReflect.Descriptor instead.
|
||||
func (*ErrorSet) Descriptor() ([]byte, []int) {
|
||||
return file_cel_expr_eval_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *ErrorSet) GetErrors() []*Status {
|
||||
if x != nil {
|
||||
return x.Errors
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Status struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
|
||||
Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
|
||||
Details []*anypb.Any `protobuf:"bytes,3,rep,name=details,proto3" json:"details,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Status) Reset() {
|
||||
*x = Status{}
|
||||
mi := &file_cel_expr_eval_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Status) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Status) ProtoMessage() {}
|
||||
|
||||
func (x *Status) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_cel_expr_eval_proto_msgTypes[3]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Status.ProtoReflect.Descriptor instead.
|
||||
func (*Status) Descriptor() ([]byte, []int) {
|
||||
return file_cel_expr_eval_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *Status) GetCode() int32 {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Status) GetMessage() string {
|
||||
if x != nil {
|
||||
return x.Message
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Status) GetDetails() []*anypb.Any {
|
||||
if x != nil {
|
||||
return x.Details
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type UnknownSet struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Exprs []int64 `protobuf:"varint,1,rep,packed,name=exprs,proto3" json:"exprs,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *UnknownSet) Reset() {
|
||||
*x = UnknownSet{}
|
||||
mi := &file_cel_expr_eval_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *UnknownSet) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UnknownSet) ProtoMessage() {}
|
||||
|
||||
func (x *UnknownSet) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_cel_expr_eval_proto_msgTypes[4]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use UnknownSet.ProtoReflect.Descriptor instead.
|
||||
func (*UnknownSet) Descriptor() ([]byte, []int) {
|
||||
return file_cel_expr_eval_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *UnknownSet) GetExprs() []int64 {
|
||||
if x != nil {
|
||||
return x.Exprs
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type EvalState_Result struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Expr int64 `protobuf:"varint,1,opt,name=expr,proto3" json:"expr,omitempty"`
|
||||
Value int64 `protobuf:"varint,2,opt,name=value,proto3" json:"value,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *EvalState_Result) Reset() {
|
||||
*x = EvalState_Result{}
|
||||
mi := &file_cel_expr_eval_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *EvalState_Result) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*EvalState_Result) ProtoMessage() {}
|
||||
|
||||
func (x *EvalState_Result) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_cel_expr_eval_proto_msgTypes[5]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use EvalState_Result.ProtoReflect.Descriptor instead.
|
||||
func (*EvalState_Result) Descriptor() ([]byte, []int) {
|
||||
return file_cel_expr_eval_proto_rawDescGZIP(), []int{0, 0}
|
||||
}
|
||||
|
||||
func (x *EvalState_Result) GetExpr() int64 {
|
||||
if x != nil {
|
||||
return x.Expr
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *EvalState_Result) GetValue() int64 {
|
||||
if x != nil {
|
||||
return x.Value
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_cel_expr_eval_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_cel_expr_eval_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x13cel/expr/eval.proto\x12\bcel.expr\x1a\x19google/protobuf/any.proto\x1a\x14cel/expr/value.proto\"\xa2\x01\n" +
|
||||
"\tEvalState\x12+\n" +
|
||||
"\x06values\x18\x01 \x03(\v2\x13.cel.expr.ExprValueR\x06values\x124\n" +
|
||||
"\aresults\x18\x03 \x03(\v2\x1a.cel.expr.EvalState.ResultR\aresults\x1a2\n" +
|
||||
"\x06Result\x12\x12\n" +
|
||||
"\x04expr\x18\x01 \x01(\x03R\x04expr\x12\x14\n" +
|
||||
"\x05value\x18\x02 \x01(\x03R\x05value\"\x9a\x01\n" +
|
||||
"\tExprValue\x12'\n" +
|
||||
"\x05value\x18\x01 \x01(\v2\x0f.cel.expr.ValueH\x00R\x05value\x12*\n" +
|
||||
"\x05error\x18\x02 \x01(\v2\x12.cel.expr.ErrorSetH\x00R\x05error\x120\n" +
|
||||
"\aunknown\x18\x03 \x01(\v2\x14.cel.expr.UnknownSetH\x00R\aunknownB\x06\n" +
|
||||
"\x04kind\"4\n" +
|
||||
"\bErrorSet\x12(\n" +
|
||||
"\x06errors\x18\x01 \x03(\v2\x10.cel.expr.StatusR\x06errors\"f\n" +
|
||||
"\x06Status\x12\x12\n" +
|
||||
"\x04code\x18\x01 \x01(\x05R\x04code\x12\x18\n" +
|
||||
"\amessage\x18\x02 \x01(\tR\amessage\x12.\n" +
|
||||
"\adetails\x18\x03 \x03(\v2\x14.google.protobuf.AnyR\adetails\"\"\n" +
|
||||
"\n" +
|
||||
"UnknownSet\x12\x14\n" +
|
||||
"\x05exprs\x18\x01 \x03(\x03R\x05exprsB,\n" +
|
||||
"\fdev.cel.exprB\tEvalProtoP\x01Z\fcel.dev/expr\xf8\x01\x01b\x06proto3"
|
||||
|
||||
var (
|
||||
file_cel_expr_eval_proto_rawDescOnce sync.Once
|
||||
file_cel_expr_eval_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_cel_expr_eval_proto_rawDescGZIP() []byte {
|
||||
file_cel_expr_eval_proto_rawDescOnce.Do(func() {
|
||||
file_cel_expr_eval_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_cel_expr_eval_proto_rawDesc), len(file_cel_expr_eval_proto_rawDesc)))
|
||||
})
|
||||
return file_cel_expr_eval_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_cel_expr_eval_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
||||
var file_cel_expr_eval_proto_goTypes = []any{
|
||||
(*EvalState)(nil), // 0: cel.expr.EvalState
|
||||
(*ExprValue)(nil), // 1: cel.expr.ExprValue
|
||||
(*ErrorSet)(nil), // 2: cel.expr.ErrorSet
|
||||
(*Status)(nil), // 3: cel.expr.Status
|
||||
(*UnknownSet)(nil), // 4: cel.expr.UnknownSet
|
||||
(*EvalState_Result)(nil), // 5: cel.expr.EvalState.Result
|
||||
(*Value)(nil), // 6: cel.expr.Value
|
||||
(*anypb.Any)(nil), // 7: google.protobuf.Any
|
||||
}
|
||||
var file_cel_expr_eval_proto_depIdxs = []int32{
|
||||
1, // 0: cel.expr.EvalState.values:type_name -> cel.expr.ExprValue
|
||||
5, // 1: cel.expr.EvalState.results:type_name -> cel.expr.EvalState.Result
|
||||
6, // 2: cel.expr.ExprValue.value:type_name -> cel.expr.Value
|
||||
2, // 3: cel.expr.ExprValue.error:type_name -> cel.expr.ErrorSet
|
||||
4, // 4: cel.expr.ExprValue.unknown:type_name -> cel.expr.UnknownSet
|
||||
3, // 5: cel.expr.ErrorSet.errors:type_name -> cel.expr.Status
|
||||
7, // 6: cel.expr.Status.details:type_name -> google.protobuf.Any
|
||||
7, // [7:7] is the sub-list for method output_type
|
||||
7, // [7:7] is the sub-list for method input_type
|
||||
7, // [7:7] is the sub-list for extension type_name
|
||||
7, // [7:7] is the sub-list for extension extendee
|
||||
0, // [0:7] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_cel_expr_eval_proto_init() }
|
||||
func file_cel_expr_eval_proto_init() {
|
||||
if File_cel_expr_eval_proto != nil {
|
||||
return
|
||||
}
|
||||
file_cel_expr_value_proto_init()
|
||||
file_cel_expr_eval_proto_msgTypes[1].OneofWrappers = []any{
|
||||
(*ExprValue_Value)(nil),
|
||||
(*ExprValue_Error)(nil),
|
||||
(*ExprValue_Unknown)(nil),
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_cel_expr_eval_proto_rawDesc), len(file_cel_expr_eval_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 6,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_cel_expr_eval_proto_goTypes,
|
||||
DependencyIndexes: file_cel_expr_eval_proto_depIdxs,
|
||||
MessageInfos: file_cel_expr_eval_proto_msgTypes,
|
||||
}.Build()
|
||||
File_cel_expr_eval_proto = out.File
|
||||
file_cel_expr_eval_proto_goTypes = nil
|
||||
file_cel_expr_eval_proto_depIdxs = nil
|
||||
}
|
||||
195
.gear/predownloaded-development/vendor/cel.dev/expr/explain.pb.go
generated
vendored
Normal file
195
.gear/predownloaded-development/vendor/cel.dev/expr/explain.pb.go
generated
vendored
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.10
|
||||
// protoc v5.27.1
|
||||
// source: cel/expr/explain.proto
|
||||
|
||||
package expr
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// Deprecated: Marked as deprecated in cel/expr/explain.proto.
|
||||
type Explain struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Values []*Value `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"`
|
||||
ExprSteps []*Explain_ExprStep `protobuf:"bytes,2,rep,name=expr_steps,json=exprSteps,proto3" json:"expr_steps,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Explain) Reset() {
|
||||
*x = Explain{}
|
||||
mi := &file_cel_expr_explain_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Explain) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Explain) ProtoMessage() {}
|
||||
|
||||
func (x *Explain) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_cel_expr_explain_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Explain.ProtoReflect.Descriptor instead.
|
||||
func (*Explain) Descriptor() ([]byte, []int) {
|
||||
return file_cel_expr_explain_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *Explain) GetValues() []*Value {
|
||||
if x != nil {
|
||||
return x.Values
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Explain) GetExprSteps() []*Explain_ExprStep {
|
||||
if x != nil {
|
||||
return x.ExprSteps
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Explain_ExprStep struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
ValueIndex int32 `protobuf:"varint,2,opt,name=value_index,json=valueIndex,proto3" json:"value_index,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Explain_ExprStep) Reset() {
|
||||
*x = Explain_ExprStep{}
|
||||
mi := &file_cel_expr_explain_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Explain_ExprStep) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Explain_ExprStep) ProtoMessage() {}
|
||||
|
||||
func (x *Explain_ExprStep) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_cel_expr_explain_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Explain_ExprStep.ProtoReflect.Descriptor instead.
|
||||
func (*Explain_ExprStep) Descriptor() ([]byte, []int) {
|
||||
return file_cel_expr_explain_proto_rawDescGZIP(), []int{0, 0}
|
||||
}
|
||||
|
||||
func (x *Explain_ExprStep) GetId() int64 {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Explain_ExprStep) GetValueIndex() int32 {
|
||||
if x != nil {
|
||||
return x.ValueIndex
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_cel_expr_explain_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_cel_expr_explain_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x16cel/expr/explain.proto\x12\bcel.expr\x1a\x14cel/expr/value.proto\"\xae\x01\n" +
|
||||
"\aExplain\x12'\n" +
|
||||
"\x06values\x18\x01 \x03(\v2\x0f.cel.expr.ValueR\x06values\x129\n" +
|
||||
"\n" +
|
||||
"expr_steps\x18\x02 \x03(\v2\x1a.cel.expr.Explain.ExprStepR\texprSteps\x1a;\n" +
|
||||
"\bExprStep\x12\x0e\n" +
|
||||
"\x02id\x18\x01 \x01(\x03R\x02id\x12\x1f\n" +
|
||||
"\vvalue_index\x18\x02 \x01(\x05R\n" +
|
||||
"valueIndex:\x02\x18\x01B/\n" +
|
||||
"\fdev.cel.exprB\fExplainProtoP\x01Z\fcel.dev/expr\xf8\x01\x01b\x06proto3"
|
||||
|
||||
var (
|
||||
file_cel_expr_explain_proto_rawDescOnce sync.Once
|
||||
file_cel_expr_explain_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_cel_expr_explain_proto_rawDescGZIP() []byte {
|
||||
file_cel_expr_explain_proto_rawDescOnce.Do(func() {
|
||||
file_cel_expr_explain_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_cel_expr_explain_proto_rawDesc), len(file_cel_expr_explain_proto_rawDesc)))
|
||||
})
|
||||
return file_cel_expr_explain_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_cel_expr_explain_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_cel_expr_explain_proto_goTypes = []any{
|
||||
(*Explain)(nil), // 0: cel.expr.Explain
|
||||
(*Explain_ExprStep)(nil), // 1: cel.expr.Explain.ExprStep
|
||||
(*Value)(nil), // 2: cel.expr.Value
|
||||
}
|
||||
var file_cel_expr_explain_proto_depIdxs = []int32{
|
||||
2, // 0: cel.expr.Explain.values:type_name -> cel.expr.Value
|
||||
1, // 1: cel.expr.Explain.expr_steps:type_name -> cel.expr.Explain.ExprStep
|
||||
2, // [2:2] is the sub-list for method output_type
|
||||
2, // [2:2] is the sub-list for method input_type
|
||||
2, // [2:2] is the sub-list for extension type_name
|
||||
2, // [2:2] is the sub-list for extension extendee
|
||||
0, // [0:2] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_cel_expr_explain_proto_init() }
|
||||
func file_cel_expr_explain_proto_init() {
|
||||
if File_cel_expr_explain_proto != nil {
|
||||
return
|
||||
}
|
||||
file_cel_expr_value_proto_init()
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_cel_expr_explain_proto_rawDesc), len(file_cel_expr_explain_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 2,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_cel_expr_explain_proto_goTypes,
|
||||
DependencyIndexes: file_cel_expr_explain_proto_depIdxs,
|
||||
MessageInfos: file_cel_expr_explain_proto_msgTypes,
|
||||
}.Build()
|
||||
File_cel_expr_explain_proto = out.File
|
||||
file_cel_expr_explain_proto_goTypes = nil
|
||||
file_cel_expr_explain_proto_depIdxs = nil
|
||||
}
|
||||
9
.gear/predownloaded-development/vendor/cel.dev/expr/regen_go_proto.sh
vendored
Normal file
9
.gear/predownloaded-development/vendor/cel.dev/expr/regen_go_proto.sh
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
bazel build //proto/cel/expr/conformance/...
|
||||
files=($(bazel aquery 'kind(proto, //proto/cel/expr/conformance/...)' | grep Outputs | grep "[.]pb[.]go" | sed 's/Outputs: \[//' | sed 's/\]//' | tr "," "\n"))
|
||||
for src in ${files[@]};
|
||||
do
|
||||
dst=$(echo $src | sed 's/\(.*\/cel.dev\/expr\/\(.*\)\)/\2/')
|
||||
echo "copying $dst"
|
||||
$(cp $src $dst)
|
||||
done
|
||||
10
.gear/predownloaded-development/vendor/cel.dev/expr/regen_go_proto_canonical_protos.sh
vendored
Normal file
10
.gear/predownloaded-development/vendor/cel.dev/expr/regen_go_proto_canonical_protos.sh
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
bazel build //proto/cel/expr:all
|
||||
|
||||
rm -vf ./*.pb.go
|
||||
|
||||
files=( $(bazel cquery //proto/cel/expr:expr_go_proto --output=starlark --starlark:expr="'\n'.join([f.path for f in target.output_groups.go_generated_srcs.to_list()])") )
|
||||
for src in "${files[@]}";
|
||||
do
|
||||
cp -v "${src}" ./
|
||||
done
|
||||
1394
.gear/predownloaded-development/vendor/cel.dev/expr/syntax.pb.go
generated
vendored
Normal file
1394
.gear/predownloaded-development/vendor/cel.dev/expr/syntax.pb.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
575
.gear/predownloaded-development/vendor/cel.dev/expr/value.pb.go
generated
vendored
Normal file
575
.gear/predownloaded-development/vendor/cel.dev/expr/value.pb.go
generated
vendored
Normal file
|
|
@ -0,0 +1,575 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.10
|
||||
// protoc v5.27.1
|
||||
// source: cel/expr/value.proto
|
||||
|
||||
package expr
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
anypb "google.golang.org/protobuf/types/known/anypb"
|
||||
structpb "google.golang.org/protobuf/types/known/structpb"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type Value struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Types that are valid to be assigned to Kind:
|
||||
//
|
||||
// *Value_NullValue
|
||||
// *Value_BoolValue
|
||||
// *Value_Int64Value
|
||||
// *Value_Uint64Value
|
||||
// *Value_DoubleValue
|
||||
// *Value_StringValue
|
||||
// *Value_BytesValue
|
||||
// *Value_EnumValue
|
||||
// *Value_ObjectValue
|
||||
// *Value_MapValue
|
||||
// *Value_ListValue
|
||||
// *Value_TypeValue
|
||||
Kind isValue_Kind `protobuf_oneof:"kind"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Value) Reset() {
|
||||
*x = Value{}
|
||||
mi := &file_cel_expr_value_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Value) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Value) ProtoMessage() {}
|
||||
|
||||
func (x *Value) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_cel_expr_value_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Value.ProtoReflect.Descriptor instead.
|
||||
func (*Value) Descriptor() ([]byte, []int) {
|
||||
return file_cel_expr_value_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *Value) GetKind() isValue_Kind {
|
||||
if x != nil {
|
||||
return x.Kind
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Value) GetNullValue() structpb.NullValue {
|
||||
if x != nil {
|
||||
if x, ok := x.Kind.(*Value_NullValue); ok {
|
||||
return x.NullValue
|
||||
}
|
||||
}
|
||||
return structpb.NullValue(0)
|
||||
}
|
||||
|
||||
func (x *Value) GetBoolValue() bool {
|
||||
if x != nil {
|
||||
if x, ok := x.Kind.(*Value_BoolValue); ok {
|
||||
return x.BoolValue
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *Value) GetInt64Value() int64 {
|
||||
if x != nil {
|
||||
if x, ok := x.Kind.(*Value_Int64Value); ok {
|
||||
return x.Int64Value
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Value) GetUint64Value() uint64 {
|
||||
if x != nil {
|
||||
if x, ok := x.Kind.(*Value_Uint64Value); ok {
|
||||
return x.Uint64Value
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Value) GetDoubleValue() float64 {
|
||||
if x != nil {
|
||||
if x, ok := x.Kind.(*Value_DoubleValue); ok {
|
||||
return x.DoubleValue
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Value) GetStringValue() string {
|
||||
if x != nil {
|
||||
if x, ok := x.Kind.(*Value_StringValue); ok {
|
||||
return x.StringValue
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Value) GetBytesValue() []byte {
|
||||
if x != nil {
|
||||
if x, ok := x.Kind.(*Value_BytesValue); ok {
|
||||
return x.BytesValue
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Value) GetEnumValue() *EnumValue {
|
||||
if x != nil {
|
||||
if x, ok := x.Kind.(*Value_EnumValue); ok {
|
||||
return x.EnumValue
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Value) GetObjectValue() *anypb.Any {
|
||||
if x != nil {
|
||||
if x, ok := x.Kind.(*Value_ObjectValue); ok {
|
||||
return x.ObjectValue
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Value) GetMapValue() *MapValue {
|
||||
if x != nil {
|
||||
if x, ok := x.Kind.(*Value_MapValue); ok {
|
||||
return x.MapValue
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Value) GetListValue() *ListValue {
|
||||
if x != nil {
|
||||
if x, ok := x.Kind.(*Value_ListValue); ok {
|
||||
return x.ListValue
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Value) GetTypeValue() string {
|
||||
if x != nil {
|
||||
if x, ok := x.Kind.(*Value_TypeValue); ok {
|
||||
return x.TypeValue
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type isValue_Kind interface {
|
||||
isValue_Kind()
|
||||
}
|
||||
|
||||
type Value_NullValue struct {
|
||||
NullValue structpb.NullValue `protobuf:"varint,1,opt,name=null_value,json=nullValue,proto3,enum=google.protobuf.NullValue,oneof"`
|
||||
}
|
||||
|
||||
type Value_BoolValue struct {
|
||||
BoolValue bool `protobuf:"varint,2,opt,name=bool_value,json=boolValue,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Value_Int64Value struct {
|
||||
Int64Value int64 `protobuf:"varint,3,opt,name=int64_value,json=int64Value,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Value_Uint64Value struct {
|
||||
Uint64Value uint64 `protobuf:"varint,4,opt,name=uint64_value,json=uint64Value,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Value_DoubleValue struct {
|
||||
DoubleValue float64 `protobuf:"fixed64,5,opt,name=double_value,json=doubleValue,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Value_StringValue struct {
|
||||
StringValue string `protobuf:"bytes,6,opt,name=string_value,json=stringValue,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Value_BytesValue struct {
|
||||
BytesValue []byte `protobuf:"bytes,7,opt,name=bytes_value,json=bytesValue,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Value_EnumValue struct {
|
||||
EnumValue *EnumValue `protobuf:"bytes,9,opt,name=enum_value,json=enumValue,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Value_ObjectValue struct {
|
||||
ObjectValue *anypb.Any `protobuf:"bytes,10,opt,name=object_value,json=objectValue,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Value_MapValue struct {
|
||||
MapValue *MapValue `protobuf:"bytes,11,opt,name=map_value,json=mapValue,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Value_ListValue struct {
|
||||
ListValue *ListValue `protobuf:"bytes,12,opt,name=list_value,json=listValue,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Value_TypeValue struct {
|
||||
TypeValue string `protobuf:"bytes,15,opt,name=type_value,json=typeValue,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*Value_NullValue) isValue_Kind() {}
|
||||
|
||||
func (*Value_BoolValue) isValue_Kind() {}
|
||||
|
||||
func (*Value_Int64Value) isValue_Kind() {}
|
||||
|
||||
func (*Value_Uint64Value) isValue_Kind() {}
|
||||
|
||||
func (*Value_DoubleValue) isValue_Kind() {}
|
||||
|
||||
func (*Value_StringValue) isValue_Kind() {}
|
||||
|
||||
func (*Value_BytesValue) isValue_Kind() {}
|
||||
|
||||
func (*Value_EnumValue) isValue_Kind() {}
|
||||
|
||||
func (*Value_ObjectValue) isValue_Kind() {}
|
||||
|
||||
func (*Value_MapValue) isValue_Kind() {}
|
||||
|
||||
func (*Value_ListValue) isValue_Kind() {}
|
||||
|
||||
func (*Value_TypeValue) isValue_Kind() {}
|
||||
|
||||
type EnumValue struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"`
|
||||
Value int32 `protobuf:"varint,2,opt,name=value,proto3" json:"value,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *EnumValue) Reset() {
|
||||
*x = EnumValue{}
|
||||
mi := &file_cel_expr_value_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *EnumValue) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*EnumValue) ProtoMessage() {}
|
||||
|
||||
func (x *EnumValue) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_cel_expr_value_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use EnumValue.ProtoReflect.Descriptor instead.
|
||||
func (*EnumValue) Descriptor() ([]byte, []int) {
|
||||
return file_cel_expr_value_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *EnumValue) GetType() string {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *EnumValue) GetValue() int32 {
|
||||
if x != nil {
|
||||
return x.Value
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type ListValue struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Values []*Value `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ListValue) Reset() {
|
||||
*x = ListValue{}
|
||||
mi := &file_cel_expr_value_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ListValue) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ListValue) ProtoMessage() {}
|
||||
|
||||
func (x *ListValue) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_cel_expr_value_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ListValue.ProtoReflect.Descriptor instead.
|
||||
func (*ListValue) Descriptor() ([]byte, []int) {
|
||||
return file_cel_expr_value_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *ListValue) GetValues() []*Value {
|
||||
if x != nil {
|
||||
return x.Values
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type MapValue struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Entries []*MapValue_Entry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *MapValue) Reset() {
|
||||
*x = MapValue{}
|
||||
mi := &file_cel_expr_value_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *MapValue) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*MapValue) ProtoMessage() {}
|
||||
|
||||
func (x *MapValue) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_cel_expr_value_proto_msgTypes[3]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use MapValue.ProtoReflect.Descriptor instead.
|
||||
func (*MapValue) Descriptor() ([]byte, []int) {
|
||||
return file_cel_expr_value_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *MapValue) GetEntries() []*MapValue_Entry {
|
||||
if x != nil {
|
||||
return x.Entries
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type MapValue_Entry struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Key *Value `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
||||
Value *Value `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *MapValue_Entry) Reset() {
|
||||
*x = MapValue_Entry{}
|
||||
mi := &file_cel_expr_value_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *MapValue_Entry) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*MapValue_Entry) ProtoMessage() {}
|
||||
|
||||
func (x *MapValue_Entry) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_cel_expr_value_proto_msgTypes[4]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use MapValue_Entry.ProtoReflect.Descriptor instead.
|
||||
func (*MapValue_Entry) Descriptor() ([]byte, []int) {
|
||||
return file_cel_expr_value_proto_rawDescGZIP(), []int{3, 0}
|
||||
}
|
||||
|
||||
func (x *MapValue_Entry) GetKey() *Value {
|
||||
if x != nil {
|
||||
return x.Key
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *MapValue_Entry) GetValue() *Value {
|
||||
if x != nil {
|
||||
return x.Value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_cel_expr_value_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_cel_expr_value_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x14cel/expr/value.proto\x12\bcel.expr\x1a\x19google/protobuf/any.proto\x1a\x1cgoogle/protobuf/struct.proto\"\x9d\x04\n" +
|
||||
"\x05Value\x12;\n" +
|
||||
"\n" +
|
||||
"null_value\x18\x01 \x01(\x0e2\x1a.google.protobuf.NullValueH\x00R\tnullValue\x12\x1f\n" +
|
||||
"\n" +
|
||||
"bool_value\x18\x02 \x01(\bH\x00R\tboolValue\x12!\n" +
|
||||
"\vint64_value\x18\x03 \x01(\x03H\x00R\n" +
|
||||
"int64Value\x12#\n" +
|
||||
"\fuint64_value\x18\x04 \x01(\x04H\x00R\vuint64Value\x12#\n" +
|
||||
"\fdouble_value\x18\x05 \x01(\x01H\x00R\vdoubleValue\x12#\n" +
|
||||
"\fstring_value\x18\x06 \x01(\tH\x00R\vstringValue\x12!\n" +
|
||||
"\vbytes_value\x18\a \x01(\fH\x00R\n" +
|
||||
"bytesValue\x124\n" +
|
||||
"\n" +
|
||||
"enum_value\x18\t \x01(\v2\x13.cel.expr.EnumValueH\x00R\tenumValue\x129\n" +
|
||||
"\fobject_value\x18\n" +
|
||||
" \x01(\v2\x14.google.protobuf.AnyH\x00R\vobjectValue\x121\n" +
|
||||
"\tmap_value\x18\v \x01(\v2\x12.cel.expr.MapValueH\x00R\bmapValue\x124\n" +
|
||||
"\n" +
|
||||
"list_value\x18\f \x01(\v2\x13.cel.expr.ListValueH\x00R\tlistValue\x12\x1f\n" +
|
||||
"\n" +
|
||||
"type_value\x18\x0f \x01(\tH\x00R\ttypeValueB\x06\n" +
|
||||
"\x04kind\"5\n" +
|
||||
"\tEnumValue\x12\x12\n" +
|
||||
"\x04type\x18\x01 \x01(\tR\x04type\x12\x14\n" +
|
||||
"\x05value\x18\x02 \x01(\x05R\x05value\"4\n" +
|
||||
"\tListValue\x12'\n" +
|
||||
"\x06values\x18\x01 \x03(\v2\x0f.cel.expr.ValueR\x06values\"\x91\x01\n" +
|
||||
"\bMapValue\x122\n" +
|
||||
"\aentries\x18\x01 \x03(\v2\x18.cel.expr.MapValue.EntryR\aentries\x1aQ\n" +
|
||||
"\x05Entry\x12!\n" +
|
||||
"\x03key\x18\x01 \x01(\v2\x0f.cel.expr.ValueR\x03key\x12%\n" +
|
||||
"\x05value\x18\x02 \x01(\v2\x0f.cel.expr.ValueR\x05valueB-\n" +
|
||||
"\fdev.cel.exprB\n" +
|
||||
"ValueProtoP\x01Z\fcel.dev/expr\xf8\x01\x01b\x06proto3"
|
||||
|
||||
var (
|
||||
file_cel_expr_value_proto_rawDescOnce sync.Once
|
||||
file_cel_expr_value_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_cel_expr_value_proto_rawDescGZIP() []byte {
|
||||
file_cel_expr_value_proto_rawDescOnce.Do(func() {
|
||||
file_cel_expr_value_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_cel_expr_value_proto_rawDesc), len(file_cel_expr_value_proto_rawDesc)))
|
||||
})
|
||||
return file_cel_expr_value_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_cel_expr_value_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
||||
var file_cel_expr_value_proto_goTypes = []any{
|
||||
(*Value)(nil), // 0: cel.expr.Value
|
||||
(*EnumValue)(nil), // 1: cel.expr.EnumValue
|
||||
(*ListValue)(nil), // 2: cel.expr.ListValue
|
||||
(*MapValue)(nil), // 3: cel.expr.MapValue
|
||||
(*MapValue_Entry)(nil), // 4: cel.expr.MapValue.Entry
|
||||
(structpb.NullValue)(0), // 5: google.protobuf.NullValue
|
||||
(*anypb.Any)(nil), // 6: google.protobuf.Any
|
||||
}
|
||||
var file_cel_expr_value_proto_depIdxs = []int32{
|
||||
5, // 0: cel.expr.Value.null_value:type_name -> google.protobuf.NullValue
|
||||
1, // 1: cel.expr.Value.enum_value:type_name -> cel.expr.EnumValue
|
||||
6, // 2: cel.expr.Value.object_value:type_name -> google.protobuf.Any
|
||||
3, // 3: cel.expr.Value.map_value:type_name -> cel.expr.MapValue
|
||||
2, // 4: cel.expr.Value.list_value:type_name -> cel.expr.ListValue
|
||||
0, // 5: cel.expr.ListValue.values:type_name -> cel.expr.Value
|
||||
4, // 6: cel.expr.MapValue.entries:type_name -> cel.expr.MapValue.Entry
|
||||
0, // 7: cel.expr.MapValue.Entry.key:type_name -> cel.expr.Value
|
||||
0, // 8: cel.expr.MapValue.Entry.value:type_name -> cel.expr.Value
|
||||
9, // [9:9] is the sub-list for method output_type
|
||||
9, // [9:9] is the sub-list for method input_type
|
||||
9, // [9:9] is the sub-list for extension type_name
|
||||
9, // [9:9] is the sub-list for extension extendee
|
||||
0, // [0:9] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_cel_expr_value_proto_init() }
|
||||
func file_cel_expr_value_proto_init() {
|
||||
if File_cel_expr_value_proto != nil {
|
||||
return
|
||||
}
|
||||
file_cel_expr_value_proto_msgTypes[0].OneofWrappers = []any{
|
||||
(*Value_NullValue)(nil),
|
||||
(*Value_BoolValue)(nil),
|
||||
(*Value_Int64Value)(nil),
|
||||
(*Value_Uint64Value)(nil),
|
||||
(*Value_DoubleValue)(nil),
|
||||
(*Value_StringValue)(nil),
|
||||
(*Value_BytesValue)(nil),
|
||||
(*Value_EnumValue)(nil),
|
||||
(*Value_ObjectValue)(nil),
|
||||
(*Value_MapValue)(nil),
|
||||
(*Value_ListValue)(nil),
|
||||
(*Value_TypeValue)(nil),
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_cel_expr_value_proto_rawDesc), len(file_cel_expr_value_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 5,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_cel_expr_value_proto_goTypes,
|
||||
DependencyIndexes: file_cel_expr_value_proto_depIdxs,
|
||||
MessageInfos: file_cel_expr_value_proto_msgTypes,
|
||||
}.Build()
|
||||
File_cel_expr_value_proto = out.File
|
||||
file_cel_expr_value_proto_goTypes = nil
|
||||
file_cel_expr_value_proto_depIdxs = nil
|
||||
}
|
||||
12
.gear/predownloaded-development/vendor/dario.cat/mergo/.deepsource.toml
vendored
Normal file
12
.gear/predownloaded-development/vendor/dario.cat/mergo/.deepsource.toml
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
version = 1
|
||||
|
||||
test_patterns = [
|
||||
"*_test.go"
|
||||
]
|
||||
|
||||
[[analyzers]]
|
||||
name = "go"
|
||||
enabled = true
|
||||
|
||||
[analyzers.meta]
|
||||
import_path = "dario.cat/mergo"
|
||||
33
.gear/predownloaded-development/vendor/dario.cat/mergo/.gitignore
vendored
Normal file
33
.gear/predownloaded-development/vendor/dario.cat/mergo/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#### joe made this: http://goel.io/joe
|
||||
|
||||
#### go ####
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, build with `go test -c`
|
||||
*.test
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
|
||||
.glide/
|
||||
|
||||
#### vim ####
|
||||
# Swap
|
||||
[._]*.s[a-v][a-z]
|
||||
[._]*.sw[a-p]
|
||||
[._]s[a-v][a-z]
|
||||
[._]sw[a-p]
|
||||
|
||||
# Session
|
||||
Session.vim
|
||||
|
||||
# Temporary
|
||||
.netrwhist
|
||||
*~
|
||||
# Auto-generated tag files
|
||||
tags
|
||||
12
.gear/predownloaded-development/vendor/dario.cat/mergo/.travis.yml
vendored
Normal file
12
.gear/predownloaded-development/vendor/dario.cat/mergo/.travis.yml
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
language: go
|
||||
arch:
|
||||
- amd64
|
||||
- ppc64le
|
||||
install:
|
||||
- go get -t
|
||||
- go get golang.org/x/tools/cmd/cover
|
||||
- go get github.com/mattn/goveralls
|
||||
script:
|
||||
- go test -race -v ./...
|
||||
after_script:
|
||||
- $HOME/gopath/bin/goveralls -service=travis-ci -repotoken $COVERALLS_TOKEN
|
||||
46
.gear/predownloaded-development/vendor/dario.cat/mergo/CODE_OF_CONDUCT.md
vendored
Normal file
46
.gear/predownloaded-development/vendor/dario.cat/mergo/CODE_OF_CONDUCT.md
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at i@dario.im. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
||||
112
.gear/predownloaded-development/vendor/dario.cat/mergo/CONTRIBUTING.md
vendored
Normal file
112
.gear/predownloaded-development/vendor/dario.cat/mergo/CONTRIBUTING.md
vendored
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
<!-- omit in toc -->
|
||||
# Contributing to mergo
|
||||
|
||||
First off, thanks for taking the time to contribute! ❤️
|
||||
|
||||
All types of contributions are encouraged and valued. See the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The community looks forward to your contributions. 🎉
|
||||
|
||||
> And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about:
|
||||
> - Star the project
|
||||
> - Tweet about it
|
||||
> - Refer this project in your project's readme
|
||||
> - Mention the project at local meetups and tell your friends/colleagues
|
||||
|
||||
<!-- omit in toc -->
|
||||
## Table of Contents
|
||||
|
||||
- [Code of Conduct](#code-of-conduct)
|
||||
- [I Have a Question](#i-have-a-question)
|
||||
- [I Want To Contribute](#i-want-to-contribute)
|
||||
- [Reporting Bugs](#reporting-bugs)
|
||||
- [Suggesting Enhancements](#suggesting-enhancements)
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
This project and everyone participating in it is governed by the
|
||||
[mergo Code of Conduct](https://github.com/imdario/mergoblob/master/CODE_OF_CONDUCT.md).
|
||||
By participating, you are expected to uphold this code. Please report unacceptable behavior
|
||||
to <>.
|
||||
|
||||
|
||||
## I Have a Question
|
||||
|
||||
> If you want to ask a question, we assume that you have read the available [Documentation](https://pkg.go.dev/github.com/imdario/mergo).
|
||||
|
||||
Before you ask a question, it is best to search for existing [Issues](https://github.com/imdario/mergo/issues) that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue. It is also advisable to search the internet for answers first.
|
||||
|
||||
If you then still feel the need to ask a question and need clarification, we recommend the following:
|
||||
|
||||
- Open an [Issue](https://github.com/imdario/mergo/issues/new).
|
||||
- Provide as much context as you can about what you're running into.
|
||||
- Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant.
|
||||
|
||||
We will then take care of the issue as soon as possible.
|
||||
|
||||
## I Want To Contribute
|
||||
|
||||
> ### Legal Notice <!-- omit in toc -->
|
||||
> When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content and that the content you contribute may be provided under the project license.
|
||||
|
||||
### Reporting Bugs
|
||||
|
||||
<!-- omit in toc -->
|
||||
#### Before Submitting a Bug Report
|
||||
|
||||
A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible.
|
||||
|
||||
- Make sure that you are using the latest version.
|
||||
- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](). If you are looking for support, you might want to check [this section](#i-have-a-question)).
|
||||
- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/imdario/mergoissues?q=label%3Abug).
|
||||
- Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue.
|
||||
- Collect information about the bug:
|
||||
- Stack trace (Traceback)
|
||||
- OS, Platform and Version (Windows, Linux, macOS, x86, ARM)
|
||||
- Version of the interpreter, compiler, SDK, runtime environment, package manager, depending on what seems relevant.
|
||||
- Possibly your input and the output
|
||||
- Can you reliably reproduce the issue? And can you also reproduce it with older versions?
|
||||
|
||||
<!-- omit in toc -->
|
||||
#### How Do I Submit a Good Bug Report?
|
||||
|
||||
> You must never report security related issues, vulnerabilities or bugs including sensitive information to the issue tracker, or elsewhere in public. Instead sensitive bugs must be sent by email to .
|
||||
<!-- You may add a PGP key to allow the messages to be sent encrypted as well. -->
|
||||
|
||||
We use GitHub issues to track bugs and errors. If you run into an issue with the project:
|
||||
|
||||
- Open an [Issue](https://github.com/imdario/mergo/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.)
|
||||
- Explain the behavior you would expect and the actual behavior.
|
||||
- Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case.
|
||||
- Provide the information you collected in the previous section.
|
||||
|
||||
Once it's filed:
|
||||
|
||||
- The project team will label the issue accordingly.
|
||||
- A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced.
|
||||
- If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be implemented by someone.
|
||||
|
||||
### Suggesting Enhancements
|
||||
|
||||
This section guides you through submitting an enhancement suggestion for mergo, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community to understand your suggestion and find related suggestions.
|
||||
|
||||
<!-- omit in toc -->
|
||||
#### Before Submitting an Enhancement
|
||||
|
||||
- Make sure that you are using the latest version.
|
||||
- Read the [documentation]() carefully and find out if the functionality is already covered, maybe by an individual configuration.
|
||||
- Perform a [search](https://github.com/imdario/mergo/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
|
||||
- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library.
|
||||
|
||||
<!-- omit in toc -->
|
||||
#### How Do I Submit a Good Enhancement Suggestion?
|
||||
|
||||
Enhancement suggestions are tracked as [GitHub issues](https://github.com/imdario/mergo/issues).
|
||||
|
||||
- Use a **clear and descriptive title** for the issue to identify the suggestion.
|
||||
- Provide a **step-by-step description of the suggested enhancement** in as many details as possible.
|
||||
- **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you.
|
||||
- You may want to **include screenshots and animated GIFs** which help you demonstrate the steps or point out the part which the suggestion is related to. You can use [this tool](https://www.cockos.com/licecap/) to record GIFs on macOS and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or [this tool](https://github.com/GNOME/byzanz) on Linux. <!-- this should only be included if the project has a GUI -->
|
||||
- **Explain why this enhancement would be useful** to most mergo users. You may also want to point out the other projects that solved it better and which could serve as inspiration.
|
||||
|
||||
<!-- omit in toc -->
|
||||
## Attribution
|
||||
This guide is based on the **contributing-gen**. [Make your own](https://github.com/bttger/contributing-gen)!
|
||||
28
.gear/predownloaded-development/vendor/dario.cat/mergo/LICENSE
vendored
Normal file
28
.gear/predownloaded-development/vendor/dario.cat/mergo/LICENSE
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
Copyright (c) 2013 Dario Castañé. All rights reserved.
|
||||
Copyright (c) 2012 The Go Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
248
.gear/predownloaded-development/vendor/dario.cat/mergo/README.md
vendored
Normal file
248
.gear/predownloaded-development/vendor/dario.cat/mergo/README.md
vendored
Normal file
|
|
@ -0,0 +1,248 @@
|
|||
# Mergo
|
||||
|
||||
[![GitHub release][5]][6]
|
||||
[![GoCard][7]][8]
|
||||
[![Test status][1]][2]
|
||||
[![OpenSSF Scorecard][21]][22]
|
||||
[![OpenSSF Best Practices][19]][20]
|
||||
[![Coverage status][9]][10]
|
||||
[![Sourcegraph][11]][12]
|
||||
[![FOSSA status][13]][14]
|
||||
|
||||
[![GoDoc][3]][4]
|
||||
[![Become my sponsor][15]][16]
|
||||
[![Tidelift][17]][18]
|
||||
|
||||
[1]: https://github.com/imdario/mergo/workflows/tests/badge.svg?branch=master
|
||||
[2]: https://github.com/imdario/mergo/actions/workflows/tests.yml
|
||||
[3]: https://godoc.org/github.com/imdario/mergo?status.svg
|
||||
[4]: https://godoc.org/github.com/imdario/mergo
|
||||
[5]: https://img.shields.io/github/release/imdario/mergo.svg
|
||||
[6]: https://github.com/imdario/mergo/releases
|
||||
[7]: https://goreportcard.com/badge/imdario/mergo
|
||||
[8]: https://goreportcard.com/report/github.com/imdario/mergo
|
||||
[9]: https://coveralls.io/repos/github/imdario/mergo/badge.svg?branch=master
|
||||
[10]: https://coveralls.io/github/imdario/mergo?branch=master
|
||||
[11]: https://sourcegraph.com/github.com/imdario/mergo/-/badge.svg
|
||||
[12]: https://sourcegraph.com/github.com/imdario/mergo?badge
|
||||
[13]: https://app.fossa.io/api/projects/git%2Bgithub.com%2Fimdario%2Fmergo.svg?type=shield
|
||||
[14]: https://app.fossa.io/projects/git%2Bgithub.com%2Fimdario%2Fmergo?ref=badge_shield
|
||||
[15]: https://img.shields.io/github/sponsors/imdario
|
||||
[16]: https://github.com/sponsors/imdario
|
||||
[17]: https://tidelift.com/badges/package/go/github.com%2Fimdario%2Fmergo
|
||||
[18]: https://tidelift.com/subscription/pkg/go-github.com-imdario-mergo
|
||||
[19]: https://bestpractices.coreinfrastructure.org/projects/7177/badge
|
||||
[20]: https://bestpractices.coreinfrastructure.org/projects/7177
|
||||
[21]: https://api.securityscorecards.dev/projects/github.com/imdario/mergo/badge
|
||||
[22]: https://api.securityscorecards.dev/projects/github.com/imdario/mergo
|
||||
|
||||
A helper to merge structs and maps in Golang. Useful for configuration default values, avoiding messy if-statements.
|
||||
|
||||
Mergo merges same-type structs and maps by setting default values in zero-value fields. Mergo won't merge unexported (private) fields. It will do recursively any exported one. It also won't merge structs inside maps (because they are not addressable using Go reflection).
|
||||
|
||||
Also a lovely [comune](http://en.wikipedia.org/wiki/Mergo) (municipality) in the Province of Ancona in the Italian region of Marche.
|
||||
|
||||
## Status
|
||||
|
||||
It is ready for production use. [It is used in several projects by Docker, Google, The Linux Foundation, VMWare, Shopify, Microsoft, etc](https://github.com/imdario/mergo#mergo-in-the-wild).
|
||||
|
||||
### Important notes
|
||||
|
||||
#### 1.0.0
|
||||
|
||||
In [1.0.0](//github.com/imdario/mergo/releases/tag/1.0.0) Mergo moves to a vanity URL `dario.cat/mergo`.
|
||||
|
||||
#### 0.3.9
|
||||
|
||||
Please keep in mind that a problematic PR broke [0.3.9](//github.com/imdario/mergo/releases/tag/0.3.9). I reverted it in [0.3.10](//github.com/imdario/mergo/releases/tag/0.3.10), and I consider it stable but not bug-free. Also, this version adds support for go modules.
|
||||
|
||||
Keep in mind that in [0.3.2](//github.com/imdario/mergo/releases/tag/0.3.2), Mergo changed `Merge()`and `Map()` signatures to support [transformers](#transformers). I added an optional/variadic argument so that it won't break the existing code.
|
||||
|
||||
If you were using Mergo before April 6th, 2015, please check your project works as intended after updating your local copy with ```go get -u dario.cat/mergo```. I apologize for any issue caused by its previous behavior and any future bug that Mergo could cause in existing projects after the change (release 0.2.0).
|
||||
|
||||
### Donations
|
||||
|
||||
If Mergo is useful to you, consider buying me a coffee, a beer, or making a monthly donation to allow me to keep building great free software. :heart_eyes:
|
||||
|
||||
<a href='https://ko-fi.com/B0B58839' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://az743702.vo.msecnd.net/cdn/kofi1.png?v=0' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>
|
||||
<a href="https://liberapay.com/dario/donate"><img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a>
|
||||
<a href='https://github.com/sponsors/imdario' target='_blank'><img alt="Become my sponsor" src="https://img.shields.io/github/sponsors/imdario?style=for-the-badge" /></a>
|
||||
|
||||
### Mergo in the wild
|
||||
|
||||
- [moby/moby](https://github.com/moby/moby)
|
||||
- [kubernetes/kubernetes](https://github.com/kubernetes/kubernetes)
|
||||
- [vmware/dispatch](https://github.com/vmware/dispatch)
|
||||
- [Shopify/themekit](https://github.com/Shopify/themekit)
|
||||
- [imdario/zas](https://github.com/imdario/zas)
|
||||
- [matcornic/hermes](https://github.com/matcornic/hermes)
|
||||
- [OpenBazaar/openbazaar-go](https://github.com/OpenBazaar/openbazaar-go)
|
||||
- [kataras/iris](https://github.com/kataras/iris)
|
||||
- [michaelsauter/crane](https://github.com/michaelsauter/crane)
|
||||
- [go-task/task](https://github.com/go-task/task)
|
||||
- [sensu/uchiwa](https://github.com/sensu/uchiwa)
|
||||
- [ory/hydra](https://github.com/ory/hydra)
|
||||
- [sisatech/vcli](https://github.com/sisatech/vcli)
|
||||
- [dairycart/dairycart](https://github.com/dairycart/dairycart)
|
||||
- [projectcalico/felix](https://github.com/projectcalico/felix)
|
||||
- [resin-os/balena](https://github.com/resin-os/balena)
|
||||
- [go-kivik/kivik](https://github.com/go-kivik/kivik)
|
||||
- [Telefonica/govice](https://github.com/Telefonica/govice)
|
||||
- [supergiant/supergiant](supergiant/supergiant)
|
||||
- [SergeyTsalkov/brooce](https://github.com/SergeyTsalkov/brooce)
|
||||
- [soniah/dnsmadeeasy](https://github.com/soniah/dnsmadeeasy)
|
||||
- [ohsu-comp-bio/funnel](https://github.com/ohsu-comp-bio/funnel)
|
||||
- [EagerIO/Stout](https://github.com/EagerIO/Stout)
|
||||
- [lynndylanhurley/defsynth-api](https://github.com/lynndylanhurley/defsynth-api)
|
||||
- [russross/canvasassignments](https://github.com/russross/canvasassignments)
|
||||
- [rdegges/cryptly-api](https://github.com/rdegges/cryptly-api)
|
||||
- [casualjim/exeggutor](https://github.com/casualjim/exeggutor)
|
||||
- [divshot/gitling](https://github.com/divshot/gitling)
|
||||
- [RWJMurphy/gorl](https://github.com/RWJMurphy/gorl)
|
||||
- [andrerocker/deploy42](https://github.com/andrerocker/deploy42)
|
||||
- [elwinar/rambler](https://github.com/elwinar/rambler)
|
||||
- [tmaiaroto/gopartman](https://github.com/tmaiaroto/gopartman)
|
||||
- [jfbus/impressionist](https://github.com/jfbus/impressionist)
|
||||
- [Jmeyering/zealot](https://github.com/Jmeyering/zealot)
|
||||
- [godep-migrator/rigger-host](https://github.com/godep-migrator/rigger-host)
|
||||
- [Dronevery/MultiwaySwitch-Go](https://github.com/Dronevery/MultiwaySwitch-Go)
|
||||
- [thoas/picfit](https://github.com/thoas/picfit)
|
||||
- [mantasmatelis/whooplist-server](https://github.com/mantasmatelis/whooplist-server)
|
||||
- [jnuthong/item_search](https://github.com/jnuthong/item_search)
|
||||
- [bukalapak/snowboard](https://github.com/bukalapak/snowboard)
|
||||
- [containerssh/containerssh](https://github.com/containerssh/containerssh)
|
||||
- [goreleaser/goreleaser](https://github.com/goreleaser/goreleaser)
|
||||
- [tjpnz/structbot](https://github.com/tjpnz/structbot)
|
||||
|
||||
## Install
|
||||
|
||||
go get dario.cat/mergo
|
||||
|
||||
// use in your .go code
|
||||
import (
|
||||
"dario.cat/mergo"
|
||||
)
|
||||
|
||||
## Usage
|
||||
|
||||
You can only merge same-type structs with exported fields initialized as zero value of their type and same-types maps. Mergo won't merge unexported (private) fields but will do recursively any exported one. It won't merge empty structs value as [they are zero values](https://golang.org/ref/spec#The_zero_value) too. Also, maps will be merged recursively except for structs inside maps (because they are not addressable using Go reflection).
|
||||
|
||||
```go
|
||||
if err := mergo.Merge(&dst, src); err != nil {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
Also, you can merge overwriting values using the transformer `WithOverride`.
|
||||
|
||||
```go
|
||||
if err := mergo.Merge(&dst, src, mergo.WithOverride); err != nil {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
Additionally, you can map a `map[string]interface{}` to a struct (and otherwise, from struct to map), following the same restrictions as in `Merge()`. Keys are capitalized to find each corresponding exported field.
|
||||
|
||||
```go
|
||||
if err := mergo.Map(&dst, srcMap); err != nil {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
Warning: if you map a struct to map, it won't do it recursively. Don't expect Mergo to map struct members of your struct as `map[string]interface{}`. They will be just assigned as values.
|
||||
|
||||
Here is a nice example:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"dario.cat/mergo"
|
||||
)
|
||||
|
||||
type Foo struct {
|
||||
A string
|
||||
B int64
|
||||
}
|
||||
|
||||
func main() {
|
||||
src := Foo{
|
||||
A: "one",
|
||||
B: 2,
|
||||
}
|
||||
dest := Foo{
|
||||
A: "two",
|
||||
}
|
||||
mergo.Merge(&dest, src)
|
||||
fmt.Println(dest)
|
||||
// Will print
|
||||
// {two 2}
|
||||
}
|
||||
```
|
||||
|
||||
Note: if test are failing due missing package, please execute:
|
||||
|
||||
go get gopkg.in/yaml.v3
|
||||
|
||||
### Transformers
|
||||
|
||||
Transformers allow to merge specific types differently than in the default behavior. In other words, now you can customize how some types are merged. For example, `time.Time` is a struct; it doesn't have zero value but IsZero can return true because it has fields with zero value. How can we merge a non-zero `time.Time`?
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"dario.cat/mergo"
|
||||
"reflect"
|
||||
"time"
|
||||
)
|
||||
|
||||
type timeTransformer struct {
|
||||
}
|
||||
|
||||
func (t timeTransformer) Transformer(typ reflect.Type) func(dst, src reflect.Value) error {
|
||||
if typ == reflect.TypeOf(time.Time{}) {
|
||||
return func(dst, src reflect.Value) error {
|
||||
if dst.CanSet() {
|
||||
isZero := dst.MethodByName("IsZero")
|
||||
result := isZero.Call([]reflect.Value{})
|
||||
if result[0].Bool() {
|
||||
dst.Set(src)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Snapshot struct {
|
||||
Time time.Time
|
||||
// ...
|
||||
}
|
||||
|
||||
func main() {
|
||||
src := Snapshot{time.Now()}
|
||||
dest := Snapshot{}
|
||||
mergo.Merge(&dest, src, mergo.WithTransformers(timeTransformer{}))
|
||||
fmt.Println(dest)
|
||||
// Will print
|
||||
// { 2018-01-12 01:15:00 +0000 UTC m=+0.000000001 }
|
||||
}
|
||||
```
|
||||
|
||||
## Contact me
|
||||
|
||||
If I can help you, you have an idea or you are using Mergo in your projects, don't hesitate to drop me a line (or a pull request): [@im_dario](https://twitter.com/im_dario)
|
||||
|
||||
## About
|
||||
|
||||
Written by [Dario Castañé](http://dario.im).
|
||||
|
||||
## License
|
||||
|
||||
[BSD 3-Clause](http://opensource.org/licenses/BSD-3-Clause) license, as [Go language](http://golang.org/LICENSE).
|
||||
|
||||
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fimdario%2Fmergo?ref=badge_large)
|
||||
14
.gear/predownloaded-development/vendor/dario.cat/mergo/SECURITY.md
vendored
Normal file
14
.gear/predownloaded-development/vendor/dario.cat/mergo/SECURITY.md
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 0.3.x | :white_check_mark: |
|
||||
| < 0.3 | :x: |
|
||||
|
||||
## Security contact information
|
||||
|
||||
To report a security vulnerability, please use the
|
||||
[Tidelift security contact](https://tidelift.com/security).
|
||||
Tidelift will coordinate the fix and disclosure.
|
||||
148
.gear/predownloaded-development/vendor/dario.cat/mergo/doc.go
vendored
Normal file
148
.gear/predownloaded-development/vendor/dario.cat/mergo/doc.go
vendored
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
// Copyright 2013 Dario Castañé. All rights reserved.
|
||||
// Copyright 2009 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.
|
||||
|
||||
/*
|
||||
A helper to merge structs and maps in Golang. Useful for configuration default values, avoiding messy if-statements.
|
||||
|
||||
Mergo merges same-type structs and maps by setting default values in zero-value fields. Mergo won't merge unexported (private) fields. It will do recursively any exported one. It also won't merge structs inside maps (because they are not addressable using Go reflection).
|
||||
|
||||
# Status
|
||||
|
||||
It is ready for production use. It is used in several projects by Docker, Google, The Linux Foundation, VMWare, Shopify, etc.
|
||||
|
||||
# Important notes
|
||||
|
||||
1.0.0
|
||||
|
||||
In 1.0.0 Mergo moves to a vanity URL `dario.cat/mergo`.
|
||||
|
||||
0.3.9
|
||||
|
||||
Please keep in mind that a problematic PR broke 0.3.9. We reverted it in 0.3.10. We consider 0.3.10 as stable but not bug-free. . Also, this version adds suppot for go modules.
|
||||
|
||||
Keep in mind that in 0.3.2, Mergo changed Merge() and Map() signatures to support transformers. We added an optional/variadic argument so that it won't break the existing code.
|
||||
|
||||
If you were using Mergo before April 6th, 2015, please check your project works as intended after updating your local copy with go get -u dario.cat/mergo. I apologize for any issue caused by its previous behavior and any future bug that Mergo could cause in existing projects after the change (release 0.2.0).
|
||||
|
||||
# Install
|
||||
|
||||
Do your usual installation procedure:
|
||||
|
||||
go get dario.cat/mergo
|
||||
|
||||
// use in your .go code
|
||||
import (
|
||||
"dario.cat/mergo"
|
||||
)
|
||||
|
||||
# Usage
|
||||
|
||||
You can only merge same-type structs with exported fields initialized as zero value of their type and same-types maps. Mergo won't merge unexported (private) fields but will do recursively any exported one. It won't merge empty structs value as they are zero values too. Also, maps will be merged recursively except for structs inside maps (because they are not addressable using Go reflection).
|
||||
|
||||
if err := mergo.Merge(&dst, src); err != nil {
|
||||
// ...
|
||||
}
|
||||
|
||||
Also, you can merge overwriting values using the transformer WithOverride.
|
||||
|
||||
if err := mergo.Merge(&dst, src, mergo.WithOverride); err != nil {
|
||||
// ...
|
||||
}
|
||||
|
||||
Additionally, you can map a map[string]interface{} to a struct (and otherwise, from struct to map), following the same restrictions as in Merge(). Keys are capitalized to find each corresponding exported field.
|
||||
|
||||
if err := mergo.Map(&dst, srcMap); err != nil {
|
||||
// ...
|
||||
}
|
||||
|
||||
Warning: if you map a struct to map, it won't do it recursively. Don't expect Mergo to map struct members of your struct as map[string]interface{}. They will be just assigned as values.
|
||||
|
||||
Here is a nice example:
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"dario.cat/mergo"
|
||||
)
|
||||
|
||||
type Foo struct {
|
||||
A string
|
||||
B int64
|
||||
}
|
||||
|
||||
func main() {
|
||||
src := Foo{
|
||||
A: "one",
|
||||
B: 2,
|
||||
}
|
||||
dest := Foo{
|
||||
A: "two",
|
||||
}
|
||||
mergo.Merge(&dest, src)
|
||||
fmt.Println(dest)
|
||||
// Will print
|
||||
// {two 2}
|
||||
}
|
||||
|
||||
# Transformers
|
||||
|
||||
Transformers allow to merge specific types differently than in the default behavior. In other words, now you can customize how some types are merged. For example, time.Time is a struct; it doesn't have zero value but IsZero can return true because it has fields with zero value. How can we merge a non-zero time.Time?
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"dario.cat/mergo"
|
||||
"reflect"
|
||||
"time"
|
||||
)
|
||||
|
||||
type timeTransformer struct {
|
||||
}
|
||||
|
||||
func (t timeTransformer) Transformer(typ reflect.Type) func(dst, src reflect.Value) error {
|
||||
if typ == reflect.TypeOf(time.Time{}) {
|
||||
return func(dst, src reflect.Value) error {
|
||||
if dst.CanSet() {
|
||||
isZero := dst.MethodByName("IsZero")
|
||||
result := isZero.Call([]reflect.Value{})
|
||||
if result[0].Bool() {
|
||||
dst.Set(src)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Snapshot struct {
|
||||
Time time.Time
|
||||
// ...
|
||||
}
|
||||
|
||||
func main() {
|
||||
src := Snapshot{time.Now()}
|
||||
dest := Snapshot{}
|
||||
mergo.Merge(&dest, src, mergo.WithTransformers(timeTransformer{}))
|
||||
fmt.Println(dest)
|
||||
// Will print
|
||||
// { 2018-01-12 01:15:00 +0000 UTC m=+0.000000001 }
|
||||
}
|
||||
|
||||
# Contact me
|
||||
|
||||
If I can help you, you have an idea or you are using Mergo in your projects, don't hesitate to drop me a line (or a pull request): https://twitter.com/im_dario
|
||||
|
||||
# About
|
||||
|
||||
Written by Dario Castañé: https://da.rio.hn
|
||||
|
||||
# License
|
||||
|
||||
BSD 3-Clause license, as Go language.
|
||||
*/
|
||||
package mergo
|
||||
178
.gear/predownloaded-development/vendor/dario.cat/mergo/map.go
vendored
Normal file
178
.gear/predownloaded-development/vendor/dario.cat/mergo/map.go
vendored
Normal file
|
|
@ -0,0 +1,178 @@
|
|||
// Copyright 2014 Dario Castañé. All rights reserved.
|
||||
// Copyright 2009 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.
|
||||
|
||||
// Based on src/pkg/reflect/deepequal.go from official
|
||||
// golang's stdlib.
|
||||
|
||||
package mergo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
func changeInitialCase(s string, mapper func(rune) rune) string {
|
||||
if s == "" {
|
||||
return s
|
||||
}
|
||||
r, n := utf8.DecodeRuneInString(s)
|
||||
return string(mapper(r)) + s[n:]
|
||||
}
|
||||
|
||||
func isExported(field reflect.StructField) bool {
|
||||
r, _ := utf8.DecodeRuneInString(field.Name)
|
||||
return r >= 'A' && r <= 'Z'
|
||||
}
|
||||
|
||||
// Traverses recursively both values, assigning src's fields values to dst.
|
||||
// The map argument tracks comparisons that have already been seen, which allows
|
||||
// short circuiting on recursive types.
|
||||
func deepMap(dst, src reflect.Value, visited map[uintptr]*visit, depth int, config *Config) (err error) {
|
||||
overwrite := config.Overwrite
|
||||
if dst.CanAddr() {
|
||||
addr := dst.UnsafeAddr()
|
||||
h := 17 * addr
|
||||
seen := visited[h]
|
||||
typ := dst.Type()
|
||||
for p := seen; p != nil; p = p.next {
|
||||
if p.ptr == addr && p.typ == typ {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
// Remember, remember...
|
||||
visited[h] = &visit{typ, seen, addr}
|
||||
}
|
||||
zeroValue := reflect.Value{}
|
||||
switch dst.Kind() {
|
||||
case reflect.Map:
|
||||
dstMap := dst.Interface().(map[string]interface{})
|
||||
for i, n := 0, src.NumField(); i < n; i++ {
|
||||
srcType := src.Type()
|
||||
field := srcType.Field(i)
|
||||
if !isExported(field) {
|
||||
continue
|
||||
}
|
||||
fieldName := field.Name
|
||||
fieldName = changeInitialCase(fieldName, unicode.ToLower)
|
||||
if v, ok := dstMap[fieldName]; !ok || (isEmptyValue(reflect.ValueOf(v), !config.ShouldNotDereference) || overwrite) {
|
||||
dstMap[fieldName] = src.Field(i).Interface()
|
||||
}
|
||||
}
|
||||
case reflect.Ptr:
|
||||
if dst.IsNil() {
|
||||
v := reflect.New(dst.Type().Elem())
|
||||
dst.Set(v)
|
||||
}
|
||||
dst = dst.Elem()
|
||||
fallthrough
|
||||
case reflect.Struct:
|
||||
srcMap := src.Interface().(map[string]interface{})
|
||||
for key := range srcMap {
|
||||
config.overwriteWithEmptyValue = true
|
||||
srcValue := srcMap[key]
|
||||
fieldName := changeInitialCase(key, unicode.ToUpper)
|
||||
dstElement := dst.FieldByName(fieldName)
|
||||
if dstElement == zeroValue {
|
||||
// We discard it because the field doesn't exist.
|
||||
continue
|
||||
}
|
||||
srcElement := reflect.ValueOf(srcValue)
|
||||
dstKind := dstElement.Kind()
|
||||
srcKind := srcElement.Kind()
|
||||
if srcKind == reflect.Ptr && dstKind != reflect.Ptr {
|
||||
srcElement = srcElement.Elem()
|
||||
srcKind = reflect.TypeOf(srcElement.Interface()).Kind()
|
||||
} else if dstKind == reflect.Ptr {
|
||||
// Can this work? I guess it can't.
|
||||
if srcKind != reflect.Ptr && srcElement.CanAddr() {
|
||||
srcPtr := srcElement.Addr()
|
||||
srcElement = reflect.ValueOf(srcPtr)
|
||||
srcKind = reflect.Ptr
|
||||
}
|
||||
}
|
||||
|
||||
if !srcElement.IsValid() {
|
||||
continue
|
||||
}
|
||||
if srcKind == dstKind {
|
||||
if err = deepMerge(dstElement, srcElement, visited, depth+1, config); err != nil {
|
||||
return
|
||||
}
|
||||
} else if dstKind == reflect.Interface && dstElement.Kind() == reflect.Interface {
|
||||
if err = deepMerge(dstElement, srcElement, visited, depth+1, config); err != nil {
|
||||
return
|
||||
}
|
||||
} else if srcKind == reflect.Map {
|
||||
if err = deepMap(dstElement, srcElement, visited, depth+1, config); err != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("type mismatch on %s field: found %v, expected %v", fieldName, srcKind, dstKind)
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Map sets fields' values in dst from src.
|
||||
// src can be a map with string keys or a struct. dst must be the opposite:
|
||||
// if src is a map, dst must be a valid pointer to struct. If src is a struct,
|
||||
// dst must be map[string]interface{}.
|
||||
// It won't merge unexported (private) fields and will do recursively
|
||||
// any exported field.
|
||||
// If dst is a map, keys will be src fields' names in lower camel case.
|
||||
// Missing key in src that doesn't match a field in dst will be skipped. This
|
||||
// doesn't apply if dst is a map.
|
||||
// This is separated method from Merge because it is cleaner and it keeps sane
|
||||
// semantics: merging equal types, mapping different (restricted) types.
|
||||
func Map(dst, src interface{}, opts ...func(*Config)) error {
|
||||
return _map(dst, src, opts...)
|
||||
}
|
||||
|
||||
// MapWithOverwrite will do the same as Map except that non-empty dst attributes will be overridden by
|
||||
// non-empty src attribute values.
|
||||
// Deprecated: Use Map(…) with WithOverride
|
||||
func MapWithOverwrite(dst, src interface{}, opts ...func(*Config)) error {
|
||||
return _map(dst, src, append(opts, WithOverride)...)
|
||||
}
|
||||
|
||||
func _map(dst, src interface{}, opts ...func(*Config)) error {
|
||||
if dst != nil && reflect.ValueOf(dst).Kind() != reflect.Ptr {
|
||||
return ErrNonPointerArgument
|
||||
}
|
||||
var (
|
||||
vDst, vSrc reflect.Value
|
||||
err error
|
||||
)
|
||||
config := &Config{}
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(config)
|
||||
}
|
||||
|
||||
if vDst, vSrc, err = resolveValues(dst, src); err != nil {
|
||||
return err
|
||||
}
|
||||
// To be friction-less, we redirect equal-type arguments
|
||||
// to deepMerge. Only because arguments can be anything.
|
||||
if vSrc.Kind() == vDst.Kind() {
|
||||
return deepMerge(vDst, vSrc, make(map[uintptr]*visit), 0, config)
|
||||
}
|
||||
switch vSrc.Kind() {
|
||||
case reflect.Struct:
|
||||
if vDst.Kind() != reflect.Map {
|
||||
return ErrExpectedMapAsDestination
|
||||
}
|
||||
case reflect.Map:
|
||||
if vDst.Kind() != reflect.Struct {
|
||||
return ErrExpectedStructAsDestination
|
||||
}
|
||||
default:
|
||||
return ErrNotSupported
|
||||
}
|
||||
return deepMap(vDst, vSrc, make(map[uintptr]*visit), 0, config)
|
||||
}
|
||||
409
.gear/predownloaded-development/vendor/dario.cat/mergo/merge.go
vendored
Normal file
409
.gear/predownloaded-development/vendor/dario.cat/mergo/merge.go
vendored
Normal file
|
|
@ -0,0 +1,409 @@
|
|||
// Copyright 2013 Dario Castañé. All rights reserved.
|
||||
// Copyright 2009 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.
|
||||
|
||||
// Based on src/pkg/reflect/deepequal.go from official
|
||||
// golang's stdlib.
|
||||
|
||||
package mergo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
func hasMergeableFields(dst reflect.Value) (exported bool) {
|
||||
for i, n := 0, dst.NumField(); i < n; i++ {
|
||||
field := dst.Type().Field(i)
|
||||
if field.Anonymous && dst.Field(i).Kind() == reflect.Struct {
|
||||
exported = exported || hasMergeableFields(dst.Field(i))
|
||||
} else if isExportedComponent(&field) {
|
||||
exported = exported || len(field.PkgPath) == 0
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func isExportedComponent(field *reflect.StructField) bool {
|
||||
pkgPath := field.PkgPath
|
||||
if len(pkgPath) > 0 {
|
||||
return false
|
||||
}
|
||||
c := field.Name[0]
|
||||
if 'a' <= c && c <= 'z' || c == '_' {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Transformers Transformers
|
||||
Overwrite bool
|
||||
ShouldNotDereference bool
|
||||
AppendSlice bool
|
||||
TypeCheck bool
|
||||
overwriteWithEmptyValue bool
|
||||
overwriteSliceWithEmptyValue bool
|
||||
sliceDeepCopy bool
|
||||
debug bool
|
||||
}
|
||||
|
||||
type Transformers interface {
|
||||
Transformer(reflect.Type) func(dst, src reflect.Value) error
|
||||
}
|
||||
|
||||
// Traverses recursively both values, assigning src's fields values to dst.
|
||||
// The map argument tracks comparisons that have already been seen, which allows
|
||||
// short circuiting on recursive types.
|
||||
func deepMerge(dst, src reflect.Value, visited map[uintptr]*visit, depth int, config *Config) (err error) {
|
||||
overwrite := config.Overwrite
|
||||
typeCheck := config.TypeCheck
|
||||
overwriteWithEmptySrc := config.overwriteWithEmptyValue
|
||||
overwriteSliceWithEmptySrc := config.overwriteSliceWithEmptyValue
|
||||
sliceDeepCopy := config.sliceDeepCopy
|
||||
|
||||
if !src.IsValid() {
|
||||
return
|
||||
}
|
||||
if dst.CanAddr() {
|
||||
addr := dst.UnsafeAddr()
|
||||
h := 17 * addr
|
||||
seen := visited[h]
|
||||
typ := dst.Type()
|
||||
for p := seen; p != nil; p = p.next {
|
||||
if p.ptr == addr && p.typ == typ {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
// Remember, remember...
|
||||
visited[h] = &visit{typ, seen, addr}
|
||||
}
|
||||
|
||||
if config.Transformers != nil && !isReflectNil(dst) && dst.IsValid() {
|
||||
if fn := config.Transformers.Transformer(dst.Type()); fn != nil {
|
||||
err = fn(dst, src)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
switch dst.Kind() {
|
||||
case reflect.Struct:
|
||||
if hasMergeableFields(dst) {
|
||||
for i, n := 0, dst.NumField(); i < n; i++ {
|
||||
if err = deepMerge(dst.Field(i), src.Field(i), visited, depth+1, config); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if dst.CanSet() && (isReflectNil(dst) || overwrite) && (!isEmptyValue(src, !config.ShouldNotDereference) || overwriteWithEmptySrc) {
|
||||
dst.Set(src)
|
||||
}
|
||||
}
|
||||
case reflect.Map:
|
||||
if dst.IsNil() && !src.IsNil() {
|
||||
if dst.CanSet() {
|
||||
dst.Set(reflect.MakeMap(dst.Type()))
|
||||
} else {
|
||||
dst = src
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if src.Kind() != reflect.Map {
|
||||
if overwrite && dst.CanSet() {
|
||||
dst.Set(src)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
for _, key := range src.MapKeys() {
|
||||
srcElement := src.MapIndex(key)
|
||||
if !srcElement.IsValid() {
|
||||
continue
|
||||
}
|
||||
dstElement := dst.MapIndex(key)
|
||||
switch srcElement.Kind() {
|
||||
case reflect.Chan, reflect.Func, reflect.Map, reflect.Interface, reflect.Slice:
|
||||
if srcElement.IsNil() {
|
||||
if overwrite {
|
||||
dst.SetMapIndex(key, srcElement)
|
||||
}
|
||||
continue
|
||||
}
|
||||
fallthrough
|
||||
default:
|
||||
if !srcElement.CanInterface() {
|
||||
continue
|
||||
}
|
||||
switch reflect.TypeOf(srcElement.Interface()).Kind() {
|
||||
case reflect.Struct:
|
||||
fallthrough
|
||||
case reflect.Ptr:
|
||||
fallthrough
|
||||
case reflect.Map:
|
||||
srcMapElm := srcElement
|
||||
dstMapElm := dstElement
|
||||
if srcMapElm.CanInterface() {
|
||||
srcMapElm = reflect.ValueOf(srcMapElm.Interface())
|
||||
if dstMapElm.IsValid() {
|
||||
dstMapElm = reflect.ValueOf(dstMapElm.Interface())
|
||||
}
|
||||
}
|
||||
if err = deepMerge(dstMapElm, srcMapElm, visited, depth+1, config); err != nil {
|
||||
return
|
||||
}
|
||||
case reflect.Slice:
|
||||
srcSlice := reflect.ValueOf(srcElement.Interface())
|
||||
|
||||
var dstSlice reflect.Value
|
||||
if !dstElement.IsValid() || dstElement.IsNil() {
|
||||
dstSlice = reflect.MakeSlice(srcSlice.Type(), 0, srcSlice.Len())
|
||||
} else {
|
||||
dstSlice = reflect.ValueOf(dstElement.Interface())
|
||||
}
|
||||
|
||||
if (!isEmptyValue(src, !config.ShouldNotDereference) || overwriteWithEmptySrc || overwriteSliceWithEmptySrc) && (overwrite || isEmptyValue(dst, !config.ShouldNotDereference)) && !config.AppendSlice && !sliceDeepCopy {
|
||||
if typeCheck && srcSlice.Type() != dstSlice.Type() {
|
||||
return fmt.Errorf("cannot override two slices with different type (%s, %s)", srcSlice.Type(), dstSlice.Type())
|
||||
}
|
||||
dstSlice = srcSlice
|
||||
} else if config.AppendSlice {
|
||||
if srcSlice.Type() != dstSlice.Type() {
|
||||
return fmt.Errorf("cannot append two slices with different type (%s, %s)", srcSlice.Type(), dstSlice.Type())
|
||||
}
|
||||
dstSlice = reflect.AppendSlice(dstSlice, srcSlice)
|
||||
} else if sliceDeepCopy {
|
||||
i := 0
|
||||
for ; i < srcSlice.Len() && i < dstSlice.Len(); i++ {
|
||||
srcElement := srcSlice.Index(i)
|
||||
dstElement := dstSlice.Index(i)
|
||||
|
||||
if srcElement.CanInterface() {
|
||||
srcElement = reflect.ValueOf(srcElement.Interface())
|
||||
}
|
||||
if dstElement.CanInterface() {
|
||||
dstElement = reflect.ValueOf(dstElement.Interface())
|
||||
}
|
||||
|
||||
if err = deepMerge(dstElement, srcElement, visited, depth+1, config); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
dst.SetMapIndex(key, dstSlice)
|
||||
}
|
||||
}
|
||||
|
||||
if dstElement.IsValid() && !isEmptyValue(dstElement, !config.ShouldNotDereference) {
|
||||
if reflect.TypeOf(srcElement.Interface()).Kind() == reflect.Slice {
|
||||
continue
|
||||
}
|
||||
if reflect.TypeOf(srcElement.Interface()).Kind() == reflect.Map && reflect.TypeOf(dstElement.Interface()).Kind() == reflect.Map {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if srcElement.IsValid() && ((srcElement.Kind() != reflect.Ptr && overwrite) || !dstElement.IsValid() || isEmptyValue(dstElement, !config.ShouldNotDereference)) {
|
||||
if dst.IsNil() {
|
||||
dst.Set(reflect.MakeMap(dst.Type()))
|
||||
}
|
||||
dst.SetMapIndex(key, srcElement)
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure that all keys in dst are deleted if they are not in src.
|
||||
if overwriteWithEmptySrc {
|
||||
for _, key := range dst.MapKeys() {
|
||||
srcElement := src.MapIndex(key)
|
||||
if !srcElement.IsValid() {
|
||||
dst.SetMapIndex(key, reflect.Value{})
|
||||
}
|
||||
}
|
||||
}
|
||||
case reflect.Slice:
|
||||
if !dst.CanSet() {
|
||||
break
|
||||
}
|
||||
if (!isEmptyValue(src, !config.ShouldNotDereference) || overwriteWithEmptySrc || overwriteSliceWithEmptySrc) && (overwrite || isEmptyValue(dst, !config.ShouldNotDereference)) && !config.AppendSlice && !sliceDeepCopy {
|
||||
dst.Set(src)
|
||||
} else if config.AppendSlice {
|
||||
if src.Type() != dst.Type() {
|
||||
return fmt.Errorf("cannot append two slice with different type (%s, %s)", src.Type(), dst.Type())
|
||||
}
|
||||
dst.Set(reflect.AppendSlice(dst, src))
|
||||
} else if sliceDeepCopy {
|
||||
for i := 0; i < src.Len() && i < dst.Len(); i++ {
|
||||
srcElement := src.Index(i)
|
||||
dstElement := dst.Index(i)
|
||||
if srcElement.CanInterface() {
|
||||
srcElement = reflect.ValueOf(srcElement.Interface())
|
||||
}
|
||||
if dstElement.CanInterface() {
|
||||
dstElement = reflect.ValueOf(dstElement.Interface())
|
||||
}
|
||||
|
||||
if err = deepMerge(dstElement, srcElement, visited, depth+1, config); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
case reflect.Ptr:
|
||||
fallthrough
|
||||
case reflect.Interface:
|
||||
if isReflectNil(src) {
|
||||
if overwriteWithEmptySrc && dst.CanSet() && src.Type().AssignableTo(dst.Type()) {
|
||||
dst.Set(src)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
if src.Kind() != reflect.Interface {
|
||||
if dst.IsNil() || (src.Kind() != reflect.Ptr && overwrite) {
|
||||
if dst.CanSet() && (overwrite || isEmptyValue(dst, !config.ShouldNotDereference)) {
|
||||
dst.Set(src)
|
||||
}
|
||||
} else if src.Kind() == reflect.Ptr {
|
||||
if !config.ShouldNotDereference {
|
||||
if err = deepMerge(dst.Elem(), src.Elem(), visited, depth+1, config); err != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if overwriteWithEmptySrc || (overwrite && !src.IsNil()) || dst.IsNil() {
|
||||
dst.Set(src)
|
||||
}
|
||||
}
|
||||
} else if dst.Elem().Type() == src.Type() {
|
||||
if err = deepMerge(dst.Elem(), src, visited, depth+1, config); err != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
return ErrDifferentArgumentsTypes
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
if dst.IsNil() || overwrite {
|
||||
if dst.CanSet() && (overwrite || isEmptyValue(dst, !config.ShouldNotDereference)) {
|
||||
dst.Set(src)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
if dst.Elem().Kind() == src.Elem().Kind() {
|
||||
if err = deepMerge(dst.Elem(), src.Elem(), visited, depth+1, config); err != nil {
|
||||
return
|
||||
}
|
||||
break
|
||||
}
|
||||
default:
|
||||
mustSet := (isEmptyValue(dst, !config.ShouldNotDereference) || overwrite) && (!isEmptyValue(src, !config.ShouldNotDereference) || overwriteWithEmptySrc)
|
||||
if mustSet {
|
||||
if dst.CanSet() {
|
||||
dst.Set(src)
|
||||
} else {
|
||||
dst = src
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Merge will fill any empty for value type attributes on the dst struct using corresponding
|
||||
// src attributes if they themselves are not empty. dst and src must be valid same-type structs
|
||||
// and dst must be a pointer to struct.
|
||||
// It won't merge unexported (private) fields and will do recursively any exported field.
|
||||
func Merge(dst, src interface{}, opts ...func(*Config)) error {
|
||||
return merge(dst, src, opts...)
|
||||
}
|
||||
|
||||
// MergeWithOverwrite will do the same as Merge except that non-empty dst attributes will be overridden by
|
||||
// non-empty src attribute values.
|
||||
// Deprecated: use Merge(…) with WithOverride
|
||||
func MergeWithOverwrite(dst, src interface{}, opts ...func(*Config)) error {
|
||||
return merge(dst, src, append(opts, WithOverride)...)
|
||||
}
|
||||
|
||||
// WithTransformers adds transformers to merge, allowing to customize the merging of some types.
|
||||
func WithTransformers(transformers Transformers) func(*Config) {
|
||||
return func(config *Config) {
|
||||
config.Transformers = transformers
|
||||
}
|
||||
}
|
||||
|
||||
// WithOverride will make merge override non-empty dst attributes with non-empty src attributes values.
|
||||
func WithOverride(config *Config) {
|
||||
config.Overwrite = true
|
||||
}
|
||||
|
||||
// WithOverwriteWithEmptyValue will make merge override non empty dst attributes with empty src attributes values.
|
||||
func WithOverwriteWithEmptyValue(config *Config) {
|
||||
config.Overwrite = true
|
||||
config.overwriteWithEmptyValue = true
|
||||
}
|
||||
|
||||
// WithOverrideEmptySlice will make merge override empty dst slice with empty src slice.
|
||||
func WithOverrideEmptySlice(config *Config) {
|
||||
config.overwriteSliceWithEmptyValue = true
|
||||
}
|
||||
|
||||
// WithoutDereference prevents dereferencing pointers when evaluating whether they are empty
|
||||
// (i.e. a non-nil pointer is never considered empty).
|
||||
func WithoutDereference(config *Config) {
|
||||
config.ShouldNotDereference = true
|
||||
}
|
||||
|
||||
// WithAppendSlice will make merge append slices instead of overwriting it.
|
||||
func WithAppendSlice(config *Config) {
|
||||
config.AppendSlice = true
|
||||
}
|
||||
|
||||
// WithTypeCheck will make merge check types while overwriting it (must be used with WithOverride).
|
||||
func WithTypeCheck(config *Config) {
|
||||
config.TypeCheck = true
|
||||
}
|
||||
|
||||
// WithSliceDeepCopy will merge slice element one by one with Overwrite flag.
|
||||
func WithSliceDeepCopy(config *Config) {
|
||||
config.sliceDeepCopy = true
|
||||
config.Overwrite = true
|
||||
}
|
||||
|
||||
func merge(dst, src interface{}, opts ...func(*Config)) error {
|
||||
if dst != nil && reflect.ValueOf(dst).Kind() != reflect.Ptr {
|
||||
return ErrNonPointerArgument
|
||||
}
|
||||
var (
|
||||
vDst, vSrc reflect.Value
|
||||
err error
|
||||
)
|
||||
|
||||
config := &Config{}
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(config)
|
||||
}
|
||||
|
||||
if vDst, vSrc, err = resolveValues(dst, src); err != nil {
|
||||
return err
|
||||
}
|
||||
if vDst.Type() != vSrc.Type() {
|
||||
return ErrDifferentArgumentsTypes
|
||||
}
|
||||
return deepMerge(vDst, vSrc, make(map[uintptr]*visit), 0, config)
|
||||
}
|
||||
|
||||
// IsReflectNil is the reflect value provided nil
|
||||
func isReflectNil(v reflect.Value) bool {
|
||||
k := v.Kind()
|
||||
switch k {
|
||||
case reflect.Interface, reflect.Slice, reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr:
|
||||
// Both interface and slice are nil if first word is 0.
|
||||
// Both are always bigger than a word; assume flagIndir.
|
||||
return v.IsNil()
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
81
.gear/predownloaded-development/vendor/dario.cat/mergo/mergo.go
vendored
Normal file
81
.gear/predownloaded-development/vendor/dario.cat/mergo/mergo.go
vendored
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
// Copyright 2013 Dario Castañé. All rights reserved.
|
||||
// Copyright 2009 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.
|
||||
|
||||
// Based on src/pkg/reflect/deepequal.go from official
|
||||
// golang's stdlib.
|
||||
|
||||
package mergo
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
// Errors reported by Mergo when it finds invalid arguments.
|
||||
var (
|
||||
ErrNilArguments = errors.New("src and dst must not be nil")
|
||||
ErrDifferentArgumentsTypes = errors.New("src and dst must be of same type")
|
||||
ErrNotSupported = errors.New("only structs, maps, and slices are supported")
|
||||
ErrExpectedMapAsDestination = errors.New("dst was expected to be a map")
|
||||
ErrExpectedStructAsDestination = errors.New("dst was expected to be a struct")
|
||||
ErrNonPointerArgument = errors.New("dst must be a pointer")
|
||||
)
|
||||
|
||||
// During deepMerge, must keep track of checks that are
|
||||
// in progress. The comparison algorithm assumes that all
|
||||
// checks in progress are true when it reencounters them.
|
||||
// Visited are stored in a map indexed by 17 * a1 + a2;
|
||||
type visit struct {
|
||||
typ reflect.Type
|
||||
next *visit
|
||||
ptr uintptr
|
||||
}
|
||||
|
||||
// From src/pkg/encoding/json/encode.go.
|
||||
func isEmptyValue(v reflect.Value, shouldDereference bool) bool {
|
||||
switch v.Kind() {
|
||||
case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
|
||||
return v.Len() == 0
|
||||
case reflect.Bool:
|
||||
return !v.Bool()
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
return v.Int() == 0
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
|
||||
return v.Uint() == 0
|
||||
case reflect.Float32, reflect.Float64:
|
||||
return v.Float() == 0
|
||||
case reflect.Interface, reflect.Ptr:
|
||||
if v.IsNil() {
|
||||
return true
|
||||
}
|
||||
if shouldDereference {
|
||||
return isEmptyValue(v.Elem(), shouldDereference)
|
||||
}
|
||||
return false
|
||||
case reflect.Func:
|
||||
return v.IsNil()
|
||||
case reflect.Invalid:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func resolveValues(dst, src interface{}) (vDst, vSrc reflect.Value, err error) {
|
||||
if dst == nil || src == nil {
|
||||
err = ErrNilArguments
|
||||
return
|
||||
}
|
||||
vDst = reflect.ValueOf(dst).Elem()
|
||||
if vDst.Kind() != reflect.Struct && vDst.Kind() != reflect.Map && vDst.Kind() != reflect.Slice {
|
||||
err = ErrNotSupported
|
||||
return
|
||||
}
|
||||
vSrc = reflect.ValueOf(src)
|
||||
// We check if vSrc is a pointer to dereference it.
|
||||
if vSrc.Kind() == reflect.Ptr {
|
||||
vSrc = vSrc.Elem()
|
||||
}
|
||||
return
|
||||
}
|
||||
21
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/LICENSE
generated
vendored
Normal file
21
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Microsoft Corporation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
12
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/README.md
generated
vendored
Normal file
12
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# go-ansiterm
|
||||
|
||||
This is a cross platform Ansi Terminal Emulation library. It reads a stream of Ansi characters and produces the appropriate function calls. The results of the function calls are platform dependent.
|
||||
|
||||
For example the parser might receive "ESC, [, A" as a stream of three characters. This is the code for Cursor Up (http://www.vt100.net/docs/vt510-rm/CUU). The parser then calls the cursor up function (CUU()) on an event handler. The event handler determines what platform specific work must be done to cause the cursor to move up one position.
|
||||
|
||||
The parser (parser.go) is a partial implementation of this state machine (http://vt100.net/emu/vt500_parser.png). There are also two event handler implementations, one for tests (test_event_handler.go) to validate that the expected events are being produced and called, the other is a Windows implementation (winterm/win_event_handler.go).
|
||||
|
||||
See parser_test.go for examples exercising the state machine and generating appropriate function calls.
|
||||
|
||||
-----
|
||||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
||||
41
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/SECURITY.md
generated
vendored
Normal file
41
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/SECURITY.md
generated
vendored
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.8 BLOCK -->
|
||||
|
||||
## Security
|
||||
|
||||
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
|
||||
|
||||
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below.
|
||||
|
||||
## Reporting Security Issues
|
||||
|
||||
**Please do not report security vulnerabilities through public GitHub issues.**
|
||||
|
||||
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report).
|
||||
|
||||
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey).
|
||||
|
||||
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc).
|
||||
|
||||
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
|
||||
|
||||
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
|
||||
* Full paths of source file(s) related to the manifestation of the issue
|
||||
* The location of the affected source code (tag/branch/commit or direct URL)
|
||||
* Any special configuration required to reproduce the issue
|
||||
* Step-by-step instructions to reproduce the issue
|
||||
* Proof-of-concept or exploit code (if possible)
|
||||
* Impact of the issue, including how an attacker might exploit the issue
|
||||
|
||||
This information will help us triage your report more quickly.
|
||||
|
||||
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs.
|
||||
|
||||
## Preferred Languages
|
||||
|
||||
We prefer all communications to be in English.
|
||||
|
||||
## Policy
|
||||
|
||||
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd).
|
||||
|
||||
<!-- END MICROSOFT SECURITY.MD BLOCK -->
|
||||
188
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/constants.go
generated
vendored
Normal file
188
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/constants.go
generated
vendored
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
package ansiterm
|
||||
|
||||
const LogEnv = "DEBUG_TERMINAL"
|
||||
|
||||
// ANSI constants
|
||||
// References:
|
||||
// -- http://www.ecma-international.org/publications/standards/Ecma-048.htm
|
||||
// -- http://man7.org/linux/man-pages/man4/console_codes.4.html
|
||||
// -- http://manpages.ubuntu.com/manpages/intrepid/man4/console_codes.4.html
|
||||
// -- http://en.wikipedia.org/wiki/ANSI_escape_code
|
||||
// -- http://vt100.net/emu/dec_ansi_parser
|
||||
// -- http://vt100.net/emu/vt500_parser.svg
|
||||
// -- http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
|
||||
// -- http://www.inwap.com/pdp10/ansicode.txt
|
||||
const (
|
||||
// ECMA-48 Set Graphics Rendition
|
||||
// Note:
|
||||
// -- Constants leading with an underscore (e.g., _ANSI_xxx) are unsupported or reserved
|
||||
// -- Fonts could possibly be supported via SetCurrentConsoleFontEx
|
||||
// -- Windows does not expose the per-window cursor (i.e., caret) blink times
|
||||
ANSI_SGR_RESET = 0
|
||||
ANSI_SGR_BOLD = 1
|
||||
ANSI_SGR_DIM = 2
|
||||
_ANSI_SGR_ITALIC = 3
|
||||
ANSI_SGR_UNDERLINE = 4
|
||||
_ANSI_SGR_BLINKSLOW = 5
|
||||
_ANSI_SGR_BLINKFAST = 6
|
||||
ANSI_SGR_REVERSE = 7
|
||||
_ANSI_SGR_INVISIBLE = 8
|
||||
_ANSI_SGR_LINETHROUGH = 9
|
||||
_ANSI_SGR_FONT_00 = 10
|
||||
_ANSI_SGR_FONT_01 = 11
|
||||
_ANSI_SGR_FONT_02 = 12
|
||||
_ANSI_SGR_FONT_03 = 13
|
||||
_ANSI_SGR_FONT_04 = 14
|
||||
_ANSI_SGR_FONT_05 = 15
|
||||
_ANSI_SGR_FONT_06 = 16
|
||||
_ANSI_SGR_FONT_07 = 17
|
||||
_ANSI_SGR_FONT_08 = 18
|
||||
_ANSI_SGR_FONT_09 = 19
|
||||
_ANSI_SGR_FONT_10 = 20
|
||||
_ANSI_SGR_DOUBLEUNDERLINE = 21
|
||||
ANSI_SGR_BOLD_DIM_OFF = 22
|
||||
_ANSI_SGR_ITALIC_OFF = 23
|
||||
ANSI_SGR_UNDERLINE_OFF = 24
|
||||
_ANSI_SGR_BLINK_OFF = 25
|
||||
_ANSI_SGR_RESERVED_00 = 26
|
||||
ANSI_SGR_REVERSE_OFF = 27
|
||||
_ANSI_SGR_INVISIBLE_OFF = 28
|
||||
_ANSI_SGR_LINETHROUGH_OFF = 29
|
||||
ANSI_SGR_FOREGROUND_BLACK = 30
|
||||
ANSI_SGR_FOREGROUND_RED = 31
|
||||
ANSI_SGR_FOREGROUND_GREEN = 32
|
||||
ANSI_SGR_FOREGROUND_YELLOW = 33
|
||||
ANSI_SGR_FOREGROUND_BLUE = 34
|
||||
ANSI_SGR_FOREGROUND_MAGENTA = 35
|
||||
ANSI_SGR_FOREGROUND_CYAN = 36
|
||||
ANSI_SGR_FOREGROUND_WHITE = 37
|
||||
_ANSI_SGR_RESERVED_01 = 38
|
||||
ANSI_SGR_FOREGROUND_DEFAULT = 39
|
||||
ANSI_SGR_BACKGROUND_BLACK = 40
|
||||
ANSI_SGR_BACKGROUND_RED = 41
|
||||
ANSI_SGR_BACKGROUND_GREEN = 42
|
||||
ANSI_SGR_BACKGROUND_YELLOW = 43
|
||||
ANSI_SGR_BACKGROUND_BLUE = 44
|
||||
ANSI_SGR_BACKGROUND_MAGENTA = 45
|
||||
ANSI_SGR_BACKGROUND_CYAN = 46
|
||||
ANSI_SGR_BACKGROUND_WHITE = 47
|
||||
_ANSI_SGR_RESERVED_02 = 48
|
||||
ANSI_SGR_BACKGROUND_DEFAULT = 49
|
||||
// 50 - 65: Unsupported
|
||||
|
||||
ANSI_MAX_CMD_LENGTH = 4096
|
||||
|
||||
MAX_INPUT_EVENTS = 128
|
||||
DEFAULT_WIDTH = 80
|
||||
DEFAULT_HEIGHT = 24
|
||||
|
||||
ANSI_BEL = 0x07
|
||||
ANSI_BACKSPACE = 0x08
|
||||
ANSI_TAB = 0x09
|
||||
ANSI_LINE_FEED = 0x0A
|
||||
ANSI_VERTICAL_TAB = 0x0B
|
||||
ANSI_FORM_FEED = 0x0C
|
||||
ANSI_CARRIAGE_RETURN = 0x0D
|
||||
ANSI_ESCAPE_PRIMARY = 0x1B
|
||||
ANSI_ESCAPE_SECONDARY = 0x5B
|
||||
ANSI_OSC_STRING_ENTRY = 0x5D
|
||||
ANSI_COMMAND_FIRST = 0x40
|
||||
ANSI_COMMAND_LAST = 0x7E
|
||||
DCS_ENTRY = 0x90
|
||||
CSI_ENTRY = 0x9B
|
||||
OSC_STRING = 0x9D
|
||||
ANSI_PARAMETER_SEP = ";"
|
||||
ANSI_CMD_G0 = '('
|
||||
ANSI_CMD_G1 = ')'
|
||||
ANSI_CMD_G2 = '*'
|
||||
ANSI_CMD_G3 = '+'
|
||||
ANSI_CMD_DECPNM = '>'
|
||||
ANSI_CMD_DECPAM = '='
|
||||
ANSI_CMD_OSC = ']'
|
||||
ANSI_CMD_STR_TERM = '\\'
|
||||
|
||||
KEY_CONTROL_PARAM_2 = ";2"
|
||||
KEY_CONTROL_PARAM_3 = ";3"
|
||||
KEY_CONTROL_PARAM_4 = ";4"
|
||||
KEY_CONTROL_PARAM_5 = ";5"
|
||||
KEY_CONTROL_PARAM_6 = ";6"
|
||||
KEY_CONTROL_PARAM_7 = ";7"
|
||||
KEY_CONTROL_PARAM_8 = ";8"
|
||||
KEY_ESC_CSI = "\x1B["
|
||||
KEY_ESC_N = "\x1BN"
|
||||
KEY_ESC_O = "\x1BO"
|
||||
|
||||
FILL_CHARACTER = ' '
|
||||
)
|
||||
|
||||
func getByteRange(start byte, end byte) []byte {
|
||||
bytes := make([]byte, 0, 32)
|
||||
for i := start; i <= end; i++ {
|
||||
bytes = append(bytes, byte(i))
|
||||
}
|
||||
|
||||
return bytes
|
||||
}
|
||||
|
||||
var toGroundBytes = getToGroundBytes()
|
||||
var executors = getExecuteBytes()
|
||||
|
||||
// SPACE 20+A0 hex Always and everywhere a blank space
|
||||
// Intermediate 20-2F hex !"#$%&'()*+,-./
|
||||
var intermeds = getByteRange(0x20, 0x2F)
|
||||
|
||||
// Parameters 30-3F hex 0123456789:;<=>?
|
||||
// CSI Parameters 30-39, 3B hex 0123456789;
|
||||
var csiParams = getByteRange(0x30, 0x3F)
|
||||
|
||||
var csiCollectables = append(getByteRange(0x30, 0x39), getByteRange(0x3B, 0x3F)...)
|
||||
|
||||
// Uppercase 40-5F hex @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
|
||||
var upperCase = getByteRange(0x40, 0x5F)
|
||||
|
||||
// Lowercase 60-7E hex `abcdefghijlkmnopqrstuvwxyz{|}~
|
||||
var lowerCase = getByteRange(0x60, 0x7E)
|
||||
|
||||
// Alphabetics 40-7E hex (all of upper and lower case)
|
||||
var alphabetics = append(upperCase, lowerCase...)
|
||||
|
||||
var printables = getByteRange(0x20, 0x7F)
|
||||
|
||||
var escapeIntermediateToGroundBytes = getByteRange(0x30, 0x7E)
|
||||
var escapeToGroundBytes = getEscapeToGroundBytes()
|
||||
|
||||
// See http://www.vt100.net/emu/vt500_parser.png for description of the complex
|
||||
// byte ranges below
|
||||
|
||||
func getEscapeToGroundBytes() []byte {
|
||||
escapeToGroundBytes := getByteRange(0x30, 0x4F)
|
||||
escapeToGroundBytes = append(escapeToGroundBytes, getByteRange(0x51, 0x57)...)
|
||||
escapeToGroundBytes = append(escapeToGroundBytes, 0x59)
|
||||
escapeToGroundBytes = append(escapeToGroundBytes, 0x5A)
|
||||
escapeToGroundBytes = append(escapeToGroundBytes, 0x5C)
|
||||
escapeToGroundBytes = append(escapeToGroundBytes, getByteRange(0x60, 0x7E)...)
|
||||
return escapeToGroundBytes
|
||||
}
|
||||
|
||||
func getExecuteBytes() []byte {
|
||||
executeBytes := getByteRange(0x00, 0x17)
|
||||
executeBytes = append(executeBytes, 0x19)
|
||||
executeBytes = append(executeBytes, getByteRange(0x1C, 0x1F)...)
|
||||
return executeBytes
|
||||
}
|
||||
|
||||
func getToGroundBytes() []byte {
|
||||
groundBytes := []byte{0x18}
|
||||
groundBytes = append(groundBytes, 0x1A)
|
||||
groundBytes = append(groundBytes, getByteRange(0x80, 0x8F)...)
|
||||
groundBytes = append(groundBytes, getByteRange(0x91, 0x97)...)
|
||||
groundBytes = append(groundBytes, 0x99)
|
||||
groundBytes = append(groundBytes, 0x9A)
|
||||
groundBytes = append(groundBytes, 0x9C)
|
||||
return groundBytes
|
||||
}
|
||||
|
||||
// Delete 7F hex Always and everywhere ignored
|
||||
// C1 Control 80-9F hex 32 additional control characters
|
||||
// G1 Displayable A1-FE hex 94 additional displayable characters
|
||||
// Special A0+FF hex Same as SPACE and DELETE
|
||||
7
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/context.go
generated
vendored
Normal file
7
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/context.go
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
package ansiterm
|
||||
|
||||
type ansiContext struct {
|
||||
currentChar byte
|
||||
paramBuffer []byte
|
||||
interBuffer []byte
|
||||
}
|
||||
49
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/csi_entry_state.go
generated
vendored
Normal file
49
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/csi_entry_state.go
generated
vendored
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
package ansiterm
|
||||
|
||||
type csiEntryState struct {
|
||||
baseState
|
||||
}
|
||||
|
||||
func (csiState csiEntryState) Handle(b byte) (s state, e error) {
|
||||
csiState.parser.logf("CsiEntry::Handle %#x", b)
|
||||
|
||||
nextState, err := csiState.baseState.Handle(b)
|
||||
if nextState != nil || err != nil {
|
||||
return nextState, err
|
||||
}
|
||||
|
||||
switch {
|
||||
case sliceContains(alphabetics, b):
|
||||
return csiState.parser.ground, nil
|
||||
case sliceContains(csiCollectables, b):
|
||||
return csiState.parser.csiParam, nil
|
||||
case sliceContains(executors, b):
|
||||
return csiState, csiState.parser.execute()
|
||||
}
|
||||
|
||||
return csiState, nil
|
||||
}
|
||||
|
||||
func (csiState csiEntryState) Transition(s state) error {
|
||||
csiState.parser.logf("CsiEntry::Transition %s --> %s", csiState.Name(), s.Name())
|
||||
csiState.baseState.Transition(s)
|
||||
|
||||
switch s {
|
||||
case csiState.parser.ground:
|
||||
return csiState.parser.csiDispatch()
|
||||
case csiState.parser.csiParam:
|
||||
switch {
|
||||
case sliceContains(csiParams, csiState.parser.context.currentChar):
|
||||
csiState.parser.collectParam()
|
||||
case sliceContains(intermeds, csiState.parser.context.currentChar):
|
||||
csiState.parser.collectInter()
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (csiState csiEntryState) Enter() error {
|
||||
csiState.parser.clear()
|
||||
return nil
|
||||
}
|
||||
38
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/csi_param_state.go
generated
vendored
Normal file
38
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/csi_param_state.go
generated
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
package ansiterm
|
||||
|
||||
type csiParamState struct {
|
||||
baseState
|
||||
}
|
||||
|
||||
func (csiState csiParamState) Handle(b byte) (s state, e error) {
|
||||
csiState.parser.logf("CsiParam::Handle %#x", b)
|
||||
|
||||
nextState, err := csiState.baseState.Handle(b)
|
||||
if nextState != nil || err != nil {
|
||||
return nextState, err
|
||||
}
|
||||
|
||||
switch {
|
||||
case sliceContains(alphabetics, b):
|
||||
return csiState.parser.ground, nil
|
||||
case sliceContains(csiCollectables, b):
|
||||
csiState.parser.collectParam()
|
||||
return csiState, nil
|
||||
case sliceContains(executors, b):
|
||||
return csiState, csiState.parser.execute()
|
||||
}
|
||||
|
||||
return csiState, nil
|
||||
}
|
||||
|
||||
func (csiState csiParamState) Transition(s state) error {
|
||||
csiState.parser.logf("CsiParam::Transition %s --> %s", csiState.Name(), s.Name())
|
||||
csiState.baseState.Transition(s)
|
||||
|
||||
switch s {
|
||||
case csiState.parser.ground:
|
||||
return csiState.parser.csiDispatch()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
36
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/escape_intermediate_state.go
generated
vendored
Normal file
36
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/escape_intermediate_state.go
generated
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
package ansiterm
|
||||
|
||||
type escapeIntermediateState struct {
|
||||
baseState
|
||||
}
|
||||
|
||||
func (escState escapeIntermediateState) Handle(b byte) (s state, e error) {
|
||||
escState.parser.logf("escapeIntermediateState::Handle %#x", b)
|
||||
nextState, err := escState.baseState.Handle(b)
|
||||
if nextState != nil || err != nil {
|
||||
return nextState, err
|
||||
}
|
||||
|
||||
switch {
|
||||
case sliceContains(intermeds, b):
|
||||
return escState, escState.parser.collectInter()
|
||||
case sliceContains(executors, b):
|
||||
return escState, escState.parser.execute()
|
||||
case sliceContains(escapeIntermediateToGroundBytes, b):
|
||||
return escState.parser.ground, nil
|
||||
}
|
||||
|
||||
return escState, nil
|
||||
}
|
||||
|
||||
func (escState escapeIntermediateState) Transition(s state) error {
|
||||
escState.parser.logf("escapeIntermediateState::Transition %s --> %s", escState.Name(), s.Name())
|
||||
escState.baseState.Transition(s)
|
||||
|
||||
switch s {
|
||||
case escState.parser.ground:
|
||||
return escState.parser.escDispatch()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
47
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/escape_state.go
generated
vendored
Normal file
47
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/escape_state.go
generated
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
package ansiterm
|
||||
|
||||
type escapeState struct {
|
||||
baseState
|
||||
}
|
||||
|
||||
func (escState escapeState) Handle(b byte) (s state, e error) {
|
||||
escState.parser.logf("escapeState::Handle %#x", b)
|
||||
nextState, err := escState.baseState.Handle(b)
|
||||
if nextState != nil || err != nil {
|
||||
return nextState, err
|
||||
}
|
||||
|
||||
switch {
|
||||
case b == ANSI_ESCAPE_SECONDARY:
|
||||
return escState.parser.csiEntry, nil
|
||||
case b == ANSI_OSC_STRING_ENTRY:
|
||||
return escState.parser.oscString, nil
|
||||
case sliceContains(executors, b):
|
||||
return escState, escState.parser.execute()
|
||||
case sliceContains(escapeToGroundBytes, b):
|
||||
return escState.parser.ground, nil
|
||||
case sliceContains(intermeds, b):
|
||||
return escState.parser.escapeIntermediate, nil
|
||||
}
|
||||
|
||||
return escState, nil
|
||||
}
|
||||
|
||||
func (escState escapeState) Transition(s state) error {
|
||||
escState.parser.logf("Escape::Transition %s --> %s", escState.Name(), s.Name())
|
||||
escState.baseState.Transition(s)
|
||||
|
||||
switch s {
|
||||
case escState.parser.ground:
|
||||
return escState.parser.escDispatch()
|
||||
case escState.parser.escapeIntermediate:
|
||||
return escState.parser.collectInter()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (escState escapeState) Enter() error {
|
||||
escState.parser.clear()
|
||||
return nil
|
||||
}
|
||||
90
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/event_handler.go
generated
vendored
Normal file
90
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/event_handler.go
generated
vendored
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
package ansiterm
|
||||
|
||||
type AnsiEventHandler interface {
|
||||
// Print
|
||||
Print(b byte) error
|
||||
|
||||
// Execute C0 commands
|
||||
Execute(b byte) error
|
||||
|
||||
// CUrsor Up
|
||||
CUU(int) error
|
||||
|
||||
// CUrsor Down
|
||||
CUD(int) error
|
||||
|
||||
// CUrsor Forward
|
||||
CUF(int) error
|
||||
|
||||
// CUrsor Backward
|
||||
CUB(int) error
|
||||
|
||||
// Cursor to Next Line
|
||||
CNL(int) error
|
||||
|
||||
// Cursor to Previous Line
|
||||
CPL(int) error
|
||||
|
||||
// Cursor Horizontal position Absolute
|
||||
CHA(int) error
|
||||
|
||||
// Vertical line Position Absolute
|
||||
VPA(int) error
|
||||
|
||||
// CUrsor Position
|
||||
CUP(int, int) error
|
||||
|
||||
// Horizontal and Vertical Position (depends on PUM)
|
||||
HVP(int, int) error
|
||||
|
||||
// Text Cursor Enable Mode
|
||||
DECTCEM(bool) error
|
||||
|
||||
// Origin Mode
|
||||
DECOM(bool) error
|
||||
|
||||
// 132 Column Mode
|
||||
DECCOLM(bool) error
|
||||
|
||||
// Erase in Display
|
||||
ED(int) error
|
||||
|
||||
// Erase in Line
|
||||
EL(int) error
|
||||
|
||||
// Insert Line
|
||||
IL(int) error
|
||||
|
||||
// Delete Line
|
||||
DL(int) error
|
||||
|
||||
// Insert Character
|
||||
ICH(int) error
|
||||
|
||||
// Delete Character
|
||||
DCH(int) error
|
||||
|
||||
// Set Graphics Rendition
|
||||
SGR([]int) error
|
||||
|
||||
// Pan Down
|
||||
SU(int) error
|
||||
|
||||
// Pan Up
|
||||
SD(int) error
|
||||
|
||||
// Device Attributes
|
||||
DA([]string) error
|
||||
|
||||
// Set Top and Bottom Margins
|
||||
DECSTBM(int, int) error
|
||||
|
||||
// Index
|
||||
IND() error
|
||||
|
||||
// Reverse Index
|
||||
RI() error
|
||||
|
||||
// Flush updates from previous commands
|
||||
Flush() error
|
||||
}
|
||||
24
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/ground_state.go
generated
vendored
Normal file
24
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/ground_state.go
generated
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package ansiterm
|
||||
|
||||
type groundState struct {
|
||||
baseState
|
||||
}
|
||||
|
||||
func (gs groundState) Handle(b byte) (s state, e error) {
|
||||
gs.parser.context.currentChar = b
|
||||
|
||||
nextState, err := gs.baseState.Handle(b)
|
||||
if nextState != nil || err != nil {
|
||||
return nextState, err
|
||||
}
|
||||
|
||||
switch {
|
||||
case sliceContains(printables, b):
|
||||
return gs, gs.parser.print()
|
||||
|
||||
case sliceContains(executors, b):
|
||||
return gs, gs.parser.execute()
|
||||
}
|
||||
|
||||
return gs, nil
|
||||
}
|
||||
31
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/osc_string_state.go
generated
vendored
Normal file
31
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/osc_string_state.go
generated
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package ansiterm
|
||||
|
||||
type oscStringState struct {
|
||||
baseState
|
||||
}
|
||||
|
||||
func (oscState oscStringState) Handle(b byte) (s state, e error) {
|
||||
oscState.parser.logf("OscString::Handle %#x", b)
|
||||
nextState, err := oscState.baseState.Handle(b)
|
||||
if nextState != nil || err != nil {
|
||||
return nextState, err
|
||||
}
|
||||
|
||||
switch {
|
||||
case isOscStringTerminator(b):
|
||||
return oscState.parser.ground, nil
|
||||
}
|
||||
|
||||
return oscState, nil
|
||||
}
|
||||
|
||||
// See below for OSC string terminators for linux
|
||||
// http://man7.org/linux/man-pages/man4/console_codes.4.html
|
||||
func isOscStringTerminator(b byte) bool {
|
||||
|
||||
if b == ANSI_BEL || b == 0x5C {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
151
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/parser.go
generated
vendored
Normal file
151
.gear/predownloaded-development/vendor/github.com/Azure/go-ansiterm/parser.go
generated
vendored
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
package ansiterm
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
type AnsiParser struct {
|
||||
currState state
|
||||
eventHandler AnsiEventHandler
|
||||
context *ansiContext
|
||||
csiEntry state
|
||||
csiParam state
|
||||
dcsEntry state
|
||||
escape state
|
||||
escapeIntermediate state
|
||||
error state
|
||||
ground state
|
||||
oscString state
|
||||
stateMap []state
|
||||
|
||||
logf func(string, ...interface{})
|
||||
}
|
||||
|
||||
type Option func(*AnsiParser)
|
||||
|
||||
func WithLogf(f func(string, ...interface{})) Option {
|
||||
return func(ap *AnsiParser) {
|
||||
ap.logf = f
|
||||
}
|
||||
}
|
||||
|
||||
func CreateParser(initialState string, evtHandler AnsiEventHandler, opts ...Option) *AnsiParser {
|
||||
ap := &AnsiParser{
|
||||
eventHandler: evtHandler,
|
||||
context: &ansiContext{},
|
||||
}
|
||||
for _, o := range opts {
|
||||
o(ap)
|
||||
}
|
||||
|
||||
if isDebugEnv := os.Getenv(LogEnv); isDebugEnv == "1" {
|
||||
logFile, _ := os.Create("ansiParser.log")
|
||||
logger := log.New(logFile, "", log.LstdFlags)
|
||||
if ap.logf != nil {
|
||||
l := ap.logf
|
||||
ap.logf = func(s string, v ...interface{}) {
|
||||
l(s, v...)
|
||||
logger.Printf(s, v...)
|
||||
}
|
||||
} else {
|
||||
ap.logf = logger.Printf
|
||||
}
|
||||
}
|
||||
|
||||
if ap.logf == nil {
|
||||
ap.logf = func(string, ...interface{}) {}
|
||||
}
|
||||
|
||||
ap.csiEntry = csiEntryState{baseState{name: "CsiEntry", parser: ap}}
|
||||
ap.csiParam = csiParamState{baseState{name: "CsiParam", parser: ap}}
|
||||
ap.dcsEntry = dcsEntryState{baseState{name: "DcsEntry", parser: ap}}
|
||||
ap.escape = escapeState{baseState{name: "Escape", parser: ap}}
|
||||
ap.escapeIntermediate = escapeIntermediateState{baseState{name: "EscapeIntermediate", parser: ap}}
|
||||
ap.error = errorState{baseState{name: "Error", parser: ap}}
|
||||
ap.ground = groundState{baseState{name: "Ground", parser: ap}}
|
||||
ap.oscString = oscStringState{baseState{name: "OscString", parser: ap}}
|
||||
|
||||
ap.stateMap = []state{
|
||||
ap.csiEntry,
|
||||
ap.csiParam,
|
||||
ap.dcsEntry,
|
||||
ap.escape,
|
||||
ap.escapeIntermediate,
|
||||
ap.error,
|
||||
ap.ground,
|
||||
ap.oscString,
|
||||
}
|
||||
|
||||
ap.currState = getState(initialState, ap.stateMap)
|
||||
|
||||
ap.logf("CreateParser: parser %p", ap)
|
||||
return ap
|
||||
}
|
||||
|
||||
func getState(name string, states []state) state {
|
||||
for _, el := range states {
|
||||
if el.Name() == name {
|
||||
return el
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ap *AnsiParser) Parse(bytes []byte) (int, error) {
|
||||
for i, b := range bytes {
|
||||
if err := ap.handle(b); err != nil {
|
||||
return i, err
|
||||
}
|
||||
}
|
||||
|
||||
return len(bytes), ap.eventHandler.Flush()
|
||||
}
|
||||
|
||||
func (ap *AnsiParser) handle(b byte) error {
|
||||
ap.context.currentChar = b
|
||||
newState, err := ap.currState.Handle(b)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if newState == nil {
|
||||
ap.logf("WARNING: newState is nil")
|
||||
return errors.New("New state of 'nil' is invalid.")
|
||||
}
|
||||
|
||||
if newState != ap.currState {
|
||||
if err := ap.changeState(newState); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ap *AnsiParser) changeState(newState state) error {
|
||||
ap.logf("ChangeState %s --> %s", ap.currState.Name(), newState.Name())
|
||||
|
||||
// Exit old state
|
||||
if err := ap.currState.Exit(); err != nil {
|
||||
ap.logf("Exit state '%s' failed with : '%v'", ap.currState.Name(), err)
|
||||
return err
|
||||
}
|
||||
|
||||
// Perform transition action
|
||||
if err := ap.currState.Transition(newState); err != nil {
|
||||
ap.logf("Transition from '%s' to '%s' failed with: '%v'", ap.currState.Name(), newState.Name, err)
|
||||
return err
|
||||
}
|
||||
|
||||
// Enter new state
|
||||
if err := newState.Enter(); err != nil {
|
||||
ap.logf("Enter state '%s' failed with: '%v'", newState.Name(), err)
|
||||
return err
|
||||
}
|
||||
|
||||
ap.currState = newState
|
||||
return nil
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue