mirror of https://github.com/kubernetes/kops.git
Dependency updates
This commit is contained in:
parent
b1aaef1885
commit
7b8d73aa4a
File diff suppressed because it is too large
Load Diff
|
|
@ -1,18 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"arrays.go",
|
||||
"converter.go",
|
||||
"error.go",
|
||||
"numerics.go",
|
||||
"patterns.go",
|
||||
"types.go",
|
||||
"utils.go",
|
||||
"validator.go",
|
||||
],
|
||||
importmap = "vendor/github.com/asaskevich/govalidator",
|
||||
importpath = "github.com/asaskevich/govalidator",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
|
@ -1 +0,0 @@
|
|||
../
|
||||
|
|
@ -1 +0,0 @@
|
|||
../etcdctl
|
||||
|
|
@ -1 +0,0 @@
|
|||
../tools
|
||||
339
vendor/github.com/docker/docker/contrib/selinux-fedora-24/docker-engine-selinux/LICENSE
generated
vendored
339
vendor/github.com/docker/docker/contrib/selinux-fedora-24/docker-engine-selinux/LICENSE
generated
vendored
|
|
@ -1,339 +0,0 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
340
vendor/github.com/docker/docker/contrib/selinux-oraclelinux-7/docker-engine-selinux/LICENSE
generated
vendored
340
vendor/github.com/docker/docker/contrib/selinux-oraclelinux-7/docker-engine-selinux/LICENSE
generated
vendored
|
|
@ -1,340 +0,0 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
Copyright (c) 2013 Honza Pokorny
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. 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.
|
||||
|
||||
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.
|
||||
1
vendor/github.com/docker/docker/hack/make/.build-deb/docker-engine.docker.default
generated
vendored
1
vendor/github.com/docker/docker/hack/make/.build-deb/docker-engine.docker.default
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../../../contrib/init/sysvinit-debian/docker.default
|
||||
|
|
@ -1 +0,0 @@
|
|||
../../../contrib/init/sysvinit-debian/docker
|
||||
1
vendor/github.com/docker/docker/hack/make/.build-deb/docker-engine.docker.upstart
generated
vendored
1
vendor/github.com/docker/docker/hack/make/.build-deb/docker-engine.docker.upstart
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../../../contrib/init/upstart/docker.conf
|
||||
|
|
@ -1 +0,0 @@
|
|||
../../../contrib/udev/80-docker.rules
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"api.go",
|
||||
"auth.go",
|
||||
"headers.go",
|
||||
"middleware.go",
|
||||
"parsing.go",
|
||||
"schema.go",
|
||||
],
|
||||
importmap = "vendor/github.com/go-openapi/errors",
|
||||
importpath = "github.com/go-openapi/errors",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"bson.go",
|
||||
"date.go",
|
||||
"default.go",
|
||||
"doc.go",
|
||||
"duration.go",
|
||||
"format.go",
|
||||
"time.go",
|
||||
],
|
||||
importmap = "vendor/github.com/go-openapi/strfmt",
|
||||
importpath = "github.com/go-openapi/strfmt",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/github.com/asaskevich/govalidator:go_default_library",
|
||||
"//vendor/github.com/go-openapi/errors:go_default_library",
|
||||
"//vendor/github.com/mailru/easyjson/jlexer:go_default_library",
|
||||
"//vendor/github.com/mailru/easyjson/jwriter:go_default_library",
|
||||
"//vendor/github.com/mitchellh/mapstructure:go_default_library",
|
||||
"//vendor/gopkg.in/mgo.v2/bson:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
@ -8,7 +8,7 @@ go_library(
|
|||
"results.go",
|
||||
"urls.go",
|
||||
],
|
||||
importmap = "vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones",
|
||||
importmap = "k8s.io/kops/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones",
|
||||
importpath = "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ go_library(
|
|||
"results.go",
|
||||
"urls.go",
|
||||
],
|
||||
importmap = "vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/floatingips",
|
||||
importmap = "k8s.io/kops/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/floatingips",
|
||||
importpath = "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/floatingips",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ go_library(
|
|||
"results.go",
|
||||
"urls.go",
|
||||
],
|
||||
importmap = "vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach",
|
||||
importmap = "k8s.io/kops/vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach",
|
||||
importpath = "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
|
|
|
|||
2
vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets/BUILD.bazel
generated
vendored
2
vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets/BUILD.bazel
generated
vendored
|
|
@ -8,7 +8,7 @@ go_library(
|
|||
"results.go",
|
||||
"urls.go",
|
||||
],
|
||||
importmap = "vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets",
|
||||
importmap = "k8s.io/kops/vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets",
|
||||
importpath = "github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
|
|
|
|||
54
vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets/doc.go
generated
vendored
Normal file
54
vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets/doc.go
generated
vendored
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
Package recordsets provides information and interaction with the zone API
|
||||
resource for the OpenStack DNS service.
|
||||
|
||||
Example to List RecordSets by Zone
|
||||
|
||||
listOpts := recordsets.ListOpts{
|
||||
Type: "A",
|
||||
}
|
||||
|
||||
zoneID := "fff121f5-c506-410a-a69e-2d73ef9cbdbd"
|
||||
|
||||
allPages, err := recordsets.ListByZone(dnsClient, zoneID, listOpts).AllPages()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
allRRs, err := recordsets.ExtractRecordSets(allPages()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for _, rr := range allRRs {
|
||||
fmt.Printf("%+v\n", rr)
|
||||
}
|
||||
|
||||
Example to Create a RecordSet
|
||||
|
||||
createOpts := recordsets.CreateOpts{
|
||||
Name: "example.com.",
|
||||
Type: "A",
|
||||
TTL: 3600,
|
||||
Description: "This is a recordset.",
|
||||
Records: []string{"10.1.0.2"},
|
||||
}
|
||||
|
||||
zoneID := "fff121f5-c506-410a-a69e-2d73ef9cbdbd"
|
||||
|
||||
rr, err := recordsets.Create(dnsClient, zoneID, createOpts).Extract()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Example to Delete a RecordSet
|
||||
|
||||
zoneID := "fff121f5-c506-410a-a69e-2d73ef9cbdbd"
|
||||
recordsetID := "d96ed01a-b439-4eb8-9b90-7a9f71017f7b"
|
||||
|
||||
err := recordsets.Delete(dnsClient, zoneID, recordsetID).ExtractErr()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
*/
|
||||
package recordsets
|
||||
166
vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets/requests.go
generated
vendored
Normal file
166
vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets/requests.go
generated
vendored
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
package recordsets
|
||||
|
||||
import (
|
||||
"github.com/gophercloud/gophercloud"
|
||||
"github.com/gophercloud/gophercloud/pagination"
|
||||
)
|
||||
|
||||
// ListOptsBuilder allows extensions to add additional parameters to the
|
||||
// List request.
|
||||
type ListOptsBuilder interface {
|
||||
ToRecordSetListQuery() (string, error)
|
||||
}
|
||||
|
||||
// ListOpts allows the filtering and sorting of paginated collections through
|
||||
// the API. Filtering is achieved by passing in struct field values that map to
|
||||
// the server attributes you want to see returned. Marker and Limit are used
|
||||
// for pagination.
|
||||
// https://developer.openstack.org/api-ref/dns/
|
||||
type ListOpts struct {
|
||||
// Integer value for the limit of values to return.
|
||||
Limit int `q:"limit"`
|
||||
|
||||
// UUID of the recordset at which you want to set a marker.
|
||||
Marker string `q:"marker"`
|
||||
|
||||
Data string `q:"data"`
|
||||
Description string `q:"description"`
|
||||
Name string `q:"name"`
|
||||
SortDir string `q:"sort_dir"`
|
||||
SortKey string `q:"sort_key"`
|
||||
Status string `q:"status"`
|
||||
TTL int `q:"ttl"`
|
||||
Type string `q:"type"`
|
||||
ZoneID string `q:"zone_id"`
|
||||
}
|
||||
|
||||
// ToRecordSetListQuery formats a ListOpts into a query string.
|
||||
func (opts ListOpts) ToRecordSetListQuery() (string, error) {
|
||||
q, err := gophercloud.BuildQueryString(opts)
|
||||
return q.String(), err
|
||||
}
|
||||
|
||||
// ListByZone implements the recordset list request.
|
||||
func ListByZone(client *gophercloud.ServiceClient, zoneID string, opts ListOptsBuilder) pagination.Pager {
|
||||
url := baseURL(client, zoneID)
|
||||
if opts != nil {
|
||||
query, err := opts.ToRecordSetListQuery()
|
||||
if err != nil {
|
||||
return pagination.Pager{Err: err}
|
||||
}
|
||||
url += query
|
||||
}
|
||||
return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page {
|
||||
return RecordSetPage{pagination.LinkedPageBase{PageResult: r}}
|
||||
})
|
||||
}
|
||||
|
||||
// Get implements the recordset Get request.
|
||||
func Get(client *gophercloud.ServiceClient, zoneID string, rrsetID string) (r GetResult) {
|
||||
_, r.Err = client.Get(rrsetURL(client, zoneID, rrsetID), &r.Body, nil)
|
||||
return
|
||||
}
|
||||
|
||||
// CreateOptsBuilder allows extensions to add additional attributes to the
|
||||
// Create request.
|
||||
type CreateOptsBuilder interface {
|
||||
ToRecordSetCreateMap() (map[string]interface{}, error)
|
||||
}
|
||||
|
||||
// CreateOpts specifies the base attributes that may be used to create a
|
||||
// RecordSet.
|
||||
type CreateOpts struct {
|
||||
// Name is the name of the RecordSet.
|
||||
Name string `json:"name" required:"true"`
|
||||
|
||||
// Description is a description of the RecordSet.
|
||||
Description string `json:"description,omitempty"`
|
||||
|
||||
// Records are the DNS records of the RecordSet.
|
||||
Records []string `json:"records,omitempty"`
|
||||
|
||||
// TTL is the time to live of the RecordSet.
|
||||
TTL int `json:"ttl,omitempty"`
|
||||
|
||||
// Type is the RRTYPE of the RecordSet.
|
||||
Type string `json:"type,omitempty"`
|
||||
}
|
||||
|
||||
// ToRecordSetCreateMap formats an CreateOpts structure into a request body.
|
||||
func (opts CreateOpts) ToRecordSetCreateMap() (map[string]interface{}, error) {
|
||||
b, err := gophercloud.BuildRequestBody(opts, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return b, nil
|
||||
}
|
||||
|
||||
// Create creates a recordset in a given zone.
|
||||
func Create(client *gophercloud.ServiceClient, zoneID string, opts CreateOptsBuilder) (r CreateResult) {
|
||||
b, err := opts.ToRecordSetCreateMap()
|
||||
if err != nil {
|
||||
r.Err = err
|
||||
return
|
||||
}
|
||||
_, r.Err = client.Post(baseURL(client, zoneID), &b, &r.Body, &gophercloud.RequestOpts{
|
||||
OkCodes: []int{201, 202},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateOptsBuilder allows extensions to add additional attributes to the
|
||||
// Update request.
|
||||
type UpdateOptsBuilder interface {
|
||||
ToRecordSetUpdateMap() (map[string]interface{}, error)
|
||||
}
|
||||
|
||||
// UpdateOpts specifies the base attributes that may be updated on an existing
|
||||
// RecordSet.
|
||||
type UpdateOpts struct {
|
||||
// Description is a description of the RecordSet.
|
||||
Description string `json:"description,omitempty"`
|
||||
|
||||
// TTL is the time to live of the RecordSet.
|
||||
TTL int `json:"ttl,omitempty"`
|
||||
|
||||
// Records are the DNS records of the RecordSet.
|
||||
Records []string `json:"records,omitempty"`
|
||||
}
|
||||
|
||||
// ToRecordSetUpdateMap formats an UpdateOpts structure into a request body.
|
||||
func (opts UpdateOpts) ToRecordSetUpdateMap() (map[string]interface{}, error) {
|
||||
b, err := gophercloud.BuildRequestBody(opts, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if opts.TTL > 0 {
|
||||
b["ttl"] = opts.TTL
|
||||
} else {
|
||||
b["ttl"] = nil
|
||||
}
|
||||
|
||||
return b, nil
|
||||
}
|
||||
|
||||
// Update updates a recordset in a given zone
|
||||
func Update(client *gophercloud.ServiceClient, zoneID string, rrsetID string, opts UpdateOptsBuilder) (r UpdateResult) {
|
||||
b, err := opts.ToRecordSetUpdateMap()
|
||||
if err != nil {
|
||||
r.Err = err
|
||||
return
|
||||
}
|
||||
_, r.Err = client.Put(rrsetURL(client, zoneID, rrsetID), &b, &r.Body, &gophercloud.RequestOpts{
|
||||
OkCodes: []int{200, 202},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Delete removes an existing RecordSet.
|
||||
func Delete(client *gophercloud.ServiceClient, zoneID string, rrsetID string) (r DeleteResult) {
|
||||
_, r.Err = client.Delete(rrsetURL(client, zoneID, rrsetID), &gophercloud.RequestOpts{
|
||||
OkCodes: []int{202},
|
||||
})
|
||||
return
|
||||
}
|
||||
147
vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets/results.go
generated
vendored
Normal file
147
vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets/results.go
generated
vendored
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
package recordsets
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/gophercloud/gophercloud"
|
||||
"github.com/gophercloud/gophercloud/pagination"
|
||||
)
|
||||
|
||||
type commonResult struct {
|
||||
gophercloud.Result
|
||||
}
|
||||
|
||||
// Extract interprets a GetResult, CreateResult or UpdateResult as a RecordSet.
|
||||
// An error is returned if the original call or the extraction failed.
|
||||
func (r commonResult) Extract() (*RecordSet, error) {
|
||||
var s *RecordSet
|
||||
err := r.ExtractInto(&s)
|
||||
return s, err
|
||||
}
|
||||
|
||||
// CreateResult is the result of a Create operation. Call its Extract method to
|
||||
// interpret the result as a RecordSet.
|
||||
type CreateResult struct {
|
||||
commonResult
|
||||
}
|
||||
|
||||
// GetResult is the result of a Get operation. Call its Extract method to
|
||||
// interpret the result as a RecordSet.
|
||||
type GetResult struct {
|
||||
commonResult
|
||||
}
|
||||
|
||||
// RecordSetPage is a single page of RecordSet results.
|
||||
type RecordSetPage struct {
|
||||
pagination.LinkedPageBase
|
||||
}
|
||||
|
||||
// UpdateResult is result of an Update operation. Call its Extract method to
|
||||
// interpret the result as a RecordSet.
|
||||
type UpdateResult struct {
|
||||
commonResult
|
||||
}
|
||||
|
||||
// DeleteResult is result of a Delete operation. Call its ExtractErr method to
|
||||
// determine if the operation succeeded or failed.
|
||||
type DeleteResult struct {
|
||||
gophercloud.ErrResult
|
||||
}
|
||||
|
||||
// IsEmpty returns true if the page contains no results.
|
||||
func (r RecordSetPage) IsEmpty() (bool, error) {
|
||||
s, err := ExtractRecordSets(r)
|
||||
return len(s) == 0, err
|
||||
}
|
||||
|
||||
// ExtractRecordSets extracts a slice of RecordSets from a List result.
|
||||
func ExtractRecordSets(r pagination.Page) ([]RecordSet, error) {
|
||||
var s struct {
|
||||
RecordSets []RecordSet `json:"recordsets"`
|
||||
}
|
||||
err := (r.(RecordSetPage)).ExtractInto(&s)
|
||||
return s.RecordSets, err
|
||||
}
|
||||
|
||||
// RecordSet represents a DNS Record Set.
|
||||
type RecordSet struct {
|
||||
// ID is the unique ID of the recordset
|
||||
ID string `json:"id"`
|
||||
|
||||
// ZoneID is the ID of the zone the recordset belongs to.
|
||||
ZoneID string `json:"zone_id"`
|
||||
|
||||
// ProjectID is the ID of the project that owns the recordset.
|
||||
ProjectID string `json:"project_id"`
|
||||
|
||||
// Name is the name of the recordset.
|
||||
Name string `json:"name"`
|
||||
|
||||
// ZoneName is the name of the zone the recordset belongs to.
|
||||
ZoneName string `json:"zone_name"`
|
||||
|
||||
// Type is the RRTYPE of the recordset.
|
||||
Type string `json:"type"`
|
||||
|
||||
// Records are the DNS records of the recordset.
|
||||
Records []string `json:"records"`
|
||||
|
||||
// TTL is the time to live of the recordset.
|
||||
TTL int `json:"ttl"`
|
||||
|
||||
// Status is the status of the recordset.
|
||||
Status string `json:"status"`
|
||||
|
||||
// Action is the current action in progress of the recordset.
|
||||
Action string `json:"action"`
|
||||
|
||||
// Description is the description of the recordset.
|
||||
Description string `json:"description"`
|
||||
|
||||
// Version is the revision of the recordset.
|
||||
Version int `json:"version"`
|
||||
|
||||
// CreatedAt is the date when the recordset was created.
|
||||
CreatedAt time.Time `json:"-"`
|
||||
|
||||
// UpdatedAt is the date when the recordset was updated.
|
||||
UpdatedAt time.Time `json:"-"`
|
||||
|
||||
// Links includes HTTP references to the itself,
|
||||
// useful for passing along to other APIs that might want a recordset
|
||||
// reference.
|
||||
Links []gophercloud.Link `json:"-"`
|
||||
}
|
||||
|
||||
func (r *RecordSet) UnmarshalJSON(b []byte) error {
|
||||
type tmp RecordSet
|
||||
var s struct {
|
||||
tmp
|
||||
CreatedAt gophercloud.JSONRFC3339MilliNoZ `json:"created_at"`
|
||||
UpdatedAt gophercloud.JSONRFC3339MilliNoZ `json:"updated_at"`
|
||||
Links map[string]interface{} `json:"links"`
|
||||
}
|
||||
err := json.Unmarshal(b, &s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*r = RecordSet(s.tmp)
|
||||
|
||||
r.CreatedAt = time.Time(s.CreatedAt)
|
||||
r.UpdatedAt = time.Time(s.UpdatedAt)
|
||||
|
||||
if s.Links != nil {
|
||||
for rel, href := range s.Links {
|
||||
if v, ok := href.(string); ok {
|
||||
link := gophercloud.Link{
|
||||
Rel: rel,
|
||||
Href: v,
|
||||
}
|
||||
r.Links = append(r.Links, link)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
11
vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets/urls.go
generated
vendored
Normal file
11
vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets/urls.go
generated
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package recordsets
|
||||
|
||||
import "github.com/gophercloud/gophercloud"
|
||||
|
||||
func baseURL(c *gophercloud.ServiceClient, zoneID string) string {
|
||||
return c.ServiceURL("zones", zoneID, "recordsets")
|
||||
}
|
||||
|
||||
func rrsetURL(c *gophercloud.ServiceClient, zoneID string, rrsetID string) string {
|
||||
return c.ServiceURL("zones", zoneID, "recordsets", rrsetID)
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ go_library(
|
|||
"results.go",
|
||||
"urls.go",
|
||||
],
|
||||
importmap = "vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/zones",
|
||||
importmap = "k8s.io/kops/vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/zones",
|
||||
importpath = "github.com/gophercloud/gophercloud/openstack/dns/v2/zones",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
|
|
|
|||
48
vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/zones/doc.go
generated
vendored
Normal file
48
vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/zones/doc.go
generated
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
Package zones provides information and interaction with the zone API
|
||||
resource for the OpenStack DNS service.
|
||||
|
||||
Example to List Zones
|
||||
|
||||
listOpts := zones.ListOpts{
|
||||
Email: "jdoe@example.com",
|
||||
}
|
||||
|
||||
allPages, err := zones.List(dnsClient, listOpts).AllPages()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
allZones, err := zones.ExtractZones(allPages)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for _, zone := range allZones {
|
||||
fmt.Printf("%+v\n", zone)
|
||||
}
|
||||
|
||||
Example to Create a Zone
|
||||
|
||||
createOpts := zones.CreateOpts{
|
||||
Name: "example.com.",
|
||||
Email: "jdoe@example.com",
|
||||
Type: "PRIMARY",
|
||||
TTL: 7200,
|
||||
Description: "This is a zone.",
|
||||
}
|
||||
|
||||
zone, err := zones.Create(dnsClient, createOpts).Extract()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Example to Delete a Zone
|
||||
|
||||
zoneID := "99d10f68-5623-4491-91a0-6daafa32b60e"
|
||||
err := zones.Delete(dnsClient, zoneID).ExtractErr()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
*/
|
||||
package zones
|
||||
174
vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/zones/requests.go
generated
vendored
Normal file
174
vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/zones/requests.go
generated
vendored
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
package zones
|
||||
|
||||
import (
|
||||
"github.com/gophercloud/gophercloud"
|
||||
"github.com/gophercloud/gophercloud/pagination"
|
||||
)
|
||||
|
||||
// ListOptsBuilder allows extensions to add parameters to the List request.
|
||||
type ListOptsBuilder interface {
|
||||
ToZoneListQuery() (string, error)
|
||||
}
|
||||
|
||||
// ListOpts allows the filtering and sorting of paginated collections through
|
||||
// the API. Filtering is achieved by passing in struct field values that map to
|
||||
// the server attributes you want to see returned. Marker and Limit are used
|
||||
// for pagination.
|
||||
// https://developer.openstack.org/api-ref/dns/
|
||||
type ListOpts struct {
|
||||
// Integer value for the limit of values to return.
|
||||
Limit int `q:"limit"`
|
||||
|
||||
// UUID of the zone at which you want to set a marker.
|
||||
Marker string `q:"marker"`
|
||||
|
||||
Description string `q:"description"`
|
||||
Email string `q:"email"`
|
||||
Name string `q:"name"`
|
||||
SortDir string `q:"sort_dir"`
|
||||
SortKey string `q:"sort_key"`
|
||||
Status string `q:"status"`
|
||||
TTL int `q:"ttl"`
|
||||
Type string `q:"type"`
|
||||
}
|
||||
|
||||
// ToZoneListQuery formats a ListOpts into a query string.
|
||||
func (opts ListOpts) ToZoneListQuery() (string, error) {
|
||||
q, err := gophercloud.BuildQueryString(opts)
|
||||
return q.String(), err
|
||||
}
|
||||
|
||||
// List implements a zone List request.
|
||||
func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager {
|
||||
url := baseURL(client)
|
||||
if opts != nil {
|
||||
query, err := opts.ToZoneListQuery()
|
||||
if err != nil {
|
||||
return pagination.Pager{Err: err}
|
||||
}
|
||||
url += query
|
||||
}
|
||||
return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page {
|
||||
return ZonePage{pagination.LinkedPageBase{PageResult: r}}
|
||||
})
|
||||
}
|
||||
|
||||
// Get returns information about a zone, given its ID.
|
||||
func Get(client *gophercloud.ServiceClient, zoneID string) (r GetResult) {
|
||||
_, r.Err = client.Get(zoneURL(client, zoneID), &r.Body, nil)
|
||||
return
|
||||
}
|
||||
|
||||
// CreateOptsBuilder allows extensions to add additional attributes to the
|
||||
// Create request.
|
||||
type CreateOptsBuilder interface {
|
||||
ToZoneCreateMap() (map[string]interface{}, error)
|
||||
}
|
||||
|
||||
// CreateOpts specifies the attributes used to create a zone.
|
||||
type CreateOpts struct {
|
||||
// Attributes are settings that supply hints and filters for the zone.
|
||||
Attributes map[string]string `json:"attributes,omitempty"`
|
||||
|
||||
// Email contact of the zone.
|
||||
Email string `json:"email,omitempty"`
|
||||
|
||||
// Description of the zone.
|
||||
Description string `json:"description,omitempty"`
|
||||
|
||||
// Name of the zone.
|
||||
Name string `json:"name" required:"true"`
|
||||
|
||||
// Masters specifies zone masters if this is a secondary zone.
|
||||
Masters []string `json:"masters,omitempty"`
|
||||
|
||||
// TTL is the time to live of the zone.
|
||||
TTL int `json:"-"`
|
||||
|
||||
// Type specifies if this is a primary or secondary zone.
|
||||
Type string `json:"type,omitempty"`
|
||||
}
|
||||
|
||||
// ToZoneCreateMap formats an CreateOpts structure into a request body.
|
||||
func (opts CreateOpts) ToZoneCreateMap() (map[string]interface{}, error) {
|
||||
b, err := gophercloud.BuildRequestBody(opts, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if opts.TTL > 0 {
|
||||
b["ttl"] = opts.TTL
|
||||
}
|
||||
|
||||
return b, nil
|
||||
}
|
||||
|
||||
// Create implements a zone create request.
|
||||
func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) {
|
||||
b, err := opts.ToZoneCreateMap()
|
||||
if err != nil {
|
||||
r.Err = err
|
||||
return
|
||||
}
|
||||
_, r.Err = client.Post(baseURL(client), &b, &r.Body, &gophercloud.RequestOpts{
|
||||
OkCodes: []int{201, 202},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateOptsBuilder allows extensions to add additional attributes to the
|
||||
// Update request.
|
||||
type UpdateOptsBuilder interface {
|
||||
ToZoneUpdateMap() (map[string]interface{}, error)
|
||||
}
|
||||
|
||||
// UpdateOpts specifies the attributes to update a zone.
|
||||
type UpdateOpts struct {
|
||||
// Email contact of the zone.
|
||||
Email string `json:"email,omitempty"`
|
||||
|
||||
// TTL is the time to live of the zone.
|
||||
TTL int `json:"-"`
|
||||
|
||||
// Masters specifies zone masters if this is a secondary zone.
|
||||
Masters []string `json:"masters,omitempty"`
|
||||
|
||||
// Description of the zone.
|
||||
Description string `json:"description,omitempty"`
|
||||
}
|
||||
|
||||
// ToZoneUpdateMap formats an UpdateOpts structure into a request body.
|
||||
func (opts UpdateOpts) ToZoneUpdateMap() (map[string]interface{}, error) {
|
||||
b, err := gophercloud.BuildRequestBody(opts, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if opts.TTL > 0 {
|
||||
b["ttl"] = opts.TTL
|
||||
}
|
||||
|
||||
return b, nil
|
||||
}
|
||||
|
||||
// Update implements a zone update request.
|
||||
func Update(client *gophercloud.ServiceClient, zoneID string, opts UpdateOptsBuilder) (r UpdateResult) {
|
||||
b, err := opts.ToZoneUpdateMap()
|
||||
if err != nil {
|
||||
r.Err = err
|
||||
return
|
||||
}
|
||||
_, r.Err = client.Patch(zoneURL(client, zoneID), &b, &r.Body, &gophercloud.RequestOpts{
|
||||
OkCodes: []int{200, 202},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Delete implements a zone delete request.
|
||||
func Delete(client *gophercloud.ServiceClient, zoneID string) (r DeleteResult) {
|
||||
_, r.Err = client.Delete(zoneURL(client, zoneID), &gophercloud.RequestOpts{
|
||||
OkCodes: []int{202},
|
||||
JSONResponse: &r.Body,
|
||||
})
|
||||
return
|
||||
}
|
||||
166
vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/zones/results.go
generated
vendored
Normal file
166
vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/zones/results.go
generated
vendored
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
package zones
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/gophercloud/gophercloud"
|
||||
"github.com/gophercloud/gophercloud/pagination"
|
||||
)
|
||||
|
||||
type commonResult struct {
|
||||
gophercloud.Result
|
||||
}
|
||||
|
||||
// Extract interprets a GetResult, CreateResult or UpdateResult as a Zone.
|
||||
// An error is returned if the original call or the extraction failed.
|
||||
func (r commonResult) Extract() (*Zone, error) {
|
||||
var s *Zone
|
||||
err := r.ExtractInto(&s)
|
||||
return s, err
|
||||
}
|
||||
|
||||
// CreateResult is the result of a Create request. Call its Extract method
|
||||
// to interpret the result as a Zone.
|
||||
type CreateResult struct {
|
||||
commonResult
|
||||
}
|
||||
|
||||
// GetResult is the result of a Get request. Call its Extract method
|
||||
// to interpret the result as a Zone.
|
||||
type GetResult struct {
|
||||
commonResult
|
||||
}
|
||||
|
||||
// UpdateResult is the result of an Update request. Call its Extract method
|
||||
// to interpret the result as a Zone.
|
||||
type UpdateResult struct {
|
||||
commonResult
|
||||
}
|
||||
|
||||
// DeleteResult is the result of a Delete request. Call its ExtractErr method
|
||||
// to determine if the request succeeded or failed.
|
||||
type DeleteResult struct {
|
||||
commonResult
|
||||
}
|
||||
|
||||
// ZonePage is a single page of Zone results.
|
||||
type ZonePage struct {
|
||||
pagination.LinkedPageBase
|
||||
}
|
||||
|
||||
// IsEmpty returns true if the page contains no results.
|
||||
func (r ZonePage) IsEmpty() (bool, error) {
|
||||
s, err := ExtractZones(r)
|
||||
return len(s) == 0, err
|
||||
}
|
||||
|
||||
// ExtractZones extracts a slice of Zones from a List result.
|
||||
func ExtractZones(r pagination.Page) ([]Zone, error) {
|
||||
var s struct {
|
||||
Zones []Zone `json:"zones"`
|
||||
}
|
||||
err := (r.(ZonePage)).ExtractInto(&s)
|
||||
return s.Zones, err
|
||||
}
|
||||
|
||||
// Zone represents a DNS zone.
|
||||
type Zone struct {
|
||||
// ID uniquely identifies this zone amongst all other zones, including those
|
||||
// not accessible to the current tenant.
|
||||
ID string `json:"id"`
|
||||
|
||||
// PoolID is the ID for the pool hosting this zone.
|
||||
PoolID string `json:"pool_id"`
|
||||
|
||||
// ProjectID identifies the project/tenant owning this resource.
|
||||
ProjectID string `json:"project_id"`
|
||||
|
||||
// Name is the DNS Name for the zone.
|
||||
Name string `json:"name"`
|
||||
|
||||
// Email for the zone. Used in SOA records for the zone.
|
||||
Email string `json:"email"`
|
||||
|
||||
// Description for this zone.
|
||||
Description string `json:"description"`
|
||||
|
||||
// TTL is the Time to Live for the zone.
|
||||
TTL int `json:"ttl"`
|
||||
|
||||
// Serial is the current serial number for the zone.
|
||||
Serial int `json:"-"`
|
||||
|
||||
// Status is the status of the resource.
|
||||
Status string `json:"status"`
|
||||
|
||||
// Action is the current action in progress on the resource.
|
||||
Action string `json:"action"`
|
||||
|
||||
// Version of the resource.
|
||||
Version int `json:"version"`
|
||||
|
||||
// Attributes for the zone.
|
||||
Attributes map[string]string `json:"attributes"`
|
||||
|
||||
// Type of zone. Primary is controlled by Designate.
|
||||
// Secondary zones are slaved from another DNS Server.
|
||||
// Defaults to Primary.
|
||||
Type string `json:"type"`
|
||||
|
||||
// Masters is the servers for slave servers to get DNS information from.
|
||||
Masters []string `json:"masters"`
|
||||
|
||||
// CreatedAt is the date when the zone was created.
|
||||
CreatedAt time.Time `json:"-"`
|
||||
|
||||
// UpdatedAt is the date when the last change was made to the zone.
|
||||
UpdatedAt time.Time `json:"-"`
|
||||
|
||||
// TransferredAt is the last time an update was retrieved from the
|
||||
// master servers.
|
||||
TransferredAt time.Time `json:"-"`
|
||||
|
||||
// Links includes HTTP references to the itself, useful for passing along
|
||||
// to other APIs that might want a server reference.
|
||||
Links map[string]interface{} `json:"links"`
|
||||
}
|
||||
|
||||
func (r *Zone) UnmarshalJSON(b []byte) error {
|
||||
type tmp Zone
|
||||
var s struct {
|
||||
tmp
|
||||
CreatedAt gophercloud.JSONRFC3339MilliNoZ `json:"created_at"`
|
||||
UpdatedAt gophercloud.JSONRFC3339MilliNoZ `json:"updated_at"`
|
||||
TransferredAt gophercloud.JSONRFC3339MilliNoZ `json:"transferred_at"`
|
||||
Serial interface{} `json:"serial"`
|
||||
}
|
||||
err := json.Unmarshal(b, &s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*r = Zone(s.tmp)
|
||||
|
||||
r.CreatedAt = time.Time(s.CreatedAt)
|
||||
r.UpdatedAt = time.Time(s.UpdatedAt)
|
||||
r.TransferredAt = time.Time(s.TransferredAt)
|
||||
|
||||
switch t := s.Serial.(type) {
|
||||
case float64:
|
||||
r.Serial = int(t)
|
||||
case string:
|
||||
switch t {
|
||||
case "":
|
||||
r.Serial = 0
|
||||
default:
|
||||
serial, err := strconv.ParseFloat(t, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.Serial = int(serial)
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
11
vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/zones/urls.go
generated
vendored
Normal file
11
vendor/github.com/gophercloud/gophercloud/openstack/dns/v2/zones/urls.go
generated
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package zones
|
||||
|
||||
import "github.com/gophercloud/gophercloud"
|
||||
|
||||
func baseURL(c *gophercloud.ServiceClient) string {
|
||||
return c.ServiceURL("zones")
|
||||
}
|
||||
|
||||
func zoneURL(c *gophercloud.ServiceClient, zoneID string) string {
|
||||
return c.ServiceURL("zones", zoneID)
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ go_library(
|
|||
"results.go",
|
||||
"urls.go",
|
||||
],
|
||||
importmap = "vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners",
|
||||
importmap = "k8s.io/kops/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners",
|
||||
importpath = "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
|
|
|
|||
71
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners/doc.go
generated
vendored
Normal file
71
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners/doc.go
generated
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
Package listeners provides information and interaction with Listeners of the
|
||||
LBaaS v2 extension for the OpenStack Networking service.
|
||||
|
||||
Example to List Listeners
|
||||
|
||||
listOpts := listeners.ListOpts{
|
||||
LoadbalancerID : "ca430f80-1737-4712-8dc6-3f640d55594b",
|
||||
}
|
||||
|
||||
allPages, err := listeners.List(networkClient, listOpts).AllPages()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
allListeners, err := listeners.ExtractListeners(allPages)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for _, listener := range allListeners {
|
||||
fmt.Printf("%+v\n", listener)
|
||||
}
|
||||
|
||||
Example to Create a Listener
|
||||
|
||||
createOpts := listeners.CreateOpts{
|
||||
Protocol: "TCP",
|
||||
Name: "db",
|
||||
LoadbalancerID: "79e05663-7f03-45d2-a092-8b94062f22ab",
|
||||
AdminStateUp: gophercloud.Enabled,
|
||||
DefaultPoolID: "41efe233-7591-43c5-9cf7-923964759f9e",
|
||||
ProtocolPort: 3306,
|
||||
}
|
||||
|
||||
listener, err := listeners.Create(networkClient, createOpts).Extract()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Example to Update a Listener
|
||||
|
||||
listenerID := "d67d56a6-4a86-4688-a282-f46444705c64"
|
||||
|
||||
i1001 := 1001
|
||||
updateOpts := listeners.UpdateOpts{
|
||||
ConnLimit: &i1001,
|
||||
}
|
||||
|
||||
listener, err := listeners.Update(networkClient, listenerID, updateOpts).Extract()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Example to Delete a Listener
|
||||
|
||||
listenerID := "d67d56a6-4a86-4688-a282-f46444705c64"
|
||||
err := listeners.Delete(networkClient, listenerID).ExtractErr()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Example to Get the Statistics of a Listener
|
||||
|
||||
listenerID := "d67d56a6-4a86-4688-a282-f46444705c64"
|
||||
stats, err := listeners.GetStats(networkClient, listenerID).Extract()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
*/
|
||||
package listeners
|
||||
200
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners/requests.go
generated
vendored
Normal file
200
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners/requests.go
generated
vendored
Normal file
|
|
@ -0,0 +1,200 @@
|
|||
package listeners
|
||||
|
||||
import (
|
||||
"github.com/gophercloud/gophercloud"
|
||||
"github.com/gophercloud/gophercloud/pagination"
|
||||
)
|
||||
|
||||
// Type Protocol represents a listener protocol.
|
||||
type Protocol string
|
||||
|
||||
// Supported attributes for create/update operations.
|
||||
const (
|
||||
ProtocolTCP Protocol = "TCP"
|
||||
ProtocolHTTP Protocol = "HTTP"
|
||||
ProtocolHTTPS Protocol = "HTTPS"
|
||||
)
|
||||
|
||||
// ListOptsBuilder allows extensions to add additional parameters to the
|
||||
// List request.
|
||||
type ListOptsBuilder interface {
|
||||
ToListenerListQuery() (string, error)
|
||||
}
|
||||
|
||||
// ListOpts allows the filtering and sorting of paginated collections through
|
||||
// the API. Filtering is achieved by passing in struct field values that map to
|
||||
// the floating IP attributes you want to see returned. SortKey allows you to
|
||||
// sort by a particular listener attribute. SortDir sets the direction, and is
|
||||
// either `asc' or `desc'. Marker and Limit are used for pagination.
|
||||
type ListOpts struct {
|
||||
ID string `q:"id"`
|
||||
Name string `q:"name"`
|
||||
AdminStateUp *bool `q:"admin_state_up"`
|
||||
ProjectID string `q:"project_id"`
|
||||
LoadbalancerID string `q:"loadbalancer_id"`
|
||||
DefaultPoolID string `q:"default_pool_id"`
|
||||
Protocol string `q:"protocol"`
|
||||
ProtocolPort int `q:"protocol_port"`
|
||||
ConnectionLimit int `q:"connection_limit"`
|
||||
Limit int `q:"limit"`
|
||||
Marker string `q:"marker"`
|
||||
SortKey string `q:"sort_key"`
|
||||
SortDir string `q:"sort_dir"`
|
||||
}
|
||||
|
||||
// ToListenerListQuery formats a ListOpts into a query string.
|
||||
func (opts ListOpts) ToListenerListQuery() (string, error) {
|
||||
q, err := gophercloud.BuildQueryString(opts)
|
||||
return q.String(), err
|
||||
}
|
||||
|
||||
// List returns a Pager which allows you to iterate over a collection of
|
||||
// listeners. It accepts a ListOpts struct, which allows you to filter and sort
|
||||
// the returned collection for greater efficiency.
|
||||
//
|
||||
// Default policy settings return only those listeners that are owned by the
|
||||
// project who submits the request, unless an admin user submits the request.
|
||||
func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager {
|
||||
url := rootURL(c)
|
||||
if opts != nil {
|
||||
query, err := opts.ToListenerListQuery()
|
||||
if err != nil {
|
||||
return pagination.Pager{Err: err}
|
||||
}
|
||||
url += query
|
||||
}
|
||||
return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page {
|
||||
return ListenerPage{pagination.LinkedPageBase{PageResult: r}}
|
||||
})
|
||||
}
|
||||
|
||||
// CreateOptsBuilder allows extensions to add additional parameters to the
|
||||
// Create request.
|
||||
type CreateOptsBuilder interface {
|
||||
ToListenerCreateMap() (map[string]interface{}, error)
|
||||
}
|
||||
|
||||
// CreateOpts represents options for creating a listener.
|
||||
type CreateOpts struct {
|
||||
// The load balancer on which to provision this listener.
|
||||
LoadbalancerID string `json:"loadbalancer_id" required:"true"`
|
||||
|
||||
// The protocol - can either be TCP, HTTP or HTTPS.
|
||||
Protocol Protocol `json:"protocol" required:"true"`
|
||||
|
||||
// The port on which to listen for client traffic.
|
||||
ProtocolPort int `json:"protocol_port" required:"true"`
|
||||
|
||||
// ProjectID is only required if the caller has an admin role and wants
|
||||
// to create a pool for another project.
|
||||
ProjectID string `json:"project_id,omitempty"`
|
||||
|
||||
// Human-readable name for the Listener. Does not have to be unique.
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
// The ID of the default pool with which the Listener is associated.
|
||||
DefaultPoolID string `json:"default_pool_id,omitempty"`
|
||||
|
||||
// Human-readable description for the Listener.
|
||||
Description string `json:"description,omitempty"`
|
||||
|
||||
// The maximum number of connections allowed for the Listener.
|
||||
ConnLimit *int `json:"connection_limit,omitempty"`
|
||||
|
||||
// A reference to a Barbican container of TLS secrets.
|
||||
DefaultTlsContainerRef string `json:"default_tls_container_ref,omitempty"`
|
||||
|
||||
// A list of references to TLS secrets.
|
||||
SniContainerRefs []string `json:"sni_container_refs,omitempty"`
|
||||
|
||||
// The administrative state of the Listener. A valid value is true (UP)
|
||||
// or false (DOWN).
|
||||
AdminStateUp *bool `json:"admin_state_up,omitempty"`
|
||||
}
|
||||
|
||||
// ToListenerCreateMap builds a request body from CreateOpts.
|
||||
func (opts CreateOpts) ToListenerCreateMap() (map[string]interface{}, error) {
|
||||
return gophercloud.BuildRequestBody(opts, "listener")
|
||||
}
|
||||
|
||||
// Create is an operation which provisions a new Listeners based on the
|
||||
// configuration defined in the CreateOpts struct. Once the request is
|
||||
// validated and progress has started on the provisioning process, a
|
||||
// CreateResult will be returned.
|
||||
//
|
||||
// Users with an admin role can create Listeners on behalf of other projects by
|
||||
// specifying a ProjectID attribute different than their own.
|
||||
func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) {
|
||||
b, err := opts.ToListenerCreateMap()
|
||||
if err != nil {
|
||||
r.Err = err
|
||||
return
|
||||
}
|
||||
_, r.Err = c.Post(rootURL(c), b, &r.Body, nil)
|
||||
return
|
||||
}
|
||||
|
||||
// Get retrieves a particular Listeners based on its unique ID.
|
||||
func Get(c *gophercloud.ServiceClient, id string) (r GetResult) {
|
||||
_, r.Err = c.Get(resourceURL(c, id), &r.Body, nil)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateOptsBuilder allows extensions to add additional parameters to the
|
||||
// Update request.
|
||||
type UpdateOptsBuilder interface {
|
||||
ToListenerUpdateMap() (map[string]interface{}, error)
|
||||
}
|
||||
|
||||
// UpdateOpts represents options for updating a Listener.
|
||||
type UpdateOpts struct {
|
||||
// Human-readable name for the Listener. Does not have to be unique.
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
// Human-readable description for the Listener.
|
||||
Description string `json:"description,omitempty"`
|
||||
|
||||
// The maximum number of connections allowed for the Listener.
|
||||
ConnLimit *int `json:"connection_limit,omitempty"`
|
||||
|
||||
// A reference to a Barbican container of TLS secrets.
|
||||
DefaultTlsContainerRef string `json:"default_tls_container_ref,omitempty"`
|
||||
|
||||
// A list of references to TLS secrets.
|
||||
SniContainerRefs []string `json:"sni_container_refs,omitempty"`
|
||||
|
||||
// The administrative state of the Listener. A valid value is true (UP)
|
||||
// or false (DOWN).
|
||||
AdminStateUp *bool `json:"admin_state_up,omitempty"`
|
||||
}
|
||||
|
||||
// ToListenerUpdateMap builds a request body from UpdateOpts.
|
||||
func (opts UpdateOpts) ToListenerUpdateMap() (map[string]interface{}, error) {
|
||||
return gophercloud.BuildRequestBody(opts, "listener")
|
||||
}
|
||||
|
||||
// Update is an operation which modifies the attributes of the specified
|
||||
// Listener.
|
||||
func Update(c *gophercloud.ServiceClient, id string, opts UpdateOpts) (r UpdateResult) {
|
||||
b, err := opts.ToListenerUpdateMap()
|
||||
if err != nil {
|
||||
r.Err = err
|
||||
return
|
||||
}
|
||||
_, r.Err = c.Put(resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{
|
||||
OkCodes: []int{200, 202},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Delete will permanently delete a particular Listeners based on its unique ID.
|
||||
func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) {
|
||||
_, r.Err = c.Delete(resourceURL(c, id), nil)
|
||||
return
|
||||
}
|
||||
|
||||
// GetStats will return the shows the current statistics of a particular Listeners.
|
||||
func GetStats(c *gophercloud.ServiceClient, id string) (r StatsResult) {
|
||||
_, r.Err = c.Get(statisticsRootURL(c, id), &r.Body, nil)
|
||||
return
|
||||
}
|
||||
168
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners/results.go
generated
vendored
Normal file
168
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners/results.go
generated
vendored
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
package listeners
|
||||
|
||||
import (
|
||||
"github.com/gophercloud/gophercloud"
|
||||
"github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools"
|
||||
"github.com/gophercloud/gophercloud/pagination"
|
||||
)
|
||||
|
||||
type LoadBalancerID struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
// Listener is the primary load balancing configuration object that specifies
|
||||
// the loadbalancer and port on which client traffic is received, as well
|
||||
// as other details such as the load balancing method to be use, protocol, etc.
|
||||
type Listener struct {
|
||||
// The unique ID for the Listener.
|
||||
ID string `json:"id"`
|
||||
|
||||
// Owner of the Listener.
|
||||
ProjectID string `json:"project_id"`
|
||||
|
||||
// Human-readable name for the Listener. Does not have to be unique.
|
||||
Name string `json:"name"`
|
||||
|
||||
// Human-readable description for the Listener.
|
||||
Description string `json:"description"`
|
||||
|
||||
// The protocol to loadbalance. A valid value is TCP, HTTP, or HTTPS.
|
||||
Protocol string `json:"protocol"`
|
||||
|
||||
// The port on which to listen to client traffic that is associated with the
|
||||
// Loadbalancer. A valid value is from 0 to 65535.
|
||||
ProtocolPort int `json:"protocol_port"`
|
||||
|
||||
// The UUID of default pool. Must have compatible protocol with listener.
|
||||
DefaultPoolID string `json:"default_pool_id"`
|
||||
|
||||
// A list of load balancer IDs.
|
||||
Loadbalancers []LoadBalancerID `json:"loadbalancers"`
|
||||
|
||||
// The maximum number of connections allowed for the Loadbalancer.
|
||||
// Default is -1, meaning no limit.
|
||||
ConnLimit int `json:"connection_limit"`
|
||||
|
||||
// The list of references to TLS secrets.
|
||||
SniContainerRefs []string `json:"sni_container_refs"`
|
||||
|
||||
// A reference to a Barbican container of TLS secrets.
|
||||
DefaultTlsContainerRef string `json:"default_tls_container_ref"`
|
||||
|
||||
// The administrative state of the Listener. A valid value is true (UP) or false (DOWN).
|
||||
AdminStateUp bool `json:"admin_state_up"`
|
||||
|
||||
// Pools are the pools which are part of this listener.
|
||||
Pools []pools.Pool `json:"pools"`
|
||||
|
||||
// The provisioning status of the Listener.
|
||||
// This value is ACTIVE, PENDING_* or ERROR.
|
||||
ProvisioningStatus string `json:"provisioning_status"`
|
||||
}
|
||||
|
||||
type Stats struct {
|
||||
// The currently active connections.
|
||||
ActiveConnections int `json:"active_connections"`
|
||||
|
||||
// The total bytes received.
|
||||
BytesIn int `json:"bytes_in"`
|
||||
|
||||
// The total bytes sent.
|
||||
BytesOut int `json:"bytes_out"`
|
||||
|
||||
// The total requests that were unable to be fulfilled.
|
||||
RequestErrors int `json:"request_errors"`
|
||||
|
||||
// The total connections handled.
|
||||
TotalConnections int `json:"total_connections"`
|
||||
}
|
||||
|
||||
// ListenerPage is the page returned by a pager when traversing over a
|
||||
// collection of listeners.
|
||||
type ListenerPage struct {
|
||||
pagination.LinkedPageBase
|
||||
}
|
||||
|
||||
// NextPageURL is invoked when a paginated collection of listeners has reached
|
||||
// the end of a page and the pager seeks to traverse over a new one. In order
|
||||
// to do this, it needs to construct the next page's URL.
|
||||
func (r ListenerPage) NextPageURL() (string, error) {
|
||||
var s struct {
|
||||
Links []gophercloud.Link `json:"listeners_links"`
|
||||
}
|
||||
err := r.ExtractInto(&s)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return gophercloud.ExtractNextURL(s.Links)
|
||||
}
|
||||
|
||||
// IsEmpty checks whether a ListenerPage struct is empty.
|
||||
func (r ListenerPage) IsEmpty() (bool, error) {
|
||||
is, err := ExtractListeners(r)
|
||||
return len(is) == 0, err
|
||||
}
|
||||
|
||||
// ExtractListeners accepts a Page struct, specifically a ListenerPage struct,
|
||||
// and extracts the elements into a slice of Listener structs. In other words,
|
||||
// a generic collection is mapped into a relevant slice.
|
||||
func ExtractListeners(r pagination.Page) ([]Listener, error) {
|
||||
var s struct {
|
||||
Listeners []Listener `json:"listeners"`
|
||||
}
|
||||
err := (r.(ListenerPage)).ExtractInto(&s)
|
||||
return s.Listeners, err
|
||||
}
|
||||
|
||||
type commonResult struct {
|
||||
gophercloud.Result
|
||||
}
|
||||
|
||||
// Extract is a function that accepts a result and extracts a listener.
|
||||
func (r commonResult) Extract() (*Listener, error) {
|
||||
var s struct {
|
||||
Listener *Listener `json:"listener"`
|
||||
}
|
||||
err := r.ExtractInto(&s)
|
||||
return s.Listener, err
|
||||
}
|
||||
|
||||
// CreateResult represents the result of a create operation. Call its Extract
|
||||
// method to interpret it as a Listener.
|
||||
type CreateResult struct {
|
||||
commonResult
|
||||
}
|
||||
|
||||
// GetResult represents the result of a get operation. Call its Extract
|
||||
// method to interpret it as a Listener.
|
||||
type GetResult struct {
|
||||
commonResult
|
||||
}
|
||||
|
||||
// UpdateResult represents the result of an update operation. Call its Extract
|
||||
// method to interpret it as a Listener.
|
||||
type UpdateResult struct {
|
||||
commonResult
|
||||
}
|
||||
|
||||
// DeleteResult represents the result of a delete operation. Call its
|
||||
// ExtractErr method to determine if the request succeeded or failed.
|
||||
type DeleteResult struct {
|
||||
gophercloud.ErrResult
|
||||
}
|
||||
|
||||
// StatsResult represents the result of a GetStats operation.
|
||||
// Call its Extract method to interpret it as a Stats.
|
||||
type StatsResult struct {
|
||||
gophercloud.Result
|
||||
}
|
||||
|
||||
// Extract is a function that accepts a result and extracts the status of
|
||||
// a Listener.
|
||||
func (r StatsResult) Extract() (*Stats, error) {
|
||||
var s struct {
|
||||
Stats *Stats `json:"stats"`
|
||||
}
|
||||
err := r.ExtractInto(&s)
|
||||
return s.Stats, err
|
||||
}
|
||||
21
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners/urls.go
generated
vendored
Normal file
21
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners/urls.go
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package listeners
|
||||
|
||||
import "github.com/gophercloud/gophercloud"
|
||||
|
||||
const (
|
||||
rootPath = "lbaas"
|
||||
resourcePath = "listeners"
|
||||
statisticsPath = "stats"
|
||||
)
|
||||
|
||||
func rootURL(c *gophercloud.ServiceClient) string {
|
||||
return c.ServiceURL(rootPath, resourcePath)
|
||||
}
|
||||
|
||||
func resourceURL(c *gophercloud.ServiceClient, id string) string {
|
||||
return c.ServiceURL(rootPath, resourcePath, id)
|
||||
}
|
||||
|
||||
func statisticsRootURL(c *gophercloud.ServiceClient, id string) string {
|
||||
return c.ServiceURL(rootPath, resourcePath, id, statisticsPath)
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ go_library(
|
|||
"results.go",
|
||||
"urls.go",
|
||||
],
|
||||
importmap = "vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers",
|
||||
importmap = "k8s.io/kops/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers",
|
||||
importpath = "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
|
|
|
|||
84
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers/doc.go
generated
vendored
Normal file
84
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers/doc.go
generated
vendored
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
Package loadbalancers provides information and interaction with Load Balancers
|
||||
of the LBaaS v2 extension for the OpenStack Networking service.
|
||||
|
||||
Example to List Load Balancers
|
||||
|
||||
listOpts := loadbalancers.ListOpts{
|
||||
Provider: "haproxy",
|
||||
}
|
||||
|
||||
allPages, err := loadbalancers.List(networkClient, listOpts).AllPages()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
allLoadbalancers, err := loadbalancers.ExtractLoadBalancers(allPages)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for _, lb := range allLoadbalancers {
|
||||
fmt.Printf("%+v\n", lb)
|
||||
}
|
||||
|
||||
Example to Create a Load Balancer
|
||||
|
||||
createOpts := loadbalancers.CreateOpts{
|
||||
Name: "db_lb",
|
||||
AdminStateUp: gophercloud.Enabled,
|
||||
VipSubnetID: "9cedb85d-0759-4898-8a4b-fa5a5ea10086",
|
||||
VipAddress: "10.30.176.48",
|
||||
Flavor: "medium",
|
||||
Provider: "haproxy",
|
||||
}
|
||||
|
||||
lb, err := loadbalancers.Create(networkClient, createOpts).Extract()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Example to Update a Load Balancer
|
||||
|
||||
lbID := "d67d56a6-4a86-4688-a282-f46444705c64"
|
||||
|
||||
i1001 := 1001
|
||||
updateOpts := loadbalancers.UpdateOpts{
|
||||
Name: "new-name",
|
||||
}
|
||||
|
||||
lb, err := loadbalancers.Update(networkClient, lbID, updateOpts).Extract()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Example to Delete a Load Balancers
|
||||
|
||||
deleteOpts := loadbalancers.DeleteOpts{
|
||||
Cascade: true,
|
||||
}
|
||||
|
||||
lbID := "d67d56a6-4a86-4688-a282-f46444705c64"
|
||||
|
||||
err := loadbalancers.Delete(networkClient, lbID, deleteOpts).ExtractErr()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Example to Get the Status of a Load Balancer
|
||||
|
||||
lbID := "d67d56a6-4a86-4688-a282-f46444705c64"
|
||||
status, err := loadbalancers.GetStatuses(networkClient, LBID).Extract()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Example to Get the Statistics of a Load Balancer
|
||||
|
||||
lbID := "d67d56a6-4a86-4688-a282-f46444705c64"
|
||||
stats, err := loadbalancers.GetStats(networkClient, LBID).Extract()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
*/
|
||||
package loadbalancers
|
||||
211
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers/requests.go
generated
vendored
Normal file
211
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers/requests.go
generated
vendored
Normal file
|
|
@ -0,0 +1,211 @@
|
|||
package loadbalancers
|
||||
|
||||
import (
|
||||
"github.com/gophercloud/gophercloud"
|
||||
"github.com/gophercloud/gophercloud/pagination"
|
||||
)
|
||||
|
||||
// ListOptsBuilder allows extensions to add additional parameters to the
|
||||
// List request.
|
||||
type ListOptsBuilder interface {
|
||||
ToLoadBalancerListQuery() (string, error)
|
||||
}
|
||||
|
||||
// ListOpts allows the filtering and sorting of paginated collections through
|
||||
// the API. Filtering is achieved by passing in struct field values that map to
|
||||
// the Loadbalancer attributes you want to see returned. SortKey allows you to
|
||||
// sort by a particular attribute. SortDir sets the direction, and is
|
||||
// either `asc' or `desc'. Marker and Limit are used for pagination.
|
||||
type ListOpts struct {
|
||||
Description string `q:"description"`
|
||||
AdminStateUp *bool `q:"admin_state_up"`
|
||||
ProjectID string `q:"project_id"`
|
||||
ProvisioningStatus string `q:"provisioning_status"`
|
||||
VipAddress string `q:"vip_address"`
|
||||
VipPortID string `q:"vip_port_id"`
|
||||
VipSubnetID string `q:"vip_subnet_id"`
|
||||
ID string `q:"id"`
|
||||
OperatingStatus string `q:"operating_status"`
|
||||
Name string `q:"name"`
|
||||
Flavor string `q:"flavor"`
|
||||
Provider string `q:"provider"`
|
||||
Limit int `q:"limit"`
|
||||
Marker string `q:"marker"`
|
||||
SortKey string `q:"sort_key"`
|
||||
SortDir string `q:"sort_dir"`
|
||||
}
|
||||
|
||||
// ToLoadBalancerListQuery formats a ListOpts into a query string.
|
||||
func (opts ListOpts) ToLoadBalancerListQuery() (string, error) {
|
||||
q, err := gophercloud.BuildQueryString(opts)
|
||||
return q.String(), err
|
||||
}
|
||||
|
||||
// List returns a Pager which allows you to iterate over a collection of
|
||||
// load balancers. It accepts a ListOpts struct, which allows you to filter
|
||||
// and sort the returned collection for greater efficiency.
|
||||
//
|
||||
// Default policy settings return only those load balancers that are owned by
|
||||
// the project who submits the request, unless an admin user submits the request.
|
||||
func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager {
|
||||
url := rootURL(c)
|
||||
if opts != nil {
|
||||
query, err := opts.ToLoadBalancerListQuery()
|
||||
if err != nil {
|
||||
return pagination.Pager{Err: err}
|
||||
}
|
||||
url += query
|
||||
}
|
||||
return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page {
|
||||
return LoadBalancerPage{pagination.LinkedPageBase{PageResult: r}}
|
||||
})
|
||||
}
|
||||
|
||||
// CreateOptsBuilder allows extensions to add additional parameters to the
|
||||
// Create request.
|
||||
type CreateOptsBuilder interface {
|
||||
ToLoadBalancerCreateMap() (map[string]interface{}, error)
|
||||
}
|
||||
|
||||
// CreateOpts is the common options struct used in this package's Create
|
||||
// operation.
|
||||
type CreateOpts struct {
|
||||
// Human-readable name for the Loadbalancer. Does not have to be unique.
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
// Human-readable description for the Loadbalancer.
|
||||
Description string `json:"description,omitempty"`
|
||||
|
||||
// The network on which to allocate the Loadbalancer's address. A project can
|
||||
// only create Loadbalancers on networks authorized by policy (e.g. networks
|
||||
// that belong to them or networks that are shared).
|
||||
VipSubnetID string `json:"vip_subnet_id" required:"true"`
|
||||
|
||||
// ProjectID is the UUID of the project who owns the Loadbalancer.
|
||||
// Only administrative users can specify a project UUID other than their own.
|
||||
ProjectID string `json:"project_id,omitempty"`
|
||||
|
||||
// The IP address of the Loadbalancer.
|
||||
VipAddress string `json:"vip_address,omitempty"`
|
||||
|
||||
// The administrative state of the Loadbalancer. A valid value is true (UP)
|
||||
// or false (DOWN).
|
||||
AdminStateUp *bool `json:"admin_state_up,omitempty"`
|
||||
|
||||
// The UUID of a flavor.
|
||||
Flavor string `json:"flavor,omitempty"`
|
||||
|
||||
// The name of the provider.
|
||||
Provider string `json:"provider,omitempty"`
|
||||
}
|
||||
|
||||
// ToLoadBalancerCreateMap builds a request body from CreateOpts.
|
||||
func (opts CreateOpts) ToLoadBalancerCreateMap() (map[string]interface{}, error) {
|
||||
return gophercloud.BuildRequestBody(opts, "loadbalancer")
|
||||
}
|
||||
|
||||
// Create is an operation which provisions a new loadbalancer based on the
|
||||
// configuration defined in the CreateOpts struct. Once the request is
|
||||
// validated and progress has started on the provisioning process, a
|
||||
// CreateResult will be returned.
|
||||
func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) {
|
||||
b, err := opts.ToLoadBalancerCreateMap()
|
||||
if err != nil {
|
||||
r.Err = err
|
||||
return
|
||||
}
|
||||
_, r.Err = c.Post(rootURL(c), b, &r.Body, nil)
|
||||
return
|
||||
}
|
||||
|
||||
// Get retrieves a particular Loadbalancer based on its unique ID.
|
||||
func Get(c *gophercloud.ServiceClient, id string) (r GetResult) {
|
||||
_, r.Err = c.Get(resourceURL(c, id), &r.Body, nil)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateOptsBuilder allows extensions to add additional parameters to the
|
||||
// Update request.
|
||||
type UpdateOptsBuilder interface {
|
||||
ToLoadBalancerUpdateMap() (map[string]interface{}, error)
|
||||
}
|
||||
|
||||
// UpdateOpts is the common options struct used in this package's Update
|
||||
// operation.
|
||||
type UpdateOpts struct {
|
||||
// Human-readable name for the Loadbalancer. Does not have to be unique.
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
// Human-readable description for the Loadbalancer.
|
||||
Description string `json:"description,omitempty"`
|
||||
|
||||
// The administrative state of the Loadbalancer. A valid value is true (UP)
|
||||
// or false (DOWN).
|
||||
AdminStateUp *bool `json:"admin_state_up,omitempty"`
|
||||
}
|
||||
|
||||
// ToLoadBalancerUpdateMap builds a request body from UpdateOpts.
|
||||
func (opts UpdateOpts) ToLoadBalancerUpdateMap() (map[string]interface{}, error) {
|
||||
return gophercloud.BuildRequestBody(opts, "loadbalancer")
|
||||
}
|
||||
|
||||
// Update is an operation which modifies the attributes of the specified
|
||||
// LoadBalancer.
|
||||
func Update(c *gophercloud.ServiceClient, id string, opts UpdateOpts) (r UpdateResult) {
|
||||
b, err := opts.ToLoadBalancerUpdateMap()
|
||||
if err != nil {
|
||||
r.Err = err
|
||||
return
|
||||
}
|
||||
_, r.Err = c.Put(resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{
|
||||
OkCodes: []int{200, 202},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteOptsBuilder allows extensions to add additional parameters to the
|
||||
// Delete request.
|
||||
type DeleteOptsBuilder interface {
|
||||
ToLoadBalancerDeleteQuery() (string, error)
|
||||
}
|
||||
|
||||
// DeleteOpts is the common options struct used in this package's Delete
|
||||
// operation.
|
||||
type DeleteOpts struct {
|
||||
// Cascade will delete all children of the load balancer (listners, monitors, etc).
|
||||
Cascade bool `q:"cascade"`
|
||||
}
|
||||
|
||||
// ToLoadBalancerDeleteQuery formats a DeleteOpts into a query string.
|
||||
func (opts DeleteOpts) ToLoadBalancerDeleteQuery() (string, error) {
|
||||
q, err := gophercloud.BuildQueryString(opts)
|
||||
return q.String(), err
|
||||
}
|
||||
|
||||
// Delete will permanently delete a particular LoadBalancer based on its
|
||||
// unique ID.
|
||||
func Delete(c *gophercloud.ServiceClient, id string, opts DeleteOptsBuilder) (r DeleteResult) {
|
||||
url := resourceURL(c, id)
|
||||
if opts != nil {
|
||||
query, err := opts.ToLoadBalancerDeleteQuery()
|
||||
if err != nil {
|
||||
r.Err = err
|
||||
return
|
||||
}
|
||||
url += query
|
||||
}
|
||||
_, r.Err = c.Delete(url, nil)
|
||||
return
|
||||
}
|
||||
|
||||
// GetStatuses will return the status of a particular LoadBalancer.
|
||||
func GetStatuses(c *gophercloud.ServiceClient, id string) (r GetStatusesResult) {
|
||||
_, r.Err = c.Get(statusRootURL(c, id), &r.Body, nil)
|
||||
return
|
||||
}
|
||||
|
||||
// GetStats will return the shows the current statistics of a particular LoadBalancer.
|
||||
func GetStats(c *gophercloud.ServiceClient, id string) (r StatsResult) {
|
||||
_, r.Err = c.Get(statisticsRootURL(c, id), &r.Body, nil)
|
||||
return
|
||||
}
|
||||
182
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers/results.go
generated
vendored
Normal file
182
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers/results.go
generated
vendored
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
package loadbalancers
|
||||
|
||||
import (
|
||||
"github.com/gophercloud/gophercloud"
|
||||
"github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/listeners"
|
||||
"github.com/gophercloud/gophercloud/pagination"
|
||||
)
|
||||
|
||||
// LoadBalancer is the primary load balancing configuration object that
|
||||
// specifies the virtual IP address on which client traffic is received, as well
|
||||
// as other details such as the load balancing method to be use, protocol, etc.
|
||||
type LoadBalancer struct {
|
||||
// Human-readable description for the Loadbalancer.
|
||||
Description string `json:"description"`
|
||||
|
||||
// The administrative state of the Loadbalancer.
|
||||
// A valid value is true (UP) or false (DOWN).
|
||||
AdminStateUp bool `json:"admin_state_up"`
|
||||
|
||||
// Owner of the LoadBalancer.
|
||||
ProjectID string `json:"project_id"`
|
||||
|
||||
// The provisioning status of the LoadBalancer.
|
||||
// This value is ACTIVE, PENDING_CREATE or ERROR.
|
||||
ProvisioningStatus string `json:"provisioning_status"`
|
||||
|
||||
// The IP address of the Loadbalancer.
|
||||
VipAddress string `json:"vip_address"`
|
||||
|
||||
// The UUID of the port associated with the IP address.
|
||||
VipPortID string `json:"vip_port_id"`
|
||||
|
||||
// The UUID of the subnet on which to allocate the virtual IP for the
|
||||
// Loadbalancer address.
|
||||
VipSubnetID string `json:"vip_subnet_id"`
|
||||
|
||||
// The unique ID for the LoadBalancer.
|
||||
ID string `json:"id"`
|
||||
|
||||
// The operating status of the LoadBalancer. This value is ONLINE or OFFLINE.
|
||||
OperatingStatus string `json:"operating_status"`
|
||||
|
||||
// Human-readable name for the LoadBalancer. Does not have to be unique.
|
||||
Name string `json:"name"`
|
||||
|
||||
// The UUID of a flavor if set.
|
||||
Flavor string `json:"flavor"`
|
||||
|
||||
// The name of the provider.
|
||||
Provider string `json:"provider"`
|
||||
|
||||
// Listeners are the listeners related to this Loadbalancer.
|
||||
Listeners []listeners.Listener `json:"listeners"`
|
||||
}
|
||||
|
||||
// StatusTree represents the status of a loadbalancer.
|
||||
type StatusTree struct {
|
||||
Loadbalancer *LoadBalancer `json:"loadbalancer"`
|
||||
}
|
||||
|
||||
type Stats struct {
|
||||
// The currently active connections.
|
||||
ActiveConnections int `json:"active_connections"`
|
||||
|
||||
// The total bytes received.
|
||||
BytesIn int `json:"bytes_in"`
|
||||
|
||||
// The total bytes sent.
|
||||
BytesOut int `json:"bytes_out"`
|
||||
|
||||
// The total requests that were unable to be fulfilled.
|
||||
RequestErrors int `json:"request_errors"`
|
||||
|
||||
// The total connections handled.
|
||||
TotalConnections int `json:"total_connections"`
|
||||
}
|
||||
|
||||
// LoadBalancerPage is the page returned by a pager when traversing over a
|
||||
// collection of load balancers.
|
||||
type LoadBalancerPage struct {
|
||||
pagination.LinkedPageBase
|
||||
}
|
||||
|
||||
// NextPageURL is invoked when a paginated collection of load balancers has
|
||||
// reached the end of a page and the pager seeks to traverse over a new one.
|
||||
// In order to do this, it needs to construct the next page's URL.
|
||||
func (r LoadBalancerPage) NextPageURL() (string, error) {
|
||||
var s struct {
|
||||
Links []gophercloud.Link `json:"loadbalancers_links"`
|
||||
}
|
||||
err := r.ExtractInto(&s)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return gophercloud.ExtractNextURL(s.Links)
|
||||
}
|
||||
|
||||
// IsEmpty checks whether a LoadBalancerPage struct is empty.
|
||||
func (r LoadBalancerPage) IsEmpty() (bool, error) {
|
||||
is, err := ExtractLoadBalancers(r)
|
||||
return len(is) == 0, err
|
||||
}
|
||||
|
||||
// ExtractLoadBalancers accepts a Page struct, specifically a LoadbalancerPage
|
||||
// struct, and extracts the elements into a slice of LoadBalancer structs. In
|
||||
// other words, a generic collection is mapped into a relevant slice.
|
||||
func ExtractLoadBalancers(r pagination.Page) ([]LoadBalancer, error) {
|
||||
var s struct {
|
||||
LoadBalancers []LoadBalancer `json:"loadbalancers"`
|
||||
}
|
||||
err := (r.(LoadBalancerPage)).ExtractInto(&s)
|
||||
return s.LoadBalancers, err
|
||||
}
|
||||
|
||||
type commonResult struct {
|
||||
gophercloud.Result
|
||||
}
|
||||
|
||||
// Extract is a function that accepts a result and extracts a loadbalancer.
|
||||
func (r commonResult) Extract() (*LoadBalancer, error) {
|
||||
var s struct {
|
||||
LoadBalancer *LoadBalancer `json:"loadbalancer"`
|
||||
}
|
||||
err := r.ExtractInto(&s)
|
||||
return s.LoadBalancer, err
|
||||
}
|
||||
|
||||
// GetStatusesResult represents the result of a GetStatuses operation.
|
||||
// Call its Extract method to interpret it as a StatusTree.
|
||||
type GetStatusesResult struct {
|
||||
gophercloud.Result
|
||||
}
|
||||
|
||||
// Extract is a function that accepts a result and extracts the status of
|
||||
// a Loadbalancer.
|
||||
func (r GetStatusesResult) Extract() (*StatusTree, error) {
|
||||
var s struct {
|
||||
Statuses *StatusTree `json:"statuses"`
|
||||
}
|
||||
err := r.ExtractInto(&s)
|
||||
return s.Statuses, err
|
||||
}
|
||||
|
||||
// StatsResult represents the result of a GetStats operation.
|
||||
// Call its Extract method to interpret it as a Stats.
|
||||
type StatsResult struct {
|
||||
gophercloud.Result
|
||||
}
|
||||
|
||||
// Extract is a function that accepts a result and extracts the status of
|
||||
// a Loadbalancer.
|
||||
func (r StatsResult) Extract() (*Stats, error) {
|
||||
var s struct {
|
||||
Stats *Stats `json:"stats"`
|
||||
}
|
||||
err := r.ExtractInto(&s)
|
||||
return s.Stats, err
|
||||
}
|
||||
|
||||
// CreateResult represents the result of a create operation. Call its Extract
|
||||
// method to interpret it as a LoadBalancer.
|
||||
type CreateResult struct {
|
||||
commonResult
|
||||
}
|
||||
|
||||
// GetResult represents the result of a get operation. Call its Extract
|
||||
// method to interpret it as a LoadBalancer.
|
||||
type GetResult struct {
|
||||
commonResult
|
||||
}
|
||||
|
||||
// UpdateResult represents the result of an update operation. Call its Extract
|
||||
// method to interpret it as a LoadBalancer.
|
||||
type UpdateResult struct {
|
||||
commonResult
|
||||
}
|
||||
|
||||
// DeleteResult represents the result of a delete operation. Call its
|
||||
// ExtractErr method to determine if the request succeeded or failed.
|
||||
type DeleteResult struct {
|
||||
gophercloud.ErrResult
|
||||
}
|
||||
26
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers/urls.go
generated
vendored
Normal file
26
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/loadbalancers/urls.go
generated
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package loadbalancers
|
||||
|
||||
import "github.com/gophercloud/gophercloud"
|
||||
|
||||
const (
|
||||
rootPath = "lbaas"
|
||||
resourcePath = "loadbalancers"
|
||||
statusPath = "status"
|
||||
statisticsPath = "stats"
|
||||
)
|
||||
|
||||
func rootURL(c *gophercloud.ServiceClient) string {
|
||||
return c.ServiceURL(rootPath, resourcePath)
|
||||
}
|
||||
|
||||
func resourceURL(c *gophercloud.ServiceClient, id string) string {
|
||||
return c.ServiceURL(rootPath, resourcePath, id)
|
||||
}
|
||||
|
||||
func statusRootURL(c *gophercloud.ServiceClient, id string) string {
|
||||
return c.ServiceURL(rootPath, resourcePath, id, statusPath)
|
||||
}
|
||||
|
||||
func statisticsRootURL(c *gophercloud.ServiceClient, id string) string {
|
||||
return c.ServiceURL(rootPath, resourcePath, id, statisticsPath)
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ go_library(
|
|||
"results.go",
|
||||
"urls.go",
|
||||
],
|
||||
importmap = "vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors",
|
||||
importmap = "k8s.io/kops/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors",
|
||||
importpath = "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
|
|
|
|||
69
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors/doc.go
generated
vendored
Normal file
69
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors/doc.go
generated
vendored
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
Package monitors provides information and interaction with Monitors
|
||||
of the LBaaS v2 extension for the OpenStack Networking service.
|
||||
|
||||
Example to List Monitors
|
||||
|
||||
listOpts := monitors.ListOpts{
|
||||
PoolID: "c79a4468-d788-410c-bf79-9a8ef6354852",
|
||||
}
|
||||
|
||||
allPages, err := monitors.List(networkClient, listOpts).AllPages()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
allMonitors, err := monitors.ExtractMonitors(allPages)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for _, monitor := range allMonitors {
|
||||
fmt.Printf("%+v\n", monitor)
|
||||
}
|
||||
|
||||
Example to Create a Monitor
|
||||
|
||||
createOpts := monitors.CreateOpts{
|
||||
Type: "HTTP",
|
||||
Name: "db",
|
||||
PoolID: "84f1b61f-58c4-45bf-a8a9-2dafb9e5214d",
|
||||
Delay: 20,
|
||||
Timeout: 10,
|
||||
MaxRetries: 5,
|
||||
URLPath: "/check",
|
||||
ExpectedCodes: "200-299",
|
||||
}
|
||||
|
||||
monitor, err := monitors.Create(networkClient, createOpts).Extract()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Example to Update a Monitor
|
||||
|
||||
monitorID := "d67d56a6-4a86-4688-a282-f46444705c64"
|
||||
|
||||
updateOpts := monitors.UpdateOpts{
|
||||
Name: "NewHealthmonitorName",
|
||||
Delay: 3,
|
||||
Timeout: 20,
|
||||
MaxRetries: 10,
|
||||
URLPath: "/another_check",
|
||||
ExpectedCodes: "301",
|
||||
}
|
||||
|
||||
monitor, err := monitors.Update(networkClient, monitorID, updateOpts).Extract()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Example to Delete a Monitor
|
||||
|
||||
monitorID := "d67d56a6-4a86-4688-a282-f46444705c64"
|
||||
err := monitors.Delete(networkClient, monitorID).ExtractErr()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
*/
|
||||
package monitors
|
||||
257
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors/requests.go
generated
vendored
Normal file
257
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors/requests.go
generated
vendored
Normal file
|
|
@ -0,0 +1,257 @@
|
|||
package monitors
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gophercloud/gophercloud"
|
||||
"github.com/gophercloud/gophercloud/pagination"
|
||||
)
|
||||
|
||||
// ListOptsBuilder allows extensions to add additional parameters to the
|
||||
// List request.
|
||||
type ListOptsBuilder interface {
|
||||
ToMonitorListQuery() (string, error)
|
||||
}
|
||||
|
||||
// ListOpts allows the filtering and sorting of paginated collections through
|
||||
// the API. Filtering is achieved by passing in struct field values that map to
|
||||
// the Monitor attributes you want to see returned. SortKey allows you to
|
||||
// sort by a particular Monitor attribute. SortDir sets the direction, and is
|
||||
// either `asc' or `desc'. Marker and Limit are used for pagination.
|
||||
type ListOpts struct {
|
||||
ID string `q:"id"`
|
||||
Name string `q:"name"`
|
||||
TenantID string `q:"tenant_id"`
|
||||
ProjectID string `q:"project_id"`
|
||||
PoolID string `q:"pool_id"`
|
||||
Type string `q:"type"`
|
||||
Delay int `q:"delay"`
|
||||
Timeout int `q:"timeout"`
|
||||
MaxRetries int `q:"max_retries"`
|
||||
HTTPMethod string `q:"http_method"`
|
||||
URLPath string `q:"url_path"`
|
||||
ExpectedCodes string `q:"expected_codes"`
|
||||
AdminStateUp *bool `q:"admin_state_up"`
|
||||
Status string `q:"status"`
|
||||
Limit int `q:"limit"`
|
||||
Marker string `q:"marker"`
|
||||
SortKey string `q:"sort_key"`
|
||||
SortDir string `q:"sort_dir"`
|
||||
}
|
||||
|
||||
// ToMonitorListQuery formats a ListOpts into a query string.
|
||||
func (opts ListOpts) ToMonitorListQuery() (string, error) {
|
||||
q, err := gophercloud.BuildQueryString(opts)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return q.String(), nil
|
||||
}
|
||||
|
||||
// List returns a Pager which allows you to iterate over a collection of
|
||||
// health monitors. It accepts a ListOpts struct, which allows you to filter and sort
|
||||
// the returned collection for greater efficiency.
|
||||
//
|
||||
// Default policy settings return only those health monitors that are owned by the
|
||||
// tenant who submits the request, unless an admin user submits the request.
|
||||
func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager {
|
||||
url := rootURL(c)
|
||||
if opts != nil {
|
||||
query, err := opts.ToMonitorListQuery()
|
||||
if err != nil {
|
||||
return pagination.Pager{Err: err}
|
||||
}
|
||||
url += query
|
||||
}
|
||||
return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page {
|
||||
return MonitorPage{pagination.LinkedPageBase{PageResult: r}}
|
||||
})
|
||||
}
|
||||
|
||||
// Constants that represent approved monitoring types.
|
||||
const (
|
||||
TypePING = "PING"
|
||||
TypeTCP = "TCP"
|
||||
TypeHTTP = "HTTP"
|
||||
TypeHTTPS = "HTTPS"
|
||||
)
|
||||
|
||||
var (
|
||||
errDelayMustGETimeout = fmt.Errorf("Delay must be greater than or equal to timeout")
|
||||
)
|
||||
|
||||
// CreateOptsBuilder allows extensions to add additional parameters to the
|
||||
// List request.
|
||||
type CreateOptsBuilder interface {
|
||||
ToMonitorCreateMap() (map[string]interface{}, error)
|
||||
}
|
||||
|
||||
// CreateOpts is the common options struct used in this package's Create
|
||||
// operation.
|
||||
type CreateOpts struct {
|
||||
// The Pool to Monitor.
|
||||
PoolID string `json:"pool_id" required:"true"`
|
||||
|
||||
// The type of probe, which is PING, TCP, HTTP, or HTTPS, that is
|
||||
// sent by the load balancer to verify the member state.
|
||||
Type string `json:"type" required:"true"`
|
||||
|
||||
// The time, in seconds, between sending probes to members.
|
||||
Delay int `json:"delay" required:"true"`
|
||||
|
||||
// Maximum number of seconds for a Monitor to wait for a ping reply
|
||||
// before it times out. The value must be less than the delay value.
|
||||
Timeout int `json:"timeout" required:"true"`
|
||||
|
||||
// Number of permissible ping failures before changing the member's
|
||||
// status to INACTIVE. Must be a number between 1 and 10.
|
||||
MaxRetries int `json:"max_retries" required:"true"`
|
||||
|
||||
// URI path that will be accessed if Monitor type is HTTP or HTTPS.
|
||||
// Required for HTTP(S) types.
|
||||
URLPath string `json:"url_path,omitempty"`
|
||||
|
||||
// The HTTP method used for requests by the Monitor. If this attribute
|
||||
// is not specified, it defaults to "GET". Required for HTTP(S) types.
|
||||
HTTPMethod string `json:"http_method,omitempty"`
|
||||
|
||||
// Expected HTTP codes for a passing HTTP(S) Monitor. You can either specify
|
||||
// a single status like "200", or a range like "200-202". Required for HTTP(S)
|
||||
// types.
|
||||
ExpectedCodes string `json:"expected_codes,omitempty"`
|
||||
|
||||
// TenantID is the UUID of the project who owns the Monitor.
|
||||
// Only administrative users can specify a project UUID other than their own.
|
||||
TenantID string `json:"tenant_id,omitempty"`
|
||||
|
||||
// ProjectID is the UUID of the project who owns the Monitor.
|
||||
// Only administrative users can specify a project UUID other than their own.
|
||||
ProjectID string `json:"project_id,omitempty"`
|
||||
|
||||
// The Name of the Monitor.
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
// The administrative state of the Monitor. A valid value is true (UP)
|
||||
// or false (DOWN).
|
||||
AdminStateUp *bool `json:"admin_state_up,omitempty"`
|
||||
}
|
||||
|
||||
// ToMonitorCreateMap builds a request body from CreateOpts.
|
||||
func (opts CreateOpts) ToMonitorCreateMap() (map[string]interface{}, error) {
|
||||
b, err := gophercloud.BuildRequestBody(opts, "healthmonitor")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
switch opts.Type {
|
||||
case TypeHTTP, TypeHTTPS:
|
||||
switch opts.URLPath {
|
||||
case "":
|
||||
return nil, fmt.Errorf("URLPath must be provided for HTTP and HTTPS")
|
||||
}
|
||||
switch opts.ExpectedCodes {
|
||||
case "":
|
||||
return nil, fmt.Errorf("ExpectedCodes must be provided for HTTP and HTTPS")
|
||||
}
|
||||
}
|
||||
|
||||
return b, nil
|
||||
}
|
||||
|
||||
/*
|
||||
Create is an operation which provisions a new Health Monitor. There are
|
||||
different types of Monitor you can provision: PING, TCP or HTTP(S). Below
|
||||
are examples of how to create each one.
|
||||
|
||||
Here is an example config struct to use when creating a PING or TCP Monitor:
|
||||
|
||||
CreateOpts{Type: TypePING, Delay: 20, Timeout: 10, MaxRetries: 3}
|
||||
CreateOpts{Type: TypeTCP, Delay: 20, Timeout: 10, MaxRetries: 3}
|
||||
|
||||
Here is an example config struct to use when creating a HTTP(S) Monitor:
|
||||
|
||||
CreateOpts{Type: TypeHTTP, Delay: 20, Timeout: 10, MaxRetries: 3,
|
||||
HttpMethod: "HEAD", ExpectedCodes: "200", PoolID: "2c946bfc-1804-43ab-a2ff-58f6a762b505"}
|
||||
*/
|
||||
func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) {
|
||||
b, err := opts.ToMonitorCreateMap()
|
||||
if err != nil {
|
||||
r.Err = err
|
||||
return
|
||||
}
|
||||
_, r.Err = c.Post(rootURL(c), b, &r.Body, nil)
|
||||
return
|
||||
}
|
||||
|
||||
// Get retrieves a particular Health Monitor based on its unique ID.
|
||||
func Get(c *gophercloud.ServiceClient, id string) (r GetResult) {
|
||||
_, r.Err = c.Get(resourceURL(c, id), &r.Body, nil)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateOptsBuilder allows extensions to add additional parameters to the
|
||||
// Update request.
|
||||
type UpdateOptsBuilder interface {
|
||||
ToMonitorUpdateMap() (map[string]interface{}, error)
|
||||
}
|
||||
|
||||
// UpdateOpts is the common options struct used in this package's Update
|
||||
// operation.
|
||||
type UpdateOpts struct {
|
||||
// The time, in seconds, between sending probes to members.
|
||||
Delay int `json:"delay,omitempty"`
|
||||
|
||||
// Maximum number of seconds for a Monitor to wait for a ping reply
|
||||
// before it times out. The value must be less than the delay value.
|
||||
Timeout int `json:"timeout,omitempty"`
|
||||
|
||||
// Number of permissible ping failures before changing the member's
|
||||
// status to INACTIVE. Must be a number between 1 and 10.
|
||||
MaxRetries int `json:"max_retries,omitempty"`
|
||||
|
||||
// URI path that will be accessed if Monitor type is HTTP or HTTPS.
|
||||
// Required for HTTP(S) types.
|
||||
URLPath string `json:"url_path,omitempty"`
|
||||
|
||||
// The HTTP method used for requests by the Monitor. If this attribute
|
||||
// is not specified, it defaults to "GET". Required for HTTP(S) types.
|
||||
HTTPMethod string `json:"http_method,omitempty"`
|
||||
|
||||
// Expected HTTP codes for a passing HTTP(S) Monitor. You can either specify
|
||||
// a single status like "200", or a range like "200-202". Required for HTTP(S)
|
||||
// types.
|
||||
ExpectedCodes string `json:"expected_codes,omitempty"`
|
||||
|
||||
// The Name of the Monitor.
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
// The administrative state of the Monitor. A valid value is true (UP)
|
||||
// or false (DOWN).
|
||||
AdminStateUp *bool `json:"admin_state_up,omitempty"`
|
||||
}
|
||||
|
||||
// ToMonitorUpdateMap builds a request body from UpdateOpts.
|
||||
func (opts UpdateOpts) ToMonitorUpdateMap() (map[string]interface{}, error) {
|
||||
return gophercloud.BuildRequestBody(opts, "healthmonitor")
|
||||
}
|
||||
|
||||
// Update is an operation which modifies the attributes of the specified
|
||||
// Monitor.
|
||||
func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) {
|
||||
b, err := opts.ToMonitorUpdateMap()
|
||||
if err != nil {
|
||||
r.Err = err
|
||||
return
|
||||
}
|
||||
|
||||
_, r.Err = c.Put(resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{
|
||||
OkCodes: []int{200, 202},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Delete will permanently delete a particular Monitor based on its unique ID.
|
||||
func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) {
|
||||
_, r.Err = c.Delete(resourceURL(c, id), nil)
|
||||
return
|
||||
}
|
||||
153
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors/results.go
generated
vendored
Normal file
153
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors/results.go
generated
vendored
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
package monitors
|
||||
|
||||
import (
|
||||
"github.com/gophercloud/gophercloud"
|
||||
"github.com/gophercloud/gophercloud/pagination"
|
||||
)
|
||||
|
||||
type PoolID struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
// Monitor represents a load balancer health monitor. A health monitor is used
|
||||
// to determine whether or not back-end members of the VIP's pool are usable
|
||||
// for processing a request. A pool can have several health monitors associated
|
||||
// with it. There are different types of health monitors supported:
|
||||
//
|
||||
// PING: used to ping the members using ICMP.
|
||||
// TCP: used to connect to the members using TCP.
|
||||
// HTTP: used to send an HTTP request to the member.
|
||||
// HTTPS: used to send a secure HTTP request to the member.
|
||||
//
|
||||
// When a pool has several monitors associated with it, each member of the pool
|
||||
// is monitored by all these monitors. If any monitor declares the member as
|
||||
// unhealthy, then the member status is changed to INACTIVE and the member
|
||||
// won't participate in its pool's load balancing. In other words, ALL monitors
|
||||
// must declare the member to be healthy for it to stay ACTIVE.
|
||||
type Monitor struct {
|
||||
// The unique ID for the Monitor.
|
||||
ID string `json:"id"`
|
||||
|
||||
// The Name of the Monitor.
|
||||
Name string `json:"name"`
|
||||
|
||||
// The owner of the Monitor.
|
||||
ProjectID string `json:"project_id"`
|
||||
|
||||
// The type of probe sent by the load balancer to verify the member state,
|
||||
// which is PING, TCP, HTTP, or HTTPS.
|
||||
Type string `json:"type"`
|
||||
|
||||
// The time, in seconds, between sending probes to members.
|
||||
Delay int `json:"delay"`
|
||||
|
||||
// The maximum number of seconds for a monitor to wait for a connection to be
|
||||
// established before it times out. This value must be less than the delay
|
||||
// value.
|
||||
Timeout int `json:"timeout"`
|
||||
|
||||
// Number of allowed connection failures before changing the status of the
|
||||
// member to INACTIVE. A valid value is from 1 to 10.
|
||||
MaxRetries int `json:"max_retries"`
|
||||
|
||||
// The HTTP method that the monitor uses for requests.
|
||||
HTTPMethod string `json:"http_method"`
|
||||
|
||||
// The HTTP path of the request sent by the monitor to test the health of a
|
||||
// member. Must be a string beginning with a forward slash (/).
|
||||
URLPath string `json:"url_path" `
|
||||
|
||||
// Expected HTTP codes for a passing HTTP(S) monitor.
|
||||
ExpectedCodes string `json:"expected_codes"`
|
||||
|
||||
// The administrative state of the health monitor, which is up (true) or
|
||||
// down (false).
|
||||
AdminStateUp bool `json:"admin_state_up"`
|
||||
|
||||
// The status of the health monitor. Indicates whether the health monitor is
|
||||
// operational.
|
||||
Status string `json:"status"`
|
||||
|
||||
// List of pools that are associated with the health monitor.
|
||||
Pools []PoolID `json:"pools"`
|
||||
|
||||
// The provisioning status of the Monitor.
|
||||
// This value is ACTIVE, PENDING_* or ERROR.
|
||||
ProvisioningStatus string `json:"provisioning_status"`
|
||||
}
|
||||
|
||||
// MonitorPage is the page returned by a pager when traversing over a
|
||||
// collection of health monitors.
|
||||
type MonitorPage struct {
|
||||
pagination.LinkedPageBase
|
||||
}
|
||||
|
||||
// NextPageURL is invoked when a paginated collection of monitors has reached
|
||||
// the end of a page and the pager seeks to traverse over a new one. In order
|
||||
// to do this, it needs to construct the next page's URL.
|
||||
func (r MonitorPage) NextPageURL() (string, error) {
|
||||
var s struct {
|
||||
Links []gophercloud.Link `json:"healthmonitors_links"`
|
||||
}
|
||||
|
||||
err := r.ExtractInto(&s)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return gophercloud.ExtractNextURL(s.Links)
|
||||
}
|
||||
|
||||
// IsEmpty checks whether a MonitorPage struct is empty.
|
||||
func (r MonitorPage) IsEmpty() (bool, error) {
|
||||
is, err := ExtractMonitors(r)
|
||||
return len(is) == 0, err
|
||||
}
|
||||
|
||||
// ExtractMonitors accepts a Page struct, specifically a MonitorPage struct,
|
||||
// and extracts the elements into a slice of Monitor structs. In other words,
|
||||
// a generic collection is mapped into a relevant slice.
|
||||
func ExtractMonitors(r pagination.Page) ([]Monitor, error) {
|
||||
var s struct {
|
||||
Monitors []Monitor `json:"healthmonitors"`
|
||||
}
|
||||
err := (r.(MonitorPage)).ExtractInto(&s)
|
||||
return s.Monitors, err
|
||||
}
|
||||
|
||||
type commonResult struct {
|
||||
gophercloud.Result
|
||||
}
|
||||
|
||||
// Extract is a function that accepts a result and extracts a monitor.
|
||||
func (r commonResult) Extract() (*Monitor, error) {
|
||||
var s struct {
|
||||
Monitor *Monitor `json:"healthmonitor"`
|
||||
}
|
||||
err := r.ExtractInto(&s)
|
||||
return s.Monitor, err
|
||||
}
|
||||
|
||||
// CreateResult represents the result of a create operation. Call its Extract
|
||||
// method to interpret it as a Monitor.
|
||||
type CreateResult struct {
|
||||
commonResult
|
||||
}
|
||||
|
||||
// GetResult represents the result of a get operation. Call its Extract
|
||||
// method to interpret it as a Monitor.
|
||||
type GetResult struct {
|
||||
commonResult
|
||||
}
|
||||
|
||||
// UpdateResult represents the result of an update operation. Call its Extract
|
||||
// method to interpret it as a Monitor.
|
||||
type UpdateResult struct {
|
||||
commonResult
|
||||
}
|
||||
|
||||
// DeleteResult represents the result of a delete operation. Call its
|
||||
// ExtractErr method to determine if the result succeeded or failed.
|
||||
type DeleteResult struct {
|
||||
gophercloud.ErrResult
|
||||
}
|
||||
16
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors/urls.go
generated
vendored
Normal file
16
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors/urls.go
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
package monitors
|
||||
|
||||
import "github.com/gophercloud/gophercloud"
|
||||
|
||||
const (
|
||||
rootPath = "lbaas"
|
||||
resourcePath = "healthmonitors"
|
||||
)
|
||||
|
||||
func rootURL(c *gophercloud.ServiceClient) string {
|
||||
return c.ServiceURL(rootPath, resourcePath)
|
||||
}
|
||||
|
||||
func resourceURL(c *gophercloud.ServiceClient, id string) string {
|
||||
return c.ServiceURL(rootPath, resourcePath, id)
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ go_library(
|
|||
"results.go",
|
||||
"urls.go",
|
||||
],
|
||||
importmap = "vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools",
|
||||
importmap = "k8s.io/kops/vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools",
|
||||
importpath = "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
|
|
|
|||
124
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools/doc.go
generated
vendored
Normal file
124
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools/doc.go
generated
vendored
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
Package pools provides information and interaction with Pools and
|
||||
Members of the LBaaS v2 extension for the OpenStack Networking service.
|
||||
|
||||
Example to List Pools
|
||||
|
||||
listOpts := pools.ListOpts{
|
||||
LoadbalancerID: "c79a4468-d788-410c-bf79-9a8ef6354852",
|
||||
}
|
||||
|
||||
allPages, err := pools.List(networkClient, listOpts).AllPages()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
allPools, err := pools.ExtractMonitors(allPages)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for _, pools := range allPools {
|
||||
fmt.Printf("%+v\n", pool)
|
||||
}
|
||||
|
||||
Example to Create a Pool
|
||||
|
||||
createOpts := pools.CreateOpts{
|
||||
LBMethod: pools.LBMethodRoundRobin,
|
||||
Protocol: "HTTP",
|
||||
Name: "Example pool",
|
||||
LoadbalancerID: "79e05663-7f03-45d2-a092-8b94062f22ab",
|
||||
}
|
||||
|
||||
pool, err := pools.Create(networkClient, createOpts).Extract()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Example to Update a Pool
|
||||
|
||||
poolID := "d67d56a6-4a86-4688-a282-f46444705c64"
|
||||
|
||||
updateOpts := pools.UpdateOpts{
|
||||
Name: "new-name",
|
||||
}
|
||||
|
||||
pool, err := pools.Update(networkClient, poolID, updateOpts).Extract()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Example to Delete a Pool
|
||||
|
||||
poolID := "d67d56a6-4a86-4688-a282-f46444705c64"
|
||||
err := pools.Delete(networkClient, poolID).ExtractErr()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Example to List Pool Members
|
||||
|
||||
poolID := "d67d56a6-4a86-4688-a282-f46444705c64"
|
||||
|
||||
listOpts := pools.ListMemberOpts{
|
||||
ProtocolPort: 80,
|
||||
}
|
||||
|
||||
allPages, err := pools.ListMembers(networkClient, poolID, listOpts).AllPages()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
allMembers, err := pools.ExtractMembers(allPages)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for _, member := allMembers {
|
||||
fmt.Printf("%+v\n", member)
|
||||
}
|
||||
|
||||
Example to Create a Member
|
||||
|
||||
poolID := "d67d56a6-4a86-4688-a282-f46444705c64"
|
||||
|
||||
createOpts := pools.CreateMemberOpts{
|
||||
Name: "db",
|
||||
SubnetID: "1981f108-3c48-48d2-b908-30f7d28532c9",
|
||||
Address: "10.0.2.11",
|
||||
ProtocolPort: 80,
|
||||
Weight: 10,
|
||||
}
|
||||
|
||||
member, err := pools.CreateMember(networkClient, poolID, createOpts).Extract()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Example to Update a Member
|
||||
|
||||
poolID := "d67d56a6-4a86-4688-a282-f46444705c64"
|
||||
memberID := "64dba99f-8af8-4200-8882-e32a0660f23e"
|
||||
|
||||
updateOpts := pools.UpdateMemberOpts{
|
||||
Name: "new-name",
|
||||
Weight: 4,
|
||||
}
|
||||
|
||||
member, err := pools.UpdateMember(networkClient, poolID, memberID, updateOpts).Extract()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Example to Delete a Member
|
||||
|
||||
poolID := "d67d56a6-4a86-4688-a282-f46444705c64"
|
||||
memberID := "64dba99f-8af8-4200-8882-e32a0660f23e"
|
||||
|
||||
err := pools.DeleteMember(networkClient, poolID, memberID).ExtractErr()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
*/
|
||||
package pools
|
||||
346
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools/requests.go
generated
vendored
Normal file
346
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools/requests.go
generated
vendored
Normal file
|
|
@ -0,0 +1,346 @@
|
|||
package pools
|
||||
|
||||
import (
|
||||
"github.com/gophercloud/gophercloud"
|
||||
"github.com/gophercloud/gophercloud/pagination"
|
||||
)
|
||||
|
||||
// ListOptsBuilder allows extensions to add additional parameters to the
|
||||
// List request.
|
||||
type ListOptsBuilder interface {
|
||||
ToPoolListQuery() (string, error)
|
||||
}
|
||||
|
||||
// ListOpts allows the filtering and sorting of paginated collections through
|
||||
// the API. Filtering is achieved by passing in struct field values that map to
|
||||
// the Pool attributes you want to see returned. SortKey allows you to
|
||||
// sort by a particular Pool attribute. SortDir sets the direction, and is
|
||||
// either `asc' or `desc'. Marker and Limit are used for pagination.
|
||||
type ListOpts struct {
|
||||
LBMethod string `q:"lb_algorithm"`
|
||||
Protocol string `q:"protocol"`
|
||||
ProjectID string `q:"project_id"`
|
||||
AdminStateUp *bool `q:"admin_state_up"`
|
||||
Name string `q:"name"`
|
||||
ID string `q:"id"`
|
||||
LoadbalancerID string `q:"loadbalancer_id"`
|
||||
Limit int `q:"limit"`
|
||||
Marker string `q:"marker"`
|
||||
SortKey string `q:"sort_key"`
|
||||
SortDir string `q:"sort_dir"`
|
||||
}
|
||||
|
||||
// ToPoolListQuery formats a ListOpts into a query string.
|
||||
func (opts ListOpts) ToPoolListQuery() (string, error) {
|
||||
q, err := gophercloud.BuildQueryString(opts)
|
||||
return q.String(), err
|
||||
}
|
||||
|
||||
// List returns a Pager which allows you to iterate over a collection of
|
||||
// pools. It accepts a ListOpts struct, which allows you to filter and sort
|
||||
// the returned collection for greater efficiency.
|
||||
//
|
||||
// Default policy settings return only those pools that are owned by the
|
||||
// project who submits the request, unless an admin user submits the request.
|
||||
func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager {
|
||||
url := rootURL(c)
|
||||
if opts != nil {
|
||||
query, err := opts.ToPoolListQuery()
|
||||
if err != nil {
|
||||
return pagination.Pager{Err: err}
|
||||
}
|
||||
url += query
|
||||
}
|
||||
return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page {
|
||||
return PoolPage{pagination.LinkedPageBase{PageResult: r}}
|
||||
})
|
||||
}
|
||||
|
||||
type LBMethod string
|
||||
type Protocol string
|
||||
|
||||
// Supported attributes for create/update operations.
|
||||
const (
|
||||
LBMethodRoundRobin LBMethod = "ROUND_ROBIN"
|
||||
LBMethodLeastConnections LBMethod = "LEAST_CONNECTIONS"
|
||||
LBMethodSourceIp LBMethod = "SOURCE_IP"
|
||||
|
||||
ProtocolTCP Protocol = "TCP"
|
||||
ProtocolHTTP Protocol = "HTTP"
|
||||
ProtocolHTTPS Protocol = "HTTPS"
|
||||
)
|
||||
|
||||
// CreateOptsBuilder allows extensions to add additional parameters to the
|
||||
// Create request.
|
||||
type CreateOptsBuilder interface {
|
||||
ToPoolCreateMap() (map[string]interface{}, error)
|
||||
}
|
||||
|
||||
// CreateOpts is the common options struct used in this package's Create
|
||||
// operation.
|
||||
type CreateOpts struct {
|
||||
// The algorithm used to distribute load between the members of the pool. The
|
||||
// current specification supports LBMethodRoundRobin, LBMethodLeastConnections
|
||||
// and LBMethodSourceIp as valid values for this attribute.
|
||||
LBMethod LBMethod `json:"lb_algorithm" required:"true"`
|
||||
|
||||
// The protocol used by the pool members, you can use either
|
||||
// ProtocolTCP, ProtocolHTTP, or ProtocolHTTPS.
|
||||
Protocol Protocol `json:"protocol" required:"true"`
|
||||
|
||||
// The Loadbalancer on which the members of the pool will be associated with.
|
||||
// Note: one of LoadbalancerID or ListenerID must be provided.
|
||||
LoadbalancerID string `json:"loadbalancer_id,omitempty" xor:"ListenerID"`
|
||||
|
||||
// The Listener on which the members of the pool will be associated with.
|
||||
// Note: one of LoadbalancerID or ListenerID must be provided.
|
||||
ListenerID string `json:"listener_id,omitempty" xor:"LoadbalancerID"`
|
||||
|
||||
// ProjectID is the UUID of the project who owns the Pool.
|
||||
// Only administrative users can specify a project UUID other than their own.
|
||||
ProjectID string `json:"project_id,omitempty"`
|
||||
|
||||
// Name of the pool.
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
// Human-readable description for the pool.
|
||||
Description string `json:"description,omitempty"`
|
||||
|
||||
// Persistence is the session persistence of the pool.
|
||||
// Omit this field to prevent session persistence.
|
||||
Persistence *SessionPersistence `json:"session_persistence,omitempty"`
|
||||
|
||||
// The administrative state of the Pool. A valid value is true (UP)
|
||||
// or false (DOWN).
|
||||
AdminStateUp *bool `json:"admin_state_up,omitempty"`
|
||||
}
|
||||
|
||||
// ToPoolCreateMap builds a request body from CreateOpts.
|
||||
func (opts CreateOpts) ToPoolCreateMap() (map[string]interface{}, error) {
|
||||
return gophercloud.BuildRequestBody(opts, "pool")
|
||||
}
|
||||
|
||||
// Create accepts a CreateOpts struct and uses the values to create a new
|
||||
// load balancer pool.
|
||||
func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) {
|
||||
b, err := opts.ToPoolCreateMap()
|
||||
if err != nil {
|
||||
r.Err = err
|
||||
return
|
||||
}
|
||||
_, r.Err = c.Post(rootURL(c), b, &r.Body, nil)
|
||||
return
|
||||
}
|
||||
|
||||
// Get retrieves a particular pool based on its unique ID.
|
||||
func Get(c *gophercloud.ServiceClient, id string) (r GetResult) {
|
||||
_, r.Err = c.Get(resourceURL(c, id), &r.Body, nil)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateOptsBuilder allows extensions to add additional parameters to the
|
||||
// Update request.
|
||||
type UpdateOptsBuilder interface {
|
||||
ToPoolUpdateMap() (map[string]interface{}, error)
|
||||
}
|
||||
|
||||
// UpdateOpts is the common options struct used in this package's Update
|
||||
// operation.
|
||||
type UpdateOpts struct {
|
||||
// Name of the pool.
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
// Human-readable description for the pool.
|
||||
Description string `json:"description,omitempty"`
|
||||
|
||||
// The algorithm used to distribute load between the members of the pool. The
|
||||
// current specification supports LBMethodRoundRobin, LBMethodLeastConnections
|
||||
// and LBMethodSourceIp as valid values for this attribute.
|
||||
LBMethod LBMethod `json:"lb_algorithm,omitempty"`
|
||||
|
||||
// The administrative state of the Pool. A valid value is true (UP)
|
||||
// or false (DOWN).
|
||||
AdminStateUp *bool `json:"admin_state_up,omitempty"`
|
||||
}
|
||||
|
||||
// ToPoolUpdateMap builds a request body from UpdateOpts.
|
||||
func (opts UpdateOpts) ToPoolUpdateMap() (map[string]interface{}, error) {
|
||||
return gophercloud.BuildRequestBody(opts, "pool")
|
||||
}
|
||||
|
||||
// Update allows pools to be updated.
|
||||
func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) {
|
||||
b, err := opts.ToPoolUpdateMap()
|
||||
if err != nil {
|
||||
r.Err = err
|
||||
return
|
||||
}
|
||||
_, r.Err = c.Put(resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{
|
||||
OkCodes: []int{200},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Delete will permanently delete a particular pool based on its unique ID.
|
||||
func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) {
|
||||
_, r.Err = c.Delete(resourceURL(c, id), nil)
|
||||
return
|
||||
}
|
||||
|
||||
// ListMemberOptsBuilder allows extensions to add additional parameters to the
|
||||
// ListMembers request.
|
||||
type ListMembersOptsBuilder interface {
|
||||
ToMembersListQuery() (string, error)
|
||||
}
|
||||
|
||||
// ListMembersOpts allows the filtering and sorting of paginated collections
|
||||
// through the API. Filtering is achieved by passing in struct field values
|
||||
// that map to the Member attributes you want to see returned. SortKey allows
|
||||
// you to sort by a particular Member attribute. SortDir sets the direction,
|
||||
// and is either `asc' or `desc'. Marker and Limit are used for pagination.
|
||||
type ListMembersOpts struct {
|
||||
Name string `q:"name"`
|
||||
Weight int `q:"weight"`
|
||||
AdminStateUp *bool `q:"admin_state_up"`
|
||||
ProjectID string `q:"project_id"`
|
||||
Address string `q:"address"`
|
||||
ProtocolPort int `q:"protocol_port"`
|
||||
ID string `q:"id"`
|
||||
Limit int `q:"limit"`
|
||||
Marker string `q:"marker"`
|
||||
SortKey string `q:"sort_key"`
|
||||
SortDir string `q:"sort_dir"`
|
||||
}
|
||||
|
||||
// ToMemberListQuery formats a ListOpts into a query string.
|
||||
func (opts ListMembersOpts) ToMembersListQuery() (string, error) {
|
||||
q, err := gophercloud.BuildQueryString(opts)
|
||||
return q.String(), err
|
||||
}
|
||||
|
||||
// ListMembers returns a Pager which allows you to iterate over a collection of
|
||||
// members. It accepts a ListMembersOptsBuilder, which allows you to filter and
|
||||
// sort the returned collection for greater efficiency.
|
||||
//
|
||||
// Default policy settings return only those members that are owned by the
|
||||
// project who submits the request, unless an admin user submits the request.
|
||||
func ListMembers(c *gophercloud.ServiceClient, poolID string, opts ListMembersOptsBuilder) pagination.Pager {
|
||||
url := memberRootURL(c, poolID)
|
||||
if opts != nil {
|
||||
query, err := opts.ToMembersListQuery()
|
||||
if err != nil {
|
||||
return pagination.Pager{Err: err}
|
||||
}
|
||||
url += query
|
||||
}
|
||||
return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page {
|
||||
return MemberPage{pagination.LinkedPageBase{PageResult: r}}
|
||||
})
|
||||
}
|
||||
|
||||
// CreateMemberOptsBuilder allows extensions to add additional parameters to the
|
||||
// CreateMember request.
|
||||
type CreateMemberOptsBuilder interface {
|
||||
ToMemberCreateMap() (map[string]interface{}, error)
|
||||
}
|
||||
|
||||
// CreateMemberOpts is the common options struct used in this package's CreateMember
|
||||
// operation.
|
||||
type CreateMemberOpts struct {
|
||||
// The IP address of the member to receive traffic from the load balancer.
|
||||
Address string `json:"address" required:"true"`
|
||||
|
||||
// The port on which to listen for client traffic.
|
||||
ProtocolPort int `json:"protocol_port" required:"true"`
|
||||
|
||||
// Name of the Member.
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
// ProjectID is the UUID of the project who owns the Member.
|
||||
// Only administrative users can specify a project UUID other than their own.
|
||||
ProjectID string `json:"project_id,omitempty"`
|
||||
|
||||
// A positive integer value that indicates the relative portion of traffic
|
||||
// that this member should receive from the pool. For example, a member with
|
||||
// a weight of 10 receives five times as much traffic as a member with a
|
||||
// weight of 2.
|
||||
Weight int `json:"weight,omitempty"`
|
||||
|
||||
// If you omit this parameter, LBaaS uses the vip_subnet_id parameter value
|
||||
// for the subnet UUID.
|
||||
SubnetID string `json:"subnet_id,omitempty"`
|
||||
|
||||
// The administrative state of the Pool. A valid value is true (UP)
|
||||
// or false (DOWN).
|
||||
AdminStateUp *bool `json:"admin_state_up,omitempty"`
|
||||
}
|
||||
|
||||
// ToMemberCreateMap builds a request body from CreateMemberOpts.
|
||||
func (opts CreateMemberOpts) ToMemberCreateMap() (map[string]interface{}, error) {
|
||||
return gophercloud.BuildRequestBody(opts, "member")
|
||||
}
|
||||
|
||||
// CreateMember will create and associate a Member with a particular Pool.
|
||||
func CreateMember(c *gophercloud.ServiceClient, poolID string, opts CreateMemberOpts) (r CreateMemberResult) {
|
||||
b, err := opts.ToMemberCreateMap()
|
||||
if err != nil {
|
||||
r.Err = err
|
||||
return
|
||||
}
|
||||
_, r.Err = c.Post(memberRootURL(c, poolID), b, &r.Body, nil)
|
||||
return
|
||||
}
|
||||
|
||||
// GetMember retrieves a particular Pool Member based on its unique ID.
|
||||
func GetMember(c *gophercloud.ServiceClient, poolID string, memberID string) (r GetMemberResult) {
|
||||
_, r.Err = c.Get(memberResourceURL(c, poolID, memberID), &r.Body, nil)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateMemberOptsBuilder allows extensions to add additional parameters to the
|
||||
// List request.
|
||||
type UpdateMemberOptsBuilder interface {
|
||||
ToMemberUpdateMap() (map[string]interface{}, error)
|
||||
}
|
||||
|
||||
// UpdateMemberOpts is the common options struct used in this package's Update
|
||||
// operation.
|
||||
type UpdateMemberOpts struct {
|
||||
// Name of the Member.
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
// A positive integer value that indicates the relative portion of traffic
|
||||
// that this member should receive from the pool. For example, a member with
|
||||
// a weight of 10 receives five times as much traffic as a member with a
|
||||
// weight of 2.
|
||||
Weight int `json:"weight,omitempty"`
|
||||
|
||||
// The administrative state of the Pool. A valid value is true (UP)
|
||||
// or false (DOWN).
|
||||
AdminStateUp *bool `json:"admin_state_up,omitempty"`
|
||||
}
|
||||
|
||||
// ToMemberUpdateMap builds a request body from UpdateMemberOpts.
|
||||
func (opts UpdateMemberOpts) ToMemberUpdateMap() (map[string]interface{}, error) {
|
||||
return gophercloud.BuildRequestBody(opts, "member")
|
||||
}
|
||||
|
||||
// Update allows Member to be updated.
|
||||
func UpdateMember(c *gophercloud.ServiceClient, poolID string, memberID string, opts UpdateMemberOptsBuilder) (r UpdateMemberResult) {
|
||||
b, err := opts.ToMemberUpdateMap()
|
||||
if err != nil {
|
||||
r.Err = err
|
||||
return
|
||||
}
|
||||
_, r.Err = c.Put(memberResourceURL(c, poolID, memberID), b, &r.Body, &gophercloud.RequestOpts{
|
||||
OkCodes: []int{200, 201, 202},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// DisassociateMember will remove and disassociate a Member from a particular
|
||||
// Pool.
|
||||
func DeleteMember(c *gophercloud.ServiceClient, poolID string, memberID string) (r DeleteMemberResult) {
|
||||
_, r.Err = c.Delete(memberResourceURL(c, poolID, memberID), nil)
|
||||
return
|
||||
}
|
||||
281
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools/results.go
generated
vendored
Normal file
281
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools/results.go
generated
vendored
Normal file
|
|
@ -0,0 +1,281 @@
|
|||
package pools
|
||||
|
||||
import (
|
||||
"github.com/gophercloud/gophercloud"
|
||||
"github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/monitors"
|
||||
"github.com/gophercloud/gophercloud/pagination"
|
||||
)
|
||||
|
||||
// SessionPersistence represents the session persistence feature of the load
|
||||
// balancing service. It attempts to force connections or requests in the same
|
||||
// session to be processed by the same member as long as it is ative. Three
|
||||
// types of persistence are supported:
|
||||
//
|
||||
// SOURCE_IP: With this mode, all connections originating from the same source
|
||||
// IP address, will be handled by the same Member of the Pool.
|
||||
// HTTP_COOKIE: With this persistence mode, the load balancing function will
|
||||
// create a cookie on the first request from a client. Subsequent
|
||||
// requests containing the same cookie value will be handled by
|
||||
// the same Member of the Pool.
|
||||
// APP_COOKIE: With this persistence mode, the load balancing function will
|
||||
// rely on a cookie established by the backend application. All
|
||||
// requests carrying the same cookie value will be handled by the
|
||||
// same Member of the Pool.
|
||||
type SessionPersistence struct {
|
||||
// The type of persistence mode.
|
||||
Type string `json:"type"`
|
||||
|
||||
// Name of cookie if persistence mode is set appropriately.
|
||||
CookieName string `json:"cookie_name,omitempty"`
|
||||
}
|
||||
|
||||
// LoadBalancerID represents a load balancer.
|
||||
type LoadBalancerID struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
// ListenerID represents a listener.
|
||||
type ListenerID struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
// Pool represents a logical set of devices, such as web servers, that you
|
||||
// group together to receive and process traffic. The load balancing function
|
||||
// chooses a Member of the Pool according to the configured load balancing
|
||||
// method to handle the new requests or connections received on the VIP address.
|
||||
type Pool struct {
|
||||
// The load-balancer algorithm, which is round-robin, least-connections, and
|
||||
// so on. This value, which must be supported, is dependent on the provider.
|
||||
// Round-robin must be supported.
|
||||
LBMethod string `json:"lb_algorithm"`
|
||||
|
||||
// The protocol of the Pool, which is TCP, HTTP, or HTTPS.
|
||||
Protocol string `json:"protocol"`
|
||||
|
||||
// Description for the Pool.
|
||||
Description string `json:"description"`
|
||||
|
||||
// A list of listeners objects IDs.
|
||||
Listeners []ListenerID `json:"listeners"` //[]map[string]interface{}
|
||||
|
||||
// A list of member objects IDs.
|
||||
Members []Member `json:"members"`
|
||||
|
||||
// The ID of associated health monitor.
|
||||
MonitorID string `json:"healthmonitor_id"`
|
||||
|
||||
// The network on which the members of the Pool will be located. Only members
|
||||
// that are on this network can be added to the Pool.
|
||||
SubnetID string `json:"subnet_id"`
|
||||
|
||||
// Owner of the Pool.
|
||||
ProjectID string `json:"project_id"`
|
||||
|
||||
// The administrative state of the Pool, which is up (true) or down (false).
|
||||
AdminStateUp bool `json:"admin_state_up"`
|
||||
|
||||
// Pool name. Does not have to be unique.
|
||||
Name string `json:"name"`
|
||||
|
||||
// The unique ID for the Pool.
|
||||
ID string `json:"id"`
|
||||
|
||||
// A list of load balancer objects IDs.
|
||||
Loadbalancers []LoadBalancerID `json:"loadbalancers"`
|
||||
|
||||
// Indicates whether connections in the same session will be processed by the
|
||||
// same Pool member or not.
|
||||
Persistence SessionPersistence `json:"session_persistence"`
|
||||
|
||||
// The load balancer provider.
|
||||
Provider string `json:"provider"`
|
||||
|
||||
// The Monitor associated with this Pool.
|
||||
Monitor monitors.Monitor `json:"healthmonitor"`
|
||||
|
||||
// The provisioning status of the pool.
|
||||
// This value is ACTIVE, PENDING_* or ERROR.
|
||||
ProvisioningStatus string `json:"provisioning_status"`
|
||||
}
|
||||
|
||||
// PoolPage is the page returned by a pager when traversing over a
|
||||
// collection of pools.
|
||||
type PoolPage struct {
|
||||
pagination.LinkedPageBase
|
||||
}
|
||||
|
||||
// NextPageURL is invoked when a paginated collection of pools has reached
|
||||
// the end of a page and the pager seeks to traverse over a new one. In order
|
||||
// to do this, it needs to construct the next page's URL.
|
||||
func (r PoolPage) NextPageURL() (string, error) {
|
||||
var s struct {
|
||||
Links []gophercloud.Link `json:"pools_links"`
|
||||
}
|
||||
err := r.ExtractInto(&s)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return gophercloud.ExtractNextURL(s.Links)
|
||||
}
|
||||
|
||||
// IsEmpty checks whether a PoolPage struct is empty.
|
||||
func (r PoolPage) IsEmpty() (bool, error) {
|
||||
is, err := ExtractPools(r)
|
||||
return len(is) == 0, err
|
||||
}
|
||||
|
||||
// ExtractPools accepts a Page struct, specifically a PoolPage struct,
|
||||
// and extracts the elements into a slice of Pool structs. In other words,
|
||||
// a generic collection is mapped into a relevant slice.
|
||||
func ExtractPools(r pagination.Page) ([]Pool, error) {
|
||||
var s struct {
|
||||
Pools []Pool `json:"pools"`
|
||||
}
|
||||
err := (r.(PoolPage)).ExtractInto(&s)
|
||||
return s.Pools, err
|
||||
}
|
||||
|
||||
type commonResult struct {
|
||||
gophercloud.Result
|
||||
}
|
||||
|
||||
// Extract is a function that accepts a result and extracts a pool.
|
||||
func (r commonResult) Extract() (*Pool, error) {
|
||||
var s struct {
|
||||
Pool *Pool `json:"pool"`
|
||||
}
|
||||
err := r.ExtractInto(&s)
|
||||
return s.Pool, err
|
||||
}
|
||||
|
||||
// CreateResult represents the result of a Create operation. Call its Extract
|
||||
// method to interpret the result as a Pool.
|
||||
type CreateResult struct {
|
||||
commonResult
|
||||
}
|
||||
|
||||
// GetResult represents the result of a Get operation. Call its Extract
|
||||
// method to interpret the result as a Pool.
|
||||
type GetResult struct {
|
||||
commonResult
|
||||
}
|
||||
|
||||
// UpdateResult represents the result of an Update operation. Call its Extract
|
||||
// method to interpret the result as a Pool.
|
||||
type UpdateResult struct {
|
||||
commonResult
|
||||
}
|
||||
|
||||
// DeleteResult represents the result of a Delete operation. Call its
|
||||
// ExtractErr method to determine if the request succeeded or failed.
|
||||
type DeleteResult struct {
|
||||
gophercloud.ErrResult
|
||||
}
|
||||
|
||||
// Member represents the application running on a backend server.
|
||||
type Member struct {
|
||||
// Name of the Member.
|
||||
Name string `json:"name"`
|
||||
|
||||
// Weight of Member.
|
||||
Weight int `json:"weight"`
|
||||
|
||||
// The administrative state of the member, which is up (true) or down (false).
|
||||
AdminStateUp bool `json:"admin_state_up"`
|
||||
|
||||
// Owner of the Member.
|
||||
ProjectID string `json:"project_id"`
|
||||
|
||||
// Parameter value for the subnet UUID.
|
||||
SubnetID string `json:"subnet_id"`
|
||||
|
||||
// The Pool to which the Member belongs.
|
||||
PoolID string `json:"pool_id"`
|
||||
|
||||
// The IP address of the Member.
|
||||
Address string `json:"address"`
|
||||
|
||||
// The port on which the application is hosted.
|
||||
ProtocolPort int `json:"protocol_port"`
|
||||
|
||||
// The unique ID for the Member.
|
||||
ID string `json:"id"`
|
||||
|
||||
// The provisioning status of the pool.
|
||||
// This value is ACTIVE, PENDING_* or ERROR.
|
||||
ProvisioningStatus string `json:"provisioning_status"`
|
||||
}
|
||||
|
||||
// MemberPage is the page returned by a pager when traversing over a
|
||||
// collection of Members in a Pool.
|
||||
type MemberPage struct {
|
||||
pagination.LinkedPageBase
|
||||
}
|
||||
|
||||
// NextPageURL is invoked when a paginated collection of members has reached
|
||||
// the end of a page and the pager seeks to traverse over a new one. In order
|
||||
// to do this, it needs to construct the next page's URL.
|
||||
func (r MemberPage) NextPageURL() (string, error) {
|
||||
var s struct {
|
||||
Links []gophercloud.Link `json:"members_links"`
|
||||
}
|
||||
err := r.ExtractInto(&s)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return gophercloud.ExtractNextURL(s.Links)
|
||||
}
|
||||
|
||||
// IsEmpty checks whether a MemberPage struct is empty.
|
||||
func (r MemberPage) IsEmpty() (bool, error) {
|
||||
is, err := ExtractMembers(r)
|
||||
return len(is) == 0, err
|
||||
}
|
||||
|
||||
// ExtractMembers accepts a Page struct, specifically a MemberPage struct,
|
||||
// and extracts the elements into a slice of Members structs. In other words,
|
||||
// a generic collection is mapped into a relevant slice.
|
||||
func ExtractMembers(r pagination.Page) ([]Member, error) {
|
||||
var s struct {
|
||||
Members []Member `json:"members"`
|
||||
}
|
||||
err := (r.(MemberPage)).ExtractInto(&s)
|
||||
return s.Members, err
|
||||
}
|
||||
|
||||
type commonMemberResult struct {
|
||||
gophercloud.Result
|
||||
}
|
||||
|
||||
// ExtractMember is a function that accepts a result and extracts a member.
|
||||
func (r commonMemberResult) Extract() (*Member, error) {
|
||||
var s struct {
|
||||
Member *Member `json:"member"`
|
||||
}
|
||||
err := r.ExtractInto(&s)
|
||||
return s.Member, err
|
||||
}
|
||||
|
||||
// CreateMemberResult represents the result of a CreateMember operation.
|
||||
// Call its Extract method to interpret it as a Member.
|
||||
type CreateMemberResult struct {
|
||||
commonMemberResult
|
||||
}
|
||||
|
||||
// GetMemberResult represents the result of a GetMember operation.
|
||||
// Call its Extract method to interpret it as a Member.
|
||||
type GetMemberResult struct {
|
||||
commonMemberResult
|
||||
}
|
||||
|
||||
// UpdateMemberResult represents the result of an UpdateMember operation.
|
||||
// Call its Extract method to interpret it as a Member.
|
||||
type UpdateMemberResult struct {
|
||||
commonMemberResult
|
||||
}
|
||||
|
||||
// DeleteMemberResult represents the result of a DeleteMember operation.
|
||||
// Call its ExtractErr method to determine if the request succeeded or failed.
|
||||
type DeleteMemberResult struct {
|
||||
gophercloud.ErrResult
|
||||
}
|
||||
25
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools/urls.go
generated
vendored
Normal file
25
vendor/github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools/urls.go
generated
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package pools
|
||||
|
||||
import "github.com/gophercloud/gophercloud"
|
||||
|
||||
const (
|
||||
rootPath = "lbaas"
|
||||
resourcePath = "pools"
|
||||
memberPath = "members"
|
||||
)
|
||||
|
||||
func rootURL(c *gophercloud.ServiceClient) string {
|
||||
return c.ServiceURL(rootPath, resourcePath)
|
||||
}
|
||||
|
||||
func resourceURL(c *gophercloud.ServiceClient, id string) string {
|
||||
return c.ServiceURL(rootPath, resourcePath, id)
|
||||
}
|
||||
|
||||
func memberRootURL(c *gophercloud.ServiceClient, poolId string) string {
|
||||
return c.ServiceURL(rootPath, resourcePath, poolId, memberPath)
|
||||
}
|
||||
|
||||
func memberResourceURL(c *gophercloud.ServiceClient, poolID string, memeberID string) string {
|
||||
return c.ServiceURL(rootPath, resourcePath, poolID, memberPath, memeberID)
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ go_library(
|
|||
"requests.go",
|
||||
"results.go",
|
||||
],
|
||||
importmap = "vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/external",
|
||||
importmap = "k8s.io/kops/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/external",
|
||||
importpath = "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/external",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ go_library(
|
|||
"results.go",
|
||||
"urls.go",
|
||||
],
|
||||
importmap = "vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips",
|
||||
importmap = "k8s.io/kops/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips",
|
||||
importpath = "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"pass.go",
|
||||
"terminal.go",
|
||||
"terminal_solaris.go",
|
||||
],
|
||||
importmap = "vendor/github.com/howeyc/gopass",
|
||||
importpath = "github.com/howeyc/gopass",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = select({
|
||||
"@io_bazel_rules_go//go/platform:android": [
|
||||
"//vendor/golang.org/x/crypto/ssh/terminal:go_default_library",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:darwin": [
|
||||
"//vendor/golang.org/x/crypto/ssh/terminal:go_default_library",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:dragonfly": [
|
||||
"//vendor/golang.org/x/crypto/ssh/terminal:go_default_library",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:freebsd": [
|
||||
"//vendor/golang.org/x/crypto/ssh/terminal:go_default_library",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:linux": [
|
||||
"//vendor/golang.org/x/crypto/ssh/terminal:go_default_library",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:nacl": [
|
||||
"//vendor/golang.org/x/crypto/ssh/terminal:go_default_library",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:netbsd": [
|
||||
"//vendor/golang.org/x/crypto/ssh/terminal:go_default_library",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:openbsd": [
|
||||
"//vendor/golang.org/x/crypto/ssh/terminal:go_default_library",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:plan9": [
|
||||
"//vendor/golang.org/x/crypto/ssh/terminal:go_default_library",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:solaris": [
|
||||
"//vendor/golang.org/x/sys/unix:go_default_library",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:windows": [
|
||||
"//vendor/golang.org/x/crypto/ssh/terminal:go_default_library",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
)
|
||||
|
|
@ -13,7 +13,7 @@ go_library(
|
|||
"license_mit.go",
|
||||
"licenses.go",
|
||||
],
|
||||
importmap = "vendor/github.com/spf13/cobra/cobra/cmd",
|
||||
importmap = "k8s.io/kops/vendor/github.com/spf13/cobra/cobra/cmd",
|
||||
importpath = "github.com/spf13/cobra/cobra/cmd",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["//vendor/github.com/spf13/viper:go_default_library"],
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
|||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["license_manager.go"],
|
||||
importmap = "vendor/github.com/vmware/govmomi/simulator",
|
||||
importmap = "k8s.io/kops/vendor/github.com/vmware/govmomi/simulator",
|
||||
importpath = "github.com/vmware/govmomi/simulator",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["tpu-gen.go"],
|
||||
importmap = "vendor/google.golang.org/api/tpu/v1alpha1",
|
||||
importpath = "google.golang.org/api/tpu/v1alpha1",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/golang.org/x/net/context:go_default_library",
|
||||
"//vendor/golang.org/x/net/context/ctxhttp:go_default_library",
|
||||
"//vendor/google.golang.org/api/gensupport:go_default_library",
|
||||
"//vendor/google.golang.org/api/googleapi:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"bson.go",
|
||||
"decimal.go",
|
||||
"decode.go",
|
||||
"encode.go",
|
||||
"json.go",
|
||||
],
|
||||
importmap = "vendor/gopkg.in/mgo.v2/bson",
|
||||
importpath = "gopkg.in/mgo.v2/bson",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["//vendor/gopkg.in/mgo.v2/internal/json:go_default_library"],
|
||||
)
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"decode.go",
|
||||
"encode.go",
|
||||
"extension.go",
|
||||
"fold.go",
|
||||
"indent.go",
|
||||
"scanner.go",
|
||||
"stream.go",
|
||||
"tags.go",
|
||||
],
|
||||
importmap = "vendor/gopkg.in/mgo.v2/internal/json",
|
||||
importpath = "gopkg.in/mgo.v2/internal/json",
|
||||
visibility = ["//vendor/gopkg.in/mgo.v2:__subpackages__"],
|
||||
)
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"doc.go",
|
||||
"types.go",
|
||||
],
|
||||
importmap = "vendor/k8s.io/apimachinery/pkg/apimachinery",
|
||||
importpath = "k8s.io/apimachinery/pkg/apimachinery",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"announced.go",
|
||||
"group_factory.go",
|
||||
],
|
||||
importmap = "vendor/k8s.io/apimachinery/pkg/apimachinery/announced",
|
||||
importpath = "k8s.io/apimachinery/pkg/apimachinery/announced",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apimachinery:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apimachinery/registered:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["registered.go"],
|
||||
importmap = "vendor/k8s.io/apimachinery/pkg/apimachinery/registered",
|
||||
importpath = "k8s.io/apimachinery/pkg/apimachinery/registered",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apimachinery:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"attributes.go",
|
||||
"conversion.go",
|
||||
"doc.go",
|
||||
],
|
||||
importmap = "vendor/k8s.io/apiserver/pkg/admission/plugin/webhook/versioned",
|
||||
importpath = "k8s.io/apiserver/pkg/admission/plugin/webhook/versioned",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/admission:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["checks.go"],
|
||||
importmap = "vendor/k8s.io/apiserver/pkg/storage/etcd3/preflight",
|
||||
importpath = "k8s.io/apiserver/pkg/storage/etcd3/preflight",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"default_rate_limiters.go",
|
||||
"delaying_queue.go",
|
||||
"doc.go",
|
||||
"metrics.go",
|
||||
"parallelizer.go",
|
||||
"queue.go",
|
||||
"rate_limitting_queue.go",
|
||||
],
|
||||
importmap = "vendor/k8s.io/client-go/util/workqueue",
|
||||
importpath = "k8s.io/client-go/util/workqueue",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/golang.org/x/time/rate:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/clock:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
@ -1 +0,0 @@
|
|||
go-to-protobuf
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["main.go"],
|
||||
importmap = "vendor/k8s.io/code-generator/cmd/go-to-protobuf",
|
||||
importpath = "k8s.io/code-generator/cmd/go-to-protobuf",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
"//vendor/github.com/spf13/pflag:go_default_library",
|
||||
"//vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "go-to-protobuf",
|
||||
embed = [":go_default_library"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
approvers:
|
||||
- smarterclayton
|
||||
reviewers:
|
||||
- smarterclayton
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// go-to-protobuf generates a Protobuf IDL from a Go struct, respecting any
|
||||
// existing IDL tags on the Go struct.
|
||||
package main
|
||||
|
||||
import (
|
||||
goflag "flag"
|
||||
|
||||
flag "github.com/spf13/pflag"
|
||||
"k8s.io/code-generator/cmd/go-to-protobuf/protobuf"
|
||||
)
|
||||
|
||||
var g = protobuf.New()
|
||||
|
||||
func init() {
|
||||
g.BindFlags(flag.CommandLine)
|
||||
goflag.Set("logtostderr", "true")
|
||||
flag.CommandLine.AddGoFlagSet(goflag.CommandLine)
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
protobuf.Run(g)
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"cmd.go",
|
||||
"generator.go",
|
||||
"import_tracker.go",
|
||||
"namer.go",
|
||||
"package.go",
|
||||
"parser.go",
|
||||
"tags.go",
|
||||
],
|
||||
importmap = "vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf",
|
||||
importpath = "k8s.io/code-generator/cmd/go-to-protobuf/protobuf",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/github.com/spf13/pflag:go_default_library",
|
||||
"//vendor/k8s.io/code-generator/pkg/util:go_default_library",
|
||||
"//vendor/k8s.io/code-generator/third_party/forked/golang/reflect:go_default_library",
|
||||
"//vendor/k8s.io/gengo/args:go_default_library",
|
||||
"//vendor/k8s.io/gengo/generator:go_default_library",
|
||||
"//vendor/k8s.io/gengo/namer:go_default_library",
|
||||
"//vendor/k8s.io/gengo/parser:go_default_library",
|
||||
"//vendor/k8s.io/gengo/types:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
@ -1,349 +0,0 @@
|
|||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// go-to-protobuf generates a Protobuf IDL from a Go struct, respecting any
|
||||
// existing IDL tags on the Go struct.
|
||||
package protobuf
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"k8s.io/code-generator/pkg/util"
|
||||
"k8s.io/gengo/args"
|
||||
"k8s.io/gengo/generator"
|
||||
"k8s.io/gengo/namer"
|
||||
"k8s.io/gengo/parser"
|
||||
"k8s.io/gengo/types"
|
||||
|
||||
flag "github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
type Generator struct {
|
||||
Common args.GeneratorArgs
|
||||
APIMachineryPackages string
|
||||
Packages string
|
||||
OutputBase string
|
||||
VendorOutputBase string
|
||||
ProtoImport []string
|
||||
Conditional string
|
||||
Clean bool
|
||||
OnlyIDL bool
|
||||
KeepGogoproto bool
|
||||
SkipGeneratedRewrite bool
|
||||
DropEmbeddedFields string
|
||||
}
|
||||
|
||||
func New() *Generator {
|
||||
sourceTree := args.DefaultSourceTree()
|
||||
common := args.GeneratorArgs{
|
||||
OutputBase: sourceTree,
|
||||
GoHeaderFilePath: filepath.Join(sourceTree, util.BoilerplatePath()),
|
||||
}
|
||||
defaultProtoImport := filepath.Join(sourceTree, "k8s.io", "kubernetes", "vendor", "github.com", "gogo", "protobuf", "protobuf")
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
log.Fatalf("Cannot get current directory.")
|
||||
}
|
||||
return &Generator{
|
||||
Common: common,
|
||||
OutputBase: sourceTree,
|
||||
VendorOutputBase: filepath.Join(cwd, "vendor"),
|
||||
ProtoImport: []string{defaultProtoImport},
|
||||
APIMachineryPackages: strings.Join([]string{
|
||||
`+k8s.io/apimachinery/pkg/util/intstr`,
|
||||
`+k8s.io/apimachinery/pkg/api/resource`,
|
||||
`+k8s.io/apimachinery/pkg/runtime/schema`,
|
||||
`+k8s.io/apimachinery/pkg/runtime`,
|
||||
`k8s.io/apimachinery/pkg/apis/meta/v1`,
|
||||
`k8s.io/apimachinery/pkg/apis/meta/v1beta1`,
|
||||
`k8s.io/apimachinery/pkg/apis/testapigroup/v1`,
|
||||
}, ","),
|
||||
Packages: "",
|
||||
DropEmbeddedFields: "k8s.io/apimachinery/pkg/apis/meta/v1.TypeMeta",
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Generator) BindFlags(flag *flag.FlagSet) {
|
||||
flag.StringVarP(&g.Common.GoHeaderFilePath, "go-header-file", "h", g.Common.GoHeaderFilePath, "File containing boilerplate header text. The string YEAR will be replaced with the current 4-digit year.")
|
||||
flag.BoolVar(&g.Common.VerifyOnly, "verify-only", g.Common.VerifyOnly, "If true, only verify existing output, do not write anything.")
|
||||
flag.StringVarP(&g.Packages, "packages", "p", g.Packages, "comma-separated list of directories to get input types from. Directories prefixed with '-' are not generated, directories prefixed with '+' only create types with explicit IDL instructions.")
|
||||
flag.StringVar(&g.APIMachineryPackages, "apimachinery-packages", g.APIMachineryPackages, "comma-separated list of directories to get apimachinery input types from which are needed by any API. Directories prefixed with '-' are not generated, directories prefixed with '+' only create types with explicit IDL instructions.")
|
||||
flag.StringVarP(&g.OutputBase, "output-base", "o", g.OutputBase, "Output base; defaults to $GOPATH/src/")
|
||||
flag.StringVar(&g.VendorOutputBase, "vendor-output-base", g.VendorOutputBase, "The vendor/ directory to look for packages in; defaults to $PWD/vendor/.")
|
||||
flag.StringSliceVar(&g.ProtoImport, "proto-import", g.ProtoImport, "The search path for the core protobuf .protos, required; defaults $GOPATH/src/k8s.io/kubernetes/vendor/github.com/gogo/protobuf/protobuf.")
|
||||
flag.StringVar(&g.Conditional, "conditional", g.Conditional, "An optional Golang build tag condition to add to the generated Go code")
|
||||
flag.BoolVar(&g.Clean, "clean", g.Clean, "If true, remove all generated files for the specified Packages.")
|
||||
flag.BoolVar(&g.OnlyIDL, "only-idl", g.OnlyIDL, "If true, only generate the IDL for each package.")
|
||||
flag.BoolVar(&g.KeepGogoproto, "keep-gogoproto", g.KeepGogoproto, "If true, the generated IDL will contain gogoprotobuf extensions which are normally removed")
|
||||
flag.BoolVar(&g.SkipGeneratedRewrite, "skip-generated-rewrite", g.SkipGeneratedRewrite, "If true, skip fixing up the generated.pb.go file (debugging only).")
|
||||
flag.StringVar(&g.DropEmbeddedFields, "drop-embedded-fields", g.DropEmbeddedFields, "Comma-delimited list of embedded Go types to omit from generated protobufs")
|
||||
}
|
||||
|
||||
func Run(g *Generator) {
|
||||
if g.Common.VerifyOnly {
|
||||
g.OnlyIDL = true
|
||||
g.Clean = false
|
||||
}
|
||||
|
||||
b := parser.New()
|
||||
b.AddBuildTags("proto")
|
||||
|
||||
omitTypes := map[types.Name]struct{}{}
|
||||
for _, t := range strings.Split(g.DropEmbeddedFields, ",") {
|
||||
name := types.Name{}
|
||||
if i := strings.LastIndex(t, "."); i != -1 {
|
||||
name.Package, name.Name = t[:i], t[i+1:]
|
||||
} else {
|
||||
name.Name = t
|
||||
}
|
||||
if len(name.Name) == 0 {
|
||||
log.Fatalf("--drop-embedded-types requires names in the form of [GOPACKAGE.]TYPENAME: %v", t)
|
||||
}
|
||||
omitTypes[name] = struct{}{}
|
||||
}
|
||||
|
||||
boilerplate, err := g.Common.LoadGoBoilerplate()
|
||||
if err != nil {
|
||||
log.Fatalf("Failed loading boilerplate (consider using the go-header-file flag): %v", err)
|
||||
}
|
||||
|
||||
protobufNames := NewProtobufNamer()
|
||||
outputPackages := generator.Packages{}
|
||||
nonOutputPackages := map[string]struct{}{}
|
||||
|
||||
var packages []string
|
||||
if len(g.APIMachineryPackages) != 0 {
|
||||
packages = append(packages, strings.Split(g.APIMachineryPackages, ",")...)
|
||||
}
|
||||
if len(g.Packages) != 0 {
|
||||
packages = append(packages, strings.Split(g.Packages, ",")...)
|
||||
}
|
||||
if len(packages) == 0 {
|
||||
log.Fatalf("Both apimachinery-packages and packages are empty. At least one package must be specified.")
|
||||
}
|
||||
|
||||
for _, d := range packages {
|
||||
generateAllTypes, outputPackage := true, true
|
||||
switch {
|
||||
case strings.HasPrefix(d, "+"):
|
||||
d = d[1:]
|
||||
generateAllTypes = false
|
||||
case strings.HasPrefix(d, "-"):
|
||||
d = d[1:]
|
||||
outputPackage = false
|
||||
}
|
||||
name := protoSafePackage(d)
|
||||
parts := strings.SplitN(d, "=", 2)
|
||||
if len(parts) > 1 {
|
||||
d = parts[0]
|
||||
name = parts[1]
|
||||
}
|
||||
p := newProtobufPackage(d, name, generateAllTypes, omitTypes)
|
||||
header := append([]byte{}, boilerplate...)
|
||||
header = append(header, p.HeaderText...)
|
||||
p.HeaderText = header
|
||||
protobufNames.Add(p)
|
||||
if outputPackage {
|
||||
outputPackages = append(outputPackages, p)
|
||||
} else {
|
||||
nonOutputPackages[name] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
if !g.Common.VerifyOnly {
|
||||
for _, p := range outputPackages {
|
||||
if err := p.(*protobufPackage).Clean(g.OutputBase); err != nil {
|
||||
log.Fatalf("Unable to clean package %s: %v", p.Name(), err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if g.Clean {
|
||||
return
|
||||
}
|
||||
|
||||
for _, p := range protobufNames.List() {
|
||||
if err := b.AddDir(p.Path()); err != nil {
|
||||
log.Fatalf("Unable to add directory %q: %v", p.Path(), err)
|
||||
}
|
||||
}
|
||||
|
||||
c, err := generator.NewContext(
|
||||
b,
|
||||
namer.NameSystems{
|
||||
"public": namer.NewPublicNamer(3),
|
||||
"proto": protobufNames,
|
||||
},
|
||||
"public",
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed making a context: %v", err)
|
||||
}
|
||||
|
||||
c.Verify = g.Common.VerifyOnly
|
||||
c.FileTypes["protoidl"] = NewProtoFile()
|
||||
|
||||
var vendoredOutputPackages, localOutputPackages generator.Packages
|
||||
for _, p := range protobufNames.packages {
|
||||
if _, ok := nonOutputPackages[p.Name()]; ok {
|
||||
// if we're not outputting the package, don't include it in either package list
|
||||
continue
|
||||
}
|
||||
p.Vendored = strings.Contains(c.Universe[p.PackagePath].SourcePath, "/vendor/")
|
||||
if p.Vendored {
|
||||
vendoredOutputPackages = append(vendoredOutputPackages, p)
|
||||
} else {
|
||||
localOutputPackages = append(localOutputPackages, p)
|
||||
}
|
||||
}
|
||||
|
||||
if err := protobufNames.AssignTypesToPackages(c); err != nil {
|
||||
log.Fatalf("Failed to identify Common types: %v", err)
|
||||
}
|
||||
|
||||
if err := c.ExecutePackages(g.VendorOutputBase, vendoredOutputPackages); err != nil {
|
||||
log.Fatalf("Failed executing vendor generator: %v", err)
|
||||
}
|
||||
if err := c.ExecutePackages(g.OutputBase, localOutputPackages); err != nil {
|
||||
log.Fatalf("Failed executing local generator: %v", err)
|
||||
}
|
||||
|
||||
if g.OnlyIDL {
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := exec.LookPath("protoc"); err != nil {
|
||||
log.Fatalf("Unable to find 'protoc': %v", err)
|
||||
}
|
||||
|
||||
searchArgs := []string{"-I", ".", "-I", g.OutputBase}
|
||||
if len(g.ProtoImport) != 0 {
|
||||
for _, s := range g.ProtoImport {
|
||||
searchArgs = append(searchArgs, "-I", s)
|
||||
}
|
||||
}
|
||||
args := append(searchArgs, fmt.Sprintf("--gogo_out=%s", g.OutputBase))
|
||||
|
||||
buf := &bytes.Buffer{}
|
||||
if len(g.Conditional) > 0 {
|
||||
fmt.Fprintf(buf, "// +build %s\n\n", g.Conditional)
|
||||
}
|
||||
buf.Write(boilerplate)
|
||||
|
||||
for _, outputPackage := range outputPackages {
|
||||
p := outputPackage.(*protobufPackage)
|
||||
|
||||
path := filepath.Join(g.OutputBase, p.ImportPath())
|
||||
outputPath := filepath.Join(g.OutputBase, p.OutputPath())
|
||||
if p.Vendored {
|
||||
path = filepath.Join(g.VendorOutputBase, p.ImportPath())
|
||||
outputPath = filepath.Join(g.VendorOutputBase, p.OutputPath())
|
||||
}
|
||||
|
||||
// generate the gogoprotobuf protoc
|
||||
cmd := exec.Command("protoc", append(args, path)...)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if len(out) > 0 {
|
||||
log.Printf(string(out))
|
||||
}
|
||||
if err != nil {
|
||||
log.Println(strings.Join(cmd.Args, " "))
|
||||
log.Fatalf("Unable to generate protoc on %s: %v", p.PackageName, err)
|
||||
}
|
||||
|
||||
if g.SkipGeneratedRewrite {
|
||||
continue
|
||||
}
|
||||
|
||||
// alter the generated protobuf file to remove the generated types (but leave the serializers) and rewrite the
|
||||
// package statement to match the desired package name
|
||||
if err := RewriteGeneratedGogoProtobufFile(outputPath, p.ExtractGeneratedType, p.OptionalTypeName, buf.Bytes()); err != nil {
|
||||
log.Fatalf("Unable to rewrite generated %s: %v", outputPath, err)
|
||||
}
|
||||
|
||||
// sort imports
|
||||
cmd = exec.Command("goimports", "-w", outputPath)
|
||||
out, err = cmd.CombinedOutput()
|
||||
if len(out) > 0 {
|
||||
log.Printf(string(out))
|
||||
}
|
||||
if err != nil {
|
||||
log.Println(strings.Join(cmd.Args, " "))
|
||||
log.Fatalf("Unable to rewrite imports for %s: %v", p.PackageName, err)
|
||||
}
|
||||
|
||||
// format and simplify the generated file
|
||||
cmd = exec.Command("gofmt", "-s", "-w", outputPath)
|
||||
out, err = cmd.CombinedOutput()
|
||||
if len(out) > 0 {
|
||||
log.Printf(string(out))
|
||||
}
|
||||
if err != nil {
|
||||
log.Println(strings.Join(cmd.Args, " "))
|
||||
log.Fatalf("Unable to apply gofmt for %s: %v", p.PackageName, err)
|
||||
}
|
||||
}
|
||||
|
||||
if g.SkipGeneratedRewrite {
|
||||
return
|
||||
}
|
||||
|
||||
if !g.KeepGogoproto {
|
||||
// generate, but do so without gogoprotobuf extensions
|
||||
for _, outputPackage := range outputPackages {
|
||||
p := outputPackage.(*protobufPackage)
|
||||
p.OmitGogo = true
|
||||
}
|
||||
if err := c.ExecutePackages(g.VendorOutputBase, vendoredOutputPackages); err != nil {
|
||||
log.Fatalf("Failed executing vendor generator: %v", err)
|
||||
}
|
||||
if err := c.ExecutePackages(g.OutputBase, localOutputPackages); err != nil {
|
||||
log.Fatalf("Failed executing local generator: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
for _, outputPackage := range outputPackages {
|
||||
p := outputPackage.(*protobufPackage)
|
||||
|
||||
if len(p.StructTags) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
pattern := filepath.Join(g.OutputBase, p.PackagePath, "*.go")
|
||||
if p.Vendored {
|
||||
pattern = filepath.Join(g.VendorOutputBase, p.PackagePath, "*.go")
|
||||
}
|
||||
files, err := filepath.Glob(pattern)
|
||||
if err != nil {
|
||||
log.Fatalf("Can't glob pattern %q: %v", pattern, err)
|
||||
}
|
||||
|
||||
for _, s := range files {
|
||||
if strings.HasSuffix(s, "_test.go") {
|
||||
continue
|
||||
}
|
||||
if err := RewriteTypesWithProtobufStructTags(s, p.StructTags); err != nil {
|
||||
log.Fatalf("Unable to rewrite with struct tags %s: %v", s, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,769 +0,0 @@
|
|||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
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 protobuf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
||||
"k8s.io/gengo/generator"
|
||||
"k8s.io/gengo/namer"
|
||||
"k8s.io/gengo/types"
|
||||
)
|
||||
|
||||
// genProtoIDL produces a .proto IDL.
|
||||
type genProtoIDL struct {
|
||||
generator.DefaultGen
|
||||
localPackage types.Name
|
||||
localGoPackage types.Name
|
||||
imports namer.ImportTracker
|
||||
|
||||
generateAll bool
|
||||
omitGogo bool
|
||||
omitFieldTypes map[types.Name]struct{}
|
||||
}
|
||||
|
||||
func (g *genProtoIDL) PackageVars(c *generator.Context) []string {
|
||||
if g.omitGogo {
|
||||
return []string{
|
||||
fmt.Sprintf("option go_package = %q;", g.localGoPackage.Name),
|
||||
}
|
||||
}
|
||||
return []string{
|
||||
"option (gogoproto.marshaler_all) = true;",
|
||||
"option (gogoproto.stable_marshaler_all) = true;",
|
||||
"option (gogoproto.sizer_all) = true;",
|
||||
"option (gogoproto.goproto_stringer_all) = false;",
|
||||
"option (gogoproto.stringer_all) = true;",
|
||||
"option (gogoproto.unmarshaler_all) = true;",
|
||||
"option (gogoproto.goproto_unrecognized_all) = false;",
|
||||
"option (gogoproto.goproto_enum_prefix_all) = false;",
|
||||
"option (gogoproto.goproto_getters_all) = false;",
|
||||
fmt.Sprintf("option go_package = %q;", g.localGoPackage.Name),
|
||||
}
|
||||
}
|
||||
func (g *genProtoIDL) Filename() string { return g.OptionalName + ".proto" }
|
||||
func (g *genProtoIDL) FileType() string { return "protoidl" }
|
||||
func (g *genProtoIDL) Namers(c *generator.Context) namer.NameSystems {
|
||||
return namer.NameSystems{
|
||||
// The local namer returns the correct protobuf name for a proto type
|
||||
// in the context of a package
|
||||
"local": localNamer{g.localPackage},
|
||||
}
|
||||
}
|
||||
|
||||
// Filter ignores types that are identified as not exportable.
|
||||
func (g *genProtoIDL) Filter(c *generator.Context, t *types.Type) bool {
|
||||
tagVals := types.ExtractCommentTags("+", t.CommentLines)["protobuf"]
|
||||
if tagVals != nil {
|
||||
if tagVals[0] == "false" {
|
||||
// Type specified "false".
|
||||
return false
|
||||
}
|
||||
if tagVals[0] == "true" {
|
||||
// Type specified "true".
|
||||
return true
|
||||
}
|
||||
glog.Fatalf(`Comment tag "protobuf" must be true or false, found: %q`, tagVals[0])
|
||||
}
|
||||
if !g.generateAll {
|
||||
// We're not generating everything.
|
||||
return false
|
||||
}
|
||||
seen := map[*types.Type]bool{}
|
||||
ok := isProtoable(seen, t)
|
||||
return ok
|
||||
}
|
||||
|
||||
func isProtoable(seen map[*types.Type]bool, t *types.Type) bool {
|
||||
if seen[t] {
|
||||
// be optimistic in the case of type cycles.
|
||||
return true
|
||||
}
|
||||
seen[t] = true
|
||||
switch t.Kind {
|
||||
case types.Builtin:
|
||||
return true
|
||||
case types.Alias:
|
||||
return isProtoable(seen, t.Underlying)
|
||||
case types.Slice, types.Pointer:
|
||||
return isProtoable(seen, t.Elem)
|
||||
case types.Map:
|
||||
return isProtoable(seen, t.Key) && isProtoable(seen, t.Elem)
|
||||
case types.Struct:
|
||||
if len(t.Members) == 0 {
|
||||
return true
|
||||
}
|
||||
for _, m := range t.Members {
|
||||
if isProtoable(seen, m.Type) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
case types.Func, types.Chan:
|
||||
return false
|
||||
case types.DeclarationOf, types.Unknown, types.Unsupported:
|
||||
return false
|
||||
case types.Interface:
|
||||
return false
|
||||
default:
|
||||
log.Printf("WARNING: type %q is not portable: %s", t.Kind, t.Name)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// isOptionalAlias should return true if the specified type has an underlying type
|
||||
// (is an alias) of a map or slice and has the comment tag protobuf.nullable=true,
|
||||
// indicating that the type should be nullable in protobuf.
|
||||
func isOptionalAlias(t *types.Type) bool {
|
||||
if t.Underlying == nil || (t.Underlying.Kind != types.Map && t.Underlying.Kind != types.Slice) {
|
||||
return false
|
||||
}
|
||||
if extractBoolTagOrDie("protobuf.nullable", t.CommentLines) == false {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (g *genProtoIDL) Imports(c *generator.Context) (imports []string) {
|
||||
lines := []string{}
|
||||
// TODO: this could be expressed more cleanly
|
||||
for _, line := range g.imports.ImportLines() {
|
||||
if g.omitGogo && line == "github.com/gogo/protobuf/gogoproto/gogo.proto" {
|
||||
continue
|
||||
}
|
||||
lines = append(lines, line)
|
||||
}
|
||||
return lines
|
||||
}
|
||||
|
||||
// GenerateType makes the body of a file implementing a set for type t.
|
||||
func (g *genProtoIDL) GenerateType(c *generator.Context, t *types.Type, w io.Writer) error {
|
||||
sw := generator.NewSnippetWriter(w, c, "$", "$")
|
||||
b := bodyGen{
|
||||
locator: &protobufLocator{
|
||||
namer: c.Namers["proto"].(ProtobufFromGoNamer),
|
||||
tracker: g.imports,
|
||||
universe: c.Universe,
|
||||
|
||||
localGoPackage: g.localGoPackage.Package,
|
||||
},
|
||||
localPackage: g.localPackage,
|
||||
|
||||
omitGogo: g.omitGogo,
|
||||
omitFieldTypes: g.omitFieldTypes,
|
||||
|
||||
t: t,
|
||||
}
|
||||
switch t.Kind {
|
||||
case types.Alias:
|
||||
return b.doAlias(sw)
|
||||
case types.Struct:
|
||||
return b.doStruct(sw)
|
||||
default:
|
||||
return b.unknown(sw)
|
||||
}
|
||||
}
|
||||
|
||||
// ProtobufFromGoNamer finds the protobuf name of a type (and its package, and
|
||||
// the package path) from its Go name.
|
||||
type ProtobufFromGoNamer interface {
|
||||
GoNameToProtoName(name types.Name) types.Name
|
||||
}
|
||||
|
||||
type ProtobufLocator interface {
|
||||
ProtoTypeFor(t *types.Type) (*types.Type, error)
|
||||
GoTypeForName(name types.Name) *types.Type
|
||||
CastTypeName(name types.Name) string
|
||||
}
|
||||
|
||||
type protobufLocator struct {
|
||||
namer ProtobufFromGoNamer
|
||||
tracker namer.ImportTracker
|
||||
universe types.Universe
|
||||
|
||||
localGoPackage string
|
||||
}
|
||||
|
||||
// CastTypeName returns the cast type name of a Go type
|
||||
// TODO: delegate to a new localgo namer?
|
||||
func (p protobufLocator) CastTypeName(name types.Name) string {
|
||||
if name.Package == p.localGoPackage {
|
||||
return name.Name
|
||||
}
|
||||
return name.String()
|
||||
}
|
||||
|
||||
func (p protobufLocator) GoTypeForName(name types.Name) *types.Type {
|
||||
if len(name.Package) == 0 {
|
||||
name.Package = p.localGoPackage
|
||||
}
|
||||
return p.universe.Type(name)
|
||||
}
|
||||
|
||||
// ProtoTypeFor locates a Protobuf type for the provided Go type (if possible).
|
||||
func (p protobufLocator) ProtoTypeFor(t *types.Type) (*types.Type, error) {
|
||||
switch {
|
||||
// we've already converted the type, or it's a map
|
||||
case t.Kind == types.Protobuf || t.Kind == types.Map:
|
||||
p.tracker.AddType(t)
|
||||
return t, nil
|
||||
}
|
||||
// it's a fundamental type
|
||||
if t, ok := isFundamentalProtoType(t); ok {
|
||||
p.tracker.AddType(t)
|
||||
return t, nil
|
||||
}
|
||||
// it's a message
|
||||
if t.Kind == types.Struct || isOptionalAlias(t) {
|
||||
t := &types.Type{
|
||||
Name: p.namer.GoNameToProtoName(t.Name),
|
||||
Kind: types.Protobuf,
|
||||
|
||||
CommentLines: t.CommentLines,
|
||||
}
|
||||
p.tracker.AddType(t)
|
||||
return t, nil
|
||||
}
|
||||
return nil, errUnrecognizedType
|
||||
}
|
||||
|
||||
type bodyGen struct {
|
||||
locator ProtobufLocator
|
||||
localPackage types.Name
|
||||
omitGogo bool
|
||||
omitFieldTypes map[types.Name]struct{}
|
||||
|
||||
t *types.Type
|
||||
}
|
||||
|
||||
func (b bodyGen) unknown(sw *generator.SnippetWriter) error {
|
||||
return fmt.Errorf("not sure how to generate: %#v", b.t)
|
||||
}
|
||||
|
||||
func (b bodyGen) doAlias(sw *generator.SnippetWriter) error {
|
||||
if !isOptionalAlias(b.t) {
|
||||
return nil
|
||||
}
|
||||
|
||||
var kind string
|
||||
switch b.t.Underlying.Kind {
|
||||
case types.Map:
|
||||
kind = "map"
|
||||
default:
|
||||
kind = "slice"
|
||||
}
|
||||
optional := &types.Type{
|
||||
Name: b.t.Name,
|
||||
Kind: types.Struct,
|
||||
|
||||
CommentLines: b.t.CommentLines,
|
||||
SecondClosestCommentLines: b.t.SecondClosestCommentLines,
|
||||
Members: []types.Member{
|
||||
{
|
||||
Name: "Items",
|
||||
CommentLines: []string{fmt.Sprintf("items, if empty, will result in an empty %s\n", kind)},
|
||||
Type: b.t.Underlying,
|
||||
},
|
||||
},
|
||||
}
|
||||
nested := b
|
||||
nested.t = optional
|
||||
return nested.doStruct(sw)
|
||||
}
|
||||
|
||||
func (b bodyGen) doStruct(sw *generator.SnippetWriter) error {
|
||||
if len(b.t.Name.Name) == 0 {
|
||||
return nil
|
||||
}
|
||||
if namer.IsPrivateGoName(b.t.Name.Name) {
|
||||
return nil
|
||||
}
|
||||
|
||||
var alias *types.Type
|
||||
var fields []protoField
|
||||
options := []string{}
|
||||
allOptions := types.ExtractCommentTags("+", b.t.CommentLines)
|
||||
for k, v := range allOptions {
|
||||
switch {
|
||||
case strings.HasPrefix(k, "protobuf.options."):
|
||||
key := strings.TrimPrefix(k, "protobuf.options.")
|
||||
switch key {
|
||||
case "marshal":
|
||||
if v[0] == "false" {
|
||||
if !b.omitGogo {
|
||||
options = append(options,
|
||||
"(gogoproto.marshaler) = false",
|
||||
"(gogoproto.unmarshaler) = false",
|
||||
"(gogoproto.sizer) = false",
|
||||
)
|
||||
}
|
||||
}
|
||||
default:
|
||||
if !b.omitGogo || !strings.HasPrefix(key, "(gogoproto.") {
|
||||
if key == "(gogoproto.goproto_stringer)" && v[0] == "false" {
|
||||
options = append(options, "(gogoproto.stringer) = false")
|
||||
}
|
||||
options = append(options, fmt.Sprintf("%s = %s", key, v[0]))
|
||||
}
|
||||
}
|
||||
// protobuf.as allows a type to have the same message contents as another Go type
|
||||
case k == "protobuf.as":
|
||||
fields = nil
|
||||
if alias = b.locator.GoTypeForName(types.Name{Name: v[0]}); alias == nil {
|
||||
return fmt.Errorf("type %v references alias %q which does not exist", b.t, v[0])
|
||||
}
|
||||
// protobuf.embed instructs the generator to use the named type in this package
|
||||
// as an embedded message.
|
||||
case k == "protobuf.embed":
|
||||
fields = []protoField{
|
||||
{
|
||||
Tag: 1,
|
||||
Name: v[0],
|
||||
Type: &types.Type{
|
||||
Name: types.Name{
|
||||
Name: v[0],
|
||||
Package: b.localPackage.Package,
|
||||
Path: b.localPackage.Path,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
if alias == nil {
|
||||
alias = b.t
|
||||
}
|
||||
|
||||
// If we don't explicitly embed anything, generate fields by traversing fields.
|
||||
if fields == nil {
|
||||
memberFields, err := membersToFields(b.locator, alias, b.localPackage, b.omitFieldTypes)
|
||||
if err != nil {
|
||||
return fmt.Errorf("type %v cannot be converted to protobuf: %v", b.t, err)
|
||||
}
|
||||
fields = memberFields
|
||||
}
|
||||
|
||||
out := sw.Out()
|
||||
genComment(out, b.t.CommentLines, "")
|
||||
sw.Do(`message $.Name.Name$ {
|
||||
`, b.t)
|
||||
|
||||
if len(options) > 0 {
|
||||
sort.Sort(sort.StringSlice(options))
|
||||
for _, s := range options {
|
||||
fmt.Fprintf(out, " option %s;\n", s)
|
||||
}
|
||||
fmt.Fprintln(out)
|
||||
}
|
||||
|
||||
for i, field := range fields {
|
||||
genComment(out, field.CommentLines, " ")
|
||||
fmt.Fprintf(out, " ")
|
||||
switch {
|
||||
case field.Map:
|
||||
case field.Repeated:
|
||||
fmt.Fprintf(out, "repeated ")
|
||||
case field.Required:
|
||||
fmt.Fprintf(out, "required ")
|
||||
default:
|
||||
fmt.Fprintf(out, "optional ")
|
||||
}
|
||||
sw.Do(`$.Type|local$ $.Name$ = $.Tag$`, field)
|
||||
if len(field.Extras) > 0 {
|
||||
extras := []string{}
|
||||
for k, v := range field.Extras {
|
||||
if b.omitGogo && strings.HasPrefix(k, "(gogoproto.") {
|
||||
continue
|
||||
}
|
||||
extras = append(extras, fmt.Sprintf("%s = %s", k, v))
|
||||
}
|
||||
sort.Sort(sort.StringSlice(extras))
|
||||
if len(extras) > 0 {
|
||||
fmt.Fprintf(out, " [")
|
||||
fmt.Fprint(out, strings.Join(extras, ", "))
|
||||
fmt.Fprintf(out, "]")
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(out, ";\n")
|
||||
if i != len(fields)-1 {
|
||||
fmt.Fprintf(out, "\n")
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(out, "}\n\n")
|
||||
return nil
|
||||
}
|
||||
|
||||
type protoField struct {
|
||||
LocalPackage types.Name
|
||||
|
||||
Tag int
|
||||
Name string
|
||||
Type *types.Type
|
||||
Map bool
|
||||
Repeated bool
|
||||
Optional bool
|
||||
Required bool
|
||||
Nullable bool
|
||||
Extras map[string]string
|
||||
|
||||
CommentLines []string
|
||||
}
|
||||
|
||||
var (
|
||||
errUnrecognizedType = fmt.Errorf("did not recognize the provided type")
|
||||
)
|
||||
|
||||
func isFundamentalProtoType(t *types.Type) (*types.Type, bool) {
|
||||
// TODO: when we enable proto3, also include other fundamental types in the google.protobuf package
|
||||
// switch {
|
||||
// case t.Kind == types.Struct && t.Name == types.Name{Package: "time", Name: "Time"}:
|
||||
// return &types.Type{
|
||||
// Kind: types.Protobuf,
|
||||
// Name: types.Name{Path: "google/protobuf/timestamp.proto", Package: "google.protobuf", Name: "Timestamp"},
|
||||
// }, true
|
||||
// }
|
||||
switch t.Kind {
|
||||
case types.Slice:
|
||||
if t.Elem.Name.Name == "byte" && len(t.Elem.Name.Package) == 0 {
|
||||
return &types.Type{Name: types.Name{Name: "bytes"}, Kind: types.Protobuf}, true
|
||||
}
|
||||
case types.Builtin:
|
||||
switch t.Name.Name {
|
||||
case "string", "uint32", "int32", "uint64", "int64", "bool":
|
||||
return &types.Type{Name: types.Name{Name: t.Name.Name}, Kind: types.Protobuf}, true
|
||||
case "int":
|
||||
return &types.Type{Name: types.Name{Name: "int64"}, Kind: types.Protobuf}, true
|
||||
case "uint":
|
||||
return &types.Type{Name: types.Name{Name: "uint64"}, Kind: types.Protobuf}, true
|
||||
case "float64", "float":
|
||||
return &types.Type{Name: types.Name{Name: "double"}, Kind: types.Protobuf}, true
|
||||
case "float32":
|
||||
return &types.Type{Name: types.Name{Name: "float"}, Kind: types.Protobuf}, true
|
||||
case "uintptr":
|
||||
return &types.Type{Name: types.Name{Name: "uint64"}, Kind: types.Protobuf}, true
|
||||
}
|
||||
// TODO: complex?
|
||||
}
|
||||
return t, false
|
||||
}
|
||||
|
||||
func memberTypeToProtobufField(locator ProtobufLocator, field *protoField, t *types.Type) error {
|
||||
var err error
|
||||
switch t.Kind {
|
||||
case types.Protobuf:
|
||||
field.Type, err = locator.ProtoTypeFor(t)
|
||||
case types.Builtin:
|
||||
field.Type, err = locator.ProtoTypeFor(t)
|
||||
case types.Map:
|
||||
valueField := &protoField{}
|
||||
if err := memberTypeToProtobufField(locator, valueField, t.Elem); err != nil {
|
||||
return err
|
||||
}
|
||||
keyField := &protoField{}
|
||||
if err := memberTypeToProtobufField(locator, keyField, t.Key); err != nil {
|
||||
return err
|
||||
}
|
||||
// All other protobuf types have kind types.Protobuf, so setting types.Map
|
||||
// here would be very misleading.
|
||||
field.Type = &types.Type{
|
||||
Kind: types.Protobuf,
|
||||
Key: keyField.Type,
|
||||
Elem: valueField.Type,
|
||||
}
|
||||
if !strings.HasPrefix(t.Name.Name, "map[") {
|
||||
field.Extras["(gogoproto.casttype)"] = strconv.Quote(locator.CastTypeName(t.Name))
|
||||
}
|
||||
if k, ok := keyField.Extras["(gogoproto.casttype)"]; ok {
|
||||
field.Extras["(gogoproto.castkey)"] = k
|
||||
}
|
||||
if v, ok := valueField.Extras["(gogoproto.casttype)"]; ok {
|
||||
field.Extras["(gogoproto.castvalue)"] = v
|
||||
}
|
||||
field.Map = true
|
||||
case types.Pointer:
|
||||
if err := memberTypeToProtobufField(locator, field, t.Elem); err != nil {
|
||||
return err
|
||||
}
|
||||
field.Nullable = true
|
||||
case types.Alias:
|
||||
if isOptionalAlias(t) {
|
||||
field.Type, err = locator.ProtoTypeFor(t)
|
||||
field.Nullable = true
|
||||
} else {
|
||||
if err := memberTypeToProtobufField(locator, field, t.Underlying); err != nil {
|
||||
log.Printf("failed to alias: %s %s: err %v", t.Name, t.Underlying.Name, err)
|
||||
return err
|
||||
}
|
||||
// If this is not an alias to a slice, cast to the alias
|
||||
if !field.Repeated {
|
||||
if field.Extras == nil {
|
||||
field.Extras = make(map[string]string)
|
||||
}
|
||||
field.Extras["(gogoproto.casttype)"] = strconv.Quote(locator.CastTypeName(t.Name))
|
||||
}
|
||||
}
|
||||
case types.Slice:
|
||||
if t.Elem.Name.Name == "byte" && len(t.Elem.Name.Package) == 0 {
|
||||
field.Type = &types.Type{Name: types.Name{Name: "bytes"}, Kind: types.Protobuf}
|
||||
return nil
|
||||
}
|
||||
if err := memberTypeToProtobufField(locator, field, t.Elem); err != nil {
|
||||
return err
|
||||
}
|
||||
field.Repeated = true
|
||||
case types.Struct:
|
||||
if len(t.Name.Name) == 0 {
|
||||
return errUnrecognizedType
|
||||
}
|
||||
field.Type, err = locator.ProtoTypeFor(t)
|
||||
field.Nullable = false
|
||||
default:
|
||||
return errUnrecognizedType
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// protobufTagToField extracts information from an existing protobuf tag
|
||||
func protobufTagToField(tag string, field *protoField, m types.Member, t *types.Type, localPackage types.Name) error {
|
||||
if len(tag) == 0 || tag == "-" {
|
||||
return nil
|
||||
}
|
||||
|
||||
// protobuf:"bytes,3,opt,name=Id,customtype=github.com/gogo/protobuf/test.Uuid"
|
||||
parts := strings.Split(tag, ",")
|
||||
if len(parts) < 3 {
|
||||
return fmt.Errorf("member %q of %q malformed 'protobuf' tag, not enough segments\n", m.Name, t.Name)
|
||||
}
|
||||
protoTag, err := strconv.Atoi(parts[1])
|
||||
if err != nil {
|
||||
return fmt.Errorf("member %q of %q malformed 'protobuf' tag, field ID is %q which is not an integer: %v\n", m.Name, t.Name, parts[1], err)
|
||||
}
|
||||
field.Tag = protoTag
|
||||
|
||||
// In general there is doesn't make sense to parse the protobuf tags to get the type,
|
||||
// as all auto-generated once will have wire type "bytes", "varint" or "fixed64".
|
||||
// However, sometimes we explicitly set them to have a custom serialization, e.g.:
|
||||
// type Time struct {
|
||||
// time.Time `protobuf:"Timestamp,1,req,name=time"`
|
||||
// }
|
||||
// to force the generator to use a given type (that we manually wrote serialization &
|
||||
// deserialization methods for).
|
||||
switch parts[0] {
|
||||
case "varint", "fixed32", "fixed64", "bytes", "group":
|
||||
default:
|
||||
name := types.Name{}
|
||||
if last := strings.LastIndex(parts[0], "."); last != -1 {
|
||||
prefix := parts[0][:last]
|
||||
name = types.Name{
|
||||
Name: parts[0][last+1:],
|
||||
Package: prefix,
|
||||
Path: strings.Replace(prefix, ".", "/", -1),
|
||||
}
|
||||
} else {
|
||||
name = types.Name{
|
||||
Name: parts[0],
|
||||
Package: localPackage.Package,
|
||||
Path: localPackage.Path,
|
||||
}
|
||||
}
|
||||
field.Type = &types.Type{
|
||||
Name: name,
|
||||
Kind: types.Protobuf,
|
||||
}
|
||||
}
|
||||
|
||||
protoExtra := make(map[string]string)
|
||||
for i, extra := range parts[3:] {
|
||||
parts := strings.SplitN(extra, "=", 2)
|
||||
if len(parts) != 2 {
|
||||
return fmt.Errorf("member %q of %q malformed 'protobuf' tag, tag %d should be key=value, got %q\n", m.Name, t.Name, i+4, extra)
|
||||
}
|
||||
switch parts[0] {
|
||||
case "name":
|
||||
protoExtra[parts[0]] = parts[1]
|
||||
case "casttype", "castkey", "castvalue":
|
||||
parts[0] = fmt.Sprintf("(gogoproto.%s)", parts[0])
|
||||
protoExtra[parts[0]] = strconv.Quote(parts[1])
|
||||
}
|
||||
}
|
||||
|
||||
field.Extras = protoExtra
|
||||
if name, ok := protoExtra["name"]; ok {
|
||||
field.Name = name
|
||||
delete(protoExtra, "name")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func membersToFields(locator ProtobufLocator, t *types.Type, localPackage types.Name, omitFieldTypes map[types.Name]struct{}) ([]protoField, error) {
|
||||
fields := []protoField{}
|
||||
|
||||
for _, m := range t.Members {
|
||||
if namer.IsPrivateGoName(m.Name) {
|
||||
// skip private fields
|
||||
continue
|
||||
}
|
||||
if _, ok := omitFieldTypes[types.Name{Name: m.Type.Name.Name, Package: m.Type.Name.Package}]; ok {
|
||||
continue
|
||||
}
|
||||
tags := reflect.StructTag(m.Tags)
|
||||
field := protoField{
|
||||
LocalPackage: localPackage,
|
||||
|
||||
Tag: -1,
|
||||
Extras: make(map[string]string),
|
||||
}
|
||||
|
||||
protobufTag := tags.Get("protobuf")
|
||||
if protobufTag == "-" {
|
||||
continue
|
||||
}
|
||||
|
||||
if err := protobufTagToField(protobufTag, &field, m, t, localPackage); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// extract information from JSON field tag
|
||||
if tag := tags.Get("json"); len(tag) > 0 {
|
||||
parts := strings.Split(tag, ",")
|
||||
if len(field.Name) == 0 && len(parts[0]) != 0 {
|
||||
field.Name = parts[0]
|
||||
}
|
||||
if field.Tag == -1 && field.Name == "-" {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if field.Type == nil {
|
||||
if err := memberTypeToProtobufField(locator, &field, m.Type); err != nil {
|
||||
return nil, fmt.Errorf("unable to embed type %q as field %q in %q: %v", m.Type, field.Name, t.Name, err)
|
||||
}
|
||||
}
|
||||
if len(field.Name) == 0 {
|
||||
field.Name = namer.IL(m.Name)
|
||||
}
|
||||
|
||||
if field.Map && field.Repeated {
|
||||
// maps cannot be repeated
|
||||
field.Repeated = false
|
||||
field.Nullable = true
|
||||
}
|
||||
|
||||
if !field.Nullable {
|
||||
field.Extras["(gogoproto.nullable)"] = "false"
|
||||
}
|
||||
if (field.Type.Name.Name == "bytes" && field.Type.Name.Package == "") || (field.Repeated && field.Type.Name.Package == "" && namer.IsPrivateGoName(field.Type.Name.Name)) {
|
||||
delete(field.Extras, "(gogoproto.nullable)")
|
||||
}
|
||||
if field.Name != m.Name {
|
||||
field.Extras["(gogoproto.customname)"] = strconv.Quote(m.Name)
|
||||
}
|
||||
field.CommentLines = m.CommentLines
|
||||
fields = append(fields, field)
|
||||
}
|
||||
|
||||
// assign tags
|
||||
highest := 0
|
||||
byTag := make(map[int]*protoField)
|
||||
// fields are in Go struct order, which we preserve
|
||||
for i := range fields {
|
||||
field := &fields[i]
|
||||
tag := field.Tag
|
||||
if tag != -1 {
|
||||
if existing, ok := byTag[tag]; ok {
|
||||
return nil, fmt.Errorf("field %q and %q both have tag %d", field.Name, existing.Name, tag)
|
||||
}
|
||||
byTag[tag] = field
|
||||
}
|
||||
if tag > highest {
|
||||
highest = tag
|
||||
}
|
||||
}
|
||||
// starting from the highest observed tag, assign new field tags
|
||||
for i := range fields {
|
||||
field := &fields[i]
|
||||
if field.Tag != -1 {
|
||||
continue
|
||||
}
|
||||
highest++
|
||||
field.Tag = highest
|
||||
byTag[field.Tag] = field
|
||||
}
|
||||
return fields, nil
|
||||
}
|
||||
|
||||
func genComment(out io.Writer, lines []string, indent string) {
|
||||
for {
|
||||
l := len(lines)
|
||||
if l == 0 || len(lines[l-1]) != 0 {
|
||||
break
|
||||
}
|
||||
lines = lines[:l-1]
|
||||
}
|
||||
for _, c := range lines {
|
||||
fmt.Fprintf(out, "%s// %s\n", indent, c)
|
||||
}
|
||||
}
|
||||
|
||||
func formatProtoFile(source []byte) ([]byte, error) {
|
||||
// TODO; Is there any protobuf formatter?
|
||||
return source, nil
|
||||
}
|
||||
|
||||
func assembleProtoFile(w io.Writer, f *generator.File) {
|
||||
w.Write(f.Header)
|
||||
|
||||
fmt.Fprint(w, "syntax = 'proto2';\n\n")
|
||||
|
||||
if len(f.PackageName) > 0 {
|
||||
fmt.Fprintf(w, "package %s;\n\n", f.PackageName)
|
||||
}
|
||||
|
||||
if len(f.Imports) > 0 {
|
||||
imports := []string{}
|
||||
for i := range f.Imports {
|
||||
imports = append(imports, i)
|
||||
}
|
||||
sort.Strings(imports)
|
||||
for _, s := range imports {
|
||||
fmt.Fprintf(w, "import %q;\n", s)
|
||||
}
|
||||
fmt.Fprint(w, "\n")
|
||||
}
|
||||
|
||||
if f.Vars.Len() > 0 {
|
||||
fmt.Fprintf(w, "%s\n", f.Vars.String())
|
||||
}
|
||||
|
||||
w.Write(f.Body.Bytes())
|
||||
}
|
||||
|
||||
func NewProtoFile() *generator.DefaultFileType {
|
||||
return &generator.DefaultFileType{
|
||||
Format: formatProtoFile,
|
||||
Assemble: assembleProtoFile,
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
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 protobuf
|
||||
|
||||
import (
|
||||
"k8s.io/gengo/namer"
|
||||
"k8s.io/gengo/types"
|
||||
)
|
||||
|
||||
type ImportTracker struct {
|
||||
namer.DefaultImportTracker
|
||||
}
|
||||
|
||||
func NewImportTracker(local types.Name, typesToAdd ...*types.Type) *ImportTracker {
|
||||
tracker := namer.NewDefaultImportTracker(local)
|
||||
tracker.IsInvalidType = func(t *types.Type) bool { return t.Kind != types.Protobuf }
|
||||
tracker.LocalName = func(name types.Name) string { return name.Package }
|
||||
tracker.PrintImport = func(path, name string) string { return path }
|
||||
|
||||
tracker.AddTypes(typesToAdd...)
|
||||
return &ImportTracker{
|
||||
DefaultImportTracker: tracker,
|
||||
}
|
||||
}
|
||||
|
||||
// AddNullable ensures that support for the nullable Gogo-protobuf extension is added.
|
||||
func (tracker *ImportTracker) AddNullable() {
|
||||
tracker.AddType(&types.Type{
|
||||
Kind: types.Protobuf,
|
||||
Name: types.Name{
|
||||
Name: "nullable",
|
||||
Package: "gogoproto",
|
||||
Path: "github.com/gogo/protobuf/gogoproto/gogo.proto",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
@ -1,205 +0,0 @@
|
|||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
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 protobuf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"k8s.io/gengo/generator"
|
||||
"k8s.io/gengo/namer"
|
||||
"k8s.io/gengo/types"
|
||||
)
|
||||
|
||||
type localNamer struct {
|
||||
localPackage types.Name
|
||||
}
|
||||
|
||||
func (n localNamer) Name(t *types.Type) string {
|
||||
if t.Key != nil && t.Elem != nil {
|
||||
return fmt.Sprintf("map<%s, %s>", n.Name(t.Key), n.Name(t.Elem))
|
||||
}
|
||||
if len(n.localPackage.Package) != 0 && n.localPackage.Package == t.Name.Package {
|
||||
return t.Name.Name
|
||||
}
|
||||
return t.Name.String()
|
||||
}
|
||||
|
||||
type protobufNamer struct {
|
||||
packages []*protobufPackage
|
||||
packagesByPath map[string]*protobufPackage
|
||||
}
|
||||
|
||||
func NewProtobufNamer() *protobufNamer {
|
||||
return &protobufNamer{
|
||||
packagesByPath: make(map[string]*protobufPackage),
|
||||
}
|
||||
}
|
||||
|
||||
func (n *protobufNamer) Name(t *types.Type) string {
|
||||
if t.Kind == types.Map {
|
||||
return fmt.Sprintf("map<%s, %s>", n.Name(t.Key), n.Name(t.Elem))
|
||||
}
|
||||
return t.Name.String()
|
||||
}
|
||||
|
||||
func (n *protobufNamer) List() []generator.Package {
|
||||
packages := make([]generator.Package, 0, len(n.packages))
|
||||
for i := range n.packages {
|
||||
packages = append(packages, n.packages[i])
|
||||
}
|
||||
return packages
|
||||
}
|
||||
|
||||
func (n *protobufNamer) Add(p *protobufPackage) {
|
||||
if _, ok := n.packagesByPath[p.PackagePath]; !ok {
|
||||
n.packagesByPath[p.PackagePath] = p
|
||||
n.packages = append(n.packages, p)
|
||||
}
|
||||
}
|
||||
|
||||
func (n *protobufNamer) GoNameToProtoName(name types.Name) types.Name {
|
||||
if p, ok := n.packagesByPath[name.Package]; ok {
|
||||
return types.Name{
|
||||
Name: name.Name,
|
||||
Package: p.PackageName,
|
||||
Path: p.ImportPath(),
|
||||
}
|
||||
}
|
||||
for _, p := range n.packages {
|
||||
if _, ok := p.FilterTypes[name]; ok {
|
||||
return types.Name{
|
||||
Name: name.Name,
|
||||
Package: p.PackageName,
|
||||
Path: p.ImportPath(),
|
||||
}
|
||||
}
|
||||
}
|
||||
return types.Name{Name: name.Name}
|
||||
}
|
||||
|
||||
func protoSafePackage(name string) string {
|
||||
pkg := strings.Replace(name, "/", ".", -1)
|
||||
return strings.Replace(pkg, "-", "_", -1)
|
||||
}
|
||||
|
||||
type typeNameSet map[types.Name]*protobufPackage
|
||||
|
||||
// assignGoTypeToProtoPackage looks for Go and Protobuf types that are referenced by a type in
|
||||
// a package. It will not recurse into protobuf types.
|
||||
func assignGoTypeToProtoPackage(p *protobufPackage, t *types.Type, local, global typeNameSet, optional map[types.Name]struct{}) {
|
||||
newT, isProto := isFundamentalProtoType(t)
|
||||
if isProto {
|
||||
t = newT
|
||||
}
|
||||
if otherP, ok := global[t.Name]; ok {
|
||||
if _, ok := local[t.Name]; !ok {
|
||||
p.Imports.AddType(&types.Type{
|
||||
Kind: types.Protobuf,
|
||||
Name: otherP.ProtoTypeName(),
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
global[t.Name] = p
|
||||
if _, ok := local[t.Name]; ok {
|
||||
return
|
||||
}
|
||||
// don't recurse into existing proto types
|
||||
if isProto {
|
||||
p.Imports.AddType(t)
|
||||
return
|
||||
}
|
||||
|
||||
local[t.Name] = p
|
||||
for _, m := range t.Members {
|
||||
if namer.IsPrivateGoName(m.Name) {
|
||||
continue
|
||||
}
|
||||
field := &protoField{}
|
||||
tag := reflect.StructTag(m.Tags).Get("protobuf")
|
||||
if tag == "-" {
|
||||
continue
|
||||
}
|
||||
if err := protobufTagToField(tag, field, m, t, p.ProtoTypeName()); err == nil && field.Type != nil {
|
||||
assignGoTypeToProtoPackage(p, field.Type, local, global, optional)
|
||||
continue
|
||||
}
|
||||
assignGoTypeToProtoPackage(p, m.Type, local, global, optional)
|
||||
}
|
||||
// TODO: should methods be walked?
|
||||
if t.Elem != nil {
|
||||
assignGoTypeToProtoPackage(p, t.Elem, local, global, optional)
|
||||
}
|
||||
if t.Key != nil {
|
||||
assignGoTypeToProtoPackage(p, t.Key, local, global, optional)
|
||||
}
|
||||
if t.Underlying != nil {
|
||||
if t.Kind == types.Alias && isOptionalAlias(t) {
|
||||
optional[t.Name] = struct{}{}
|
||||
}
|
||||
assignGoTypeToProtoPackage(p, t.Underlying, local, global, optional)
|
||||
}
|
||||
}
|
||||
|
||||
// isTypeApplicableToProtobuf checks to see if a type is relevant for protobuf processing.
|
||||
// Currently, it filters out functions and private types.
|
||||
func isTypeApplicableToProtobuf(t *types.Type) bool {
|
||||
// skip functions -- we don't care about them for protobuf
|
||||
if t.Kind == types.Func || (t.Kind == types.DeclarationOf && t.Underlying.Kind == types.Func) {
|
||||
return false
|
||||
}
|
||||
// skip private types
|
||||
if namer.IsPrivateGoName(t.Name.Name) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (n *protobufNamer) AssignTypesToPackages(c *generator.Context) error {
|
||||
global := make(typeNameSet)
|
||||
for _, p := range n.packages {
|
||||
local := make(typeNameSet)
|
||||
optional := make(map[types.Name]struct{})
|
||||
p.Imports = NewImportTracker(p.ProtoTypeName())
|
||||
for _, t := range c.Order {
|
||||
if t.Name.Package != p.PackagePath {
|
||||
continue
|
||||
}
|
||||
if !isTypeApplicableToProtobuf(t) {
|
||||
// skip types that we don't care about, like functions
|
||||
continue
|
||||
}
|
||||
assignGoTypeToProtoPackage(p, t, local, global, optional)
|
||||
}
|
||||
p.FilterTypes = make(map[types.Name]struct{})
|
||||
p.LocalNames = make(map[string]struct{})
|
||||
p.OptionalTypeNames = make(map[string]struct{})
|
||||
for k, v := range local {
|
||||
if v == p {
|
||||
p.FilterTypes[k] = struct{}{}
|
||||
p.LocalNames[k.Name] = struct{}{}
|
||||
if _, ok := optional[k]; ok {
|
||||
p.OptionalTypeNames[k.Name] = struct{}{}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -1,215 +0,0 @@
|
|||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
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 protobuf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"k8s.io/gengo/generator"
|
||||
"k8s.io/gengo/types"
|
||||
)
|
||||
|
||||
func newProtobufPackage(packagePath, packageName string, generateAll bool, omitFieldTypes map[types.Name]struct{}) *protobufPackage {
|
||||
pkg := &protobufPackage{
|
||||
DefaultPackage: generator.DefaultPackage{
|
||||
// The protobuf package name (foo.bar.baz)
|
||||
PackageName: packageName,
|
||||
// A path segment relative to the GOPATH root (foo/bar/baz)
|
||||
PackagePath: packagePath,
|
||||
HeaderText: []byte(
|
||||
`
|
||||
// This file was autogenerated by go-to-protobuf. Do not edit it manually!
|
||||
|
||||
`),
|
||||
PackageDocumentation: []byte(fmt.Sprintf(
|
||||
`// Package %s is an autogenerated protobuf IDL.
|
||||
`, packageName)),
|
||||
},
|
||||
GenerateAll: generateAll,
|
||||
OmitFieldTypes: omitFieldTypes,
|
||||
}
|
||||
pkg.FilterFunc = pkg.filterFunc
|
||||
pkg.GeneratorFunc = pkg.generatorFunc
|
||||
return pkg
|
||||
}
|
||||
|
||||
// protobufPackage contains the protobuf implementation of Package.
|
||||
type protobufPackage struct {
|
||||
generator.DefaultPackage
|
||||
|
||||
// If true, this package has been vendored into our source tree and thus can
|
||||
// only be generated by changing the vendor tree.
|
||||
Vendored bool
|
||||
|
||||
// If true, generate protobuf serializations for all public types.
|
||||
// If false, only generate protobuf serializations for structs that
|
||||
// request serialization.
|
||||
GenerateAll bool
|
||||
|
||||
// A list of types to filter to; if not specified all types will be included.
|
||||
FilterTypes map[types.Name]struct{}
|
||||
|
||||
// If true, omit any gogoprotobuf extensions not defined as types.
|
||||
OmitGogo bool
|
||||
|
||||
// A list of field types that will be excluded from the output struct
|
||||
OmitFieldTypes map[types.Name]struct{}
|
||||
|
||||
// A list of names that this package exports
|
||||
LocalNames map[string]struct{}
|
||||
|
||||
// A list of type names in this package that will need marshaller rewriting
|
||||
// to remove synthetic protobuf fields.
|
||||
OptionalTypeNames map[string]struct{}
|
||||
|
||||
// A list of struct tags to generate onto named struct fields
|
||||
StructTags map[string]map[string]string
|
||||
|
||||
// An import tracker for this package
|
||||
Imports *ImportTracker
|
||||
}
|
||||
|
||||
func (p *protobufPackage) Clean(outputBase string) error {
|
||||
for _, s := range []string{p.ImportPath(), p.OutputPath()} {
|
||||
if err := os.Remove(filepath.Join(outputBase, s)); err != nil && !os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *protobufPackage) ProtoTypeName() types.Name {
|
||||
return types.Name{
|
||||
Name: p.Path(), // the go path "foo/bar/baz"
|
||||
Package: p.Name(), // the protobuf package "foo.bar.baz"
|
||||
Path: p.ImportPath(), // the path of the import to get the proto
|
||||
}
|
||||
}
|
||||
|
||||
func (p *protobufPackage) filterFunc(c *generator.Context, t *types.Type) bool {
|
||||
switch t.Kind {
|
||||
case types.Func, types.Chan:
|
||||
return false
|
||||
case types.Struct:
|
||||
if t.Name.Name == "struct{}" {
|
||||
return false
|
||||
}
|
||||
case types.Builtin:
|
||||
return false
|
||||
case types.Alias:
|
||||
if !isOptionalAlias(t) {
|
||||
return false
|
||||
}
|
||||
case types.Slice, types.Array, types.Map:
|
||||
return false
|
||||
case types.Pointer:
|
||||
return false
|
||||
}
|
||||
if _, ok := isFundamentalProtoType(t); ok {
|
||||
return false
|
||||
}
|
||||
_, ok := p.FilterTypes[t.Name]
|
||||
return ok
|
||||
}
|
||||
|
||||
func (p *protobufPackage) HasGoType(name string) bool {
|
||||
_, ok := p.LocalNames[name]
|
||||
return ok
|
||||
}
|
||||
|
||||
func (p *protobufPackage) OptionalTypeName(name string) bool {
|
||||
_, ok := p.OptionalTypeNames[name]
|
||||
return ok
|
||||
}
|
||||
|
||||
func (p *protobufPackage) ExtractGeneratedType(t *ast.TypeSpec) bool {
|
||||
if !p.HasGoType(t.Name.Name) {
|
||||
return false
|
||||
}
|
||||
|
||||
switch s := t.Type.(type) {
|
||||
case *ast.StructType:
|
||||
for i, f := range s.Fields.List {
|
||||
if len(f.Tag.Value) == 0 {
|
||||
continue
|
||||
}
|
||||
tag := strings.Trim(f.Tag.Value, "`")
|
||||
protobufTag := reflect.StructTag(tag).Get("protobuf")
|
||||
if len(protobufTag) == 0 {
|
||||
continue
|
||||
}
|
||||
if len(f.Names) > 1 {
|
||||
log.Printf("WARNING: struct %s field %d %s: defined multiple names but single protobuf tag", t.Name.Name, i, f.Names[0].Name)
|
||||
// TODO hard error?
|
||||
}
|
||||
if p.StructTags == nil {
|
||||
p.StructTags = make(map[string]map[string]string)
|
||||
}
|
||||
m := p.StructTags[t.Name.Name]
|
||||
if m == nil {
|
||||
m = make(map[string]string)
|
||||
p.StructTags[t.Name.Name] = m
|
||||
}
|
||||
m[f.Names[0].Name] = tag
|
||||
}
|
||||
default:
|
||||
log.Printf("WARNING: unexpected Go AST type definition: %#v", t)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *protobufPackage) generatorFunc(c *generator.Context) []generator.Generator {
|
||||
generators := []generator.Generator{}
|
||||
|
||||
p.Imports.AddNullable()
|
||||
|
||||
generators = append(generators, &genProtoIDL{
|
||||
DefaultGen: generator.DefaultGen{
|
||||
OptionalName: "generated",
|
||||
},
|
||||
localPackage: types.Name{Package: p.PackageName, Path: p.PackagePath},
|
||||
localGoPackage: types.Name{Package: p.PackagePath, Name: p.GoPackageName()},
|
||||
imports: p.Imports,
|
||||
generateAll: p.GenerateAll,
|
||||
omitGogo: p.OmitGogo,
|
||||
omitFieldTypes: p.OmitFieldTypes,
|
||||
})
|
||||
return generators
|
||||
}
|
||||
|
||||
func (p *protobufPackage) GoPackageName() string {
|
||||
return filepath.Base(p.PackagePath)
|
||||
}
|
||||
|
||||
func (p *protobufPackage) ImportPath() string {
|
||||
return filepath.Join(p.PackagePath, "generated.proto")
|
||||
}
|
||||
|
||||
func (p *protobufPackage) OutputPath() string {
|
||||
return filepath.Join(p.PackagePath, "generated.pb.go")
|
||||
}
|
||||
|
||||
var (
|
||||
_ = generator.Package(&protobufPackage{})
|
||||
)
|
||||
|
|
@ -1,452 +0,0 @@
|
|||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
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 protobuf
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"go/format"
|
||||
"go/parser"
|
||||
"go/printer"
|
||||
"go/token"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
customreflect "k8s.io/code-generator/third_party/forked/golang/reflect"
|
||||
)
|
||||
|
||||
func rewriteFile(name string, header []byte, rewriteFn func(*token.FileSet, *ast.File) error) error {
|
||||
fset := token.NewFileSet()
|
||||
src, err := ioutil.ReadFile(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
file, err := parser.ParseFile(fset, name, src, parser.DeclarationErrors|parser.ParseComments)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := rewriteFn(fset, file); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
b := &bytes.Buffer{}
|
||||
b.Write(header)
|
||||
if err := printer.Fprint(b, fset, file); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
body, err := format.Source(b.Bytes())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
f, err := os.OpenFile(name, os.O_WRONLY|os.O_TRUNC, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
if _, err := f.Write(body); err != nil {
|
||||
return err
|
||||
}
|
||||
return f.Close()
|
||||
}
|
||||
|
||||
// ExtractFunc extracts information from the provided TypeSpec and returns true if the type should be
|
||||
// removed from the destination file.
|
||||
type ExtractFunc func(*ast.TypeSpec) bool
|
||||
|
||||
// OptionalFunc returns true if the provided local name is a type that has protobuf.nullable=true
|
||||
// and should have its marshal functions adjusted to remove the 'Items' accessor.
|
||||
type OptionalFunc func(name string) bool
|
||||
|
||||
func RewriteGeneratedGogoProtobufFile(name string, extractFn ExtractFunc, optionalFn OptionalFunc, header []byte) error {
|
||||
return rewriteFile(name, header, func(fset *token.FileSet, file *ast.File) error {
|
||||
cmap := ast.NewCommentMap(fset, file, file.Comments)
|
||||
|
||||
// transform methods that point to optional maps or slices
|
||||
for _, d := range file.Decls {
|
||||
rewriteOptionalMethods(d, optionalFn)
|
||||
}
|
||||
|
||||
// remove types that are already declared
|
||||
decls := []ast.Decl{}
|
||||
for _, d := range file.Decls {
|
||||
if dropExistingTypeDeclarations(d, extractFn) {
|
||||
continue
|
||||
}
|
||||
if dropEmptyImportDeclarations(d) {
|
||||
continue
|
||||
}
|
||||
decls = append(decls, d)
|
||||
}
|
||||
file.Decls = decls
|
||||
|
||||
// remove unmapped comments
|
||||
file.Comments = cmap.Filter(file).Comments()
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// rewriteOptionalMethods makes specific mutations to marshaller methods that belong to types identified
|
||||
// as being "optional" (they may be nil on the wire). This allows protobuf to serialize a map or slice and
|
||||
// properly discriminate between empty and nil (which is not possible in protobuf).
|
||||
// TODO: move into upstream gogo-protobuf once https://github.com/gogo/protobuf/issues/181
|
||||
// has agreement
|
||||
func rewriteOptionalMethods(decl ast.Decl, isOptional OptionalFunc) {
|
||||
switch t := decl.(type) {
|
||||
case *ast.FuncDecl:
|
||||
ident, ptr, ok := receiver(t)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
// correct initialization of the form `m.Field = &OptionalType{}` to
|
||||
// `m.Field = OptionalType{}`
|
||||
if t.Name.Name == "Unmarshal" {
|
||||
ast.Walk(optionalAssignmentVisitor{fn: isOptional}, t.Body)
|
||||
}
|
||||
|
||||
if !isOptional(ident.Name) {
|
||||
return
|
||||
}
|
||||
|
||||
switch t.Name.Name {
|
||||
case "Unmarshal":
|
||||
ast.Walk(&optionalItemsVisitor{}, t.Body)
|
||||
case "MarshalTo", "Size", "String":
|
||||
ast.Walk(&optionalItemsVisitor{}, t.Body)
|
||||
fallthrough
|
||||
case "Marshal":
|
||||
// if the method has a pointer receiver, set it back to a normal receiver
|
||||
if ptr {
|
||||
t.Recv.List[0].Type = ident
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type optionalAssignmentVisitor struct {
|
||||
fn OptionalFunc
|
||||
}
|
||||
|
||||
// Visit walks the provided node, transforming field initializations of the form
|
||||
// m.Field = &OptionalType{} -> m.Field = OptionalType{}
|
||||
func (v optionalAssignmentVisitor) Visit(n ast.Node) ast.Visitor {
|
||||
switch t := n.(type) {
|
||||
case *ast.AssignStmt:
|
||||
if len(t.Lhs) == 1 && len(t.Rhs) == 1 {
|
||||
if !isFieldSelector(t.Lhs[0], "m", "") {
|
||||
return nil
|
||||
}
|
||||
unary, ok := t.Rhs[0].(*ast.UnaryExpr)
|
||||
if !ok || unary.Op != token.AND {
|
||||
return nil
|
||||
}
|
||||
composite, ok := unary.X.(*ast.CompositeLit)
|
||||
if !ok || composite.Type == nil || len(composite.Elts) != 0 {
|
||||
return nil
|
||||
}
|
||||
if ident, ok := composite.Type.(*ast.Ident); ok && v.fn(ident.Name) {
|
||||
t.Rhs[0] = composite
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
type optionalItemsVisitor struct{}
|
||||
|
||||
// Visit walks the provided node, looking for specific patterns to transform that match
|
||||
// the effective outcome of turning struct{ map[x]y || []x } into map[x]y or []x.
|
||||
func (v *optionalItemsVisitor) Visit(n ast.Node) ast.Visitor {
|
||||
switch t := n.(type) {
|
||||
case *ast.RangeStmt:
|
||||
if isFieldSelector(t.X, "m", "Items") {
|
||||
t.X = &ast.Ident{Name: "m"}
|
||||
}
|
||||
case *ast.AssignStmt:
|
||||
if len(t.Lhs) == 1 && len(t.Rhs) == 1 {
|
||||
switch lhs := t.Lhs[0].(type) {
|
||||
case *ast.IndexExpr:
|
||||
if isFieldSelector(lhs.X, "m", "Items") {
|
||||
lhs.X = &ast.StarExpr{X: &ast.Ident{Name: "m"}}
|
||||
}
|
||||
default:
|
||||
if isFieldSelector(t.Lhs[0], "m", "Items") {
|
||||
t.Lhs[0] = &ast.StarExpr{X: &ast.Ident{Name: "m"}}
|
||||
}
|
||||
}
|
||||
switch rhs := t.Rhs[0].(type) {
|
||||
case *ast.CallExpr:
|
||||
if ident, ok := rhs.Fun.(*ast.Ident); ok && ident.Name == "append" {
|
||||
ast.Walk(v, rhs)
|
||||
if len(rhs.Args) > 0 {
|
||||
switch arg := rhs.Args[0].(type) {
|
||||
case *ast.Ident:
|
||||
if arg.Name == "m" {
|
||||
rhs.Args[0] = &ast.StarExpr{X: &ast.Ident{Name: "m"}}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
case *ast.IfStmt:
|
||||
switch cond := t.Cond.(type) {
|
||||
case *ast.BinaryExpr:
|
||||
if cond.Op == token.EQL {
|
||||
if isFieldSelector(cond.X, "m", "Items") && isIdent(cond.Y, "nil") {
|
||||
cond.X = &ast.StarExpr{X: &ast.Ident{Name: "m"}}
|
||||
}
|
||||
}
|
||||
}
|
||||
if t.Init != nil {
|
||||
// Find form:
|
||||
// if err := m[len(m.Items)-1].Unmarshal(data[iNdEx:postIndex]); err != nil {
|
||||
// return err
|
||||
// }
|
||||
switch s := t.Init.(type) {
|
||||
case *ast.AssignStmt:
|
||||
if call, ok := s.Rhs[0].(*ast.CallExpr); ok {
|
||||
if sel, ok := call.Fun.(*ast.SelectorExpr); ok {
|
||||
if x, ok := sel.X.(*ast.IndexExpr); ok {
|
||||
// m[] -> (*m)[]
|
||||
if sel2, ok := x.X.(*ast.SelectorExpr); ok {
|
||||
if ident, ok := sel2.X.(*ast.Ident); ok && ident.Name == "m" {
|
||||
x.X = &ast.StarExpr{X: &ast.Ident{Name: "m"}}
|
||||
}
|
||||
}
|
||||
// len(m.Items) -> len(*m)
|
||||
if bin, ok := x.Index.(*ast.BinaryExpr); ok {
|
||||
if call2, ok := bin.X.(*ast.CallExpr); ok && len(call2.Args) == 1 {
|
||||
if isFieldSelector(call2.Args[0], "m", "Items") {
|
||||
call2.Args[0] = &ast.StarExpr{X: &ast.Ident{Name: "m"}}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
case *ast.IndexExpr:
|
||||
if isFieldSelector(t.X, "m", "Items") {
|
||||
t.X = &ast.Ident{Name: "m"}
|
||||
return nil
|
||||
}
|
||||
case *ast.CallExpr:
|
||||
changed := false
|
||||
for i := range t.Args {
|
||||
if isFieldSelector(t.Args[i], "m", "Items") {
|
||||
t.Args[i] = &ast.Ident{Name: "m"}
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
if changed {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func isFieldSelector(n ast.Expr, name, field string) bool {
|
||||
s, ok := n.(*ast.SelectorExpr)
|
||||
if !ok || s.Sel == nil || (field != "" && s.Sel.Name != field) {
|
||||
return false
|
||||
}
|
||||
return isIdent(s.X, name)
|
||||
}
|
||||
|
||||
func isIdent(n ast.Expr, value string) bool {
|
||||
ident, ok := n.(*ast.Ident)
|
||||
return ok && ident.Name == value
|
||||
}
|
||||
|
||||
func receiver(f *ast.FuncDecl) (ident *ast.Ident, pointer bool, ok bool) {
|
||||
if f.Recv == nil || len(f.Recv.List) != 1 {
|
||||
return nil, false, false
|
||||
}
|
||||
switch t := f.Recv.List[0].Type.(type) {
|
||||
case *ast.StarExpr:
|
||||
identity, ok := t.X.(*ast.Ident)
|
||||
if !ok {
|
||||
return nil, false, false
|
||||
}
|
||||
return identity, true, true
|
||||
case *ast.Ident:
|
||||
return t, false, true
|
||||
}
|
||||
return nil, false, false
|
||||
}
|
||||
|
||||
// dropExistingTypeDeclarations removes any type declaration for which extractFn returns true. The function
|
||||
// returns true if the entire declaration should be dropped.
|
||||
func dropExistingTypeDeclarations(decl ast.Decl, extractFn ExtractFunc) bool {
|
||||
switch t := decl.(type) {
|
||||
case *ast.GenDecl:
|
||||
if t.Tok != token.TYPE {
|
||||
return false
|
||||
}
|
||||
specs := []ast.Spec{}
|
||||
for _, s := range t.Specs {
|
||||
switch spec := s.(type) {
|
||||
case *ast.TypeSpec:
|
||||
if extractFn(spec) {
|
||||
continue
|
||||
}
|
||||
specs = append(specs, spec)
|
||||
}
|
||||
}
|
||||
if len(specs) == 0 {
|
||||
return true
|
||||
}
|
||||
t.Specs = specs
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// dropEmptyImportDeclarations strips any generated but no-op imports from the generated code
|
||||
// to prevent generation from being able to define side-effects. The function returns true
|
||||
// if the entire declaration should be dropped.
|
||||
func dropEmptyImportDeclarations(decl ast.Decl) bool {
|
||||
switch t := decl.(type) {
|
||||
case *ast.GenDecl:
|
||||
if t.Tok != token.IMPORT {
|
||||
return false
|
||||
}
|
||||
specs := []ast.Spec{}
|
||||
for _, s := range t.Specs {
|
||||
switch spec := s.(type) {
|
||||
case *ast.ImportSpec:
|
||||
if spec.Name != nil && spec.Name.Name == "_" {
|
||||
continue
|
||||
}
|
||||
specs = append(specs, spec)
|
||||
}
|
||||
}
|
||||
if len(specs) == 0 {
|
||||
return true
|
||||
}
|
||||
t.Specs = specs
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func RewriteTypesWithProtobufStructTags(name string, structTags map[string]map[string]string) error {
|
||||
return rewriteFile(name, []byte{}, func(fset *token.FileSet, file *ast.File) error {
|
||||
allErrs := []error{}
|
||||
|
||||
// set any new struct tags
|
||||
for _, d := range file.Decls {
|
||||
if errs := updateStructTags(d, structTags, []string{"protobuf"}); len(errs) > 0 {
|
||||
allErrs = append(allErrs, errs...)
|
||||
}
|
||||
}
|
||||
|
||||
if len(allErrs) > 0 {
|
||||
var s string
|
||||
for _, err := range allErrs {
|
||||
s += err.Error() + "\n"
|
||||
}
|
||||
return errors.New(s)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func updateStructTags(decl ast.Decl, structTags map[string]map[string]string, toCopy []string) []error {
|
||||
var errs []error
|
||||
t, ok := decl.(*ast.GenDecl)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
if t.Tok != token.TYPE {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, s := range t.Specs {
|
||||
spec, ok := s.(*ast.TypeSpec)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
typeName := spec.Name.Name
|
||||
fieldTags, ok := structTags[typeName]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
st, ok := spec.Type.(*ast.StructType)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
for i := range st.Fields.List {
|
||||
f := st.Fields.List[i]
|
||||
var name string
|
||||
if len(f.Names) == 0 {
|
||||
switch t := f.Type.(type) {
|
||||
case *ast.Ident:
|
||||
name = t.Name
|
||||
case *ast.SelectorExpr:
|
||||
name = t.Sel.Name
|
||||
default:
|
||||
errs = append(errs, fmt.Errorf("unable to get name for tag from struct %q, field %#v", spec.Name.Name, t))
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
name = f.Names[0].Name
|
||||
}
|
||||
value, ok := fieldTags[name]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
var tags customreflect.StructTags
|
||||
if f.Tag != nil {
|
||||
oldTags, err := customreflect.ParseStructTags(strings.Trim(f.Tag.Value, "`"))
|
||||
if err != nil {
|
||||
errs = append(errs, fmt.Errorf("unable to read struct tag from struct %q, field %q: %v", spec.Name.Name, name, err))
|
||||
continue
|
||||
}
|
||||
tags = oldTags
|
||||
}
|
||||
for _, name := range toCopy {
|
||||
// don't overwrite existing tags
|
||||
if tags.Has(name) {
|
||||
continue
|
||||
}
|
||||
// append new tags
|
||||
if v := reflect.StructTag(value).Get(name); len(v) > 0 {
|
||||
tags = append(tags, customreflect.StructTag{Name: name, Value: v})
|
||||
}
|
||||
}
|
||||
if len(tags) == 0 {
|
||||
continue
|
||||
}
|
||||
if f.Tag == nil {
|
||||
f.Tag = &ast.BasicLit{}
|
||||
}
|
||||
f.Tag.Value = tags.String()
|
||||
}
|
||||
}
|
||||
return errs
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
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 protobuf
|
||||
|
||||
import (
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/gengo/types"
|
||||
)
|
||||
|
||||
// extractBoolTagOrDie gets the comment-tags for the key and asserts that, if
|
||||
// it exists, the value is boolean. If the tag did not exist, it returns
|
||||
// false.
|
||||
func extractBoolTagOrDie(key string, lines []string) bool {
|
||||
val, err := types.ExtractSingleBoolCommentTag("+", key, false, lines)
|
||||
if err != nil {
|
||||
glog.Fatal(err)
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["main.go"],
|
||||
importmap = "vendor/k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo",
|
||||
importpath = "k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
"//vendor/github.com/gogo/protobuf/gogoproto:go_default_library",
|
||||
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
|
||||
"//vendor/github.com/gogo/protobuf/sortkeys:go_default_library",
|
||||
"//vendor/github.com/gogo/protobuf/vanity/command:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "protoc-gen-gogo",
|
||||
embed = [":go_default_library"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
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 main defines the protoc-gen-gogo binary we use to generate our proto go files,
|
||||
// as well as takes dependencies on the correct gogo/protobuf packages for godeps.
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogo/protobuf/vanity/command"
|
||||
|
||||
// dependencies that are required for our packages
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
_ "github.com/gogo/protobuf/proto"
|
||||
_ "github.com/gogo/protobuf/sortkeys"
|
||||
)
|
||||
|
||||
func main() {
|
||||
command.Write(command.Generate(command.Read()))
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
import-boss
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["main.go"],
|
||||
importmap = "vendor/k8s.io/code-generator/cmd/import-boss",
|
||||
importpath = "k8s.io/code-generator/cmd/import-boss",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/code-generator/pkg/util:go_default_library",
|
||||
"//vendor/k8s.io/gengo/args:go_default_library",
|
||||
"//vendor/k8s.io/gengo/examples/import-boss/generators:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "import-boss",
|
||||
embed = [":go_default_library"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// import-boss enforces import restrictions in a given repository.
|
||||
//
|
||||
// When a directory is verified, import-boss looks for a file called
|
||||
// ".import-restrictions". If this file is not found, parent directories will be
|
||||
// recursively searched.
|
||||
//
|
||||
// If an ".import-restrictions" file is found, then all imports of the package
|
||||
// are checked against each "rule" in the file. A rule consists of three parts:
|
||||
// * A SelectorRegexp, to select the import paths that the rule applies to.
|
||||
// * A list of AllowedPrefixes
|
||||
// * A list of ForbiddenPrefixes
|
||||
// An import is allowed if it matches at least one allowed prefix and does not
|
||||
// match any forbidden prefix. An example file looks like this:
|
||||
//
|
||||
// {
|
||||
// "Rules": [
|
||||
// {
|
||||
// "SelectorRegexp": "k8s[.]io",
|
||||
// "AllowedPrefixes": [
|
||||
// "k8s.io/gengo/examples",
|
||||
// "k8s.io/kubernetes/third_party"
|
||||
// ],
|
||||
// "ForbiddenPrefixes": [
|
||||
// "k8s.io/kubernetes/pkg/third_party/deprecated"
|
||||
// ]
|
||||
// },
|
||||
// {
|
||||
// "SelectorRegexp": "^unsafe$",
|
||||
// "AllowedPrefixes": [
|
||||
// ],
|
||||
// "ForbiddenPrefixes": [
|
||||
// ""
|
||||
// ]
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
//
|
||||
// Note the second block explicitly matches the unsafe package, and forbids it
|
||||
// ("" is a prefix of everything).
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"k8s.io/code-generator/pkg/util"
|
||||
"k8s.io/gengo/args"
|
||||
"k8s.io/gengo/examples/import-boss/generators"
|
||||
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
func main() {
|
||||
arguments := args.Default()
|
||||
|
||||
// Override defaults.
|
||||
arguments.GoHeaderFilePath = filepath.Join(args.DefaultSourceTree(), util.BoilerplatePath())
|
||||
arguments.InputDirs = []string{
|
||||
"k8s.io/kubernetes/pkg/...",
|
||||
"k8s.io/kubernetes/cmd/...",
|
||||
"k8s.io/kubernetes/plugin/...",
|
||||
}
|
||||
|
||||
if err := arguments.Execute(
|
||||
generators.NameSystems(),
|
||||
generators.DefaultNameSystem(),
|
||||
generators.Packages,
|
||||
); err != nil {
|
||||
glog.Errorf("Error: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
glog.V(2).Info("Completed successfully.")
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
set-gen
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["main.go"],
|
||||
importmap = "vendor/k8s.io/code-generator/cmd/set-gen",
|
||||
importpath = "k8s.io/code-generator/cmd/set-gen",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/code-generator/pkg/util:go_default_library",
|
||||
"//vendor/k8s.io/gengo/args:go_default_library",
|
||||
"//vendor/k8s.io/gengo/examples/set-gen/generators:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "set-gen",
|
||||
embed = [":go_default_library"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// set-gen is an example usage of gengo.
|
||||
//
|
||||
// Structs in the input directories with the below line in their comments will
|
||||
// have sets generated for them.
|
||||
// // +genset
|
||||
//
|
||||
// Any builtin type referenced anywhere in the input directories will have a
|
||||
// set generated for it.
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"k8s.io/code-generator/pkg/util"
|
||||
"k8s.io/gengo/args"
|
||||
"k8s.io/gengo/examples/set-gen/generators"
|
||||
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
func main() {
|
||||
arguments := args.Default()
|
||||
|
||||
// Override defaults.
|
||||
arguments.GoHeaderFilePath = filepath.Join(args.DefaultSourceTree(), util.BoilerplatePath())
|
||||
arguments.InputDirs = []string{"k8s.io/kubernetes/pkg/util/sets/types"}
|
||||
arguments.OutputPackagePath = "k8s.io/apimachinery/pkg/util/sets"
|
||||
|
||||
if err := arguments.Execute(
|
||||
generators.NameSystems(),
|
||||
generators.DefaultNameSystem(),
|
||||
generators.Packages,
|
||||
); err != nil {
|
||||
glog.Errorf("Error: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
glog.V(2).Info("Completed successfully.")
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"doc.go",
|
||||
"helpers.go",
|
||||
"register.go",
|
||||
"types.go",
|
||||
"zz_generated.deepcopy.go",
|
||||
],
|
||||
importmap = "vendor/k8s.io/kubernetes/pkg/apis/componentconfig",
|
||||
importpath = "k8s.io/kubernetes/pkg/apis/componentconfig",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/net:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["install.go"],
|
||||
importmap = "vendor/k8s.io/kubernetes/pkg/apis/componentconfig/install",
|
||||
importpath = "k8s.io/kubernetes/pkg/apis/componentconfig/install",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/apimachinery/announced:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apimachinery/registered:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/api/legacyscheme:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/apis/componentconfig:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"defaults.go",
|
||||
"doc.go",
|
||||
"register.go",
|
||||
"types.go",
|
||||
"zz_generated.conversion.go",
|
||||
"zz_generated.deepcopy.go",
|
||||
"zz_generated.defaults.go",
|
||||
],
|
||||
importmap = "vendor/k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1",
|
||||
importpath = "k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/apis/componentconfig:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/apis/core:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/kubelet/apis:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/master/ports:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["qos.go"],
|
||||
importmap = "vendor/k8s.io/kubernetes/pkg/apis/core/v1/helper/qos",
|
||||
importpath = "k8s.io/kubernetes/pkg/apis/core/v1/helper/qos",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/apis/core:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"daemon_controller.go",
|
||||
"doc.go",
|
||||
"update.go",
|
||||
],
|
||||
importmap = "vendor/k8s.io/kubernetes/pkg/controller/daemon",
|
||||
importpath = "k8s.io/kubernetes/pkg/controller/daemon",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/api/apps/v1:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/json:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/rand:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/apps/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/apps/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/apps/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/record:go_default_library",
|
||||
"//vendor/k8s.io/client-go/util/integer:go_default_library",
|
||||
"//vendor/k8s.io/client-go/util/workqueue:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/api/v1/pod:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/apis/core/v1/helper:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/controller:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/controller/daemon/util:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/features:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/kubelet/types:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/scheduler/algorithm:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/scheduler/algorithm/predicates:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/scheduler/schedulercache:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/util/labels:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/util/metrics:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["daemonset_util.go"],
|
||||
importmap = "vendor/k8s.io/kubernetes/pkg/controller/daemon/util",
|
||||
importpath = "k8s.io/kubernetes/pkg/controller/daemon/util",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/api/apps/v1:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/api/extensions/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/api/v1/pod:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/apis/core/v1/helper:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/features:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/kubelet/apis:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/kubelet/types:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/scheduler/algorithm:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["controller_history.go"],
|
||||
importmap = "vendor/k8s.io/kubernetes/pkg/controller/history",
|
||||
importpath = "k8s.io/kubernetes/pkg/controller/history",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/api/apps/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/rand:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/apps/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/apps/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
"//vendor/k8s.io/client-go/util/retry:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/util/hash:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"stateful_pod_control.go",
|
||||
"stateful_set.go",
|
||||
"stateful_set_control.go",
|
||||
"stateful_set_status_updater.go",
|
||||
"stateful_set_utils.go",
|
||||
],
|
||||
importmap = "vendor/k8s.io/kubernetes/pkg/controller/statefulset",
|
||||
importpath = "k8s.io/kubernetes/pkg/controller/statefulset",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/api/apps/v1:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/strategicpatch:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/apps/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/apps/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/record:go_default_library",
|
||||
"//vendor/k8s.io/client-go/util/retry:go_default_library",
|
||||
"//vendor/k8s.io/client-go/util/workqueue:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/api/v1/pod:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/controller:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/controller/history:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["event.go"],
|
||||
importmap = "vendor/k8s.io/kubernetes/pkg/controller/volume/events",
|
||||
importpath = "k8s.io/kubernetes/pkg/controller/volume/events",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"index.go",
|
||||
"pv_controller.go",
|
||||
"pv_controller_base.go",
|
||||
"scheduler_assume_cache.go",
|
||||
"scheduler_binder.go",
|
||||
"scheduler_binder_cache.go",
|
||||
"scheduler_binder_fake.go",
|
||||
"volume_host.go",
|
||||
],
|
||||
importmap = "vendor/k8s.io/kubernetes/pkg/controller/volume/persistentvolume",
|
||||
importpath = "k8s.io/kubernetes/pkg/controller/volume/persistentvolume",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/api/storage/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/storage/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/storage/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/record:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/reference:go_default_library",
|
||||
"//vendor/k8s.io/client-go/util/workqueue:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/apis/core/v1/helper:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/cloudprovider:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/controller:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/controller/volume/events:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/controller/volume/persistentvolume/metrics:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/features:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/util/goroutinemap:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/util/goroutinemap/exponentialbackoff:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/util/io:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/util/mount:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/volume:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/volume/util:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/volume/util/recyclerclient:go_default_library",
|
||||
],
|
||||
)
|
||||
14
vendor/k8s.io/kubernetes/pkg/controller/volume/persistentvolume/metrics/BUILD.bazel
generated
vendored
14
vendor/k8s.io/kubernetes/pkg/controller/volume/persistentvolume/metrics/BUILD.bazel
generated
vendored
|
|
@ -1,14 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["metrics.go"],
|
||||
importmap = "vendor/k8s.io/kubernetes/pkg/controller/volume/persistentvolume/metrics",
|
||||
importpath = "k8s.io/kubernetes/pkg/controller/volume/persistentvolume/metrics",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/github.com/prometheus/client_golang/prometheus:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["categories.go"],
|
||||
importmap = "vendor/k8s.io/kubernetes/pkg/kubectl/categories",
|
||||
importpath = "k8s.io/kubernetes/pkg/kubectl/categories",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/client-go/discovery:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["get.go"],
|
||||
importmap = "vendor/k8s.io/kubernetes/pkg/kubectl/cmd/resource",
|
||||
importpath = "k8s.io/kubernetes/pkg/kubectl/cmd/resource",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/github.com/spf13/cobra:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
|
||||
"//vendor/k8s.io/client-go/rest:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/apis/core:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/kubectl:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/kubectl/cmd/templates:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/kubectl/cmd/util:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/kubectl/cmd/util/openapi:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/kubectl/resource:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/kubectl/util/i18n:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/printers:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/util/interrupt:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"doc.go",
|
||||
"env_parse.go",
|
||||
"env_resolve.go",
|
||||
],
|
||||
importmap = "vendor/k8s.io/kubernetes/pkg/kubectl/cmd/util/env",
|
||||
importpath = "k8s.io/kubernetes/pkg/kubectl/cmd/util/env",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/api/v1/resource:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/fieldpath:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"env.go",
|
||||
"loader.go",
|
||||
"plugins.go",
|
||||
"runner.go",
|
||||
],
|
||||
importmap = "vendor/k8s.io/kubernetes/pkg/kubectl/plugins",
|
||||
importpath = "k8s.io/kubernetes/pkg/kubectl/plugins",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/github.com/ghodss/yaml:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/github.com/spf13/pflag:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/clientcmd:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"builder.go",
|
||||
"doc.go",
|
||||
"helper.go",
|
||||
"interfaces.go",
|
||||
"mapper.go",
|
||||
"result.go",
|
||||
"selector.go",
|
||||
"visitor.go",
|
||||
],
|
||||
importmap = "vendor/k8s.io/kubernetes/pkg/kubectl/resource",
|
||||
importpath = "k8s.io/kubernetes/pkg/kubectl/resource",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/golang.org/x/text/encoding/unicode:go_default_library",
|
||||
"//vendor/golang.org/x/text/transform:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/fields:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/yaml:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
|
||||
"//vendor/k8s.io/client-go/rest:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/kubectl/categories:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/kubectl/validation:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["crlf.go"],
|
||||
importmap = "vendor/k8s.io/kubernetes/pkg/kubectl/util/crlf",
|
||||
importpath = "k8s.io/kubernetes/pkg/kubectl/util/crlf",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["round_tripper.go"],
|
||||
importmap = "vendor/k8s.io/kubernetes/pkg/kubectl/util/transport",
|
||||
importpath = "k8s.io/kubernetes/pkg/kubectl/util/transport",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/github.com/gregjones/httpcache:go_default_library",
|
||||
"//vendor/github.com/gregjones/httpcache/diskcache:go_default_library",
|
||||
"//vendor/github.com/peterbourgon/diskv:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"error.go",
|
||||
"metadata.go",
|
||||
"predicates.go",
|
||||
"testing_helper.go",
|
||||
"utils.go",
|
||||
],
|
||||
importmap = "vendor/k8s.io/kubernetes/pkg/scheduler/algorithm/predicates",
|
||||
importpath = "k8s.io/kubernetes/pkg/scheduler/algorithm/predicates",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/api/storage/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/rand:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/storage/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/util/workqueue:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/apis/core/v1/helper:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/apis/core/v1/helper/qos:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/features:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/kubelet/apis:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/scheduler/algorithm:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/scheduler/algorithm/priorities/util:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/scheduler/schedulercache:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/scheduler/util:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/scheduler/volumebinder:go_default_library",
|
||||
"//vendor/k8s.io/kubernetes/pkg/volume/util:go_default_library",
|
||||
],
|
||||
)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue