1
0
mirror of https://github.com/rancher/types.git synced 2025-05-08 23:26:19 +00:00

go generate

This commit is contained in:
gitlawr 2019-10-10 10:37:20 +08:00 committed by Alena Prokharchyk
parent 94267a93a7
commit b554d6ed66
7 changed files with 180 additions and 0 deletions

View File

@ -49,6 +49,7 @@ type Client struct {
HorizontalPodAutoscaler HorizontalPodAutoscalerOperations
VirtualService VirtualServiceOperations
DestinationRule DestinationRuleOperations
Gateway GatewayOperations
}
func NewClient(opts *clientbase.ClientOpts) (*Client, error) {
@ -103,6 +104,7 @@ func NewClient(opts *clientbase.ClientOpts) (*Client, error) {
client.HorizontalPodAutoscaler = newHorizontalPodAutoscalerClient(client)
client.VirtualService = newVirtualServiceClient(client)
client.DestinationRule = newDestinationRuleClient(client)
client.Gateway = newGatewayClient(client)
return client, nil
}

View File

@ -0,0 +1,115 @@
package client
import (
"github.com/rancher/norman/types"
)
const (
GatewayType = "gateway"
GatewayFieldAnnotations = "annotations"
GatewayFieldCreated = "created"
GatewayFieldCreatorID = "creatorId"
GatewayFieldLabels = "labels"
GatewayFieldName = "name"
GatewayFieldNamespaceId = "namespaceId"
GatewayFieldOwnerReferences = "ownerReferences"
GatewayFieldProjectID = "projectId"
GatewayFieldRemoved = "removed"
GatewayFieldSelector = "selector"
GatewayFieldServers = "servers"
GatewayFieldState = "state"
GatewayFieldStatus = "status"
GatewayFieldTransitioning = "transitioning"
GatewayFieldTransitioningMessage = "transitioningMessage"
GatewayFieldUUID = "uuid"
)
type Gateway struct {
types.Resource
Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
CreatorID string `json:"creatorId,omitempty" yaml:"creatorId,omitempty"`
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
NamespaceId string `json:"namespaceId,omitempty" yaml:"namespaceId,omitempty"`
OwnerReferences []OwnerReference `json:"ownerReferences,omitempty" yaml:"ownerReferences,omitempty"`
ProjectID string `json:"projectId,omitempty" yaml:"projectId,omitempty"`
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
Selector map[string]string `json:"selector,omitempty" yaml:"selector,omitempty"`
Servers []Server `json:"servers,omitempty" yaml:"servers,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
Status interface{} `json:"status,omitempty" yaml:"status,omitempty"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioningMessage,omitempty"`
UUID string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type GatewayCollection struct {
types.Collection
Data []Gateway `json:"data,omitempty"`
client *GatewayClient
}
type GatewayClient struct {
apiClient *Client
}
type GatewayOperations interface {
List(opts *types.ListOpts) (*GatewayCollection, error)
Create(opts *Gateway) (*Gateway, error)
Update(existing *Gateway, updates interface{}) (*Gateway, error)
Replace(existing *Gateway) (*Gateway, error)
ByID(id string) (*Gateway, error)
Delete(container *Gateway) error
}
func newGatewayClient(apiClient *Client) *GatewayClient {
return &GatewayClient{
apiClient: apiClient,
}
}
func (c *GatewayClient) Create(container *Gateway) (*Gateway, error) {
resp := &Gateway{}
err := c.apiClient.Ops.DoCreate(GatewayType, container, resp)
return resp, err
}
func (c *GatewayClient) Update(existing *Gateway, updates interface{}) (*Gateway, error) {
resp := &Gateway{}
err := c.apiClient.Ops.DoUpdate(GatewayType, &existing.Resource, updates, resp)
return resp, err
}
func (c *GatewayClient) Replace(obj *Gateway) (*Gateway, error) {
resp := &Gateway{}
err := c.apiClient.Ops.DoReplace(GatewayType, &obj.Resource, obj, resp)
return resp, err
}
func (c *GatewayClient) List(opts *types.ListOpts) (*GatewayCollection, error) {
resp := &GatewayCollection{}
err := c.apiClient.Ops.DoList(GatewayType, opts, resp)
resp.client = c
return resp, err
}
func (cc *GatewayCollection) Next() (*GatewayCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &GatewayCollection{}
err := cc.client.apiClient.Ops.DoNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *GatewayClient) ByID(id string) (*Gateway, error) {
resp := &Gateway{}
err := c.apiClient.Ops.DoByID(GatewayType, id, resp)
return resp, err
}
func (c *GatewayClient) Delete(container *Gateway) error {
return c.apiClient.Ops.DoResourceDelete(GatewayType, &container.Resource)
}

View File

@ -0,0 +1,12 @@
package client
const (
GatewaySpecType = "gatewaySpec"
GatewaySpecFieldSelector = "selector"
GatewaySpecFieldServers = "servers"
)
type GatewaySpec struct {
Selector map[string]string `json:"selector,omitempty" yaml:"selector,omitempty"`
Servers []Server `json:"servers,omitempty" yaml:"servers,omitempty"`
}

View File

@ -0,0 +1,14 @@
package client
const (
PortType = "port"
PortFieldName = "name"
PortFieldNumber = "number"
PortFieldProtocol = "protocol"
)
type Port struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Number int64 `json:"number,omitempty" yaml:"number,omitempty"`
Protocol string `json:"protocol,omitempty" yaml:"protocol,omitempty"`
}

View File

@ -0,0 +1,14 @@
package client
const (
ServerType = "server"
ServerFieldHosts = "hosts"
ServerFieldPort = "port"
ServerFieldTLS = "tls"
)
type Server struct {
Hosts []string `json:"hosts,omitempty" yaml:"hosts,omitempty"`
Port *Port `json:"port,omitempty" yaml:"port,omitempty"`
TLS *TLSOptions `json:"tls,omitempty" yaml:"tls,omitempty"`
}

View File

@ -0,0 +1,22 @@
package client
const (
TLSOptionsType = "tlsOptions"
TLSOptionsFieldCaCertificates = "caCertificates"
TLSOptionsFieldCredentialName = "credentialName"
TLSOptionsFieldHTTPSRedirect = "httpsRedirect"
TLSOptionsFieldMode = "mode"
TLSOptionsFieldPrivateKey = "privateKey"
TLSOptionsFieldServerCertificate = "serverCertificate"
TLSOptionsFieldSubjectAltNames = "subjectAltNames"
)
type TLSOptions struct {
CaCertificates string `json:"caCertificates,omitempty" yaml:"caCertificates,omitempty"`
CredentialName string `json:"credentialName,omitempty" yaml:"credentialName,omitempty"`
HTTPSRedirect bool `json:"httpsRedirect,omitempty" yaml:"httpsRedirect,omitempty"`
Mode string `json:"mode,omitempty" yaml:"mode,omitempty"`
PrivateKey string `json:"privateKey,omitempty" yaml:"privateKey,omitempty"`
ServerCertificate string `json:"serverCertificate,omitempty" yaml:"serverCertificate,omitempty"`
SubjectAltNames []string `json:"subjectAltNames,omitempty" yaml:"subjectAltNames,omitempty"`
}

View File

@ -117,4 +117,5 @@ type Config struct {
HorizontalPodAutoscalers map[string]projectClient.HorizontalPodAutoscaler `json:"horizontalPodAutoscalers,omitempty" yaml:"horizontalPodAutoscalers,omitempty"`
VirtualServices map[string]projectClient.VirtualService `json:"virtualServices,omitempty" yaml:"virtualServices,omitempty"`
DestinationRules map[string]projectClient.DestinationRule `json:"destinationRules,omitempty" yaml:"destinationRules,omitempty"`
Gateways map[string]projectClient.Gateway `json:"gateways,omitempty" yaml:"gateways,omitempty"`
}