1
0
mirror of https://github.com/rancher/types.git synced 2025-07-06 02:06:13 +00:00

Revert "Pluggable driver types"

This reverts commit 216385b63e.
This commit is contained in:
Nathan Jenan 2018-11-27 17:50:10 -07:00 committed by Craig Jellick
parent d4684eb26d
commit 7bd01e2984
5 changed files with 123 additions and 127 deletions

View File

@ -1,22 +1,13 @@
package v3
import (
"bytes"
"encoding/gob"
"github.com/rancher/norman/condition"
"github.com/rancher/norman/types"
"github.com/sirupsen/logrus"
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/version"
)
func init() {
gob.Register(map[string]interface{}{})
gob.Register([]interface{}{})
}
type ClusterConditionType string
const (
@ -70,20 +61,19 @@ type Cluster struct {
}
type ClusterSpec struct {
DisplayName string `json:"displayName" norman:"required"`
Description string `json:"description"`
Internal bool `json:"internal" norman:"nocreate,noupdate"`
DesiredAgentImage string `json:"desiredAgentImage"`
ImportedConfig *ImportedConfig `json:"importedConfig,omitempty" norman:"nocreate,noupdate"`
GoogleKubernetesEngineConfig *MapStringInterface `json:"googleKubernetesEngineConfig,omitempty"`
AzureKubernetesServiceConfig *MapStringInterface `json:"azureKubernetesServiceConfig,omitempty"`
RancherKubernetesEngineConfig *RancherKubernetesEngineConfig `json:"rancherKubernetesEngineConfig,omitempty"`
AmazonElasticContainerServiceConfig *MapStringInterface `json:"amazonElasticContainerServiceConfig,omitempty"`
GenericEngineConfig *MapStringInterface `json:"genericEngineConfig,omitempty"`
DefaultPodSecurityPolicyTemplateName string `json:"defaultPodSecurityPolicyTemplateName,omitempty" norman:"type=reference[podSecurityPolicyTemplate]"`
DefaultClusterRoleForProjectMembers string `json:"defaultClusterRoleForProjectMembers,omitempty" norman:"type=reference[roleTemplate]"`
DockerRootDir string `json:"dockerRootDir,omitempty" norman:"default=/var/lib/docker"`
EnableNetworkPolicy *bool `json:"enableNetworkPolicy" norman:"default=false"`
DisplayName string `json:"displayName" norman:"required"`
Description string `json:"description"`
Internal bool `json:"internal" norman:"nocreate,noupdate"`
DesiredAgentImage string `json:"desiredAgentImage"`
ImportedConfig *ImportedConfig `json:"importedConfig,omitempty" norman:"nocreate,noupdate"`
GoogleKubernetesEngineConfig *GoogleKubernetesEngineConfig `json:"googleKubernetesEngineConfig,omitempty"`
AzureKubernetesServiceConfig *AzureKubernetesServiceConfig `json:"azureKubernetesServiceConfig,omitempty"`
RancherKubernetesEngineConfig *RancherKubernetesEngineConfig `json:"rancherKubernetesEngineConfig,omitempty"`
AmazonElasticContainerServiceConfig *AmazonElasticContainerServiceConfig `json:"amazonElasticContainerServiceConfig,omitempty"`
DefaultPodSecurityPolicyTemplateName string `json:"defaultPodSecurityPolicyTemplateName,omitempty" norman:"type=reference[podSecurityPolicyTemplate]"`
DefaultClusterRoleForProjectMembers string `json:"defaultClusterRoleForProjectMembers,omitempty" norman:"type=reference[roleTemplate]"`
DockerRootDir string `json:"dockerRootDir,omitempty" norman:"default=/var/lib/docker"`
EnableNetworkPolicy *bool `json:"enableNetworkPolicy" norman:"default=false"`
}
type ImportedConfig struct {
@ -134,26 +124,117 @@ type ClusterCondition struct {
Message string `json:"message,omitempty"`
}
type MapStringInterface map[string]interface{}
type GoogleKubernetesEngineConfig struct {
// ProjectID is the ID of your project to use when creating a cluster
ProjectID string `json:"projectId,omitempty" norman:"required"`
// The zone to launch the cluster
Zone string `json:"zone,omitempty" norman:"required"`
// The IP address range of the container pods
ClusterIpv4Cidr string `json:"clusterIpv4Cidr,omitempty"`
// An optional description of this cluster
Description string `json:"description,omitempty"`
// The number of nodes in this cluster
NodeCount int64 `json:"nodeCount,omitempty" norman:"required"`
// Size of the disk attached to each node
DiskSizeGb int64 `json:"diskSizeGb,omitempty"`
// The name of a Google Compute Engine
MachineType string `json:"machineType,omitempty"`
// Node kubernetes version
NodeVersion string `json:"nodeVersion,omitempty"`
// the master kubernetes version
MasterVersion string `json:"masterVersion,omitempty"`
// The map of Kubernetes labels (key/value pairs) to be applied
// to each node.
Labels map[string]string `json:"labels,omitempty"`
// The content of the credential file(key.json)
Credential string `json:"credential,omitempty" norman:"required,type=password"`
// Enable alpha feature
EnableAlphaFeature bool `json:"enableAlphaFeature,omitempty"`
// Configuration for the HTTP (L7) load balancing controller addon
EnableHTTPLoadBalancing *bool `json:"enableHttpLoadBalancing,omitempty" norman:"default=true"`
// Configuration for the horizontal pod autoscaling feature, which increases or decreases the number of replica pods a replication controller has based on the resource usage of the existing pods
EnableHorizontalPodAutoscaling *bool `json:"enableHorizontalPodAutoscaling,omitempty" norman:"default=true"`
// Configuration for the Kubernetes Dashboard
EnableKubernetesDashboard bool `json:"enableKubernetesDashboard,omitempty"`
// Configuration for NetworkPolicy
EnableNetworkPolicyConfig *bool `json:"enableNetworkPolicyConfig,omitempty" norman:"default=true"`
// The list of Google Compute Engine locations in which the cluster's nodes should be located
Locations []string `json:"locations,omitempty"`
// Image Type
ImageType string `json:"imageType,omitempty"`
// Network
Network string `json:"network,omitempty"`
// Sub Network
SubNetwork string `json:"subNetwork,omitempty"`
// Configuration for LegacyAbac
EnableLegacyAbac bool `json:"enableLegacyAbac,omitempty"`
EnableStackdriverLogging *bool `json:"enableStackdriverLogging,omitempty" norman:"default=true"`
EnableStackdriverMonitoring *bool `json:"enableStackdriverMonitoring,omitempty" norman:"default=true"`
MaintenanceWindow string `json:"maintenanceWindow"`
}
func (m *MapStringInterface) DeepCopy() *MapStringInterface {
var buf bytes.Buffer
enc := gob.NewEncoder(&buf)
dec := gob.NewDecoder(&buf)
err := enc.Encode(m)
if err != nil {
logrus.Errorf("error while deep copying MapStringInterface %v", err)
return nil
}
type AzureKubernetesServiceConfig struct {
// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.
SubscriptionID string `json:"subscriptionId,omitempty" norman:"required"`
// The name of the resource group.
ResourceGroup string `json:"resourceGroup,omitempty" norman:"required"`
// Resource location
Location string `json:"location,omitempty"`
// Resource tags
Tag map[string]string `json:"tags,omitempty"`
// Number of agents (VMs) to host docker containers. Allowed values must be in the range of 1 to 100 (inclusive). The default value is 1.
Count int64 `json:"count,omitempty"`
// DNS prefix to be used to create the FQDN for the agent pool.
AgentDNSPrefix string `json:"agentDnsPrefix,,omitempty"`
// FDQN for the agent pool
AgentPoolName string `json:"agentPoolName,,omitempty"`
// OS Disk Size in GB to be used to specify the disk size for every machine in this master/agent pool. If you specify 0, it will apply the default osDisk size according to the vmSize specified.
OsDiskSizeGB int64 `json:"osDiskSizeGb,omitempty"`
// Size of agent VMs
AgentVMSize string `json:"agentVmSize,omitempty"`
// Version of Kubernetes specified when creating the managed cluster
KubernetesVersion string `json:"kubernetesVersion,omitempty"`
// Path to the public key to use for SSH into cluster
SSHPublicKeyContents string `json:"sshPublicKeyContents,omitempty" norman:"required"`
// Kubernetes Master DNS prefix (must be unique within Azure)
MasterDNSPrefix string `json:"masterDnsPrefix,omitempty"`
// Kubernetes admin username
AdminUsername string `json:"adminUsername,omitempty"`
// Different Base URL if required, usually needed for testing purposes
BaseURL string `json:"baseUrl,omitempty"`
// Azure Client ID to use
ClientID string `json:"clientId,omitempty" norman:"required"`
// Tenant ID to create the cluster under
TenantID string `json:"tenantId,omitempty" norman:"required"`
// Secret associated with the Client ID
ClientSecret string `json:"clientSecret,omitempty" norman:"required,type=password"`
// Virtual network to use for the AKS cluster
VirtualNetwork string `json:"virtualNetwork,omitempty"`
// Subnet to use for the AKS Cluster (must be within the virtual network)
Subnet string `json:"subnet,omitempty"`
// The resource group that the virtual network is in. If omited it is assumed to match the resource group of the cluster
VirtualNetworkResourceGroup string `json:"virtualNetworkResourceGroup,omitempty"`
// Additional options for setting a custom virtual network
ServiceCIDR string `json:"serviceCidr,omitempty"`
DNSServiceIP string `json:"dnsServiceIp,omitempty"`
DockerBridgeCIDR string `json:"dockerBridgeCidr,omitempty"`
}
var copy MapStringInterface
err = dec.Decode(&copy)
if err != nil {
logrus.Errorf("error while deep copying MapStringInterface %v", err)
return nil
}
type AmazonElasticContainerServiceConfig struct {
AccessKey string `json:"accessKey" norman:"required"`
SecretKey string `json:"secretKey" norman:"required,type=password"`
SessionToken string `json:"sessionToken,omitempty" norman:"type=password"`
return &copy
Region string `json:"region"`
InstanceType string `json:"instanceType"`
MinimumNodes int `json:"minimumNodes"`
MaximumNodes int `json:"maximumNodes"`
VirtualNetwork string `json:"virtualNetwork,omitempty"`
Subnets []string `json:"subnets,omitempty"`
SecurityGroups []string `json:"securityGroups,omitempty"`
ServiceRole string `json:"serviceRole,omitempty"`
AMI string `json:"ami,omitempty"`
AssociateWorkerNodePublicIP *bool `json:"associateWorkerNodePublicIp,omitempty" norman:"default=true"`
}
type ClusterRegistrationToken struct {

View File

@ -1,42 +0,0 @@
package v3
import (
"github.com/rancher/norman/condition"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
type KontainerDriver struct {
metav1.TypeMeta `json:",inline"`
// Standard objects metadata. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
metav1.ObjectMeta `json:"metadata,omitempty"`
// Specification of the desired behavior of the the cluster. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
Spec KontainerDriverSpec `json:"spec"`
// Most recent observed status of the cluster. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
Status KontainerDriverStatus `json:"status"`
}
type KontainerDriverStatus struct {
ActualURL string `json:"actualUrl"`
ExecutablePath string `json:"executablePath"`
Conditions []Condition `json:"conditions"`
DisplayName string `json:"displayName"`
}
type KontainerDriverSpec struct {
URL string `json:"url" norman:"required"`
Checksum string `json:"checksum"`
BuiltIn bool `json:"builtIn" norman:"noupdate"`
Active bool `json:"active"`
UIURL string `json:"uiUrl"`
WhitelistDomains []string `json:"whitelistDomains,omitempty"`
}
var (
KontainerDriverConditionDownloaded condition.Cond = "Downloaded"
KontainerDriverConditionInstalled condition.Cond = "Installed"
KontainerDriverConditionActive condition.Cond = "Active"
KontainerDriverConditionInactive condition.Cond = "Inactive"
)

View File

@ -36,8 +36,8 @@ var (
Init(alertTypes).
Init(composeType).
Init(projectCatalogTypes).
Init(clusterCatalogTypes).
Init(kontainerTypes)
Init(clusterCatalogTypes)
TokenSchemas = factory.Schemas(&Version).
Init(tokens)
)
@ -123,10 +123,6 @@ func clusterTypes(schemas *types.Schemas) *types.Schemas {
return schemas.
AddMapperForType(&Version, v3.Cluster{},
&m.Embed{Field: "status"},
mapper.NewDropFromSchema("genericEngineConfig"),
mapper.NewDropFromSchema("googleKubernetesEngineConfig"),
mapper.NewDropFromSchema("azureKubernetesServiceConfig"),
mapper.NewDropFromSchema("amazonElasticContainerServiceConfig"),
m.DisplayName{},
).
AddMapperForType(&Version, v3.ClusterStatus{},
@ -582,17 +578,3 @@ func clusterCatalogTypes(schemas *types.Schemas) *types.Schemas {
}
})
}
func kontainerTypes(schemas *types.Schemas) *types.Schemas {
return schemas.
AddMapperForType(&Version, v3.KontainerDriver{},
&m.Embed{Field: "status"},
m.DisplayName{},
).
MustImportAndCustomize(&Version, v3.KontainerDriver{}, func(schema *types.Schema) {
schema.ResourceActions = map[string]types.Action{
"activate": {},
"deactivate": {},
}
})
}

View File

@ -18,7 +18,6 @@ type DynamicSchema struct {
}
type DynamicSchemaSpec struct {
SchemaName string `json:"schemaName,omitempty"`
Embed bool `json:"embed,omitempty"`
EmbedType string `json:"embedType,omitempty"`
PluralName string `json:"pluralName,omitempty"`
@ -52,7 +51,6 @@ type Field struct {
ValidChars string `json:"validChars,omitempty"`
InvalidChars string `json:"invalidChars,omitempty"`
Description string `json:"description,omitempty"`
DynamicField bool `json:"dynamicField,omitempty"`
}
type Values struct {

View File

@ -1,23 +0,0 @@
package mapper
import "github.com/rancher/norman/types/mapper"
// DropFromSchema This mapper differs from the existing drop mapper in that
// it does not remove the field if it is present, only removing the field from
// the schema. This is so that fields that must be present for formatters and
// stores will be available, but not shown on the schema
type DropFromSchema struct {
mapper.Drop
}
func NewDropFromSchema(name string) *DropFromSchema {
return &DropFromSchema{
mapper.Drop{
Field: name,
},
}
}
func (d DropFromSchema) FromInternal(data map[string]interface{}) {
// Do nothing
}