mirror of
https://github.com/rancher/rke.git
synced 2025-08-31 14:36:32 +00:00
Merge pull request #56 from galal-hussein/config_changes
RKE host structure and config changes
This commit is contained in:
16
cluster.yml
16
cluster.yml
@@ -14,18 +14,18 @@ network:
|
|||||||
options:
|
options:
|
||||||
foo: bar
|
foo: bar
|
||||||
|
|
||||||
hosts:
|
nodes:
|
||||||
- advertised_hostname: server1
|
- address: 1.1.1.1
|
||||||
ip: 1.1.1.1
|
|
||||||
user: ubuntu
|
user: ubuntu
|
||||||
role: [controlplane, etcd]
|
role: [controlplane, etcd]
|
||||||
docker_socket: /var/run/docker.sock
|
- address: 2.2.2.2
|
||||||
advertise_address: 10.1.1.1
|
|
||||||
- advertised_hostname: server2
|
|
||||||
ip: 2.2.2.2
|
|
||||||
user: ubuntu
|
user: ubuntu
|
||||||
role: [worker]
|
role: [worker]
|
||||||
advertise_address: 10.2.2.2
|
- address: example.com
|
||||||
|
user: ubuntu
|
||||||
|
role: [worker]
|
||||||
|
hostname_override: node3
|
||||||
|
internal_address: 192.168.1.6
|
||||||
|
|
||||||
services:
|
services:
|
||||||
etcd:
|
etcd:
|
||||||
|
@@ -56,7 +56,7 @@ func (c *Cluster) doAddonDeploy(addonYaml, resourceName string) error {
|
|||||||
|
|
||||||
logrus.Infof("[addons] Executing deploy job..")
|
logrus.Infof("[addons] Executing deploy job..")
|
||||||
|
|
||||||
addonJob := addons.GetAddonsExcuteJob(resourceName, c.ControlPlaneHosts[0].AdvertisedHostname, c.Services.KubeAPI.Image)
|
addonJob := addons.GetAddonsExcuteJob(resourceName, c.ControlPlaneHosts[0].HostnameOverride, c.Services.KubeAPI.Image)
|
||||||
err = c.ApplySystemAddonExcuteJob(addonJob)
|
err = c.ApplySystemAddonExcuteJob(addonJob)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Failed to deploy addon execute job: %v", err)
|
return fmt.Errorf("Failed to deploy addon execute job: %v", err)
|
||||||
|
@@ -35,6 +35,13 @@ type Cluster struct {
|
|||||||
const (
|
const (
|
||||||
X509AuthenticationProvider = "x509"
|
X509AuthenticationProvider = "x509"
|
||||||
DefaultClusterConfig = "cluster.yml"
|
DefaultClusterConfig = "cluster.yml"
|
||||||
|
DefaultServiceClusterIPRange = "10.233.0.0/18"
|
||||||
|
DefaultClusterCIDR = "10.233.64.0/18"
|
||||||
|
DefaultClusterDNSService = "10.233.0.3"
|
||||||
|
DefaultClusterDomain = "cluster.local"
|
||||||
|
DefaultInfraContainerImage = "gcr.io/google_containers/pause-amd64:3.0"
|
||||||
|
DefaultAuthStrategy = "x509"
|
||||||
|
DefaultNetworkPlugin = "flannel"
|
||||||
StateConfigMapName = "cluster-state"
|
StateConfigMapName = "cluster-state"
|
||||||
UpdateStateTimeout = 30
|
UpdateStateTimeout = 30
|
||||||
GetStateTimeout = 30
|
GetStateTimeout = 30
|
||||||
@@ -96,28 +103,48 @@ func parseClusterFile(clusterFile string) (*Cluster, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for i, host := range kubeCluster.Hosts {
|
// Setting cluster Defaults
|
||||||
if len(host.AdvertisedHostname) == 0 {
|
kubeCluster.setClusterDefaults()
|
||||||
return nil, fmt.Errorf("Hostname for host (%d) is not provided", i+1)
|
|
||||||
} else if len(host.User) == 0 {
|
|
||||||
return nil, fmt.Errorf("User for host (%d) is not provided", i+1)
|
|
||||||
} else if len(host.Role) == 0 {
|
|
||||||
return nil, fmt.Errorf("Role for host (%d) is not provided", i+1)
|
|
||||||
|
|
||||||
} else if host.AdvertiseAddress == "" {
|
|
||||||
// if control_plane_ip is not set,
|
|
||||||
// default to the main IP
|
|
||||||
kubeCluster.Hosts[i].AdvertiseAddress = host.IP
|
|
||||||
}
|
|
||||||
for _, role := range host.Role {
|
|
||||||
if role != services.ETCDRole && role != services.ControlRole && role != services.WorkerRole {
|
|
||||||
return nil, fmt.Errorf("Role [%s] for host (%d) is not recognized", role, i+1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return &kubeCluster, nil
|
return &kubeCluster, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Cluster) setClusterDefaults() {
|
||||||
|
for i, host := range c.Nodes {
|
||||||
|
if len(host.InternalAddress) == 0 {
|
||||||
|
c.Nodes[i].InternalAddress = c.Nodes[i].Address
|
||||||
|
}
|
||||||
|
if len(host.HostnameOverride) == 0 {
|
||||||
|
// This is a temporary modification
|
||||||
|
c.Nodes[i].HostnameOverride = c.Nodes[i].Address
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(c.Services.KubeAPI.ServiceClusterIPRange) == 0 {
|
||||||
|
c.Services.KubeAPI.ServiceClusterIPRange = DefaultServiceClusterIPRange
|
||||||
|
}
|
||||||
|
if len(c.Services.KubeController.ServiceClusterIPRange) == 0 {
|
||||||
|
c.Services.KubeController.ServiceClusterIPRange = DefaultServiceClusterIPRange
|
||||||
|
}
|
||||||
|
if len(c.Services.KubeController.ClusterCIDR) == 0 {
|
||||||
|
c.Services.KubeController.ClusterCIDR = DefaultClusterCIDR
|
||||||
|
}
|
||||||
|
if len(c.Services.Kubelet.ClusterDNSServer) == 0 {
|
||||||
|
c.Services.Kubelet.ClusterDNSServer = DefaultClusterDNSService
|
||||||
|
}
|
||||||
|
if len(c.Services.Kubelet.ClusterDomain) == 0 {
|
||||||
|
c.Services.Kubelet.ClusterDomain = DefaultClusterDomain
|
||||||
|
}
|
||||||
|
if len(c.Services.Kubelet.InfraContainerImage) == 0 {
|
||||||
|
c.Services.Kubelet.InfraContainerImage = DefaultInfraContainerImage
|
||||||
|
}
|
||||||
|
if len(c.Authentication.Strategy) == 0 {
|
||||||
|
c.Authentication.Strategy = DefaultAuthStrategy
|
||||||
|
}
|
||||||
|
if len(c.Network.Plugin) == 0 {
|
||||||
|
c.Network.Plugin = DefaultNetworkPlugin
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func GetLocalKubeConfig(configPath string) string {
|
func GetLocalKubeConfig(configPath string) string {
|
||||||
baseDir := filepath.Dir(configPath)
|
baseDir := filepath.Dir(configPath)
|
||||||
fileName := filepath.Base(configPath)
|
fileName := filepath.Base(configPath)
|
||||||
@@ -144,11 +171,11 @@ func ReconcileCluster(kubeCluster, currentCluster *Cluster) error {
|
|||||||
cpToDelete := hosts.GetToDeleteHosts(currentCluster.ControlPlaneHosts, kubeCluster.ControlPlaneHosts)
|
cpToDelete := hosts.GetToDeleteHosts(currentCluster.ControlPlaneHosts, kubeCluster.ControlPlaneHosts)
|
||||||
for _, toDeleteHost := range cpToDelete {
|
for _, toDeleteHost := range cpToDelete {
|
||||||
if err := hosts.DeleteNode(&toDeleteHost, kubeClient); err != nil {
|
if err := hosts.DeleteNode(&toDeleteHost, kubeClient); err != nil {
|
||||||
return fmt.Errorf("Failed to delete controlplane node %s from cluster", toDeleteHost.AdvertisedHostname)
|
return fmt.Errorf("Failed to delete controlplane node %s from cluster", toDeleteHost.Address)
|
||||||
}
|
}
|
||||||
// attempting to clean up the host
|
// attempting to clean up the host
|
||||||
if err := reconcileHostCleaner(toDeleteHost, key, false); err != nil {
|
if err := reconcileHostCleaner(toDeleteHost, key, false); err != nil {
|
||||||
logrus.Warnf("[reconcile] Couldn't clean up controlplane node [%s]: %v", toDeleteHost.AdvertisedHostname, err)
|
logrus.Warnf("[reconcile] Couldn't clean up controlplane node [%s]: %v", toDeleteHost.Address, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -157,11 +184,11 @@ func ReconcileCluster(kubeCluster, currentCluster *Cluster) error {
|
|||||||
wpToDelete := hosts.GetToDeleteHosts(currentCluster.WorkerHosts, kubeCluster.WorkerHosts)
|
wpToDelete := hosts.GetToDeleteHosts(currentCluster.WorkerHosts, kubeCluster.WorkerHosts)
|
||||||
for _, toDeleteHost := range wpToDelete {
|
for _, toDeleteHost := range wpToDelete {
|
||||||
if err := hosts.DeleteNode(&toDeleteHost, kubeClient); err != nil {
|
if err := hosts.DeleteNode(&toDeleteHost, kubeClient); err != nil {
|
||||||
return fmt.Errorf("Failed to delete worker node %s from cluster", toDeleteHost.AdvertisedHostname)
|
return fmt.Errorf("Failed to delete worker node %s from cluster", toDeleteHost.Address)
|
||||||
}
|
}
|
||||||
// attempting to clean up the host
|
// attempting to clean up the host
|
||||||
if err := reconcileHostCleaner(toDeleteHost, key, true); err != nil {
|
if err := reconcileHostCleaner(toDeleteHost, key, true); err != nil {
|
||||||
logrus.Warnf("[reconcile] Couldn't clean up worker node [%s]: %v", toDeleteHost.AdvertisedHostname, err)
|
logrus.Warnf("[reconcile] Couldn't clean up worker node [%s]: %v", toDeleteHost.Address, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -201,7 +228,7 @@ func rebuildLocalAdminConfig(kubeCluster *Cluster) error {
|
|||||||
currentKubeConfig := kubeCluster.Certificates[pki.KubeAdminCommonName]
|
currentKubeConfig := kubeCluster.Certificates[pki.KubeAdminCommonName]
|
||||||
caCrt := kubeCluster.Certificates[pki.CACertName].Certificate
|
caCrt := kubeCluster.Certificates[pki.CACertName].Certificate
|
||||||
newConfig := pki.GetKubeConfigX509WithData(
|
newConfig := pki.GetKubeConfigX509WithData(
|
||||||
"https://"+kubeCluster.ControlPlaneHosts[0].IP+":6443",
|
"https://"+kubeCluster.ControlPlaneHosts[0].Address+":6443",
|
||||||
pki.KubeAdminCommonName,
|
pki.KubeAdminCommonName,
|
||||||
string(cert.EncodeCertPEM(caCrt)),
|
string(cert.EncodeCertPEM(caCrt)),
|
||||||
string(cert.EncodeCertPEM(currentKubeConfig.Certificate)),
|
string(cert.EncodeCertPEM(currentKubeConfig.Certificate)),
|
||||||
|
@@ -48,11 +48,11 @@ func (c *Cluster) InvertIndexHosts() error {
|
|||||||
c.EtcdHosts = make([]hosts.Host, 0)
|
c.EtcdHosts = make([]hosts.Host, 0)
|
||||||
c.WorkerHosts = make([]hosts.Host, 0)
|
c.WorkerHosts = make([]hosts.Host, 0)
|
||||||
c.ControlPlaneHosts = make([]hosts.Host, 0)
|
c.ControlPlaneHosts = make([]hosts.Host, 0)
|
||||||
for _, host := range c.Hosts {
|
for _, host := range c.Nodes {
|
||||||
for _, role := range host.Role {
|
for _, role := range host.Role {
|
||||||
logrus.Debugf("Host: " + host.AdvertisedHostname + " has role: " + role)
|
logrus.Debugf("Host: " + host.Address + " has role: " + role)
|
||||||
newHost := hosts.Host{
|
newHost := hosts.Host{
|
||||||
RKEConfigHost: host,
|
RKEConfigNode: host,
|
||||||
}
|
}
|
||||||
switch role {
|
switch role {
|
||||||
case services.ETCDRole:
|
case services.ETCDRole:
|
||||||
@@ -62,7 +62,7 @@ func (c *Cluster) InvertIndexHosts() error {
|
|||||||
case services.WorkerRole:
|
case services.WorkerRole:
|
||||||
c.WorkerHosts = append(c.WorkerHosts, newHost)
|
c.WorkerHosts = append(c.WorkerHosts, newHost)
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("Failed to recognize host [%s] role %s", host.AdvertisedHostname, role)
|
return fmt.Errorf("Failed to recognize host [%s] role %s", host.Address, role)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,16 +11,19 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
NetworkPluginResourceName = "rke-netwok-plugin"
|
NetworkPluginResourceName = "rke-netwok-plugin"
|
||||||
|
FlannelNetworkPlugin = "flannel"
|
||||||
|
CalicoNetworkPlugin = "calico"
|
||||||
|
CanalNetworkPlugin = "canal"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Cluster) DeployNetworkPlugin() error {
|
func (c *Cluster) DeployNetworkPlugin() error {
|
||||||
logrus.Infof("[network] Setting up network plugin: %s", c.Network.Plugin)
|
logrus.Infof("[network] Setting up network plugin: %s", c.Network.Plugin)
|
||||||
switch c.Network.Plugin {
|
switch c.Network.Plugin {
|
||||||
case "flannel":
|
case FlannelNetworkPlugin:
|
||||||
return c.doFlannelDeploy()
|
return c.doFlannelDeploy()
|
||||||
case "calico":
|
case CalicoNetworkPlugin:
|
||||||
return c.doCalicoDeploy()
|
return c.doCalicoDeploy()
|
||||||
case "canal":
|
case CanalNetworkPlugin:
|
||||||
return c.doCanalDeploy()
|
return c.doCanalDeploy()
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("[network] Unsupported network plugin: %s", c.Network.Plugin)
|
return fmt.Errorf("[network] Unsupported network plugin: %s", c.Network.Plugin)
|
||||||
|
@@ -3,6 +3,8 @@ package cluster
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/rancher/rke/services"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Cluster) ValidateCluster() error {
|
func (c *Cluster) ValidateCluster() error {
|
||||||
@@ -10,19 +12,79 @@ func (c *Cluster) ValidateCluster() error {
|
|||||||
if len(c.ControlPlaneHosts) == 0 {
|
if len(c.ControlPlaneHosts) == 0 {
|
||||||
return fmt.Errorf("Cluster must have at least one control plane host")
|
return fmt.Errorf("Cluster must have at least one control plane host")
|
||||||
}
|
}
|
||||||
if len(c.EtcdHosts) == 0 {
|
if len(c.EtcdHosts)%2 == 0 {
|
||||||
return fmt.Errorf("Cluster must have at least one etcd host")
|
return fmt.Errorf("Cluster must have odd number of etcd nodes")
|
||||||
|
}
|
||||||
|
if len(c.WorkerHosts) == 0 {
|
||||||
|
return fmt.Errorf("Cluster must have at least one worker plane host")
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate hosts options
|
||||||
|
if err := validateHostsOptions(c); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate Auth options
|
||||||
|
if err := validateAuthOptions(c); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate Network options
|
||||||
|
if err := validateNetworkOptions(c); err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate services options
|
// validate services options
|
||||||
err := validateServicesOption(c)
|
if err := validateServicesOptions(c); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateServicesOption(c *Cluster) error {
|
func validateAuthOptions(c *Cluster) error {
|
||||||
|
if c.Authentication.Strategy != DefaultAuthStrategy {
|
||||||
|
return fmt.Errorf("Authentication strategy [%s] is not supported", c.Authentication.Strategy)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func validateNetworkOptions(c *Cluster) error {
|
||||||
|
if c.Network.Plugin != FlannelNetworkPlugin && c.Network.Plugin != CalicoNetworkPlugin && c.Network.Plugin != CanalNetworkPlugin {
|
||||||
|
return fmt.Errorf("Network plugin [%s] is not supported", c.Network.Plugin)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func validateHostsOptions(c *Cluster) error {
|
||||||
|
for i, host := range c.Nodes {
|
||||||
|
if len(host.Address) == 0 {
|
||||||
|
return fmt.Errorf("User for host (%d) is not provided", i+1)
|
||||||
|
}
|
||||||
|
if len(host.User) == 0 {
|
||||||
|
return fmt.Errorf("User for host (%d) is not provided", i+1)
|
||||||
|
}
|
||||||
|
if len(host.Role) == 0 {
|
||||||
|
return fmt.Errorf("Role for host (%d) is not provided", i+1)
|
||||||
|
}
|
||||||
|
for _, role := range host.Role {
|
||||||
|
if role != services.ETCDRole && role != services.ControlRole && role != services.WorkerRole {
|
||||||
|
return fmt.Errorf("Role [%s] for host (%d) is not recognized", role, i+1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
k := 0
|
||||||
|
for _, role := range host.Role {
|
||||||
|
if role == services.ControlRole || role == services.WorkerRole {
|
||||||
|
k++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if k > 1 {
|
||||||
|
return fmt.Errorf("Host (%d) can't contain both worker and controlplane roles", i+1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func validateServicesOptions(c *Cluster) error {
|
||||||
servicesOptions := map[string]string{
|
servicesOptions := map[string]string{
|
||||||
"etcd_image": c.Services.Etcd.Image,
|
"etcd_image": c.Services.Etcd.Image,
|
||||||
"kube_api_image": c.Services.KubeAPI.Image,
|
"kube_api_image": c.Services.KubeAPI.Image,
|
||||||
|
@@ -42,7 +42,11 @@ func ConfigCommand() cli.Command {
|
|||||||
|
|
||||||
func getConfig(reader *bufio.Reader, text, def string) (string, error) {
|
func getConfig(reader *bufio.Reader, text, def string) (string, error) {
|
||||||
for {
|
for {
|
||||||
|
if def == "" {
|
||||||
|
fmt.Printf("%s [%s]: ", text, "none")
|
||||||
|
} else {
|
||||||
fmt.Printf("%s [%s]: ", text, def)
|
fmt.Printf("%s [%s]: ", text, def)
|
||||||
|
}
|
||||||
input, err := reader.ReadString('\n')
|
input, err := reader.ReadString('\n')
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@@ -81,10 +85,17 @@ func clusterConfig(ctx *cli.Context) error {
|
|||||||
|
|
||||||
// Generate empty configuration file
|
// Generate empty configuration file
|
||||||
if ctx.Bool("empty") {
|
if ctx.Bool("empty") {
|
||||||
cluster.Hosts = make([]v1.RKEConfigHost, 1)
|
cluster.Nodes = make([]v1.RKEConfigNode, 1)
|
||||||
return writeConfig(&cluster, configFile, print)
|
return writeConfig(&cluster, configFile, print)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get number of hosts
|
||||||
|
sshKeyPath, err := getConfig(reader, "SSH Private Key Path", "~/.ssh/id_rsa")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cluster.SSHKeyPath = sshKeyPath
|
||||||
|
|
||||||
// Get number of hosts
|
// Get number of hosts
|
||||||
numberOfHostsString, err := getConfig(reader, "Number of Hosts", "3")
|
numberOfHostsString, err := getConfig(reader, "Number of Hosts", "3")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -96,13 +107,13 @@ func clusterConfig(ctx *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get Hosts config
|
// Get Hosts config
|
||||||
cluster.Hosts = make([]v1.RKEConfigHost, 0)
|
cluster.Nodes = make([]v1.RKEConfigNode, 0)
|
||||||
for i := 0; i < numberOfHostsInt; i++ {
|
for i := 0; i < numberOfHostsInt; i++ {
|
||||||
hostCfg, err := getHostConfig(reader, i)
|
hostCfg, err := getHostConfig(reader, i)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cluster.Hosts = append(cluster.Hosts, *hostCfg)
|
cluster.Nodes = append(cluster.Nodes, *hostCfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get Network config
|
// Get Network config
|
||||||
@@ -129,27 +140,21 @@ func clusterConfig(ctx *cli.Context) error {
|
|||||||
return writeConfig(&cluster, configFile, print)
|
return writeConfig(&cluster, configFile, print)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getHostConfig(reader *bufio.Reader, index int) (*v1.RKEConfigHost, error) {
|
func getHostConfig(reader *bufio.Reader, index int) (*v1.RKEConfigNode, error) {
|
||||||
host := v1.RKEConfigHost{}
|
host := v1.RKEConfigNode{}
|
||||||
advertisedHostname, err := getConfig(reader, fmt.Sprintf("Hostname of host (%d)", index+1), "")
|
address, err := getConfig(reader, fmt.Sprintf("SSH Address of host (%d)", index+1), "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
host.AdvertisedHostname = advertisedHostname
|
host.Address = address
|
||||||
|
|
||||||
sshIP, err := getConfig(reader, fmt.Sprintf("SSH IP of host (%s)", advertisedHostname), "")
|
sshUser, err := getConfig(reader, fmt.Sprintf("SSH User of host (%s)", address), "ubuntu")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
host.IP = sshIP
|
host.User = sshUser
|
||||||
|
|
||||||
advertisedIP, err := getConfig(reader, fmt.Sprintf("Advertised IP of host (%s)", advertisedHostname), "")
|
isControlHost, err := getConfig(reader, fmt.Sprintf("Is host (%s) a control host (y/n)?", address), "y")
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
host.AdvertiseAddress = advertisedIP
|
|
||||||
|
|
||||||
isControlHost, err := getConfig(reader, fmt.Sprintf("Is host (%s) a control host (y/n)?", advertisedHostname), "y")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -157,7 +162,7 @@ func getHostConfig(reader *bufio.Reader, index int) (*v1.RKEConfigHost, error) {
|
|||||||
host.Role = append(host.Role, services.ControlRole)
|
host.Role = append(host.Role, services.ControlRole)
|
||||||
}
|
}
|
||||||
|
|
||||||
isWorkerHost, err := getConfig(reader, fmt.Sprintf("Is host (%s) a worker host (y/n)?", advertisedHostname), "n")
|
isWorkerHost, err := getConfig(reader, fmt.Sprintf("Is host (%s) a worker host (y/n)?", address), "n")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -165,7 +170,7 @@ func getHostConfig(reader *bufio.Reader, index int) (*v1.RKEConfigHost, error) {
|
|||||||
host.Role = append(host.Role, services.WorkerRole)
|
host.Role = append(host.Role, services.WorkerRole)
|
||||||
}
|
}
|
||||||
|
|
||||||
isEtcdHost, err := getConfig(reader, fmt.Sprintf("Is host (%s) an Etcd host (y/n)?", advertisedHostname), "n")
|
isEtcdHost, err := getConfig(reader, fmt.Sprintf("Is host (%s) an Etcd host (y/n)?", address), "n")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -173,13 +178,19 @@ func getHostConfig(reader *bufio.Reader, index int) (*v1.RKEConfigHost, error) {
|
|||||||
host.Role = append(host.Role, services.ETCDRole)
|
host.Role = append(host.Role, services.ETCDRole)
|
||||||
}
|
}
|
||||||
|
|
||||||
sshUser, err := getConfig(reader, fmt.Sprintf("SSH User of host (%s)", advertisedHostname), "ubuntu")
|
hostnameOverride, err := getConfig(reader, fmt.Sprintf("Override Hostname of host (%s)", address), "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
host.User = sshUser
|
host.HostnameOverride = hostnameOverride
|
||||||
|
|
||||||
dockerSocketPath, err := getConfig(reader, fmt.Sprintf("Docker socket path on host (%s)", advertisedHostname), "/var/run/docker.sock")
|
internalAddress, err := getConfig(reader, fmt.Sprintf("Internal IP of host (%s)", address), "")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
host.InternalAddress = internalAddress
|
||||||
|
|
||||||
|
dockerSocketPath, err := getConfig(reader, fmt.Sprintf("Docker socket path on host (%s)", address), "/var/run/docker.sock")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@@ -89,7 +89,7 @@ func ClusterUp(clusterFile string) (string, string, string, string, error) {
|
|||||||
return APIURL, caCrt, clientCert, clientKey, err
|
return APIURL, caCrt, clientCert, clientKey, err
|
||||||
}
|
}
|
||||||
|
|
||||||
APIURL = fmt.Sprintf("https://" + kubeCluster.ControlPlaneHosts[0].IP + ":6443")
|
APIURL = fmt.Sprintf("https://" + kubeCluster.ControlPlaneHosts[0].Address + ":6443")
|
||||||
caCrt = string(cert.EncodeCertPEM(kubeCluster.Certificates[pki.CACertName].Certificate))
|
caCrt = string(cert.EncodeCertPEM(kubeCluster.Certificates[pki.CACertName].Certificate))
|
||||||
clientCert = string(cert.EncodeCertPEM(kubeCluster.Certificates[pki.KubeAdminCommonName].Certificate))
|
clientCert = string(cert.EncodeCertPEM(kubeCluster.Certificates[pki.KubeAdminCommonName].Certificate))
|
||||||
clientKey = string(cert.EncodePrivateKeyPEM(kubeCluster.Certificates[pki.KubeAdminCommonName].Key))
|
clientKey = string(cert.EncodePrivateKeyPEM(kubeCluster.Certificates[pki.KubeAdminCommonName].Key))
|
||||||
|
@@ -21,7 +21,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (d *dialer) Dial(network, addr string) (net.Conn, error) {
|
func (d *dialer) Dial(network, addr string) (net.Conn, error) {
|
||||||
sshAddr := d.host.IP + ":22"
|
sshAddr := d.host.Address + ":22"
|
||||||
// Build SSH client configuration
|
// Build SSH client configuration
|
||||||
cfg, err := makeSSHConfig(d.host.User, d.signer)
|
cfg, err := makeSSHConfig(d.host.User, d.signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -37,13 +37,13 @@ func (d *dialer) Dial(network, addr string) (net.Conn, error) {
|
|||||||
}
|
}
|
||||||
remote, err := conn.Dial("unix", d.host.DockerSocket)
|
remote, err := conn.Dial("unix", d.host.DockerSocket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Error connecting to Docker socket on host [%s]: %v", d.host.AdvertisedHostname, err)
|
return nil, fmt.Errorf("Error connecting to Docker socket on host [%s]: %v", d.host.Address, err)
|
||||||
}
|
}
|
||||||
return remote, err
|
return remote, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Host) TunnelUp(signer ssh.Signer) error {
|
func (h *Host) TunnelUp(signer ssh.Signer) error {
|
||||||
logrus.Infof("[ssh] Start tunnel for host [%s]", h.AdvertisedHostname)
|
logrus.Infof("[ssh] Start tunnel for host [%s]", h.Address)
|
||||||
|
|
||||||
dialer := &dialer{
|
dialer := &dialer{
|
||||||
host: h,
|
host: h,
|
||||||
@@ -57,10 +57,10 @@ func (h *Host) TunnelUp(signer ssh.Signer) error {
|
|||||||
|
|
||||||
// set Docker client
|
// set Docker client
|
||||||
var err error
|
var err error
|
||||||
logrus.Debugf("Connecting to Docker API for host [%s]", h.AdvertisedHostname)
|
logrus.Debugf("Connecting to Docker API for host [%s]", h.Address)
|
||||||
h.DClient, err = client.NewClient("unix:///var/run/docker.sock", DockerAPIVersion, httpClient, nil)
|
h.DClient, err = client.NewClient("unix:///var/run/docker.sock", DockerAPIVersion, httpClient, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Can't connect to Docker for host [%s]: %v", h.AdvertisedHostname, err)
|
return fmt.Errorf("Can't connect to Docker for host [%s]: %v", h.Address, err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Host struct {
|
type Host struct {
|
||||||
v1.RKEConfigHost
|
v1.RKEConfigNode
|
||||||
DClient *client.Client
|
DClient *client.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (h *Host) CleanUp() error {
|
func (h *Host) CleanUp() error {
|
||||||
logrus.Infof("[hosts] Cleaning up host [%s]", h.AdvertisedHostname)
|
logrus.Infof("[hosts] Cleaning up host [%s]", h.Address)
|
||||||
toCleanDirs := []string{
|
toCleanDirs := []string{
|
||||||
ToCleanEtcdDir,
|
ToCleanEtcdDir,
|
||||||
ToCleanSSLDir,
|
ToCleanSSLDir,
|
||||||
@@ -36,9 +36,9 @@ func (h *Host) CleanUp() error {
|
|||||||
ToCleanCNIBin,
|
ToCleanCNIBin,
|
||||||
ToCleanCalicoRun,
|
ToCleanCalicoRun,
|
||||||
}
|
}
|
||||||
logrus.Infof("[hosts] Running cleaner container on host [%s]", h.AdvertisedHostname)
|
logrus.Infof("[hosts] Running cleaner container on host [%s]", h.Address)
|
||||||
imageCfg, hostCfg := buildCleanerConfig(h, toCleanDirs)
|
imageCfg, hostCfg := buildCleanerConfig(h, toCleanDirs)
|
||||||
if err := docker.DoRunContainer(h.DClient, imageCfg, hostCfg, CleanerContainerName, h.AdvertisedHostname, CleanerContainerName); err != nil {
|
if err := docker.DoRunContainer(h.DClient, imageCfg, hostCfg, CleanerContainerName, h.Address, CleanerContainerName); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,26 +46,26 @@ func (h *Host) CleanUp() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Infof("[hosts] Removing cleaner container on host [%s]", h.AdvertisedHostname)
|
logrus.Infof("[hosts] Removing cleaner container on host [%s]", h.Address)
|
||||||
if err := docker.RemoveContainer(h.DClient, h.AdvertisedHostname, CleanerContainerName); err != nil {
|
if err := docker.RemoveContainer(h.DClient, h.Address, CleanerContainerName); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logrus.Infof("[hosts] Successfully cleaned up host [%s]", h.AdvertisedHostname)
|
logrus.Infof("[hosts] Successfully cleaned up host [%s]", h.Address)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteNode(toDeleteHost *Host, kubeClient *kubernetes.Clientset) error {
|
func DeleteNode(toDeleteHost *Host, kubeClient *kubernetes.Clientset) error {
|
||||||
logrus.Infof("[hosts] Cordoning host [%s]", toDeleteHost.AdvertisedHostname)
|
logrus.Infof("[hosts] Cordoning host [%s]", toDeleteHost.Address)
|
||||||
err := k8s.CordonUncordon(kubeClient, toDeleteHost.AdvertisedHostname, true)
|
err := k8s.CordonUncordon(kubeClient, toDeleteHost.HostnameOverride, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logrus.Infof("[hosts] Deleting host [%s] from the cluster", toDeleteHost.AdvertisedHostname)
|
logrus.Infof("[hosts] Deleting host [%s] from the cluster", toDeleteHost.Address)
|
||||||
err = k8s.DeleteNode(kubeClient, toDeleteHost.AdvertisedHostname)
|
err = k8s.DeleteNode(kubeClient, toDeleteHost.HostnameOverride)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logrus.Infof("[hosts] Successfully deleted host [%s] from the cluster", toDeleteHost.AdvertisedHostname)
|
logrus.Infof("[hosts] Successfully deleted host [%s] from the cluster", toDeleteHost.Address)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ func GetToDeleteHosts(currentHosts, configHosts []Host) []Host {
|
|||||||
for _, currentHost := range currentHosts {
|
for _, currentHost := range currentHosts {
|
||||||
found := false
|
found := false
|
||||||
for _, newHost := range configHosts {
|
for _, newHost := range configHosts {
|
||||||
if currentHost.AdvertisedHostname == newHost.AdvertisedHostname {
|
if currentHost.Address == newHost.Address {
|
||||||
found = true
|
found = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,8 +90,9 @@ func IsHostListChanged(currentHosts, configHosts []Host) bool {
|
|||||||
for _, host := range currentHosts {
|
for _, host := range currentHosts {
|
||||||
found := false
|
found := false
|
||||||
for _, configHost := range configHosts {
|
for _, configHost := range configHosts {
|
||||||
if host.AdvertisedHostname == configHost.AdvertisedHostname {
|
if host.Address == configHost.Address {
|
||||||
found = true
|
found = true
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !found {
|
if !found {
|
||||||
@@ -101,8 +102,9 @@ func IsHostListChanged(currentHosts, configHosts []Host) bool {
|
|||||||
for _, host := range configHosts {
|
for _, host := range configHosts {
|
||||||
found := false
|
found := false
|
||||||
for _, currentHost := range currentHosts {
|
for _, currentHost := range currentHosts {
|
||||||
if host.AdvertisedHostname == currentHost.AdvertisedHostname {
|
if host.Address == currentHost.Address {
|
||||||
found = true
|
found = true
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !found {
|
if !found {
|
||||||
|
2
main.go
2
main.go
@@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
var VERSION = "v0.0.2-dev"
|
var VERSION = "v0.0.6-dev"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if err := mainErr(); err != nil {
|
if err := mainErr(); err != nil {
|
||||||
|
@@ -61,8 +61,8 @@ func DeployCertificatesOnWorkers(workerHosts []hosts.Host, crtMap map[string]Cer
|
|||||||
}
|
}
|
||||||
|
|
||||||
func doRunDeployer(host *hosts.Host, containerEnv []string) error {
|
func doRunDeployer(host *hosts.Host, containerEnv []string) error {
|
||||||
logrus.Debugf("[certificates] Pulling Certificate downloader Image on host [%s]", host.AdvertisedHostname)
|
logrus.Debugf("[certificates] Pulling Certificate downloader Image on host [%s]", host.Address)
|
||||||
err := docker.PullImage(host.DClient, host.AdvertisedHostname, CrtDownloaderImage)
|
err := docker.PullImage(host.DClient, host.Address, CrtDownloaderImage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -79,15 +79,15 @@ func doRunDeployer(host *hosts.Host, containerEnv []string) error {
|
|||||||
}
|
}
|
||||||
resp, err := host.DClient.ContainerCreate(context.Background(), imageCfg, hostCfg, nil, CrtDownloaderContainer)
|
resp, err := host.DClient.ContainerCreate(context.Background(), imageCfg, hostCfg, nil, CrtDownloaderContainer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Failed to create Certificates deployer container on host [%s]: %v", host.AdvertisedHostname, err)
|
return fmt.Errorf("Failed to create Certificates deployer container on host [%s]: %v", host.Address, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := host.DClient.ContainerStart(context.Background(), resp.ID, types.ContainerStartOptions{}); err != nil {
|
if err := host.DClient.ContainerStart(context.Background(), resp.ID, types.ContainerStartOptions{}); err != nil {
|
||||||
return fmt.Errorf("Failed to start Certificates deployer container on host [%s]: %v", host.AdvertisedHostname, err)
|
return fmt.Errorf("Failed to start Certificates deployer container on host [%s]: %v", host.Address, err)
|
||||||
}
|
}
|
||||||
logrus.Debugf("[certificates] Successfully started Certificate deployer container: %s", resp.ID)
|
logrus.Debugf("[certificates] Successfully started Certificate deployer container: %s", resp.ID)
|
||||||
for {
|
for {
|
||||||
isDeployerRunning, err := docker.IsContainerRunning(host.DClient, host.AdvertisedHostname, CrtDownloaderContainer)
|
isDeployerRunning, err := docker.IsContainerRunning(host.DClient, host.Address, CrtDownloaderContainer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -96,7 +96,7 @@ func doRunDeployer(host *hosts.Host, containerEnv []string) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err := host.DClient.ContainerRemove(context.Background(), resp.ID, types.ContainerRemoveOptions{}); err != nil {
|
if err := host.DClient.ContainerRemove(context.Background(), resp.ID, types.ContainerRemoveOptions{}); err != nil {
|
||||||
return fmt.Errorf("Failed to delete Certificates deployer container on host[%s]: %v", host.AdvertisedHostname, err)
|
return fmt.Errorf("Failed to delete Certificates deployer container on host [%s]: %v", host.Address, err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
24
pki/pki.go
24
pki/pki.go
@@ -167,7 +167,7 @@ func generateCerts(cpHosts []hosts.Host, clusterDomain, localConfigPath string,
|
|||||||
Certificate: kubeAdminCrt,
|
Certificate: kubeAdminCrt,
|
||||||
Key: kubeAdminKey,
|
Key: kubeAdminKey,
|
||||||
Config: GetKubeConfigX509WithData(
|
Config: GetKubeConfigX509WithData(
|
||||||
"https://"+cpHosts[0].IP+":6443",
|
"https://"+cpHosts[0].Address+":6443",
|
||||||
KubeAdminCommonName,
|
KubeAdminCommonName,
|
||||||
string(cert.EncodeCertPEM(caCrt)),
|
string(cert.EncodeCertPEM(caCrt)),
|
||||||
string(cert.EncodeCertPEM(kubeAdminCrt)),
|
string(cert.EncodeCertPEM(kubeAdminCrt)),
|
||||||
@@ -250,11 +250,25 @@ func GetAltNames(cpHosts []hosts.Host, clusterDomain string, KubernetesServiceIP
|
|||||||
ips := []net.IP{}
|
ips := []net.IP{}
|
||||||
dnsNames := []string{}
|
dnsNames := []string{}
|
||||||
for _, host := range cpHosts {
|
for _, host := range cpHosts {
|
||||||
ips = append(ips, net.ParseIP(host.IP))
|
// Check if node address is a valid IP
|
||||||
if host.IP != host.AdvertiseAddress {
|
if nodeIP := net.ParseIP(host.Address); nodeIP != nil {
|
||||||
ips = append(ips, net.ParseIP(host.AdvertiseAddress))
|
ips = append(ips, nodeIP)
|
||||||
|
} else {
|
||||||
|
dnsNames = append(dnsNames, host.Address)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if node internal address is a valid IP
|
||||||
|
if len(host.InternalAddress) != 0 && host.InternalAddress != host.Address {
|
||||||
|
if internalIP := net.ParseIP(host.InternalAddress); internalIP != nil {
|
||||||
|
ips = append(ips, internalIP)
|
||||||
|
} else {
|
||||||
|
dnsNames = append(dnsNames, host.InternalAddress)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Add hostname to the ALT dns names
|
||||||
|
if len(host.HostnameOverride) != 0 && host.HostnameOverride != host.Address {
|
||||||
|
dnsNames = append(dnsNames, host.HostnameOverride)
|
||||||
}
|
}
|
||||||
dnsNames = append(dnsNames, host.AdvertisedHostname)
|
|
||||||
}
|
}
|
||||||
ips = append(ips, net.ParseIP("127.0.0.1"))
|
ips = append(ips, net.ParseIP("127.0.0.1"))
|
||||||
ips = append(ips, KubernetesServiceIP)
|
ips = append(ips, KubernetesServiceIP)
|
||||||
|
@@ -18,11 +18,11 @@ const (
|
|||||||
func TestPKI(t *testing.T) {
|
func TestPKI(t *testing.T) {
|
||||||
cpHosts := []hosts.Host{
|
cpHosts := []hosts.Host{
|
||||||
hosts.Host{
|
hosts.Host{
|
||||||
RKEConfigHost: v1.RKEConfigHost{
|
RKEConfigNode: v1.RKEConfigNode{
|
||||||
IP: "1.1.1.1",
|
Address: "1.1.1.1",
|
||||||
AdvertiseAddress: "192.168.1.5",
|
InternalAddress: "192.168.1.5",
|
||||||
Role: []string{"controlplane"},
|
Role: []string{"controlplane"},
|
||||||
AdvertisedHostname: "server1",
|
HostnameOverride: "server1",
|
||||||
},
|
},
|
||||||
DClient: nil,
|
DClient: nil,
|
||||||
},
|
},
|
||||||
@@ -73,8 +73,8 @@ func TestPKI(t *testing.T) {
|
|||||||
// Test ALT IPs
|
// Test ALT IPs
|
||||||
kubeAPIAltIPs := []net.IP{
|
kubeAPIAltIPs := []net.IP{
|
||||||
net.ParseIP("127.0.0.1"),
|
net.ParseIP("127.0.0.1"),
|
||||||
net.ParseIP(cpHosts[0].AdvertiseAddress),
|
net.ParseIP(cpHosts[0].InternalAddress),
|
||||||
net.ParseIP(cpHosts[0].IP),
|
net.ParseIP(cpHosts[0].Address),
|
||||||
net.ParseIP(FakeKubernetesServiceIP),
|
net.ParseIP(FakeKubernetesServiceIP),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,7 +16,7 @@ func RunEtcdPlane(etcdHosts []hosts.Host, etcdService v1.ETCDService) error {
|
|||||||
initCluster := getEtcdInitialCluster(etcdHosts)
|
initCluster := getEtcdInitialCluster(etcdHosts)
|
||||||
for _, host := range etcdHosts {
|
for _, host := range etcdHosts {
|
||||||
imageCfg, hostCfg := buildEtcdConfig(host, etcdService, initCluster)
|
imageCfg, hostCfg := buildEtcdConfig(host, etcdService, initCluster)
|
||||||
err := docker.DoRunContainer(host.DClient, imageCfg, hostCfg, EtcdContainerName, host.AdvertisedHostname, ETCDRole)
|
err := docker.DoRunContainer(host.DClient, imageCfg, hostCfg, EtcdContainerName, host.Address, ETCDRole)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ func RunEtcdPlane(etcdHosts []hosts.Host, etcdService v1.ETCDService) error {
|
|||||||
func RemoveEtcdPlane(etcdHosts []hosts.Host) error {
|
func RemoveEtcdPlane(etcdHosts []hosts.Host) error {
|
||||||
logrus.Infof("[%s] Tearing down Etcd Plane..", ETCDRole)
|
logrus.Infof("[%s] Tearing down Etcd Plane..", ETCDRole)
|
||||||
for _, host := range etcdHosts {
|
for _, host := range etcdHosts {
|
||||||
err := docker.DoRemoveContainer(host.DClient, EtcdContainerName, host.AdvertisedHostname)
|
err := docker.DoRemoveContainer(host.DClient, EtcdContainerName, host.Address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -41,11 +41,11 @@ func buildEtcdConfig(host hosts.Host, etcdService v1.ETCDService, initCluster st
|
|||||||
imageCfg := &container.Config{
|
imageCfg := &container.Config{
|
||||||
Image: etcdService.Image,
|
Image: etcdService.Image,
|
||||||
Cmd: []string{"/usr/local/bin/etcd",
|
Cmd: []string{"/usr/local/bin/etcd",
|
||||||
"--name=etcd-" + host.AdvertisedHostname,
|
"--name=etcd-" + host.HostnameOverride,
|
||||||
"--data-dir=/etcd-data",
|
"--data-dir=/etcd-data",
|
||||||
"--advertise-client-urls=http://" + host.AdvertiseAddress + ":2379,http://" + host.AdvertiseAddress + ":4001",
|
"--advertise-client-urls=http://" + host.InternalAddress + ":2379,http://" + host.InternalAddress + ":4001",
|
||||||
"--listen-client-urls=http://0.0.0.0:2379",
|
"--listen-client-urls=http://0.0.0.0:2379",
|
||||||
"--initial-advertise-peer-urls=http://" + host.AdvertiseAddress + ":2380",
|
"--initial-advertise-peer-urls=http://" + host.InternalAddress + ":2380",
|
||||||
"--listen-peer-urls=http://0.0.0.0:2380",
|
"--listen-peer-urls=http://0.0.0.0:2380",
|
||||||
"--initial-cluster-token=etcd-cluster-1",
|
"--initial-cluster-token=etcd-cluster-1",
|
||||||
"--initial-cluster=" + initCluster,
|
"--initial-cluster=" + initCluster,
|
||||||
@@ -81,7 +81,7 @@ func buildEtcdConfig(host hosts.Host, etcdService v1.ETCDService, initCluster st
|
|||||||
func GetEtcdConnString(hosts []hosts.Host) string {
|
func GetEtcdConnString(hosts []hosts.Host) string {
|
||||||
connString := ""
|
connString := ""
|
||||||
for i, host := range hosts {
|
for i, host := range hosts {
|
||||||
connString += "http://" + host.AdvertiseAddress + ":2379"
|
connString += "http://" + host.InternalAddress + ":2379"
|
||||||
if i < (len(hosts) - 1) {
|
if i < (len(hosts) - 1) {
|
||||||
connString += ","
|
connString += ","
|
||||||
}
|
}
|
||||||
@@ -92,7 +92,7 @@ func GetEtcdConnString(hosts []hosts.Host) string {
|
|||||||
func getEtcdInitialCluster(hosts []hosts.Host) string {
|
func getEtcdInitialCluster(hosts []hosts.Host) string {
|
||||||
initialCluster := ""
|
initialCluster := ""
|
||||||
for i, host := range hosts {
|
for i, host := range hosts {
|
||||||
initialCluster += fmt.Sprintf("etcd-%s=http://%s:2380", host.AdvertisedHostname, host.AdvertiseAddress)
|
initialCluster += fmt.Sprintf("etcd-%s=http://%s:2380", host.HostnameOverride, host.InternalAddress)
|
||||||
if i < (len(hosts) - 1) {
|
if i < (len(hosts) - 1) {
|
||||||
initialCluster += ","
|
initialCluster += ","
|
||||||
}
|
}
|
||||||
|
@@ -14,11 +14,11 @@ import (
|
|||||||
func runKubeAPI(host hosts.Host, etcdHosts []hosts.Host, kubeAPIService v1.KubeAPIService) error {
|
func runKubeAPI(host hosts.Host, etcdHosts []hosts.Host, kubeAPIService v1.KubeAPIService) error {
|
||||||
etcdConnString := GetEtcdConnString(etcdHosts)
|
etcdConnString := GetEtcdConnString(etcdHosts)
|
||||||
imageCfg, hostCfg := buildKubeAPIConfig(host, kubeAPIService, etcdConnString)
|
imageCfg, hostCfg := buildKubeAPIConfig(host, kubeAPIService, etcdConnString)
|
||||||
return docker.DoRunContainer(host.DClient, imageCfg, hostCfg, KubeAPIContainerName, host.AdvertisedHostname, ControlRole)
|
return docker.DoRunContainer(host.DClient, imageCfg, hostCfg, KubeAPIContainerName, host.Address, ControlRole)
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeKubeAPI(host hosts.Host) error {
|
func removeKubeAPI(host hosts.Host) error {
|
||||||
return docker.DoRemoveContainer(host.DClient, KubeAPIContainerName, host.AdvertisedHostname)
|
return docker.DoRemoveContainer(host.DClient, KubeAPIContainerName, host.Address)
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildKubeAPIConfig(host hosts.Host, kubeAPIService v1.KubeAPIService, etcdConnString string) (*container.Config, *container.HostConfig) {
|
func buildKubeAPIConfig(host hosts.Host, kubeAPIService v1.KubeAPIService, etcdConnString string) (*container.Config, *container.HostConfig) {
|
||||||
@@ -26,17 +26,18 @@ func buildKubeAPIConfig(host hosts.Host, kubeAPIService v1.KubeAPIService, etcdC
|
|||||||
Image: kubeAPIService.Image,
|
Image: kubeAPIService.Image,
|
||||||
Entrypoint: []string{"kube-apiserver",
|
Entrypoint: []string{"kube-apiserver",
|
||||||
"--insecure-bind-address=127.0.0.1",
|
"--insecure-bind-address=127.0.0.1",
|
||||||
|
"--bind-address=0.0.0.0",
|
||||||
"--insecure-port=8080",
|
"--insecure-port=8080",
|
||||||
"--secure-port=6443",
|
"--secure-port=6443",
|
||||||
"--cloud-provider=",
|
"--cloud-provider=",
|
||||||
"--allow_privileged=true",
|
"--allow_privileged=true",
|
||||||
|
"--kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname",
|
||||||
"--service-cluster-ip-range=" + kubeAPIService.ServiceClusterIPRange,
|
"--service-cluster-ip-range=" + kubeAPIService.ServiceClusterIPRange,
|
||||||
"--admission-control=ServiceAccount,NamespaceLifecycle,LimitRanger,PersistentVolumeLabel,DefaultStorageClass,ResourceQuota,DefaultTolerationSeconds",
|
"--admission-control=ServiceAccount,NamespaceLifecycle,LimitRanger,PersistentVolumeLabel,DefaultStorageClass,ResourceQuota,DefaultTolerationSeconds",
|
||||||
"--runtime-config=batch/v2alpha1",
|
"--runtime-config=batch/v2alpha1",
|
||||||
"--runtime-config=authentication.k8s.io/v1beta1=true",
|
"--runtime-config=authentication.k8s.io/v1beta1=true",
|
||||||
"--storage-backend=etcd3",
|
"--storage-backend=etcd3",
|
||||||
"--etcd-servers=" + etcdConnString,
|
"--etcd-servers=" + etcdConnString,
|
||||||
"--advertise-address=" + host.AdvertiseAddress,
|
|
||||||
"--client-ca-file=" + pki.CACertPath,
|
"--client-ca-file=" + pki.CACertPath,
|
||||||
"--tls-cert-file=" + pki.KubeAPICertPath,
|
"--tls-cert-file=" + pki.KubeAPICertPath,
|
||||||
"--tls-private-key-file=" + pki.KubeAPIKeyPath,
|
"--tls-private-key-file=" + pki.KubeAPIKeyPath,
|
||||||
|
@@ -12,11 +12,11 @@ import (
|
|||||||
|
|
||||||
func runKubeController(host hosts.Host, kubeControllerService v1.KubeControllerService) error {
|
func runKubeController(host hosts.Host, kubeControllerService v1.KubeControllerService) error {
|
||||||
imageCfg, hostCfg := buildKubeControllerConfig(kubeControllerService)
|
imageCfg, hostCfg := buildKubeControllerConfig(kubeControllerService)
|
||||||
return docker.DoRunContainer(host.DClient, imageCfg, hostCfg, KubeControllerContainerName, host.AdvertisedHostname, ControlRole)
|
return docker.DoRunContainer(host.DClient, imageCfg, hostCfg, KubeControllerContainerName, host.Address, ControlRole)
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeKubeController(host hosts.Host) error {
|
func removeKubeController(host hosts.Host) error {
|
||||||
return docker.DoRemoveContainer(host.DClient, KubeControllerContainerName, host.AdvertisedHostname)
|
return docker.DoRemoveContainer(host.DClient, KubeControllerContainerName, host.Address)
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildKubeControllerConfig(kubeControllerService v1.KubeControllerService) (*container.Config, *container.HostConfig) {
|
func buildKubeControllerConfig(kubeControllerService v1.KubeControllerService) (*container.Config, *container.HostConfig) {
|
||||||
|
@@ -13,11 +13,11 @@ import (
|
|||||||
|
|
||||||
func runKubelet(host hosts.Host, kubeletService v1.KubeletService, isMaster bool) error {
|
func runKubelet(host hosts.Host, kubeletService v1.KubeletService, isMaster bool) error {
|
||||||
imageCfg, hostCfg := buildKubeletConfig(host, kubeletService, isMaster)
|
imageCfg, hostCfg := buildKubeletConfig(host, kubeletService, isMaster)
|
||||||
return docker.DoRunContainer(host.DClient, imageCfg, hostCfg, KubeletContainerName, host.AdvertisedHostname, WorkerRole)
|
return docker.DoRunContainer(host.DClient, imageCfg, hostCfg, KubeletContainerName, host.Address, WorkerRole)
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeKubelet(host hosts.Host) error {
|
func removeKubelet(host hosts.Host) error {
|
||||||
return docker.DoRemoveContainer(host.DClient, KubeletContainerName, host.AdvertisedHostname)
|
return docker.DoRemoveContainer(host.DClient, KubeletContainerName, host.Address)
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildKubeletConfig(host hosts.Host, kubeletService v1.KubeletService, isMaster bool) (*container.Config, *container.HostConfig) {
|
func buildKubeletConfig(host hosts.Host, kubeletService v1.KubeletService, isMaster bool) (*container.Config, *container.HostConfig) {
|
||||||
@@ -27,11 +27,11 @@ func buildKubeletConfig(host hosts.Host, kubeletService v1.KubeletService, isMas
|
|||||||
"--v=2",
|
"--v=2",
|
||||||
"--address=0.0.0.0",
|
"--address=0.0.0.0",
|
||||||
"--cluster-domain=" + kubeletService.ClusterDomain,
|
"--cluster-domain=" + kubeletService.ClusterDomain,
|
||||||
"--hostname-override=" + host.AdvertisedHostname,
|
|
||||||
"--pod-infra-container-image=" + kubeletService.InfraContainerImage,
|
"--pod-infra-container-image=" + kubeletService.InfraContainerImage,
|
||||||
"--cgroup-driver=cgroupfs",
|
"--cgroup-driver=cgroupfs",
|
||||||
"--cgroups-per-qos=True",
|
"--cgroups-per-qos=True",
|
||||||
"--enforce-node-allocatable=",
|
"--enforce-node-allocatable=",
|
||||||
|
"--hostname-override=" + host.HostnameOverride,
|
||||||
"--cluster-dns=" + kubeletService.ClusterDNSServer,
|
"--cluster-dns=" + kubeletService.ClusterDNSServer,
|
||||||
"--network-plugin=cni",
|
"--network-plugin=cni",
|
||||||
"--cni-conf-dir=/etc/cni/net.d",
|
"--cni-conf-dir=/etc/cni/net.d",
|
||||||
|
@@ -12,11 +12,11 @@ import (
|
|||||||
|
|
||||||
func runKubeproxy(host hosts.Host, kubeproxyService v1.KubeproxyService) error {
|
func runKubeproxy(host hosts.Host, kubeproxyService v1.KubeproxyService) error {
|
||||||
imageCfg, hostCfg := buildKubeproxyConfig(host, kubeproxyService)
|
imageCfg, hostCfg := buildKubeproxyConfig(host, kubeproxyService)
|
||||||
return docker.DoRunContainer(host.DClient, imageCfg, hostCfg, KubeproxyContainerName, host.AdvertisedHostname, WorkerRole)
|
return docker.DoRunContainer(host.DClient, imageCfg, hostCfg, KubeproxyContainerName, host.Address, WorkerRole)
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeKubeproxy(host hosts.Host) error {
|
func removeKubeproxy(host hosts.Host) error {
|
||||||
return docker.DoRemoveContainer(host.DClient, KubeproxyContainerName, host.AdvertisedHostname)
|
return docker.DoRemoveContainer(host.DClient, KubeproxyContainerName, host.Address)
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildKubeproxyConfig(host hosts.Host, kubeproxyService v1.KubeproxyService) (*container.Config, *container.HostConfig) {
|
func buildKubeproxyConfig(host hosts.Host, kubeproxyService v1.KubeproxyService) (*container.Config, *container.HostConfig) {
|
||||||
|
@@ -17,7 +17,7 @@ func RollingUpdateNginxProxy(cpHosts []hosts.Host, workerHosts []hosts.Host) err
|
|||||||
nginxProxyEnv := buildProxyEnv(cpHosts)
|
nginxProxyEnv := buildProxyEnv(cpHosts)
|
||||||
for _, host := range workerHosts {
|
for _, host := range workerHosts {
|
||||||
imageCfg, hostCfg := buildNginxProxyConfig(host, nginxProxyEnv)
|
imageCfg, hostCfg := buildNginxProxyConfig(host, nginxProxyEnv)
|
||||||
return docker.DoRollingUpdateContainer(host.DClient, imageCfg, hostCfg, NginxProxyContainerName, host.AdvertisedHostname, WorkerRole)
|
return docker.DoRollingUpdateContainer(host.DClient, imageCfg, hostCfg, NginxProxyContainerName, host.Address, WorkerRole)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -25,11 +25,11 @@ func RollingUpdateNginxProxy(cpHosts []hosts.Host, workerHosts []hosts.Host) err
|
|||||||
func runNginxProxy(host hosts.Host, cpHosts []hosts.Host) error {
|
func runNginxProxy(host hosts.Host, cpHosts []hosts.Host) error {
|
||||||
nginxProxyEnv := buildProxyEnv(cpHosts)
|
nginxProxyEnv := buildProxyEnv(cpHosts)
|
||||||
imageCfg, hostCfg := buildNginxProxyConfig(host, nginxProxyEnv)
|
imageCfg, hostCfg := buildNginxProxyConfig(host, nginxProxyEnv)
|
||||||
return docker.DoRunContainer(host.DClient, imageCfg, hostCfg, NginxProxyContainerName, host.AdvertisedHostname, WorkerRole)
|
return docker.DoRunContainer(host.DClient, imageCfg, hostCfg, NginxProxyContainerName, host.Address, WorkerRole)
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeNginxProxy(host hosts.Host) error {
|
func removeNginxProxy(host hosts.Host) error {
|
||||||
return docker.DoRemoveContainer(host.DClient, NginxProxyContainerName, host.AdvertisedHostname)
|
return docker.DoRemoveContainer(host.DClient, NginxProxyContainerName, host.Address)
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildNginxProxyConfig(host hosts.Host, nginxProxyEnv string) (*container.Config, *container.HostConfig) {
|
func buildNginxProxyConfig(host hosts.Host, nginxProxyEnv string) (*container.Config, *container.HostConfig) {
|
||||||
@@ -48,7 +48,7 @@ func buildNginxProxyConfig(host hosts.Host, nginxProxyEnv string) (*container.Co
|
|||||||
func buildProxyEnv(cpHosts []hosts.Host) string {
|
func buildProxyEnv(cpHosts []hosts.Host) string {
|
||||||
proxyEnv := ""
|
proxyEnv := ""
|
||||||
for i, cpHost := range cpHosts {
|
for i, cpHost := range cpHosts {
|
||||||
proxyEnv += fmt.Sprintf("%s", cpHost.AdvertiseAddress)
|
proxyEnv += fmt.Sprintf("%s", cpHost.InternalAddress)
|
||||||
if i < (len(cpHosts) - 1) {
|
if i < (len(cpHosts) - 1) {
|
||||||
proxyEnv += ","
|
proxyEnv += ","
|
||||||
}
|
}
|
||||||
|
@@ -12,11 +12,11 @@ import (
|
|||||||
|
|
||||||
func runScheduler(host hosts.Host, schedulerService v1.SchedulerService) error {
|
func runScheduler(host hosts.Host, schedulerService v1.SchedulerService) error {
|
||||||
imageCfg, hostCfg := buildSchedulerConfig(host, schedulerService)
|
imageCfg, hostCfg := buildSchedulerConfig(host, schedulerService)
|
||||||
return docker.DoRunContainer(host.DClient, imageCfg, hostCfg, SchedulerContainerName, host.AdvertisedHostname, ControlRole)
|
return docker.DoRunContainer(host.DClient, imageCfg, hostCfg, SchedulerContainerName, host.Address, ControlRole)
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeScheduler(host hosts.Host) error {
|
func removeScheduler(host hosts.Host) error {
|
||||||
return docker.DoRemoveContainer(host.DClient, SchedulerContainerName, host.AdvertisedHostname)
|
return docker.DoRemoveContainer(host.DClient, SchedulerContainerName, host.Address)
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildSchedulerConfig(host hosts.Host, schedulerService v1.SchedulerService) (*container.Config, *container.HostConfig) {
|
func buildSchedulerConfig(host hosts.Host, schedulerService v1.SchedulerService) (*container.Config, *container.HostConfig) {
|
||||||
|
@@ -10,12 +10,12 @@ github.com/docker/distribution 3800056b8832cf6075e78b282ac010131d8687b
|
|||||||
github.com/docker/go-connections 3ede32e2033de7505e6500d6c868c2b9ed9f169d
|
github.com/docker/go-connections 3ede32e2033de7505e6500d6c868c2b9ed9f169d
|
||||||
github.com/docker/go-units 0dadbb0345b35ec7ef35e228dabb8de89a65bf52
|
github.com/docker/go-units 0dadbb0345b35ec7ef35e228dabb8de89a65bf52
|
||||||
golang.org/x/net 186fd3fc8194a5e9980a82230d69c1ff7134229f
|
golang.org/x/net 186fd3fc8194a5e9980a82230d69c1ff7134229f
|
||||||
github.com/rancher/types a7111733a50d97a2541c72e794d216105a22b972
|
github.com/rancher/types 0a0a5647cfdec48e7f531534d383e755fae7861c
|
||||||
github.com/opencontainers/go-digest 279bed98673dd5bef374d3b6e4b09e2af76183bf
|
github.com/opencontainers/go-digest 279bed98673dd5bef374d3b6e4b09e2af76183bf
|
||||||
github.com/gogo/protobuf 117892bf1866fbaa2318c03e50e40564c8845457
|
github.com/gogo/protobuf 117892bf1866fbaa2318c03e50e40564c8845457
|
||||||
github.com/opencontainers/image-spec 7c889fafd04a893f5c5f50b7ab9963d5d64e5242
|
github.com/opencontainers/image-spec 7c889fafd04a893f5c5f50b7ab9963d5d64e5242
|
||||||
github.com/pkg/errors f15c970de5b76fac0b59abb32d62c17cc7bed265
|
github.com/pkg/errors f15c970de5b76fac0b59abb32d62c17cc7bed265
|
||||||
github.com/rancher/norman 068b9eb94326e2c566c5eed7636163b1b407c4c0
|
github.com/rancher/norman faa1fb2148211044253fc2f6403008958c72b1f0
|
||||||
gopkg.in/check.v1 11d3bc7aa68e238947792f30573146a3231fc0f1
|
gopkg.in/check.v1 11d3bc7aa68e238947792f30573146a3231fc0f1
|
||||||
k8s.io/api/core/v1 4df58c811fe2e65feb879227b2b245e4dc26e7ad
|
k8s.io/api/core/v1 4df58c811fe2e65feb879227b2b245e4dc26e7ad
|
||||||
k8s.io/client-go v5.0.0 transitive=true
|
k8s.io/client-go v5.0.0 transitive=true
|
||||||
|
14
vendor/github.com/rancher/norman/clientbase/common.go
generated
vendored
14
vendor/github.com/rancher/norman/clientbase/common.go
generated
vendored
@@ -55,7 +55,7 @@ func IsNotFound(err error) bool {
|
|||||||
return apiError.StatusCode == http.StatusNotFound
|
return apiError.StatusCode == http.StatusNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
func newApiError(resp *http.Response, url string) *APIError {
|
func newAPIError(resp *http.Response, url string) *APIError {
|
||||||
contents, err := ioutil.ReadAll(resp.Body)
|
contents, err := ioutil.ReadAll(resp.Body)
|
||||||
var body string
|
var body string
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -161,7 +161,7 @@ func NewAPIClient(opts *ClientOpts) (APIBaseClient, error) {
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
return result, newApiError(resp, opts.URL)
|
return result, newAPIError(resp, opts.URL)
|
||||||
}
|
}
|
||||||
|
|
||||||
schemasURLs := resp.Header.Get("X-API-Schemas")
|
schemasURLs := resp.Header.Get("X-API-Schemas")
|
||||||
@@ -184,7 +184,7 @@ func NewAPIClient(opts *ClientOpts) (APIBaseClient, error) {
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
return result, newApiError(resp, opts.URL)
|
return result, newAPIError(resp, opts.URL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,7 +244,7 @@ func (a *APIBaseClient) Post(url string, createObj interface{}, respObject inter
|
|||||||
func (a *APIBaseClient) GetLink(resource types.Resource, link string, respObject interface{}) error {
|
func (a *APIBaseClient) GetLink(resource types.Resource, link string, respObject interface{}) error {
|
||||||
url := resource.Links[link]
|
url := resource.Links[link]
|
||||||
if url == "" {
|
if url == "" {
|
||||||
return fmt.Errorf("Failed to find link: %s", link)
|
return fmt.Errorf("failed to find link: %s", link)
|
||||||
}
|
}
|
||||||
|
|
||||||
return a.Ops.DoGet(url, &types.ListOpts{}, respObject)
|
return a.Ops.DoGet(url, &types.ListOpts{}, respObject)
|
||||||
@@ -270,12 +270,12 @@ func (a *APIBaseClient) Delete(existing *types.Resource) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *APIBaseClient) Reload(existing *types.Resource, output interface{}) error {
|
func (a *APIBaseClient) Reload(existing *types.Resource, output interface{}) error {
|
||||||
selfUrl, ok := existing.Links[SELF]
|
selfURL, ok := existing.Links[SELF]
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New(fmt.Sprintf("Failed to find self URL of [%v]", existing))
|
return fmt.Errorf("failed to find self URL of [%v]", existing)
|
||||||
}
|
}
|
||||||
|
|
||||||
return a.Ops.DoGet(selfUrl, NewListOpts(), output)
|
return a.Ops.DoGet(selfURL, NewListOpts(), output)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *APIBaseClient) Action(schemaType string, action string,
|
func (a *APIBaseClient) Action(schemaType string, action string,
|
||||||
|
21
vendor/github.com/rancher/norman/clientbase/object_client.go
generated
vendored
21
vendor/github.com/rancher/norman/clientbase/object_client.go
generated
vendored
@@ -35,6 +35,13 @@ func NewObjectClient(namespace string, restClient rest.Interface, apiResource *m
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *ObjectClient) getAPIPrefix() string {
|
||||||
|
if p.gvk.Group == "" {
|
||||||
|
return "api"
|
||||||
|
}
|
||||||
|
return "apis"
|
||||||
|
}
|
||||||
|
|
||||||
func (p *ObjectClient) Create(o runtime.Object) (runtime.Object, error) {
|
func (p *ObjectClient) Create(o runtime.Object) (runtime.Object, error) {
|
||||||
ns := p.ns
|
ns := p.ns
|
||||||
if obj, ok := o.(metav1.Object); ok && obj.GetNamespace() != "" {
|
if obj, ok := o.(metav1.Object); ok && obj.GetNamespace() != "" {
|
||||||
@@ -42,7 +49,7 @@ func (p *ObjectClient) Create(o runtime.Object) (runtime.Object, error) {
|
|||||||
}
|
}
|
||||||
result := p.Factory.Object()
|
result := p.Factory.Object()
|
||||||
err := p.restClient.Post().
|
err := p.restClient.Post().
|
||||||
Prefix("apis", p.gvk.Group, p.gvk.Version).
|
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
|
||||||
NamespaceIfScoped(ns, p.resource.Namespaced).
|
NamespaceIfScoped(ns, p.resource.Namespaced).
|
||||||
Resource(p.resource.Name).
|
Resource(p.resource.Name).
|
||||||
Body(o).
|
Body(o).
|
||||||
@@ -54,7 +61,7 @@ func (p *ObjectClient) Create(o runtime.Object) (runtime.Object, error) {
|
|||||||
func (p *ObjectClient) Get(name string, opts metav1.GetOptions) (runtime.Object, error) {
|
func (p *ObjectClient) Get(name string, opts metav1.GetOptions) (runtime.Object, error) {
|
||||||
result := p.Factory.Object()
|
result := p.Factory.Object()
|
||||||
err := p.restClient.Get().
|
err := p.restClient.Get().
|
||||||
Prefix("apis", p.gvk.Group, p.gvk.Version).
|
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
|
||||||
NamespaceIfScoped(p.ns, p.resource.Namespaced).
|
NamespaceIfScoped(p.ns, p.resource.Namespaced).
|
||||||
Resource(p.resource.Name).
|
Resource(p.resource.Name).
|
||||||
VersionedParams(&opts, dynamic.VersionedParameterEncoderWithV1Fallback).
|
VersionedParams(&opts, dynamic.VersionedParameterEncoderWithV1Fallback).
|
||||||
@@ -74,7 +81,7 @@ func (p *ObjectClient) Update(name string, o runtime.Object) (runtime.Object, er
|
|||||||
return result, errors.New("object missing name")
|
return result, errors.New("object missing name")
|
||||||
}
|
}
|
||||||
err := p.restClient.Put().
|
err := p.restClient.Put().
|
||||||
Prefix("apis", p.gvk.Group, p.gvk.Version).
|
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
|
||||||
NamespaceIfScoped(ns, p.resource.Namespaced).
|
NamespaceIfScoped(ns, p.resource.Namespaced).
|
||||||
Resource(p.resource.Name).
|
Resource(p.resource.Name).
|
||||||
Name(name).
|
Name(name).
|
||||||
@@ -86,7 +93,7 @@ func (p *ObjectClient) Update(name string, o runtime.Object) (runtime.Object, er
|
|||||||
|
|
||||||
func (p *ObjectClient) Delete(name string, opts *metav1.DeleteOptions) error {
|
func (p *ObjectClient) Delete(name string, opts *metav1.DeleteOptions) error {
|
||||||
return p.restClient.Delete().
|
return p.restClient.Delete().
|
||||||
Prefix("apis", p.gvk.Group, p.gvk.Version).
|
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
|
||||||
NamespaceIfScoped(p.ns, p.resource.Namespaced).
|
NamespaceIfScoped(p.ns, p.resource.Namespaced).
|
||||||
Resource(p.resource.Name).
|
Resource(p.resource.Name).
|
||||||
Name(name).
|
Name(name).
|
||||||
@@ -98,7 +105,7 @@ func (p *ObjectClient) Delete(name string, opts *metav1.DeleteOptions) error {
|
|||||||
func (p *ObjectClient) List(opts metav1.ListOptions) (runtime.Object, error) {
|
func (p *ObjectClient) List(opts metav1.ListOptions) (runtime.Object, error) {
|
||||||
result := p.Factory.List()
|
result := p.Factory.List()
|
||||||
return result, p.restClient.Get().
|
return result, p.restClient.Get().
|
||||||
Prefix("apis", p.gvk.Group, p.gvk.Version).
|
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
|
||||||
NamespaceIfScoped(p.ns, p.resource.Namespaced).
|
NamespaceIfScoped(p.ns, p.resource.Namespaced).
|
||||||
Resource(p.resource.Name).
|
Resource(p.resource.Name).
|
||||||
VersionedParams(&opts, dynamic.VersionedParameterEncoderWithV1Fallback).
|
VersionedParams(&opts, dynamic.VersionedParameterEncoderWithV1Fallback).
|
||||||
@@ -108,7 +115,7 @@ func (p *ObjectClient) List(opts metav1.ListOptions) (runtime.Object, error) {
|
|||||||
|
|
||||||
func (p *ObjectClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
func (p *ObjectClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||||
r, err := p.restClient.Get().
|
r, err := p.restClient.Get().
|
||||||
Prefix("apis", p.gvk.Group, p.gvk.Version).
|
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
|
||||||
Prefix("watch").
|
Prefix("watch").
|
||||||
Namespace(p.ns).
|
Namespace(p.ns).
|
||||||
NamespaceIfScoped(p.ns, p.resource.Namespaced).
|
NamespaceIfScoped(p.ns, p.resource.Namespaced).
|
||||||
@@ -127,7 +134,7 @@ func (p *ObjectClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
|||||||
|
|
||||||
func (p *ObjectClient) DeleteCollection(deleteOptions *metav1.DeleteOptions, listOptions metav1.ListOptions) error {
|
func (p *ObjectClient) DeleteCollection(deleteOptions *metav1.DeleteOptions, listOptions metav1.ListOptions) error {
|
||||||
return p.restClient.Delete().
|
return p.restClient.Delete().
|
||||||
Prefix("apis", p.gvk.Group, p.gvk.Version).
|
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
|
||||||
NamespaceIfScoped(p.ns, p.resource.Namespaced).
|
NamespaceIfScoped(p.ns, p.resource.Namespaced).
|
||||||
Resource(p.resource.Name).
|
Resource(p.resource.Name).
|
||||||
VersionedParams(&listOptions, dynamic.VersionedParameterEncoderWithV1Fallback).
|
VersionedParams(&listOptions, dynamic.VersionedParameterEncoderWithV1Fallback).
|
||||||
|
46
vendor/github.com/rancher/norman/clientbase/ops.go
generated
vendored
46
vendor/github.com/rancher/norman/clientbase/ops.go
generated
vendored
@@ -34,7 +34,7 @@ func (a *APIOperations) DoDelete(url string) error {
|
|||||||
io.Copy(ioutil.Discard, resp.Body)
|
io.Copy(ioutil.Discard, resp.Body)
|
||||||
|
|
||||||
if resp.StatusCode >= 300 {
|
if resp.StatusCode >= 300 {
|
||||||
return newApiError(resp, url)
|
return newAPIError(resp, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -68,7 +68,7 @@ func (a *APIOperations) DoGet(url string, opts *types.ListOpts, respObject inter
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
return newApiError(resp, url)
|
return newAPIError(resp, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
byteContent, err := ioutil.ReadAll(resp.Body)
|
byteContent, err := ioutil.ReadAll(resp.Body)
|
||||||
@@ -97,16 +97,16 @@ func (a *APIOperations) DoList(schemaType string, opts *types.ListOpts, respObje
|
|||||||
return errors.New("Resource type [" + schemaType + "] is not listable")
|
return errors.New("Resource type [" + schemaType + "] is not listable")
|
||||||
}
|
}
|
||||||
|
|
||||||
collectionUrl, ok := schema.Links[COLLECTION]
|
collectionURL, ok := schema.Links[COLLECTION]
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("Failed to find collection URL for [" + schemaType + "]")
|
return errors.New("Failed to find collection URL for [" + schemaType + "]")
|
||||||
}
|
}
|
||||||
|
|
||||||
return a.DoGet(collectionUrl, opts, respObject)
|
return a.DoGet(collectionURL, opts, respObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *APIOperations) DoNext(nextUrl string, respObject interface{}) error {
|
func (a *APIOperations) DoNext(nextURL string, respObject interface{}) error {
|
||||||
return a.DoGet(nextUrl, nil, respObject)
|
return a.DoGet(nextURL, nil, respObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *APIOperations) DoModify(method string, url string, createObj interface{}, respObject interface{}) error {
|
func (a *APIOperations) DoModify(method string, url string, createObj interface{}, respObject interface{}) error {
|
||||||
@@ -136,7 +136,7 @@ func (a *APIOperations) DoModify(method string, url string, createObj interface{
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode >= 300 {
|
if resp.StatusCode >= 300 {
|
||||||
return newApiError(resp, url)
|
return newAPIError(resp, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
byteContent, err := ioutil.ReadAll(resp.Body)
|
byteContent, err := ioutil.ReadAll(resp.Body)
|
||||||
@@ -170,16 +170,16 @@ func (a *APIOperations) DoCreate(schemaType string, createObj interface{}, respO
|
|||||||
return errors.New("Resource type [" + schemaType + "] is not creatable")
|
return errors.New("Resource type [" + schemaType + "] is not creatable")
|
||||||
}
|
}
|
||||||
|
|
||||||
var collectionUrl string
|
var collectionURL string
|
||||||
collectionUrl, ok = schema.Links[COLLECTION]
|
collectionURL, ok = schema.Links[COLLECTION]
|
||||||
if !ok {
|
if !ok {
|
||||||
// return errors.New("Failed to find collection URL for [" + schemaType + "]")
|
// return errors.New("Failed to find collection URL for [" + schemaType + "]")
|
||||||
// This is a hack to address https://github.com/rancher/cattle/issues/254
|
// This is a hack to address https://github.com/rancher/cattle/issues/254
|
||||||
re := regexp.MustCompile("schemas.*")
|
re := regexp.MustCompile("schemas.*")
|
||||||
collectionUrl = re.ReplaceAllString(schema.Links[SELF], schema.PluralName)
|
collectionURL = re.ReplaceAllString(schema.Links[SELF], schema.PluralName)
|
||||||
}
|
}
|
||||||
|
|
||||||
return a.DoModify("POST", collectionUrl, createObj, respObject)
|
return a.DoModify("POST", collectionURL, createObj, respObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *APIOperations) DoUpdate(schemaType string, existing *types.Resource, updates interface{}, respObject interface{}) error {
|
func (a *APIOperations) DoUpdate(schemaType string, existing *types.Resource, updates interface{}, respObject interface{}) error {
|
||||||
@@ -187,9 +187,9 @@ func (a *APIOperations) DoUpdate(schemaType string, existing *types.Resource, up
|
|||||||
return errors.New("Existing object is nil")
|
return errors.New("Existing object is nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
selfUrl, ok := existing.Links[SELF]
|
selfURL, ok := existing.Links[SELF]
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New(fmt.Sprintf("Failed to find self URL of [%v]", existing))
|
return fmt.Errorf("failed to find self URL of [%v]", existing)
|
||||||
}
|
}
|
||||||
|
|
||||||
if updates == nil {
|
if updates == nil {
|
||||||
@@ -209,7 +209,7 @@ func (a *APIOperations) DoUpdate(schemaType string, existing *types.Resource, up
|
|||||||
return errors.New("Resource type [" + schemaType + "] is not updatable")
|
return errors.New("Resource type [" + schemaType + "] is not updatable")
|
||||||
}
|
}
|
||||||
|
|
||||||
return a.DoModify("PUT", selfUrl, updates, respObject)
|
return a.DoModify("PUT", selfURL, updates, respObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *APIOperations) DoByID(schemaType string, id string, respObject interface{}) error {
|
func (a *APIOperations) DoByID(schemaType string, id string, respObject interface{}) error {
|
||||||
@@ -222,12 +222,12 @@ func (a *APIOperations) DoByID(schemaType string, id string, respObject interfac
|
|||||||
return errors.New("Resource type [" + schemaType + "] can not be looked up by ID")
|
return errors.New("Resource type [" + schemaType + "] can not be looked up by ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
collectionUrl, ok := schema.Links[COLLECTION]
|
collectionURL, ok := schema.Links[COLLECTION]
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("Failed to find collection URL for [" + schemaType + "]")
|
return errors.New("Failed to find collection URL for [" + schemaType + "]")
|
||||||
}
|
}
|
||||||
|
|
||||||
return a.DoGet(collectionUrl+"/"+id, nil, respObject)
|
return a.DoGet(collectionURL+"/"+id, nil, respObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *APIOperations) DoResourceDelete(schemaType string, existing *types.Resource) error {
|
func (a *APIOperations) DoResourceDelete(schemaType string, existing *types.Resource) error {
|
||||||
@@ -240,12 +240,12 @@ func (a *APIOperations) DoResourceDelete(schemaType string, existing *types.Reso
|
|||||||
return errors.New("Resource type [" + schemaType + "] can not be deleted")
|
return errors.New("Resource type [" + schemaType + "] can not be deleted")
|
||||||
}
|
}
|
||||||
|
|
||||||
selfUrl, ok := existing.Links[SELF]
|
selfURL, ok := existing.Links[SELF]
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New(fmt.Sprintf("Failed to find self URL of [%v]", existing))
|
return fmt.Errorf("failed to find self URL of [%v]", existing)
|
||||||
}
|
}
|
||||||
|
|
||||||
return a.DoDelete(selfUrl)
|
return a.DoDelete(selfURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *APIOperations) DoAction(schemaType string, action string,
|
func (a *APIOperations) DoAction(schemaType string, action string,
|
||||||
@@ -255,9 +255,9 @@ func (a *APIOperations) DoAction(schemaType string, action string,
|
|||||||
return errors.New("Existing object is nil")
|
return errors.New("Existing object is nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
actionUrl, ok := existing.Actions[action]
|
actionURL, ok := existing.Actions[action]
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New(fmt.Sprintf("Action [%v] not available on [%v]", action, existing))
|
return fmt.Errorf("action [%v] not available on [%v]", action, existing)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, ok = a.Types[schemaType]
|
_, ok = a.Types[schemaType]
|
||||||
@@ -278,7 +278,7 @@ func (a *APIOperations) DoAction(schemaType string, action string,
|
|||||||
input = bytes.NewBuffer(bodyContent)
|
input = bytes.NewBuffer(bodyContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := http.NewRequest("POST", actionUrl, input)
|
req, err := http.NewRequest("POST", actionURL, input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -295,7 +295,7 @@ func (a *APIOperations) DoAction(schemaType string, action string,
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode >= 300 {
|
if resp.StatusCode >= 300 {
|
||||||
return newApiError(resp, actionUrl)
|
return newAPIError(resp, actionURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
byteContent, err := ioutil.ReadAll(resp.Body)
|
byteContent, err := ioutil.ReadAll(resp.Body)
|
||||||
|
8
vendor/github.com/rancher/norman/controller/generic_controller.go
generated
vendored
8
vendor/github.com/rancher/norman/controller/generic_controller.go
generated
vendored
@@ -25,7 +25,7 @@ type GenericController interface {
|
|||||||
Informer() cache.SharedIndexInformer
|
Informer() cache.SharedIndexInformer
|
||||||
AddHandler(handler HandlerFunc)
|
AddHandler(handler HandlerFunc)
|
||||||
Enqueue(namespace, name string)
|
Enqueue(namespace, name string)
|
||||||
Start(threadiness int, ctx context.Context) error
|
Start(ctx context.Context, threadiness int) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type genericController struct {
|
type genericController struct {
|
||||||
@@ -69,12 +69,12 @@ func (g *genericController) AddHandler(handler HandlerFunc) {
|
|||||||
g.handlers = append(g.handlers, handler)
|
g.handlers = append(g.handlers, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *genericController) Start(threadiness int, ctx context.Context) error {
|
func (g *genericController) Start(ctx context.Context, threadiness int) error {
|
||||||
g.Lock()
|
g.Lock()
|
||||||
defer g.Unlock()
|
defer g.Unlock()
|
||||||
|
|
||||||
if !g.running {
|
if !g.running {
|
||||||
go g.run(threadiness, ctx)
|
go g.run(ctx, threadiness)
|
||||||
}
|
}
|
||||||
|
|
||||||
g.running = true
|
g.running = true
|
||||||
@@ -88,7 +88,7 @@ func (g *genericController) queueObject(obj interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *genericController) run(threadiness int, ctx context.Context) {
|
func (g *genericController) run(ctx context.Context, threadiness int) {
|
||||||
defer utilruntime.HandleCrash()
|
defer utilruntime.HandleCrash()
|
||||||
defer g.queue.ShutDown()
|
defer g.queue.ShutDown()
|
||||||
|
|
||||||
|
140
vendor/github.com/rancher/norman/types/condition.go
generated
vendored
140
vendor/github.com/rancher/norman/types/condition.go
generated
vendored
@@ -1,108 +1,108 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
var (
|
import (
|
||||||
COND_EQ = QueryConditionType{"eq", 1}
|
"github.com/rancher/norman/types/convert"
|
||||||
COND_NE = QueryConditionType{"ne", 1}
|
)
|
||||||
COND_NULL = QueryConditionType{"null", 0}
|
|
||||||
COND_NOTNULL = QueryConditionType{"notnull", 0}
|
|
||||||
COND_IN = QueryConditionType{"in", -1}
|
|
||||||
COND_NOTIN = QueryConditionType{"notin", -1}
|
|
||||||
COND_OR = QueryConditionType{"or", 1}
|
|
||||||
COND_AND = QueryConditionType{"and", 1}
|
|
||||||
|
|
||||||
mods = map[string]QueryConditionType{
|
var (
|
||||||
COND_EQ.Name: COND_EQ,
|
CondEQ = QueryConditionType{ModifierEQ, 1}
|
||||||
COND_NE.Name: COND_NE,
|
CondNE = QueryConditionType{ModifierNE, 1}
|
||||||
COND_NULL.Name: COND_NULL,
|
CondNull = QueryConditionType{ModifierNull, 0}
|
||||||
COND_NOTNULL.Name: COND_NOTNULL,
|
CondNotNull = QueryConditionType{ModifierNotNull, 0}
|
||||||
COND_IN.Name: COND_IN,
|
CondIn = QueryConditionType{ModifierIn, -1}
|
||||||
COND_NOTIN.Name: COND_NOTIN,
|
CondNotIn = QueryConditionType{ModifierNotIn, -1}
|
||||||
COND_OR.Name: COND_OR,
|
CondOr = QueryConditionType{ModifierType("or"), 1}
|
||||||
COND_AND.Name: COND_AND,
|
CondAnd = QueryConditionType{ModifierType("and"), 1}
|
||||||
|
|
||||||
|
mods = map[ModifierType]QueryConditionType{
|
||||||
|
CondEQ.Name: CondEQ,
|
||||||
|
CondNE.Name: CondNE,
|
||||||
|
CondNull.Name: CondNull,
|
||||||
|
CondNotNull.Name: CondNotNull,
|
||||||
|
CondIn.Name: CondIn,
|
||||||
|
CondNotIn.Name: CondNotIn,
|
||||||
|
CondOr.Name: CondOr,
|
||||||
|
CondAnd.Name: CondAnd,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
type QueryConditionType struct {
|
type QueryConditionType struct {
|
||||||
Name string
|
Name ModifierType
|
||||||
Args int
|
Args int
|
||||||
}
|
}
|
||||||
|
|
||||||
type QueryCondition struct {
|
type QueryCondition struct {
|
||||||
Field string
|
Field string
|
||||||
Values []interface{}
|
Value string
|
||||||
|
Values map[string]bool
|
||||||
conditionType QueryConditionType
|
conditionType QueryConditionType
|
||||||
left, right *QueryCondition
|
left, right *QueryCondition
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (q *QueryCondition) Valid(data map[string]interface{}) bool {
|
||||||
|
switch q.conditionType {
|
||||||
|
case CondAnd:
|
||||||
|
if q.left == nil || q.right == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return q.left.Valid(data) && q.right.Valid(data)
|
||||||
|
case CondOr:
|
||||||
|
if q.left == nil || q.right == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return q.left.Valid(data) || q.right.Valid(data)
|
||||||
|
case CondEQ:
|
||||||
|
return q.Value == convert.ToString(data[q.Field])
|
||||||
|
case CondNE:
|
||||||
|
return q.Value != convert.ToString(data[q.Field])
|
||||||
|
case CondIn:
|
||||||
|
return q.Values[convert.ToString(data[q.Field])]
|
||||||
|
case CondNotIn:
|
||||||
|
return !q.Values[convert.ToString(data[q.Field])]
|
||||||
|
case CondNotNull:
|
||||||
|
return convert.ToString(data[q.Field]) != ""
|
||||||
|
case CondNull:
|
||||||
|
return convert.ToString(data[q.Field]) == ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (q *QueryCondition) ToCondition() Condition {
|
func (q *QueryCondition) ToCondition() Condition {
|
||||||
cond := Condition{
|
cond := Condition{
|
||||||
Modifier: q.conditionType.Name,
|
Modifier: q.conditionType.Name,
|
||||||
}
|
}
|
||||||
if q.conditionType.Args == 1 && len(q.Values) > 0 {
|
if q.conditionType.Args == 1 {
|
||||||
cond.Value = q.Values[0]
|
cond.Value = q.Value
|
||||||
} else if q.conditionType.Args == -1 {
|
} else if q.conditionType.Args == -1 {
|
||||||
cond.Value = q.Values
|
stringValues := []string{}
|
||||||
|
for val := range q.Values {
|
||||||
|
stringValues = append(stringValues, val)
|
||||||
|
}
|
||||||
|
cond.Value = stringValues
|
||||||
}
|
}
|
||||||
|
|
||||||
return cond
|
return cond
|
||||||
}
|
}
|
||||||
|
|
||||||
func ValidMod(mod string) bool {
|
func ValidMod(mod ModifierType) bool {
|
||||||
_, ok := mods[mod]
|
_, ok := mods[mod]
|
||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConditionFromString(field, mod string, values ...interface{}) *QueryCondition {
|
func NewConditionFromString(field string, mod ModifierType, values ...string) *QueryCondition {
|
||||||
return &QueryCondition{
|
q := &QueryCondition{
|
||||||
Field: field,
|
Field: field,
|
||||||
Values: values,
|
|
||||||
conditionType: mods[mod],
|
conditionType: mods[mod],
|
||||||
|
Values: map[string]bool{},
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func NewCondition(mod QueryConditionType, values ...interface{}) *QueryCondition {
|
for i, value := range values {
|
||||||
return &QueryCondition{
|
if i == 0 {
|
||||||
Values: values,
|
q.Value = value
|
||||||
conditionType: mod,
|
|
||||||
}
|
}
|
||||||
}
|
q.Values[value] = true
|
||||||
|
|
||||||
func NE(value interface{}) *QueryCondition {
|
|
||||||
return NewCondition(COND_NE, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
func EQ(value interface{}) *QueryCondition {
|
|
||||||
return NewCondition(COND_EQ, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NULL(value interface{}) *QueryCondition {
|
|
||||||
return NewCondition(COND_NULL)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NOTNULL(value interface{}) *QueryCondition {
|
|
||||||
return NewCondition(COND_NOTNULL)
|
|
||||||
}
|
|
||||||
|
|
||||||
func IN(values ...interface{}) *QueryCondition {
|
|
||||||
return NewCondition(COND_IN, values...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NOTIN(values ...interface{}) *QueryCondition {
|
|
||||||
return NewCondition(COND_NOTIN, values...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *QueryCondition) AND(right *QueryCondition) *QueryCondition {
|
|
||||||
return &QueryCondition{
|
|
||||||
conditionType: COND_AND,
|
|
||||||
left: c,
|
|
||||||
right: right,
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func (c *QueryCondition) OR(right *QueryCondition) *QueryCondition {
|
return q
|
||||||
return &QueryCondition{
|
|
||||||
conditionType: COND_OR,
|
|
||||||
left: c,
|
|
||||||
right: right,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
4
vendor/github.com/rancher/norman/types/convert/convert.go
generated
vendored
4
vendor/github.com/rancher/norman/types/convert/convert.go
generated
vendored
@@ -132,12 +132,12 @@ func ToStringSlice(data interface{}) []string {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ToObj(data interface{}, obj interface{}) error {
|
func ToObj(data interface{}, into interface{}) error {
|
||||||
bytes, err := json.Marshal(data)
|
bytes, err := json.Marshal(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return json.Unmarshal(bytes, obj)
|
return json.Unmarshal(bytes, into)
|
||||||
}
|
}
|
||||||
|
|
||||||
func EncodeToMap(obj interface{}) (map[string]interface{}, error) {
|
func EncodeToMap(obj interface{}) (map[string]interface{}, error) {
|
||||||
|
11
vendor/github.com/rancher/norman/types/convert/ref.go
generated
vendored
Normal file
11
vendor/github.com/rancher/norman/types/convert/ref.go
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package convert
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func ToReference(typeName string) string {
|
||||||
|
return fmt.Sprintf("reference[%s]", typeName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func ToFullReference(path, typeName string) string {
|
||||||
|
return fmt.Sprintf("reference[%s/schemas/%s]", path, typeName)
|
||||||
|
}
|
3
vendor/github.com/rancher/norman/types/convert/value_set_string.go
generated
vendored
3
vendor/github.com/rancher/norman/types/convert/value_set_string.go
generated
vendored
@@ -13,7 +13,6 @@ func ToValuesSlice(value string) []string {
|
|||||||
value = strings.TrimSpace(value)
|
value = strings.TrimSpace(value)
|
||||||
if strings.HasPrefix(value, "(") && strings.HasSuffix(value, ")") {
|
if strings.HasPrefix(value, "(") && strings.HasSuffix(value, ")") {
|
||||||
return splitRegexp.Split(value[1:len(value)-1], -1)
|
return splitRegexp.Split(value[1:len(value)-1], -1)
|
||||||
} else {
|
|
||||||
return []string{value}
|
|
||||||
}
|
}
|
||||||
|
return []string{value}
|
||||||
}
|
}
|
||||||
|
62
vendor/github.com/rancher/norman/types/mapper.go
generated
vendored
62
vendor/github.com/rancher/norman/types/mapper.go
generated
vendored
@@ -1,7 +1,6 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/rancher/norman/types/definition"
|
"github.com/rancher/norman/types/definition"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -11,14 +10,37 @@ type Mapper interface {
|
|||||||
ModifySchema(schema *Schema, schemas *Schemas) error
|
ModifySchema(schema *Schema, schemas *Schemas) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type TypeMapper struct {
|
type Mappers []Mapper
|
||||||
|
|
||||||
|
func (m Mappers) FromInternal(data map[string]interface{}) {
|
||||||
|
for _, mapper := range m {
|
||||||
|
mapper.FromInternal(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m Mappers) ToInternal(data map[string]interface{}) {
|
||||||
|
for i := len(m) - 1; i >= 0; i-- {
|
||||||
|
m[i].ToInternal(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m Mappers) ModifySchema(schema *Schema, schemas *Schemas) error {
|
||||||
|
for _, mapper := range m {
|
||||||
|
if err := mapper.ModifySchema(schema, schemas); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type typeMapper struct {
|
||||||
Mappers []Mapper
|
Mappers []Mapper
|
||||||
typeName string
|
typeName string
|
||||||
subSchemas map[string]*Schema
|
subSchemas map[string]*Schema
|
||||||
subArraySchemas map[string]*Schema
|
subArraySchemas map[string]*Schema
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TypeMapper) FromInternal(data map[string]interface{}) {
|
func (t *typeMapper) FromInternal(data map[string]interface{}) {
|
||||||
for fieldName, schema := range t.subSchemas {
|
for fieldName, schema := range t.subSchemas {
|
||||||
if schema.Mapper == nil {
|
if schema.Mapper == nil {
|
||||||
continue
|
continue
|
||||||
@@ -38,19 +60,29 @@ func (t *TypeMapper) FromInternal(data map[string]interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, mapper := range t.Mappers {
|
Mappers(t.Mappers).FromInternal(data)
|
||||||
mapper.FromInternal(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
if data != nil {
|
if data != nil {
|
||||||
|
if _, ok := data["type"]; !ok {
|
||||||
data["type"] = t.typeName
|
data["type"] = t.typeName
|
||||||
}
|
}
|
||||||
|
name, _ := data["name"].(string)
|
||||||
|
namespace, _ := data["namespace"].(string)
|
||||||
|
|
||||||
|
if _, ok := data["id"]; !ok {
|
||||||
|
if name != "" {
|
||||||
|
if namespace == "" {
|
||||||
|
data["id"] = name
|
||||||
|
} else {
|
||||||
|
data["id"] = namespace + ":" + name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TypeMapper) ToInternal(data map[string]interface{}) {
|
func (t *typeMapper) ToInternal(data map[string]interface{}) {
|
||||||
for i := len(t.Mappers) - 1; i >= 0; i-- {
|
Mappers(t.Mappers).ToInternal(data)
|
||||||
t.Mappers[i].ToInternal(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
for fieldName, schema := range t.subArraySchemas {
|
for fieldName, schema := range t.subArraySchemas {
|
||||||
if schema.Mapper == nil {
|
if schema.Mapper == nil {
|
||||||
@@ -71,7 +103,7 @@ func (t *TypeMapper) ToInternal(data map[string]interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TypeMapper) ModifySchema(schema *Schema, schemas *Schemas) error {
|
func (t *typeMapper) ModifySchema(schema *Schema, schemas *Schemas) error {
|
||||||
t.subSchemas = map[string]*Schema{}
|
t.subSchemas = map[string]*Schema{}
|
||||||
t.subArraySchemas = map[string]*Schema{}
|
t.subArraySchemas = map[string]*Schema{}
|
||||||
t.typeName = schema.ID
|
t.typeName = schema.ID
|
||||||
@@ -94,11 +126,5 @@ func (t *TypeMapper) ModifySchema(schema *Schema, schemas *Schemas) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, mapper := range t.Mappers {
|
return Mappers(t.Mappers).ModifySchema(schema, schemas)
|
||||||
if err := mapper.ModifySchema(schema, schemas); err != nil {
|
|
||||||
return errors.Wrapf(err, "mapping type %s", schema.ID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
115
vendor/github.com/rancher/norman/types/reflection.go
generated
vendored
115
vendor/github.com/rancher/norman/types/reflection.go
generated
vendored
@@ -6,13 +6,19 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/rancher/norman/types/convert"
|
"github.com/rancher/norman/types/convert"
|
||||||
|
"github.com/rancher/norman/types/definition"
|
||||||
|
"github.com/rancher/norman/types/slice"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
namespacedType = reflect.TypeOf(Namespaced{})
|
||||||
resourceType = reflect.TypeOf(Resource{})
|
resourceType = reflect.TypeOf(Resource{})
|
||||||
|
typeType = reflect.TypeOf(metav1.TypeMeta{})
|
||||||
metaType = reflect.TypeOf(metav1.ObjectMeta{})
|
metaType = reflect.TypeOf(metav1.ObjectMeta{})
|
||||||
blacklistNames = map[string]bool{
|
blacklistNames = map[string]bool{
|
||||||
"links": true,
|
"links": true,
|
||||||
@@ -20,10 +26,17 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *Schemas) AddMapperForType(version *APIVersion, obj interface{}, mapper Mapper) *Schemas {
|
func (s *Schemas) AddMapperForType(version *APIVersion, obj interface{}, mapper ...Mapper) *Schemas {
|
||||||
|
if len(mapper) == 0 {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
t := reflect.TypeOf(obj)
|
t := reflect.TypeOf(obj)
|
||||||
typeName := convert.LowerTitle(t.Name())
|
typeName := convert.LowerTitle(t.Name())
|
||||||
return s.AddMapper(version, typeName, mapper)
|
if len(mapper) == 1 {
|
||||||
|
return s.AddMapper(version, typeName, mapper[0])
|
||||||
|
}
|
||||||
|
return s.AddMapper(version, typeName, Mappers(mapper))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Schemas) MustImport(version *APIVersion, obj interface{}, externalOverrides ...interface{}) *Schemas {
|
func (s *Schemas) MustImport(version *APIVersion, obj interface{}, externalOverrides ...interface{}) *Schemas {
|
||||||
@@ -35,8 +48,13 @@ func (s *Schemas) MustImport(version *APIVersion, obj interface{}, externalOverr
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Schemas) MustImportAndCustomize(version *APIVersion, obj interface{}, f func(*Schema), externalOverrides ...interface{}) *Schemas {
|
||||||
|
return s.MustImport(version, obj, externalOverrides...).
|
||||||
|
MustCustomizeType(version, obj, f)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Schemas) Import(version *APIVersion, obj interface{}, externalOverrides ...interface{}) (*Schema, error) {
|
func (s *Schemas) Import(version *APIVersion, obj interface{}, externalOverrides ...interface{}) (*Schema, error) {
|
||||||
types := []reflect.Type{}
|
var types []reflect.Type
|
||||||
for _, override := range externalOverrides {
|
for _, override := range externalOverrides {
|
||||||
types = append(types, reflect.TypeOf(override))
|
types = append(types, reflect.TypeOf(override))
|
||||||
}
|
}
|
||||||
@@ -60,6 +78,54 @@ func (s *Schemas) newSchemaFromType(version *APIVersion, t reflect.Type, typeNam
|
|||||||
return schema, nil
|
return schema, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Schemas) setupFilters(schema *Schema) {
|
||||||
|
if !slice.ContainsString(schema.CollectionMethods, http.MethodGet) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for fieldName, field := range schema.ResourceFields {
|
||||||
|
var mods []ModifierType
|
||||||
|
switch field.Type {
|
||||||
|
case "enum":
|
||||||
|
mods = []ModifierType{ModifierEQ, ModifierNE, ModifierIn, ModifierNotIn}
|
||||||
|
case "string":
|
||||||
|
mods = []ModifierType{ModifierEQ, ModifierNE, ModifierIn, ModifierNotIn}
|
||||||
|
case "int":
|
||||||
|
mods = []ModifierType{ModifierEQ, ModifierNE, ModifierIn, ModifierNotIn}
|
||||||
|
case "boolean":
|
||||||
|
mods = []ModifierType{ModifierEQ, ModifierNE}
|
||||||
|
default:
|
||||||
|
if definition.IsReferenceType(field.Type) {
|
||||||
|
mods = []ModifierType{ModifierEQ, ModifierNE, ModifierIn, ModifierNotIn}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(mods) > 0 {
|
||||||
|
if schema.CollectionFilters == nil {
|
||||||
|
schema.CollectionFilters = map[string]Filter{}
|
||||||
|
}
|
||||||
|
schema.CollectionFilters[fieldName] = Filter{
|
||||||
|
Modifiers: mods,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Schemas) MustCustomizeType(version *APIVersion, obj interface{}, f func(*Schema)) *Schemas {
|
||||||
|
name := convert.LowerTitle(reflect.TypeOf(obj).Name())
|
||||||
|
schema := s.Schema(version, name)
|
||||||
|
if schema == nil {
|
||||||
|
panic("Failed to find schema " + name)
|
||||||
|
}
|
||||||
|
|
||||||
|
f(schema)
|
||||||
|
|
||||||
|
if schema.SubContext != "" {
|
||||||
|
s.schemasBySubContext[schema.SubContext] = schema
|
||||||
|
}
|
||||||
|
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Schemas) importType(version *APIVersion, t reflect.Type, overrides ...reflect.Type) (*Schema, error) {
|
func (s *Schemas) importType(version *APIVersion, t reflect.Type, overrides ...reflect.Type) (*Schema, error) {
|
||||||
typeName := convert.LowerTitle(t.Name())
|
typeName := convert.LowerTitle(t.Name())
|
||||||
|
|
||||||
@@ -75,8 +141,13 @@ func (s *Schemas) importType(version *APIVersion, t reflect.Type, overrides ...r
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
mapper := s.mapper(&schema.Version, schema.ID)
|
mappers := s.mapper(&schema.Version, schema.ID)
|
||||||
if mapper != nil {
|
if schema.CanList() {
|
||||||
|
mappers = append(s.DefaultMappers, mappers...)
|
||||||
|
}
|
||||||
|
mappers = append(mappers, s.DefaultPostMappers...)
|
||||||
|
|
||||||
|
if len(mappers) > 0 {
|
||||||
copy, err := s.newSchemaFromType(version, t, typeName)
|
copy, err := s.newSchemaFromType(version, t, typeName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -90,14 +161,16 @@ func (s *Schemas) importType(version *APIVersion, t reflect.Type, overrides ...r
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if mapper == nil {
|
mapper := &typeMapper{
|
||||||
mapper = &TypeMapper{}
|
Mappers: mappers,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := mapper.ModifySchema(schema, s); err != nil {
|
if err := mapper.ModifySchema(schema, s); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.setupFilters(schema)
|
||||||
|
|
||||||
schema.Mapper = mapper
|
schema.Mapper = mapper
|
||||||
s.AddSchema(schema)
|
s.AddSchema(schema)
|
||||||
|
|
||||||
@@ -114,6 +187,9 @@ func (s *Schemas) readFields(schema *Schema, t reflect.Type) error {
|
|||||||
schema.ResourceMethods = []string{"GET", "PUT", "DELETE"}
|
schema.ResourceMethods = []string{"GET", "PUT", "DELETE"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasType := false
|
||||||
|
hasMeta := false
|
||||||
|
|
||||||
for i := 0; i < t.NumField(); i++ {
|
for i := 0; i < t.NumField(); i++ {
|
||||||
field := t.Field(i)
|
field := t.Field(i)
|
||||||
|
|
||||||
@@ -128,12 +204,23 @@ func (s *Schemas) readFields(schema *Schema, t reflect.Type) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if field.Anonymous && jsonName == "" && field.Type == typeType {
|
||||||
|
hasType = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if field.Anonymous && jsonName == "metadata" && field.Type == metaType {
|
||||||
|
hasMeta = true
|
||||||
|
}
|
||||||
|
|
||||||
if field.Anonymous && jsonName == "" {
|
if field.Anonymous && jsonName == "" {
|
||||||
t := field.Type
|
t := field.Type
|
||||||
if t.Kind() == reflect.Ptr {
|
if t.Kind() == reflect.Ptr {
|
||||||
t = t.Elem()
|
t = t.Elem()
|
||||||
}
|
}
|
||||||
if t.Kind() == reflect.Struct {
|
if t.Kind() == reflect.Struct {
|
||||||
|
if t == namespacedType {
|
||||||
|
schema.Scope = NamespaceScope
|
||||||
|
}
|
||||||
if err := s.readFields(schema, t); err != nil {
|
if err := s.readFields(schema, t); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -144,6 +231,9 @@ func (s *Schemas) readFields(schema *Schema, t reflect.Type) error {
|
|||||||
fieldName := jsonName
|
fieldName := jsonName
|
||||||
if fieldName == "" {
|
if fieldName == "" {
|
||||||
fieldName = convert.LowerTitle(field.Name)
|
fieldName = convert.LowerTitle(field.Name)
|
||||||
|
if strings.HasSuffix(fieldName, "ID") {
|
||||||
|
fieldName = strings.TrimSuffix(fieldName, "ID") + "Id"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if blacklistNames[fieldName] {
|
if blacklistNames[fieldName] {
|
||||||
@@ -156,6 +246,7 @@ func (s *Schemas) readFields(schema *Schema, t reflect.Type) error {
|
|||||||
schemaField := Field{
|
schemaField := Field{
|
||||||
Create: true,
|
Create: true,
|
||||||
Update: true,
|
Update: true,
|
||||||
|
Nullable: true,
|
||||||
CodeName: field.Name,
|
CodeName: field.Name,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,15 +268,15 @@ func (s *Schemas) readFields(schema *Schema, t reflect.Type) error {
|
|||||||
schemaField.Type = inferedType
|
schemaField.Type = inferedType
|
||||||
}
|
}
|
||||||
|
|
||||||
if field.Type == metaType {
|
|
||||||
schema.CollectionMethods = []string{"GET", "POST"}
|
|
||||||
schema.ResourceMethods = []string{"GET", "PUT", "DELETE"}
|
|
||||||
}
|
|
||||||
|
|
||||||
logrus.Debugf("Setting field %s.%s: %#v", schema.ID, fieldName, schemaField)
|
logrus.Debugf("Setting field %s.%s: %#v", schema.ID, fieldName, schemaField)
|
||||||
schema.ResourceFields[fieldName] = schemaField
|
schema.ResourceFields[fieldName] = schemaField
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if hasType && hasMeta {
|
||||||
|
schema.CollectionMethods = []string{"GET", "POST"}
|
||||||
|
schema.ResourceMethods = []string{"GET", "PUT", "DELETE"}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
26
vendor/github.com/rancher/norman/types/schema_funcs.go
generated
vendored
Normal file
26
vendor/github.com/rancher/norman/types/schema_funcs.go
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package types
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/rancher/norman/types/slice"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s *Schema) MustCustomizeField(name string, f func(f Field) Field) *Schema {
|
||||||
|
field, ok := s.ResourceFields[name]
|
||||||
|
if !ok {
|
||||||
|
panic("Failed to find field " + name + " on schema " + s.ID)
|
||||||
|
}
|
||||||
|
s.ResourceFields[name] = f(field)
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *APIVersion) Equals(other *APIVersion) bool {
|
||||||
|
return v.Version == other.Version &&
|
||||||
|
v.Group == other.Group &&
|
||||||
|
v.Path == other.Path
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Schema) CanList() bool {
|
||||||
|
return slice.ContainsString(s.CollectionMethods, http.MethodGet)
|
||||||
|
}
|
48
vendor/github.com/rancher/norman/types/schemas.go
generated
vendored
48
vendor/github.com/rancher/norman/types/schemas.go
generated
vendored
@@ -13,9 +13,14 @@ type SchemaCollection struct {
|
|||||||
Data []Schema
|
Data []Schema
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SchemaInitFunc func(*Schemas) *Schemas
|
||||||
|
|
||||||
type Schemas struct {
|
type Schemas struct {
|
||||||
schemasByPath map[string]map[string]*Schema
|
schemasByPath map[string]map[string]*Schema
|
||||||
mappers map[string]map[string]Mapper
|
schemasBySubContext map[string]*Schema
|
||||||
|
mappers map[string]map[string][]Mapper
|
||||||
|
DefaultMappers []Mapper
|
||||||
|
DefaultPostMappers []Mapper
|
||||||
versions []APIVersion
|
versions []APIVersion
|
||||||
schemas []*Schema
|
schemas []*Schema
|
||||||
errors []error
|
errors []error
|
||||||
@@ -24,14 +29,27 @@ type Schemas struct {
|
|||||||
func NewSchemas() *Schemas {
|
func NewSchemas() *Schemas {
|
||||||
return &Schemas{
|
return &Schemas{
|
||||||
schemasByPath: map[string]map[string]*Schema{},
|
schemasByPath: map[string]map[string]*Schema{},
|
||||||
mappers: map[string]map[string]Mapper{},
|
schemasBySubContext: map[string]*Schema{},
|
||||||
|
mappers: map[string]map[string][]Mapper{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Schemas) Init(initFunc SchemaInitFunc) *Schemas {
|
||||||
|
return initFunc(s)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Schemas) Err() error {
|
func (s *Schemas) Err() error {
|
||||||
return NewErrors(s.errors)
|
return NewErrors(s.errors)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Schemas) SubContext(subContext string) *Schema {
|
||||||
|
return s.schemasBySubContext[subContext]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Schemas) SubContextSchemas() map[string]*Schema {
|
||||||
|
return s.schemasBySubContext
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Schemas) AddSchemas(schema *Schemas) *Schemas {
|
func (s *Schemas) AddSchemas(schema *Schemas) *Schemas {
|
||||||
for _, schema := range schema.Schemas() {
|
for _, schema := range schema.Schemas() {
|
||||||
s.AddSchema(schema)
|
s.AddSchema(schema)
|
||||||
@@ -40,7 +58,7 @@ func (s *Schemas) AddSchemas(schema *Schemas) *Schemas {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Schemas) AddSchema(schema *Schema) *Schemas {
|
func (s *Schemas) AddSchema(schema *Schema) *Schemas {
|
||||||
schema.Type = "schema"
|
schema.Type = "/v1-meta/schemas/schema"
|
||||||
if schema.ID == "" {
|
if schema.ID == "" {
|
||||||
s.errors = append(s.errors, fmt.Errorf("ID is not set on schema: %v", schema))
|
s.errors = append(s.errors, fmt.Errorf("ID is not set on schema: %v", schema))
|
||||||
return s
|
return s
|
||||||
@@ -58,6 +76,9 @@ func (s *Schemas) AddSchema(schema *Schema) *Schemas {
|
|||||||
if schema.CodeNamePlural == "" {
|
if schema.CodeNamePlural == "" {
|
||||||
schema.CodeNamePlural = name.GuessPluralName(schema.CodeName)
|
schema.CodeNamePlural = name.GuessPluralName(schema.CodeName)
|
||||||
}
|
}
|
||||||
|
if schema.BaseType == "" {
|
||||||
|
schema.BaseType = schema.ID
|
||||||
|
}
|
||||||
|
|
||||||
schemas, ok := s.schemasByPath[schema.Version.Path]
|
schemas, ok := s.schemasByPath[schema.Version.Path]
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -71,20 +92,21 @@ func (s *Schemas) AddSchema(schema *Schema) *Schemas {
|
|||||||
s.schemas = append(s.schemas, schema)
|
s.schemas = append(s.schemas, schema)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if schema.SubContext != "" {
|
||||||
|
s.schemasBySubContext[schema.SubContext] = schema
|
||||||
|
}
|
||||||
|
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Schemas) AddMapper(version *APIVersion, schemaID string, mapper Mapper) *Schemas {
|
func (s *Schemas) AddMapper(version *APIVersion, schemaID string, mapper Mapper) *Schemas {
|
||||||
mappers, ok := s.mappers[version.Path]
|
mappers, ok := s.mappers[version.Path]
|
||||||
if !ok {
|
if !ok {
|
||||||
mappers = map[string]Mapper{}
|
mappers = map[string][]Mapper{}
|
||||||
s.mappers[version.Path] = mappers
|
s.mappers[version.Path] = mappers
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := mappers[schemaID]; !ok {
|
mappers[schemaID] = append(mappers[schemaID], mapper)
|
||||||
mappers[schemaID] = mapper
|
|
||||||
}
|
|
||||||
|
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +122,7 @@ func (s *Schemas) Schemas() []*Schema {
|
|||||||
return s.schemas
|
return s.schemas
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Schemas) mapper(version *APIVersion, name string) Mapper {
|
func (s *Schemas) mapper(version *APIVersion, name string) []Mapper {
|
||||||
var (
|
var (
|
||||||
path string
|
path string
|
||||||
)
|
)
|
||||||
@@ -133,10 +155,10 @@ func (s *Schemas) Schema(version *APIVersion, name string) *Schema {
|
|||||||
path string
|
path string
|
||||||
)
|
)
|
||||||
|
|
||||||
if strings.Contains(name, "/") {
|
if strings.Contains(name, "/schemas/") {
|
||||||
idx := strings.LastIndex(name, "/")
|
parts := strings.SplitN(name, "/schemas/", 2)
|
||||||
path = name[0:idx]
|
path = parts[0]
|
||||||
name = name[idx+1:]
|
name = parts[1]
|
||||||
} else if version != nil {
|
} else if version != nil {
|
||||||
path = version.Path
|
path = version.Path
|
||||||
} else {
|
} else {
|
||||||
|
56
vendor/github.com/rancher/norman/types/server_types.go
generated
vendored
56
vendor/github.com/rancher/norman/types/server_types.go
generated
vendored
@@ -27,12 +27,14 @@ func (r *RawResource) MarshalJSON() ([]byte, error) {
|
|||||||
if r.ID != "" {
|
if r.ID != "" {
|
||||||
data["id"] = r.ID
|
data["id"] = r.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
data["type"] = r.Type
|
data["type"] = r.Type
|
||||||
|
data["baseType"] = r.Schema.BaseType
|
||||||
data["links"] = r.Links
|
data["links"] = r.Links
|
||||||
if r.ActionLinks {
|
if r.ActionLinks {
|
||||||
data["actionLinks"] = r.Actions
|
data["actionLinks"] = r.Actions
|
||||||
} else {
|
} else {
|
||||||
data["action"] = r.Actions
|
data["actions"] = r.Actions
|
||||||
}
|
}
|
||||||
return json.Marshal(data)
|
return json.Marshal(data)
|
||||||
}
|
}
|
||||||
@@ -41,12 +43,19 @@ type ActionHandler func(actionName string, action *Action, request *APIContext)
|
|||||||
|
|
||||||
type RequestHandler func(request *APIContext) error
|
type RequestHandler func(request *APIContext) error
|
||||||
|
|
||||||
|
type QueryFilter func(opts QueryOptions, data []map[string]interface{}) []map[string]interface{}
|
||||||
|
|
||||||
type Validator func(request *APIContext, data map[string]interface{}) error
|
type Validator func(request *APIContext, data map[string]interface{}) error
|
||||||
|
|
||||||
type Formatter func(request *APIContext, resource *RawResource)
|
type Formatter func(request *APIContext, resource *RawResource)
|
||||||
|
|
||||||
type ErrorHandler func(request *APIContext, err error)
|
type ErrorHandler func(request *APIContext, err error)
|
||||||
|
|
||||||
|
type SubContextAttributeProvider interface {
|
||||||
|
Query(apiContext *APIContext, schema *Schema) []*QueryCondition
|
||||||
|
Create(apiContext *APIContext, schema *Schema) map[string]interface{}
|
||||||
|
}
|
||||||
|
|
||||||
type ResponseWriter interface {
|
type ResponseWriter interface {
|
||||||
Write(apiContext *APIContext, code int, obj interface{})
|
Write(apiContext *APIContext, code int, obj interface{})
|
||||||
}
|
}
|
||||||
@@ -68,11 +77,13 @@ type APIContext struct {
|
|||||||
ResponseFormat string
|
ResponseFormat string
|
||||||
ReferenceValidator ReferenceValidator
|
ReferenceValidator ReferenceValidator
|
||||||
ResponseWriter ResponseWriter
|
ResponseWriter ResponseWriter
|
||||||
QueryOptions *QueryOptions
|
QueryFilter QueryFilter
|
||||||
Body map[string]interface{}
|
SubContextAttributeProvider SubContextAttributeProvider
|
||||||
|
//QueryOptions *QueryOptions
|
||||||
URLBuilder URLBuilder
|
URLBuilder URLBuilder
|
||||||
AccessControl AccessControl
|
AccessControl AccessControl
|
||||||
SubContext map[string]interface{}
|
SubContext map[string]string
|
||||||
|
Attributes map[string]interface{}
|
||||||
|
|
||||||
Request *http.Request
|
Request *http.Request
|
||||||
Response http.ResponseWriter
|
Response http.ResponseWriter
|
||||||
@@ -82,6 +93,30 @@ func (r *APIContext) WriteResponse(code int, obj interface{}) {
|
|||||||
r.ResponseWriter.Write(r, code, obj)
|
r.ResponseWriter.Write(r, code, obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *APIContext) FilterList(opts QueryOptions, obj []map[string]interface{}) []map[string]interface{} {
|
||||||
|
return r.QueryFilter(opts, obj)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *APIContext) FilterObject(opts QueryOptions, obj map[string]interface{}) map[string]interface{} {
|
||||||
|
opts.Pagination = nil
|
||||||
|
result := r.QueryFilter(opts, []map[string]interface{}{obj})
|
||||||
|
if len(result) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return result[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *APIContext) Filter(opts QueryOptions, obj interface{}) interface{} {
|
||||||
|
switch v := obj.(type) {
|
||||||
|
case []map[string]interface{}:
|
||||||
|
return r.FilterList(opts, v)
|
||||||
|
case map[string]interface{}:
|
||||||
|
return r.FilterObject(opts, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ASC = SortOrder("asc")
|
ASC = SortOrder("asc")
|
||||||
DESC = SortOrder("desc")
|
DESC = SortOrder("desc")
|
||||||
@@ -100,20 +135,21 @@ type ReferenceValidator interface {
|
|||||||
|
|
||||||
type URLBuilder interface {
|
type URLBuilder interface {
|
||||||
Current() string
|
Current() string
|
||||||
Collection(schema *Schema) string
|
Collection(schema *Schema, versionOverride *APIVersion) string
|
||||||
|
SubContextCollection(subContext *Schema, contextName string, schema *Schema) string
|
||||||
|
SchemaLink(schema *Schema) string
|
||||||
ResourceLink(resource *RawResource) string
|
ResourceLink(resource *RawResource) string
|
||||||
RelativeToRoot(path string) string
|
RelativeToRoot(path string) string
|
||||||
//Link(resource Resource, name string) string
|
Version(version APIVersion) string
|
||||||
//ReferenceLink(resource Resource) string
|
Marker(marker string) string
|
||||||
//ReferenceByIdLink(resourceType string, id string) string
|
|
||||||
Version(version string) string
|
|
||||||
ReverseSort(order SortOrder) string
|
ReverseSort(order SortOrder) string
|
||||||
|
Sort(field string) string
|
||||||
SetSubContext(subContext string)
|
SetSubContext(subContext string)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Store interface {
|
type Store interface {
|
||||||
ByID(apiContext *APIContext, schema *Schema, id string) (map[string]interface{}, error)
|
ByID(apiContext *APIContext, schema *Schema, id string) (map[string]interface{}, error)
|
||||||
List(apiContext *APIContext, schema *Schema, opt *QueryOptions) ([]map[string]interface{}, error)
|
List(apiContext *APIContext, schema *Schema, opt QueryOptions) ([]map[string]interface{}, error)
|
||||||
Create(apiContext *APIContext, schema *Schema, data map[string]interface{}) (map[string]interface{}, error)
|
Create(apiContext *APIContext, schema *Schema, data map[string]interface{}) (map[string]interface{}, error)
|
||||||
Update(apiContext *APIContext, schema *Schema, data map[string]interface{}, id string) (map[string]interface{}, error)
|
Update(apiContext *APIContext, schema *Schema, data map[string]interface{}, id string) (map[string]interface{}, error)
|
||||||
Delete(apiContext *APIContext, schema *Schema, id string) error
|
Delete(apiContext *APIContext, schema *Schema, id string) error
|
||||||
|
10
vendor/github.com/rancher/norman/types/slice/contains.go
generated
vendored
Normal file
10
vendor/github.com/rancher/norman/types/slice/contains.go
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package slice
|
||||||
|
|
||||||
|
func ContainsString(slice []string, item string) bool {
|
||||||
|
for _, j := range slice {
|
||||||
|
if j == item {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
27
vendor/github.com/rancher/norman/types/types.go
generated
vendored
27
vendor/github.com/rancher/norman/types/types.go
generated
vendored
@@ -27,11 +27,22 @@ type Sort struct {
|
|||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Order SortOrder `json:"order,omitempty"`
|
Order SortOrder `json:"order,omitempty"`
|
||||||
Reverse string `json:"reverse,omitempty"`
|
Reverse string `json:"reverse,omitempty"`
|
||||||
Links map[string]string `json:"sortLinks,omitempty"`
|
Links map[string]string `json:"links,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
ModifierEQ ModifierType = "eq"
|
||||||
|
ModifierNE ModifierType = "ne"
|
||||||
|
ModifierNull ModifierType = "null"
|
||||||
|
ModifierNotNull ModifierType = "notnull"
|
||||||
|
ModifierIn ModifierType = "in"
|
||||||
|
ModifierNotIn ModifierType = "notin"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ModifierType string
|
||||||
|
|
||||||
type Condition struct {
|
type Condition struct {
|
||||||
Modifier string `json:"modifier,omitempty"`
|
Modifier ModifierType `json:"modifier,omitempty"`
|
||||||
Value interface{} `json:"value,omitempty"`
|
Value interface{} `json:"value,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,6 +51,7 @@ type Pagination struct {
|
|||||||
First string `json:"first,omitempty"`
|
First string `json:"first,omitempty"`
|
||||||
Previous string `json:"previous,omitempty"`
|
Previous string `json:"previous,omitempty"`
|
||||||
Next string `json:"next,omitempty"`
|
Next string `json:"next,omitempty"`
|
||||||
|
Last string `json:"last,omitempty"`
|
||||||
Limit *int64 `json:"limit,omitempty"`
|
Limit *int64 `json:"limit,omitempty"`
|
||||||
Total *int64 `json:"total,omitempty"`
|
Total *int64 `json:"total,omitempty"`
|
||||||
Partial bool `json:"partial,omitempty"`
|
Partial bool `json:"partial,omitempty"`
|
||||||
@@ -59,12 +71,20 @@ type APIVersion struct {
|
|||||||
SubContexts map[string]bool `json:"subContext,omitempty"`
|
SubContexts map[string]bool `json:"subContext,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Namespaced struct{}
|
||||||
|
|
||||||
|
var NamespaceScope TypeScope = "namespace"
|
||||||
|
|
||||||
|
type TypeScope string
|
||||||
|
|
||||||
type Schema struct {
|
type Schema struct {
|
||||||
ID string `json:"id,omitempty"`
|
ID string `json:"id,omitempty"`
|
||||||
CodeName string `json:"-"`
|
CodeName string `json:"-"`
|
||||||
CodeNamePlural string `json:"-"`
|
CodeNamePlural string `json:"-"`
|
||||||
PkgName string `json:"-"`
|
PkgName string `json:"-"`
|
||||||
Type string `json:"type,omitempty"`
|
Type string `json:"type,omitempty"`
|
||||||
|
BaseType string `json:"baseType,omitempty"`
|
||||||
|
SubContext string `json:"-,omitempty"`
|
||||||
Links map[string]string `json:"links"`
|
Links map[string]string `json:"links"`
|
||||||
Version APIVersion `json:"version"`
|
Version APIVersion `json:"version"`
|
||||||
PluralName string `json:"pluralName,omitempty"`
|
PluralName string `json:"pluralName,omitempty"`
|
||||||
@@ -75,6 +95,7 @@ type Schema struct {
|
|||||||
CollectionFields map[string]Field `json:"collectionFields,omitempty"`
|
CollectionFields map[string]Field `json:"collectionFields,omitempty"`
|
||||||
CollectionActions map[string]Action `json:"collectionActions,omitempty"`
|
CollectionActions map[string]Action `json:"collectionActions,omitempty"`
|
||||||
CollectionFilters map[string]Filter `json:"collectionFilters,omitempty"`
|
CollectionFilters map[string]Filter `json:"collectionFilters,omitempty"`
|
||||||
|
Scope TypeScope `json:"-"`
|
||||||
|
|
||||||
InternalSchema *Schema `json:"-"`
|
InternalSchema *Schema `json:"-"`
|
||||||
Mapper Mapper `json:"-"`
|
Mapper Mapper `json:"-"`
|
||||||
@@ -115,7 +136,7 @@ type Action struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Filter struct {
|
type Filter struct {
|
||||||
Modifiers []string `json:"modifiers,omitempty"`
|
Modifiers []ModifierType `json:"modifiers,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ListOpts struct {
|
type ListOpts struct {
|
||||||
|
20
vendor/github.com/rancher/types/apis/cluster.cattle.io/v1/types.go
generated
vendored
20
vendor/github.com/rancher/types/apis/cluster.cattle.io/v1/types.go
generated
vendored
@@ -107,7 +107,7 @@ type AzureKubernetesServiceConfig struct {
|
|||||||
|
|
||||||
type RancherKubernetesEngineConfig struct {
|
type RancherKubernetesEngineConfig struct {
|
||||||
// Kubernetes nodes
|
// Kubernetes nodes
|
||||||
Hosts []RKEConfigHost `yaml:"hosts" json:"hosts,omitempty"`
|
Nodes []RKEConfigNode `yaml:"nodes" json:"nodes,omitempty"`
|
||||||
// Kubernetes components
|
// Kubernetes components
|
||||||
Services RKEConfigServices `yaml:"services" json:"services,omitempty"`
|
Services RKEConfigServices `yaml:"services" json:"services,omitempty"`
|
||||||
// Network configuration used in the kubernetes cluster (flannel, calico)
|
// Network configuration used in the kubernetes cluster (flannel, calico)
|
||||||
@@ -120,18 +120,18 @@ type RancherKubernetesEngineConfig struct {
|
|||||||
SSHKeyPath string `yaml:"ssh_key_path" json:"sshKeyPath,omitempty"`
|
SSHKeyPath string `yaml:"ssh_key_path" json:"sshKeyPath,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RKEConfigHost struct {
|
type RKEConfigNode struct {
|
||||||
// SSH IP address of the host
|
// IP or FQDN that is fully resolvable and used for SSH communication
|
||||||
IP string `yaml:"ip" json:"ip,omitempty"`
|
Address string `yaml:"address" json:"address,omitempty"`
|
||||||
// Advertised address that will be used for components communication
|
// Optional - Internal address that will be used for components communication
|
||||||
AdvertiseAddress string `yaml:"advertise_address" json:"advertiseAddress,omitempty"`
|
InternalAddress string `yaml:"internal_address" json:"internalAddress,omitempty"`
|
||||||
// Host role in kubernetes cluster (controlplane, worker, or etcd)
|
// Node role in kubernetes cluster (controlplane, worker, or etcd)
|
||||||
Role []string `yaml:"role" json:"role,omitempty"`
|
Role []string `yaml:"role" json:"role,omitempty"`
|
||||||
// Hostname of the host
|
// Optional - Hostname of the node
|
||||||
AdvertisedHostname string `yaml:"advertised_hostname" json:"advertisedHostname,omitempty"`
|
HostnameOverride string `yaml:"hostname_override" json:"hostnameOverride,omitempty"`
|
||||||
// SSH usesr that will be used by RKE
|
// SSH usesr that will be used by RKE
|
||||||
User string `yaml:"user" json:"user,omitempty"`
|
User string `yaml:"user" json:"user,omitempty"`
|
||||||
// Docker socket on the host that will be used in tunneling
|
// Optional - Docker socket on the node that will be used in tunneling
|
||||||
DockerSocket string `yaml:"docker_socket" json:"dockerSocket,omitempty"`
|
DockerSocket string `yaml:"docker_socket" json:"dockerSocket,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -38,7 +38,7 @@ type ClusterController interface {
|
|||||||
Informer() cache.SharedIndexInformer
|
Informer() cache.SharedIndexInformer
|
||||||
AddHandler(handler ClusterHandlerFunc)
|
AddHandler(handler ClusterHandlerFunc)
|
||||||
Enqueue(namespace, name string)
|
Enqueue(namespace, name string)
|
||||||
Start(threadiness int, ctx context.Context) error
|
Start(ctx context.Context, threadiness int) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClusterInterface interface {
|
type ClusterInterface interface {
|
||||||
|
@@ -38,7 +38,7 @@ type ClusterNodeController interface {
|
|||||||
Informer() cache.SharedIndexInformer
|
Informer() cache.SharedIndexInformer
|
||||||
AddHandler(handler ClusterNodeHandlerFunc)
|
AddHandler(handler ClusterNodeHandlerFunc)
|
||||||
Enqueue(namespace, name string)
|
Enqueue(namespace, name string)
|
||||||
Start(threadiness int, ctx context.Context) error
|
Start(ctx context.Context, threadiness int) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClusterNodeInterface interface {
|
type ClusterNodeInterface interface {
|
||||||
|
14
vendor/github.com/rancher/types/apis/cluster.cattle.io/v1/zz_generated_deepcopy.go
generated
vendored
14
vendor/github.com/rancher/types/apis/cluster.cattle.io/v1/zz_generated_deepcopy.go
generated
vendored
@@ -445,7 +445,7 @@ func (in *NetworkConfig) DeepCopy() *NetworkConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
func (in *RKEConfigHost) DeepCopyInto(out *RKEConfigHost) {
|
func (in *RKEConfigNode) DeepCopyInto(out *RKEConfigNode) {
|
||||||
*out = *in
|
*out = *in
|
||||||
if in.Role != nil {
|
if in.Role != nil {
|
||||||
in, out := &in.Role, &out.Role
|
in, out := &in.Role, &out.Role
|
||||||
@@ -455,12 +455,12 @@ func (in *RKEConfigHost) DeepCopyInto(out *RKEConfigHost) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RKEConfigHost.
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RKEConfigNode.
|
||||||
func (in *RKEConfigHost) DeepCopy() *RKEConfigHost {
|
func (in *RKEConfigNode) DeepCopy() *RKEConfigNode {
|
||||||
if in == nil {
|
if in == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
out := new(RKEConfigHost)
|
out := new(RKEConfigNode)
|
||||||
in.DeepCopyInto(out)
|
in.DeepCopyInto(out)
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
@@ -490,9 +490,9 @@ func (in *RKEConfigServices) DeepCopy() *RKEConfigServices {
|
|||||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
func (in *RancherKubernetesEngineConfig) DeepCopyInto(out *RancherKubernetesEngineConfig) {
|
func (in *RancherKubernetesEngineConfig) DeepCopyInto(out *RancherKubernetesEngineConfig) {
|
||||||
*out = *in
|
*out = *in
|
||||||
if in.Hosts != nil {
|
if in.Nodes != nil {
|
||||||
in, out := &in.Hosts, &out.Hosts
|
in, out := &in.Nodes, &out.Nodes
|
||||||
*out = make([]RKEConfigHost, len(*in))
|
*out = make([]RKEConfigNode, len(*in))
|
||||||
for i := range *in {
|
for i := range *in {
|
||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||||
}
|
}
|
||||||
|
2
vendor/github.com/rancher/types/vendor.conf
generated
vendored
2
vendor/github.com/rancher/types/vendor.conf
generated
vendored
@@ -3,4 +3,4 @@ github.com/rancher/types
|
|||||||
|
|
||||||
k8s.io/kubernetes v1.8.3 transitive=true,staging=true
|
k8s.io/kubernetes v1.8.3 transitive=true,staging=true
|
||||||
bitbucket.org/ww/goautoneg a547fc61f48d567d5b4ec6f8aee5573d8efce11d https://github.com/rancher/goautoneg.git
|
bitbucket.org/ww/goautoneg a547fc61f48d567d5b4ec6f8aee5573d8efce11d https://github.com/rancher/goautoneg.git
|
||||||
github.com/rancher/norman 80024df69414f7cce0847ea72b0557f14edbc852
|
github.com/rancher/norman faa1fb2148211044253fc2f6403008958c72b1f0
|
||||||
|
Reference in New Issue
Block a user