Rainbond/db/model/gateway.go

116 lines
3.5 KiB
Go
Raw Normal View History

// RAINBOND, Application Management Platform
// Copyright (C) 2014-2017 Goodrain Co., Ltd.
// 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 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// 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, see <http://www.gnu.org/licenses/>.
package model
2018-11-23 20:39:34 +08:00
// TableName returns table name of Certificate
func (Certificate) TableName() string {
2018-11-19 15:17:44 +08:00
return "gateway_certificate"
}
// Certificate contains TLS information
type Certificate struct {
Model
2018-11-19 15:17:44 +08:00
UUID string `gorm:"column:uuid"`
CertificateName string `gorm:"column:certificate_name;size:128"`
Certificate string `gorm:"column:certificate;size:65535"`
PrivateKey string `gorm:"column:private_key;size:65535"`
}
2018-11-23 20:39:34 +08:00
// TableName returns table name of RuleExtension
func (RuleExtension) TableName() string {
2018-11-19 15:17:44 +08:00
return "gateway_rule_extension"
}
// RuleExtensionKey rule extension key
type RuleExtensionKey string
2018-11-23 20:39:34 +08:00
// HTTPToHTTPS forces http rewrite to https
2018-12-04 00:25:16 +08:00
var HTTPToHTTPS RuleExtensionKey = "httptohttps"
// LBType load balancer type
2018-12-04 00:25:16 +08:00
var LBType RuleExtensionKey = "lb-type"
// RuleExtension contains rule extensions for http rule or tcp rule
type RuleExtension struct {
Model
2018-11-21 15:04:03 +08:00
UUID string `gorm:"column:uuid"`
RuleID string `gorm:"column:rule_id"`
2018-11-22 09:34:00 +08:00
Key string `gorm:"column:key"`
2018-11-21 15:04:03 +08:00
Value string `gorm:"column:value"`
}
2018-11-23 20:39:34 +08:00
// LoadBalancerType load balancer type
type LoadBalancerType string
2018-11-23 20:39:34 +08:00
// RoundRobin round-robin load balancer type
var RoundRobin LoadBalancerType = "RoundRobin"
2018-11-23 20:39:34 +08:00
// ConsistenceHash consistence hash load balancer type
var ConsistenceHash LoadBalancerType = "ConsistentHash"
2018-11-23 20:39:34 +08:00
// TableName returns table name of HTTPRule
func (HTTPRule) TableName() string {
2018-11-19 15:17:44 +08:00
return "gateway_http_rule"
}
2018-11-23 20:39:34 +08:00
// HTTPRule contains http rule
type HTTPRule struct {
Model
UUID string `gorm:"column:uuid"`
ServiceID string `gorm:"column:service_id"`
ContainerPort int `gorm:"column:container_port"`
Domain string `gorm:"column:domain"`
Path string `gorm:"column:path"`
Header string `gorm:"column:header"`
Cookie string `gorm:"column:cookie"`
2018-12-04 17:11:15 +08:00
Weight int `gorm:"column:weight"`
IP string `gorm:"column:ip"`
CertificateID string `gorm:"column:certificate_id"`
}
2018-11-23 20:39:34 +08:00
// TableName returns table name of TCPRule
func (TCPRule) TableName() string {
2018-11-19 15:17:44 +08:00
return "gateway_tcp_rule"
}
2018-11-23 20:39:34 +08:00
// TCPRule contain stream rule
type TCPRule struct {
Model
UUID string `gorm:"column:uuid"`
ServiceID string `gorm:"column:service_id"`
ContainerPort int `gorm:"column:container_port"`
// external access ip
IP string `gorm:"column:ip"`
// external access port
Port int `gorm:"column:port"`
}
2018-12-18 15:48:42 +08:00
// GwRuleConfig describes a configuration of gateway rule.
type GwRuleConfig struct {
Model
RuleID string `gorm:"column:rule_id;size:32"`
Key string `gorm:"column:key"`
Value string `gorm:"column:value"`
}
// TableName -
func (GwRuleConfig) TableName() string {
return "gateway_rule_config"
}