mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-10-26 15:00:22 +08:00
Merge branch 'feature/namespaces' into develop
This commit is contained in:
201
LICENSE
Normal file
201
LICENSE
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
@@ -58,6 +58,52 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "pageSize",
|
||||||
|
"in": "query",
|
||||||
|
"required": false,
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "page",
|
||||||
|
"in": "query",
|
||||||
|
"required": false,
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "query",
|
||||||
|
"in": "query",
|
||||||
|
"required": false,
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"NamespaceService"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"post": {
|
||||||
|
"operationId": "CreateNamespace",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A successful response.",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/Namespace"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "body",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/Namespace"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"NamespaceService"
|
"NamespaceService"
|
||||||
]
|
]
|
||||||
@@ -1586,6 +1632,18 @@
|
|||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/definitions/Namespace"
|
"$ref": "#/definitions/Namespace"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"page": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int32"
|
||||||
|
},
|
||||||
|
"pages": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int32"
|
||||||
|
},
|
||||||
|
"totalCount": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int32"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import (
|
|||||||
context "context"
|
context "context"
|
||||||
fmt "fmt"
|
fmt "fmt"
|
||||||
proto "github.com/golang/protobuf/proto"
|
proto "github.com/golang/protobuf/proto"
|
||||||
empty "github.com/golang/protobuf/ptypes/empty"
|
|
||||||
_ "google.golang.org/genproto/googleapis/api/annotations"
|
_ "google.golang.org/genproto/googleapis/api/annotations"
|
||||||
grpc "google.golang.org/grpc"
|
grpc "google.golang.org/grpc"
|
||||||
codes "google.golang.org/grpc/codes"
|
codes "google.golang.org/grpc/codes"
|
||||||
@@ -26,9 +25,67 @@ var _ = math.Inf
|
|||||||
// proto package needs to be updated.
|
// proto package needs to be updated.
|
||||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||||
|
|
||||||
|
type ListNamespacesRequest struct {
|
||||||
|
PageSize int32 `protobuf:"varint,1,opt,name=pageSize,proto3" json:"pageSize,omitempty"`
|
||||||
|
Page int32 `protobuf:"varint,2,opt,name=page,proto3" json:"page,omitempty"`
|
||||||
|
Query string `protobuf:"bytes,3,opt,name=query,proto3" json:"query,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ListNamespacesRequest) Reset() { *m = ListNamespacesRequest{} }
|
||||||
|
func (m *ListNamespacesRequest) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*ListNamespacesRequest) ProtoMessage() {}
|
||||||
|
func (*ListNamespacesRequest) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_ecb1e126f615f5dd, []int{0}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ListNamespacesRequest) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_ListNamespacesRequest.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *ListNamespacesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_ListNamespacesRequest.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *ListNamespacesRequest) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_ListNamespacesRequest.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *ListNamespacesRequest) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_ListNamespacesRequest.Size(m)
|
||||||
|
}
|
||||||
|
func (m *ListNamespacesRequest) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_ListNamespacesRequest.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_ListNamespacesRequest proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *ListNamespacesRequest) GetPageSize() int32 {
|
||||||
|
if m != nil {
|
||||||
|
return m.PageSize
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ListNamespacesRequest) GetPage() int32 {
|
||||||
|
if m != nil {
|
||||||
|
return m.Page
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ListNamespacesRequest) GetQuery() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Query
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
type ListNamespacesResponse struct {
|
type ListNamespacesResponse struct {
|
||||||
Count int32 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"`
|
Count int32 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"`
|
||||||
Namespaces []*Namespace `protobuf:"bytes,2,rep,name=namespaces,proto3" json:"namespaces,omitempty"`
|
Namespaces []*Namespace `protobuf:"bytes,2,rep,name=namespaces,proto3" json:"namespaces,omitempty"`
|
||||||
|
Page int32 `protobuf:"varint,3,opt,name=page,proto3" json:"page,omitempty"`
|
||||||
|
Pages int32 `protobuf:"varint,4,opt,name=pages,proto3" json:"pages,omitempty"`
|
||||||
|
TotalCount int32 `protobuf:"varint,5,opt,name=totalCount,proto3" json:"totalCount,omitempty"`
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
XXX_unrecognized []byte `json:"-"`
|
XXX_unrecognized []byte `json:"-"`
|
||||||
XXX_sizecache int32 `json:"-"`
|
XXX_sizecache int32 `json:"-"`
|
||||||
@@ -38,7 +95,7 @@ func (m *ListNamespacesResponse) Reset() { *m = ListNamespacesResponse{}
|
|||||||
func (m *ListNamespacesResponse) String() string { return proto.CompactTextString(m) }
|
func (m *ListNamespacesResponse) String() string { return proto.CompactTextString(m) }
|
||||||
func (*ListNamespacesResponse) ProtoMessage() {}
|
func (*ListNamespacesResponse) ProtoMessage() {}
|
||||||
func (*ListNamespacesResponse) Descriptor() ([]byte, []int) {
|
func (*ListNamespacesResponse) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_ecb1e126f615f5dd, []int{0}
|
return fileDescriptor_ecb1e126f615f5dd, []int{1}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ListNamespacesResponse) XXX_Unmarshal(b []byte) error {
|
func (m *ListNamespacesResponse) XXX_Unmarshal(b []byte) error {
|
||||||
@@ -73,6 +130,66 @@ func (m *ListNamespacesResponse) GetNamespaces() []*Namespace {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *ListNamespacesResponse) GetPage() int32 {
|
||||||
|
if m != nil {
|
||||||
|
return m.Page
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ListNamespacesResponse) GetPages() int32 {
|
||||||
|
if m != nil {
|
||||||
|
return m.Pages
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ListNamespacesResponse) GetTotalCount() int32 {
|
||||||
|
if m != nil {
|
||||||
|
return m.TotalCount
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateNamespaceRequest struct {
|
||||||
|
Namespace *Namespace `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *CreateNamespaceRequest) Reset() { *m = CreateNamespaceRequest{} }
|
||||||
|
func (m *CreateNamespaceRequest) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*CreateNamespaceRequest) ProtoMessage() {}
|
||||||
|
func (*CreateNamespaceRequest) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_ecb1e126f615f5dd, []int{2}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *CreateNamespaceRequest) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_CreateNamespaceRequest.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *CreateNamespaceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_CreateNamespaceRequest.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *CreateNamespaceRequest) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_CreateNamespaceRequest.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *CreateNamespaceRequest) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_CreateNamespaceRequest.Size(m)
|
||||||
|
}
|
||||||
|
func (m *CreateNamespaceRequest) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_CreateNamespaceRequest.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_CreateNamespaceRequest proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *CreateNamespaceRequest) GetNamespace() *Namespace {
|
||||||
|
if m != nil {
|
||||||
|
return m.Namespace
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type Namespace struct {
|
type Namespace struct {
|
||||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
@@ -84,7 +201,7 @@ func (m *Namespace) Reset() { *m = Namespace{} }
|
|||||||
func (m *Namespace) String() string { return proto.CompactTextString(m) }
|
func (m *Namespace) String() string { return proto.CompactTextString(m) }
|
||||||
func (*Namespace) ProtoMessage() {}
|
func (*Namespace) ProtoMessage() {}
|
||||||
func (*Namespace) Descriptor() ([]byte, []int) {
|
func (*Namespace) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_ecb1e126f615f5dd, []int{1}
|
return fileDescriptor_ecb1e126f615f5dd, []int{3}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Namespace) XXX_Unmarshal(b []byte) error {
|
func (m *Namespace) XXX_Unmarshal(b []byte) error {
|
||||||
@@ -113,29 +230,38 @@ func (m *Namespace) GetName() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
proto.RegisterType((*ListNamespacesRequest)(nil), "api.ListNamespacesRequest")
|
||||||
proto.RegisterType((*ListNamespacesResponse)(nil), "api.ListNamespacesResponse")
|
proto.RegisterType((*ListNamespacesResponse)(nil), "api.ListNamespacesResponse")
|
||||||
|
proto.RegisterType((*CreateNamespaceRequest)(nil), "api.CreateNamespaceRequest")
|
||||||
proto.RegisterType((*Namespace)(nil), "api.Namespace")
|
proto.RegisterType((*Namespace)(nil), "api.Namespace")
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { proto.RegisterFile("namespace.proto", fileDescriptor_ecb1e126f615f5dd) }
|
func init() { proto.RegisterFile("namespace.proto", fileDescriptor_ecb1e126f615f5dd) }
|
||||||
|
|
||||||
var fileDescriptor_ecb1e126f615f5dd = []byte{
|
var fileDescriptor_ecb1e126f615f5dd = []byte{
|
||||||
// 238 bytes of a gzipped FileDescriptorProto
|
// 341 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xcf, 0x4b, 0xcc, 0x4d,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x52, 0xcb, 0x4a, 0xc3, 0x40,
|
||||||
0x2d, 0x2e, 0x48, 0x4c, 0x4e, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x4e, 0x2c, 0xc8,
|
0x14, 0x25, 0x4d, 0x2b, 0xe6, 0x0a, 0xad, 0x0c, 0x5a, 0x42, 0x14, 0x0d, 0x03, 0x42, 0x41, 0x49,
|
||||||
0x94, 0x92, 0x49, 0xcf, 0xcf, 0x4f, 0xcf, 0x49, 0xd5, 0x4f, 0x2c, 0xc8, 0xd4, 0x4f, 0xcc, 0xcb,
|
0x68, 0xdd, 0xb9, 0x2d, 0xb8, 0x12, 0x17, 0xe9, 0xda, 0xc5, 0xb4, 0x5c, 0xca, 0xd0, 0x9a, 0x99,
|
||||||
0xcb, 0x2f, 0x49, 0x2c, 0xc9, 0xcc, 0xcf, 0x2b, 0x86, 0x28, 0x91, 0x92, 0x86, 0xca, 0x82, 0x79,
|
0x66, 0xa6, 0x05, 0x5d, 0xfa, 0x0b, 0xfe, 0x84, 0xff, 0xe3, 0x2f, 0xb8, 0xf4, 0x23, 0x24, 0x37,
|
||||||
0x49, 0xa5, 0x69, 0xfa, 0xa9, 0xb9, 0x05, 0x25, 0x95, 0x10, 0x49, 0xa5, 0x38, 0x2e, 0x31, 0x9f,
|
0x75, 0xfa, 0x30, 0xae, 0x72, 0x9f, 0xe7, 0x9c, 0x7b, 0x26, 0xd0, 0xc9, 0xc5, 0x33, 0x1a, 0x2d,
|
||||||
0xcc, 0xe2, 0x12, 0x3f, 0x98, 0xb1, 0xc5, 0x41, 0xa9, 0xc5, 0x05, 0xf9, 0x79, 0xc5, 0xa9, 0x42,
|
0x26, 0x98, 0xe8, 0x42, 0x59, 0xc5, 0x7c, 0xa1, 0x65, 0x74, 0x3e, 0x55, 0x6a, 0x3a, 0xc7, 0x54,
|
||||||
0x22, 0x5c, 0xac, 0xc9, 0xf9, 0xa5, 0x79, 0x25, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xac, 0x41, 0x10,
|
0x68, 0x99, 0x8a, 0x3c, 0x57, 0x56, 0x58, 0xa9, 0x72, 0x53, 0x8d, 0xf0, 0x27, 0x38, 0x7d, 0x90,
|
||||||
0x8e, 0x90, 0x1e, 0x17, 0x17, 0xdc, 0x09, 0xc5, 0x12, 0x4c, 0x0a, 0xcc, 0x1a, 0xdc, 0x46, 0x7c,
|
0xc6, 0x3e, 0xfe, 0x6e, 0x9a, 0x0c, 0x17, 0x4b, 0x34, 0x96, 0x45, 0x70, 0xa8, 0xc5, 0x14, 0x47,
|
||||||
0x7a, 0x89, 0x05, 0x99, 0x7a, 0x70, 0x23, 0x82, 0x90, 0x54, 0x28, 0xc9, 0x73, 0x71, 0xc2, 0x25,
|
0xf2, 0x15, 0x43, 0x2f, 0xf6, 0x7a, 0xad, 0xcc, 0xe5, 0x8c, 0x41, 0xb3, 0x8c, 0xc3, 0x06, 0xd5,
|
||||||
0x84, 0x84, 0xb8, 0x58, 0x40, 0x52, 0x60, 0x13, 0x39, 0x83, 0xc0, 0x6c, 0xa3, 0x6a, 0x2e, 0x01,
|
0x29, 0x66, 0x27, 0xd0, 0x5a, 0x2c, 0xb1, 0x78, 0x09, 0xfd, 0xd8, 0xeb, 0x05, 0x59, 0x95, 0xf0,
|
||||||
0xb8, 0x82, 0xe0, 0xd4, 0xa2, 0xb2, 0xcc, 0xe4, 0x54, 0xa1, 0x74, 0x2e, 0x3e, 0x54, 0x47, 0x09,
|
0x0f, 0x0f, 0xba, 0xfb, 0xf8, 0x46, 0xab, 0xdc, 0xd0, 0xc2, 0x44, 0x2d, 0x73, 0xbb, 0x46, 0xaf,
|
||||||
0x89, 0xe9, 0x41, 0x3c, 0xa1, 0x07, 0xf3, 0x84, 0x9e, 0x2b, 0xc8, 0x13, 0x52, 0xd2, 0x60, 0xab,
|
0x12, 0x96, 0x00, 0xb8, 0x2b, 0x4c, 0xd8, 0x88, 0xfd, 0xde, 0xd1, 0xa0, 0x9d, 0x08, 0x2d, 0x13,
|
||||||
0xb1, 0xfb, 0x40, 0x49, 0xa1, 0xe9, 0xf2, 0x93, 0xc9, 0x4c, 0x52, 0x42, 0x12, 0xa0, 0x80, 0x29,
|
0x07, 0x91, 0x6d, 0x4d, 0x38, 0x29, 0xfe, 0xae, 0x94, 0xf2, 0x6b, 0xc2, 0x66, 0x85, 0x4c, 0x09,
|
||||||
0xd6, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x47, 0xb8, 0x2e, 0x89, 0x0d, 0x6c, 0x9c,
|
0xbb, 0x00, 0xb0, 0xca, 0x8a, 0xf9, 0x90, 0x48, 0x5b, 0xd4, 0xda, 0xaa, 0xf0, 0x7b, 0xe8, 0x0e,
|
||||||
0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xb5, 0xa6, 0xf4, 0xfe, 0x57, 0x01, 0x00, 0x00,
|
0x0b, 0x14, 0x16, 0x37, 0x44, 0x6b, 0x2b, 0x6e, 0x20, 0x70, 0x8c, 0xa4, 0xf6, 0xaf, 0xa4, 0xcd,
|
||||||
|
0x00, 0xbf, 0x84, 0xc0, 0xd5, 0x4b, 0x79, 0x65, 0x87, 0xb6, 0x82, 0x8c, 0xe2, 0xc1, 0xb7, 0x07,
|
||||||
|
0xc7, 0x6e, 0x62, 0x84, 0xc5, 0x4a, 0x4e, 0x90, 0xcd, 0xa0, 0xbd, 0xeb, 0x13, 0x8b, 0x88, 0xa2,
|
||||||
|
0xf6, 0x71, 0xa2, 0xb3, 0xda, 0x5e, 0x65, 0x2c, 0x8f, 0xdf, 0x3e, 0xbf, 0xde, 0x1b, 0x11, 0x0b,
|
||||||
|
0xcb, 0x27, 0x37, 0xe9, 0xaa, 0x3f, 0x46, 0x2b, 0xfa, 0xe9, 0x96, 0x69, 0x33, 0xe8, 0xec, 0x9d,
|
||||||
|
0xca, 0x2a, 0xc4, 0x7a, 0x03, 0xa2, 0xbd, 0x6b, 0xf9, 0x35, 0x31, 0x5c, 0xf1, 0x7f, 0x19, 0xee,
|
||||||
|
0x36, 0x7e, 0x8c, 0x0f, 0xe8, 0x47, 0xbb, 0xfd, 0x09, 0x00, 0x00, 0xff, 0xff, 0x92, 0x90, 0x1e,
|
||||||
|
0xf0, 0x9e, 0x02, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
@@ -150,7 +276,8 @@ const _ = grpc.SupportPackageIsVersion4
|
|||||||
//
|
//
|
||||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
|
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
|
||||||
type NamespaceServiceClient interface {
|
type NamespaceServiceClient interface {
|
||||||
ListNamespaces(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*ListNamespacesResponse, error)
|
ListNamespaces(ctx context.Context, in *ListNamespacesRequest, opts ...grpc.CallOption) (*ListNamespacesResponse, error)
|
||||||
|
CreateNamespace(ctx context.Context, in *CreateNamespaceRequest, opts ...grpc.CallOption) (*Namespace, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type namespaceServiceClient struct {
|
type namespaceServiceClient struct {
|
||||||
@@ -161,7 +288,7 @@ func NewNamespaceServiceClient(cc *grpc.ClientConn) NamespaceServiceClient {
|
|||||||
return &namespaceServiceClient{cc}
|
return &namespaceServiceClient{cc}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *namespaceServiceClient) ListNamespaces(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*ListNamespacesResponse, error) {
|
func (c *namespaceServiceClient) ListNamespaces(ctx context.Context, in *ListNamespacesRequest, opts ...grpc.CallOption) (*ListNamespacesResponse, error) {
|
||||||
out := new(ListNamespacesResponse)
|
out := new(ListNamespacesResponse)
|
||||||
err := c.cc.Invoke(ctx, "/api.NamespaceService/ListNamespaces", in, out, opts...)
|
err := c.cc.Invoke(ctx, "/api.NamespaceService/ListNamespaces", in, out, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -170,25 +297,38 @@ func (c *namespaceServiceClient) ListNamespaces(ctx context.Context, in *empty.E
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *namespaceServiceClient) CreateNamespace(ctx context.Context, in *CreateNamespaceRequest, opts ...grpc.CallOption) (*Namespace, error) {
|
||||||
|
out := new(Namespace)
|
||||||
|
err := c.cc.Invoke(ctx, "/api.NamespaceService/CreateNamespace", in, out, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
// NamespaceServiceServer is the server API for NamespaceService service.
|
// NamespaceServiceServer is the server API for NamespaceService service.
|
||||||
type NamespaceServiceServer interface {
|
type NamespaceServiceServer interface {
|
||||||
ListNamespaces(context.Context, *empty.Empty) (*ListNamespacesResponse, error)
|
ListNamespaces(context.Context, *ListNamespacesRequest) (*ListNamespacesResponse, error)
|
||||||
|
CreateNamespace(context.Context, *CreateNamespaceRequest) (*Namespace, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnimplementedNamespaceServiceServer can be embedded to have forward compatible implementations.
|
// UnimplementedNamespaceServiceServer can be embedded to have forward compatible implementations.
|
||||||
type UnimplementedNamespaceServiceServer struct {
|
type UnimplementedNamespaceServiceServer struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*UnimplementedNamespaceServiceServer) ListNamespaces(ctx context.Context, req *empty.Empty) (*ListNamespacesResponse, error) {
|
func (*UnimplementedNamespaceServiceServer) ListNamespaces(ctx context.Context, req *ListNamespacesRequest) (*ListNamespacesResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method ListNamespaces not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method ListNamespaces not implemented")
|
||||||
}
|
}
|
||||||
|
func (*UnimplementedNamespaceServiceServer) CreateNamespace(ctx context.Context, req *CreateNamespaceRequest) (*Namespace, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method CreateNamespace not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
func RegisterNamespaceServiceServer(s *grpc.Server, srv NamespaceServiceServer) {
|
func RegisterNamespaceServiceServer(s *grpc.Server, srv NamespaceServiceServer) {
|
||||||
s.RegisterService(&_NamespaceService_serviceDesc, srv)
|
s.RegisterService(&_NamespaceService_serviceDesc, srv)
|
||||||
}
|
}
|
||||||
|
|
||||||
func _NamespaceService_ListNamespaces_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
func _NamespaceService_ListNamespaces_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
in := new(empty.Empty)
|
in := new(ListNamespacesRequest)
|
||||||
if err := dec(in); err != nil {
|
if err := dec(in); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -200,7 +340,25 @@ func _NamespaceService_ListNamespaces_Handler(srv interface{}, ctx context.Conte
|
|||||||
FullMethod: "/api.NamespaceService/ListNamespaces",
|
FullMethod: "/api.NamespaceService/ListNamespaces",
|
||||||
}
|
}
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
return srv.(NamespaceServiceServer).ListNamespaces(ctx, req.(*empty.Empty))
|
return srv.(NamespaceServiceServer).ListNamespaces(ctx, req.(*ListNamespacesRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _NamespaceService_CreateNamespace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(CreateNamespaceRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(NamespaceServiceServer).CreateNamespace(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: "/api.NamespaceService/CreateNamespace",
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(NamespaceServiceServer).CreateNamespace(ctx, req.(*CreateNamespaceRequest))
|
||||||
}
|
}
|
||||||
return interceptor(ctx, in, info, handler)
|
return interceptor(ctx, in, info, handler)
|
||||||
}
|
}
|
||||||
@@ -213,6 +371,10 @@ var _NamespaceService_serviceDesc = grpc.ServiceDesc{
|
|||||||
MethodName: "ListNamespaces",
|
MethodName: "ListNamespaces",
|
||||||
Handler: _NamespaceService_ListNamespaces_Handler,
|
Handler: _NamespaceService_ListNamespaces_Handler,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
MethodName: "CreateNamespace",
|
||||||
|
Handler: _NamespaceService_CreateNamespace_Handler,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Streams: []grpc.StreamDesc{},
|
Streams: []grpc.StreamDesc{},
|
||||||
Metadata: "namespace.proto",
|
Metadata: "namespace.proto",
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import (
|
|||||||
|
|
||||||
"github.com/golang/protobuf/descriptor"
|
"github.com/golang/protobuf/descriptor"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
"github.com/golang/protobuf/ptypes/empty"
|
|
||||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||||
"github.com/grpc-ecosystem/grpc-gateway/utilities"
|
"github.com/grpc-ecosystem/grpc-gateway/utilities"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
@@ -32,24 +31,73 @@ var _ = runtime.String
|
|||||||
var _ = utilities.NewDoubleArray
|
var _ = utilities.NewDoubleArray
|
||||||
var _ = descriptor.ForMessage
|
var _ = descriptor.ForMessage
|
||||||
|
|
||||||
|
var (
|
||||||
|
filter_NamespaceService_ListNamespaces_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||||
|
)
|
||||||
|
|
||||||
func request_NamespaceService_ListNamespaces_0(ctx context.Context, marshaler runtime.Marshaler, client NamespaceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
func request_NamespaceService_ListNamespaces_0(ctx context.Context, marshaler runtime.Marshaler, client NamespaceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
var protoReq empty.Empty
|
var protoReq ListNamespacesRequest
|
||||||
var metadata runtime.ServerMetadata
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
if err := req.ParseForm(); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_NamespaceService_ListNamespaces_0); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
msg, err := client.ListNamespaces(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
msg, err := client.ListNamespaces(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
return msg, metadata, err
|
return msg, metadata, err
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func local_request_NamespaceService_ListNamespaces_0(ctx context.Context, marshaler runtime.Marshaler, server NamespaceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
func local_request_NamespaceService_ListNamespaces_0(ctx context.Context, marshaler runtime.Marshaler, server NamespaceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
var protoReq empty.Empty
|
var protoReq ListNamespacesRequest
|
||||||
var metadata runtime.ServerMetadata
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_NamespaceService_ListNamespaces_0); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
msg, err := server.ListNamespaces(ctx, &protoReq)
|
msg, err := server.ListNamespaces(ctx, &protoReq)
|
||||||
return msg, metadata, err
|
return msg, metadata, err
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func request_NamespaceService_CreateNamespace_0(ctx context.Context, marshaler runtime.Marshaler, client NamespaceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq CreateNamespaceRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||||
|
if berr != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||||
|
}
|
||||||
|
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Namespace); err != nil && err != io.EOF {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := client.CreateNamespace(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func local_request_NamespaceService_CreateNamespace_0(ctx context.Context, marshaler runtime.Marshaler, server NamespaceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq CreateNamespaceRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||||
|
if berr != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||||
|
}
|
||||||
|
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Namespace); err != nil && err != io.EOF {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := server.CreateNamespace(ctx, &protoReq)
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// RegisterNamespaceServiceHandlerServer registers the http handlers for service NamespaceService to "mux".
|
// RegisterNamespaceServiceHandlerServer registers the http handlers for service NamespaceService to "mux".
|
||||||
// UnaryRPC :call NamespaceServiceServer directly.
|
// UnaryRPC :call NamespaceServiceServer directly.
|
||||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||||
@@ -75,6 +123,26 @@ func RegisterNamespaceServiceHandlerServer(ctx context.Context, mux *runtime.Ser
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
mux.Handle("POST", pattern_NamespaceService_CreateNamespace_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := local_request_NamespaceService_CreateNamespace_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||||
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_NamespaceService_CreateNamespace_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,13 +204,37 @@ func RegisterNamespaceServiceHandlerClient(ctx context.Context, mux *runtime.Ser
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
mux.Handle("POST", pattern_NamespaceService_CreateNamespace_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := request_NamespaceService_CreateNamespace_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||||
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_NamespaceService_CreateNamespace_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
pattern_NamespaceService_ListNamespaces_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"apis", "v1beta1", "namespaces"}, "", runtime.AssumeColonVerbOpt(true)))
|
pattern_NamespaceService_ListNamespaces_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"apis", "v1beta1", "namespaces"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||||
|
|
||||||
|
pattern_NamespaceService_CreateNamespace_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"apis", "v1beta1", "namespaces"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
forward_NamespaceService_ListNamespaces_0 = runtime.ForwardResponseMessage
|
forward_NamespaceService_ListNamespaces_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
|
forward_NamespaceService_CreateNamespace_0 = runtime.ForwardResponseMessage
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,19 +3,38 @@ syntax = "proto3";
|
|||||||
package api;
|
package api;
|
||||||
|
|
||||||
import "google/api/annotations.proto";
|
import "google/api/annotations.proto";
|
||||||
import "google/protobuf/empty.proto";
|
|
||||||
|
|
||||||
service NamespaceService {
|
service NamespaceService {
|
||||||
rpc ListNamespaces(google.protobuf.Empty) returns (ListNamespacesResponse) {
|
rpc ListNamespaces(ListNamespacesRequest) returns (ListNamespacesResponse) {
|
||||||
option (google.api.http) = {
|
option (google.api.http) = {
|
||||||
get: "/apis/v1beta1/namespaces"
|
get: "/apis/v1beta1/namespaces"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpc CreateNamespace(CreateNamespaceRequest) returns (Namespace) {
|
||||||
|
option (google.api.http) = {
|
||||||
|
post: "/apis/v1beta1/namespaces"
|
||||||
|
body: "namespace"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message ListNamespacesRequest {
|
||||||
|
int32 pageSize = 1;
|
||||||
|
int32 page = 2;
|
||||||
|
string query = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ListNamespacesResponse {
|
message ListNamespacesResponse {
|
||||||
int32 count = 1;
|
int32 count = 1;
|
||||||
repeated Namespace namespaces = 2;
|
repeated Namespace namespaces = 2;
|
||||||
|
int32 page = 3;
|
||||||
|
int32 pages = 4;
|
||||||
|
int32 totalCount = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
message CreateNamespaceRequest {
|
||||||
|
Namespace namespace = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Namespace {
|
message Namespace {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package v1
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
v1 "k8s.io/api/core/v1"
|
||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
)
|
)
|
||||||
@@ -43,3 +44,26 @@ func (c *Client) ListNamespaces() (namespaces []*Namespace, err error) {
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Client) CreateNamespace(name string) (namespace *Namespace, err error) {
|
||||||
|
createNamespace := &v1.Namespace{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: name,
|
||||||
|
Labels: map[string]string{
|
||||||
|
"istio-injection": "enabled",
|
||||||
|
onepanelEnabledLabelKey: "true",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
k8Namespace, err := c.CoreV1().Namespaces().Create(createNamespace)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace = &Namespace{
|
||||||
|
Name: k8Namespace.Name,
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ func (c *Client) injectAutomatedFields(namespace string, wf *wfv1.Workflow, opts
|
|||||||
if sysErr != nil {
|
if sysErr != nil {
|
||||||
return sysErr
|
return sysErr
|
||||||
}
|
}
|
||||||
|
|
||||||
addEnvToTemplate(&template, "ONEPANEL_API_URL", sysConfig["ONEPANEL_API_URL"])
|
addEnvToTemplate(&template, "ONEPANEL_API_URL", sysConfig["ONEPANEL_API_URL"])
|
||||||
addEnvToTemplate(&template, "PROVIDER_TYPE", sysConfig["PROVIDER_TYPE"])
|
addEnvToTemplate(&template, "PROVIDER_TYPE", sysConfig["PROVIDER_TYPE"])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ package server
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"math"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/golang/protobuf/ptypes/empty"
|
|
||||||
"github.com/onepanelio/core/api"
|
"github.com/onepanelio/core/api"
|
||||||
v1 "github.com/onepanelio/core/pkg"
|
v1 "github.com/onepanelio/core/pkg"
|
||||||
"github.com/onepanelio/core/server/auth"
|
"github.com/onepanelio/core/server/auth"
|
||||||
@@ -23,25 +24,66 @@ func apiNamespace(ns *v1.Namespace) (namespace *api.Namespace) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *NamespaceServer) ListNamespaces(ctx context.Context, empty *empty.Empty) (*api.ListNamespacesResponse, error) {
|
func (s *NamespaceServer) ListNamespaces(ctx context.Context, req *api.ListNamespacesRequest) (*api.ListNamespacesResponse, error) {
|
||||||
client := ctx.Value("kubeClient").(*v1.Client)
|
client := ctx.Value("kubeClient").(*v1.Client)
|
||||||
allowed, err := auth.IsAuthorized(client, "", "list", "", "namespaces", "")
|
allowed, err := auth.IsAuthorized(client, "", "list", "", "namespaces", "")
|
||||||
if err != nil || !allowed {
|
if err != nil || !allowed {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if req.PageSize <= 0 {
|
||||||
|
req.PageSize = 15
|
||||||
|
}
|
||||||
|
|
||||||
namespaces, err := client.ListNamespaces()
|
namespaces, err := client.ListNamespaces()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
apiNamespaces := []*api.Namespace{}
|
var apiNamespaces []*api.Namespace
|
||||||
for _, ns := range namespaces {
|
for _, ns := range namespaces {
|
||||||
|
if req.Query == "" || (req.Query != "" && strings.Contains(ns.Name, req.Query)) {
|
||||||
apiNamespaces = append(apiNamespaces, apiNamespace(ns))
|
apiNamespaces = append(apiNamespaces, apiNamespace(ns))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pages := int32(math.Ceil(float64(len(apiNamespaces)) / float64(req.PageSize)))
|
||||||
|
if req.Page > pages {
|
||||||
|
req.Page = pages
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.Page <= 0 {
|
||||||
|
req.Page = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
start := (req.Page - 1) * req.PageSize
|
||||||
|
end := start + req.PageSize
|
||||||
|
if end >= int32(len(apiNamespaces)) {
|
||||||
|
end = int32(len(apiNamespaces))
|
||||||
|
}
|
||||||
|
|
||||||
return &api.ListNamespacesResponse{
|
return &api.ListNamespacesResponse{
|
||||||
Count: int32(len(apiNamespaces)),
|
Count: end - start,
|
||||||
Namespaces: apiNamespaces,
|
Namespaces: apiNamespaces[start:end],
|
||||||
|
Page: req.Page,
|
||||||
|
Pages: pages,
|
||||||
|
TotalCount: int32(len(apiNamespaces)),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *NamespaceServer) CreateNamespace(ctx context.Context, createNamespace *api.CreateNamespaceRequest) (*api.Namespace, error) {
|
||||||
|
client := ctx.Value("kubeClient").(*v1.Client)
|
||||||
|
allowed, err := auth.IsAuthorized(client, "", "create", "", "namespaces", "")
|
||||||
|
if err != nil || !allowed {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace, err := client.CreateNamespace(createNamespace.Namespace.Name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &api.Namespace{
|
||||||
|
Name: namespace.Name,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user