2018-11-18 11:53:11 +08:00
|
|
|
// 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
|
2018-11-18 11:53:11 +08:00
|
|
|
func (Certificate) TableName() string {
|
2018-11-19 15:17:44 +08:00
|
|
|
return "gateway_certificate"
|
2018-11-18 11:53:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Certificate contains TLS information
|
|
|
|
type Certificate struct {
|
|
|
|
Model
|
2018-11-19 15:17:44 +08:00
|
|
|
UUID string `gorm:"column:uuid"`
|
2018-11-18 11:53:11 +08:00
|
|
|
CertificateName string `gorm:"column:certificate_name;size:128"`
|
2019-01-16 00:15:33 +08:00
|
|
|
Certificate string `gorm:"column:certificate;size:65535"`
|
|
|
|
PrivateKey string `gorm:"column:private_key;size:65535"`
|
2018-11-18 11:53:11 +08:00
|
|
|
}
|
|
|
|
|
2018-11-23 20:39:34 +08:00
|
|
|
// TableName returns table name of RuleExtension
|
2018-11-18 11:53:11 +08:00
|
|
|
func (RuleExtension) TableName() string {
|
2018-11-19 15:17:44 +08:00
|
|
|
return "gateway_rule_extension"
|
2018-11-18 11:53:11 +08:00
|
|
|
}
|
|
|
|
|
2018-11-23 20:15:38 +08:00
|
|
|
// RuleExtensionKey rule extension key
|
|
|
|
type RuleExtensionKey string
|
2018-11-18 11:53:11 +08:00
|
|
|
|
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"
|
2018-11-18 11:53:11 +08:00
|
|
|
|
2018-11-23 20:15:38 +08:00
|
|
|
// LBType load balancer type
|
2018-12-04 00:25:16 +08:00
|
|
|
var LBType RuleExtensionKey = "lb-type"
|
2018-11-23 20:15:38 +08:00
|
|
|
|
|
|
|
// RuleExtension contains rule extensions for http rule or tcp rule
|
2018-11-18 11:53:11 +08:00
|
|
|
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-18 11:53:11 +08:00
|
|
|
}
|
|
|
|
|
2018-11-23 20:39:34 +08:00
|
|
|
// LoadBalancerType load balancer type
|
2018-11-18 11:53:11 +08:00
|
|
|
type LoadBalancerType string
|
|
|
|
|
2018-11-23 20:39:34 +08:00
|
|
|
// RoundRobin round-robin load balancer type
|
|
|
|
var RoundRobin LoadBalancerType = "RoundRobin"
|
2018-11-18 11:53:11 +08:00
|
|
|
|
2018-11-23 20:39:34 +08:00
|
|
|
// ConsistenceHash consistence hash load balancer type
|
|
|
|
var ConsistenceHash LoadBalancerType = "ConsistentHash"
|
2018-11-18 11:53:11 +08:00
|
|
|
|
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-18 11:53:11 +08:00
|
|
|
}
|
|
|
|
|
2018-11-23 20:39:34 +08:00
|
|
|
// HTTPRule contains http rule
|
|
|
|
type HTTPRule struct {
|
2018-11-18 11:53:11 +08:00
|
|
|
Model
|
2018-11-22 14:33:29 +08:00
|
|
|
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"`
|
2018-11-22 14:33:29 +08:00
|
|
|
IP string `gorm:"column:ip"`
|
|
|
|
CertificateID string `gorm:"column:certificate_id"`
|
2018-11-18 11:53:11 +08:00
|
|
|
}
|
|
|
|
|
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-18 11:53:11 +08:00
|
|
|
}
|
|
|
|
|
2018-11-23 20:39:34 +08:00
|
|
|
// TCPRule contain stream rule
|
|
|
|
type TCPRule struct {
|
2018-11-18 11:53:11 +08:00
|
|
|
Model
|
2018-11-22 14:33:29 +08:00
|
|
|
UUID string `gorm:"column:uuid"`
|
|
|
|
ServiceID string `gorm:"column:service_id"`
|
|
|
|
ContainerPort int `gorm:"column:container_port"`
|
2018-11-23 20:15:38 +08:00
|
|
|
// external access ip
|
|
|
|
IP string `gorm:"column:ip"`
|
|
|
|
// external access port
|
|
|
|
Port int `gorm:"column:port"`
|
2018-11-18 11:53:11 +08:00
|
|
|
}
|
2018-12-18 15:48:42 +08:00
|
|
|
|
2019-03-11 01:07:10 +08:00
|
|
|
// GwRuleConfig describes a configuration of gateway rule.
|
|
|
|
type GwRuleConfig struct {
|
|
|
|
Model
|
2019-03-12 18:15:48 +08:00
|
|
|
RuleID string `gorm:"column:rule_id;size:32"`
|
|
|
|
Key string `gorm:"column:key"`
|
|
|
|
Value string `gorm:"column:value"`
|
2019-03-11 01:07:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// TableName -
|
|
|
|
func (GwRuleConfig) TableName() string {
|
|
|
|
return "gateway_rule_config"
|
|
|
|
}
|