diff --git a/Makefile b/Makefile index a9534e287f9..1837cc2bcee 100644 --- a/Makefile +++ b/Makefile @@ -65,6 +65,8 @@ pkg/api/rest/operations/kubernikus_api.go: swagger.yml ifneq (,$(wildcard $(SWAGGER_BIN))) $(SWAGGER_BIN) generate server --name kubernikus --target pkg/api --model-package models \ --server-package rest --flag-strategy pflag --principal models.Principal --exclude-main + sed -e's/^package.*/package spec/' pkg/api/rest/embedded_spec.go > pkg/api/spec/embedded_spec.go + rm pkg/api/rest/embedded_spec.go else $(warning WARNING: $(SWAGGER_BIN) missing. Run `make bootstrap` to fix.) endif @@ -73,8 +75,7 @@ endif swagger-generate: make -B pkg/api/rest/operations/kubernikus_api.go -# --existing-models github.com/sapcc/kubernikus/pkg/api/models seems not to work in our case -pkg/client/kubernikus_generated/kubernikus_client.go: swagger.yml +pkg/api/client/kubernikus_client.go: swagger.yml ifneq (,$(wildcard $(SWAGGER_BIN))) $(SWAGGER_BIN) generate client --name kubernikus --target pkg/api --client-package client \ --existing-models github.com/sapcc/kubernikus/pkg/api/models \ diff --git a/cmd/apiserver/main.go b/cmd/apiserver/main.go index bc31770b020..3f1b0ca1a2a 100644 --- a/cmd/apiserver/main.go +++ b/cmd/apiserver/main.go @@ -6,11 +6,11 @@ import ( "log" "os" - loads "github.com/go-openapi/loads" "github.com/spf13/pflag" "github.com/sapcc/kubernikus/pkg/api/rest" "github.com/sapcc/kubernikus/pkg/api/rest/operations" + "github.com/sapcc/kubernikus/pkg/api/spec" ) // This file was generated by the swagger tool. @@ -18,7 +18,7 @@ import ( func main() { - swaggerSpec, err := loads.Analyzed(rest.SwaggerJSON, "") + swaggerSpec, err := spec.Spec() if err != nil { log.Fatalln(err) } diff --git a/pkg/api/client/operations/create_cluster_parameters.go b/pkg/api/client/operations/create_cluster_parameters.go index 6ae86b8e67e..b8dc0120249 100644 --- a/pkg/api/client/operations/create_cluster_parameters.go +++ b/pkg/api/client/operations/create_cluster_parameters.go @@ -65,7 +65,7 @@ for the create cluster operation typically these are written to a http.Request type CreateClusterParams struct { /*Body*/ - Body *models.Cluster + Body *models.Kluster timeout time.Duration Context context.Context @@ -106,13 +106,13 @@ func (o *CreateClusterParams) SetHTTPClient(client *http.Client) { } // WithBody adds the body to the create cluster params -func (o *CreateClusterParams) WithBody(body *models.Cluster) *CreateClusterParams { +func (o *CreateClusterParams) WithBody(body *models.Kluster) *CreateClusterParams { o.SetBody(body) return o } // SetBody adds the body to the create cluster params -func (o *CreateClusterParams) SetBody(body *models.Cluster) { +func (o *CreateClusterParams) SetBody(body *models.Kluster) { o.Body = body } @@ -125,7 +125,7 @@ func (o *CreateClusterParams) WriteToRequest(r runtime.ClientRequest, reg strfmt var res []error if o.Body == nil { - o.Body = new(models.Cluster) + o.Body = new(models.Kluster) } if err := r.SetBodyParam(o.Body); err != nil { diff --git a/pkg/api/client/operations/create_cluster_responses.go b/pkg/api/client/operations/create_cluster_responses.go index ef7d3b355f8..c3c98e577f7 100644 --- a/pkg/api/client/operations/create_cluster_responses.go +++ b/pkg/api/client/operations/create_cluster_responses.go @@ -54,7 +54,7 @@ func NewCreateClusterCreated() *CreateClusterCreated { OK */ type CreateClusterCreated struct { - Payload *models.Cluster + Payload *models.Kluster } func (o *CreateClusterCreated) Error() string { @@ -63,7 +63,7 @@ func (o *CreateClusterCreated) Error() string { func (o *CreateClusterCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - o.Payload = new(models.Cluster) + o.Payload = new(models.Kluster) // response payload if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { diff --git a/pkg/api/client/operations/get_cluster_info_responses.go b/pkg/api/client/operations/get_cluster_info_responses.go index 5e7449ecf8c..12bc1178c45 100644 --- a/pkg/api/client/operations/get_cluster_info_responses.go +++ b/pkg/api/client/operations/get_cluster_info_responses.go @@ -54,7 +54,7 @@ func NewGetClusterInfoOK() *GetClusterInfoOK { OK */ type GetClusterInfoOK struct { - Payload *models.ClusterInfo + Payload *models.KlusterInfo } func (o *GetClusterInfoOK) Error() string { @@ -63,7 +63,7 @@ func (o *GetClusterInfoOK) Error() string { func (o *GetClusterInfoOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - o.Payload = new(models.ClusterInfo) + o.Payload = new(models.KlusterInfo) // response payload if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { diff --git a/pkg/api/client/operations/list_clusters_responses.go b/pkg/api/client/operations/list_clusters_responses.go index 960a91c8e83..0fd1339dec8 100644 --- a/pkg/api/client/operations/list_clusters_responses.go +++ b/pkg/api/client/operations/list_clusters_responses.go @@ -54,7 +54,7 @@ func NewListClustersOK() *ListClustersOK { OK */ type ListClustersOK struct { - Payload []*models.Cluster + Payload []*models.Kluster } func (o *ListClustersOK) Error() string { diff --git a/pkg/api/client/operations/show_cluster_responses.go b/pkg/api/client/operations/show_cluster_responses.go index cfb9eb00f25..7d084439d56 100644 --- a/pkg/api/client/operations/show_cluster_responses.go +++ b/pkg/api/client/operations/show_cluster_responses.go @@ -54,7 +54,7 @@ func NewShowClusterOK() *ShowClusterOK { OK */ type ShowClusterOK struct { - Payload *models.Cluster + Payload *models.Kluster } func (o *ShowClusterOK) Error() string { @@ -63,7 +63,7 @@ func (o *ShowClusterOK) Error() string { func (o *ShowClusterOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - o.Payload = new(models.Cluster) + o.Payload = new(models.Kluster) // response payload if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { diff --git a/pkg/api/client/operations/update_cluster_parameters.go b/pkg/api/client/operations/update_cluster_parameters.go index 69e6c4095fd..234a9261260 100644 --- a/pkg/api/client/operations/update_cluster_parameters.go +++ b/pkg/api/client/operations/update_cluster_parameters.go @@ -65,7 +65,7 @@ for the update cluster operation typically these are written to a http.Request type UpdateClusterParams struct { /*Body*/ - Body *models.Cluster + Body *models.Kluster /*Name*/ Name string @@ -108,13 +108,13 @@ func (o *UpdateClusterParams) SetHTTPClient(client *http.Client) { } // WithBody adds the body to the update cluster params -func (o *UpdateClusterParams) WithBody(body *models.Cluster) *UpdateClusterParams { +func (o *UpdateClusterParams) WithBody(body *models.Kluster) *UpdateClusterParams { o.SetBody(body) return o } // SetBody adds the body to the update cluster params -func (o *UpdateClusterParams) SetBody(body *models.Cluster) { +func (o *UpdateClusterParams) SetBody(body *models.Kluster) { o.Body = body } @@ -138,7 +138,7 @@ func (o *UpdateClusterParams) WriteToRequest(r runtime.ClientRequest, reg strfmt var res []error if o.Body == nil { - o.Body = new(models.Cluster) + o.Body = new(models.Kluster) } if err := r.SetBodyParam(o.Body); err != nil { diff --git a/pkg/api/client/operations/update_cluster_responses.go b/pkg/api/client/operations/update_cluster_responses.go index 5c2363617e6..456e2563f27 100644 --- a/pkg/api/client/operations/update_cluster_responses.go +++ b/pkg/api/client/operations/update_cluster_responses.go @@ -54,7 +54,7 @@ func NewUpdateClusterOK() *UpdateClusterOK { OK */ type UpdateClusterOK struct { - Payload *models.Cluster + Payload *models.Kluster } func (o *UpdateClusterOK) Error() string { @@ -63,7 +63,7 @@ func (o *UpdateClusterOK) Error() string { func (o *UpdateClusterOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - o.Payload = new(models.Cluster) + o.Payload = new(models.Kluster) // response payload if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { diff --git a/pkg/api/handlers/create_cluster.go b/pkg/api/handlers/create_cluster.go index 6da973ad828..5fef4f5608c 100644 --- a/pkg/api/handlers/create_cluster.go +++ b/pkg/api/handlers/create_cluster.go @@ -10,7 +10,6 @@ import ( "github.com/sapcc/kubernikus/pkg/api/models" "github.com/sapcc/kubernikus/pkg/api/rest/operations" "github.com/sapcc/kubernikus/pkg/apis/kubernikus" - "github.com/sapcc/kubernikus/pkg/apis/kubernikus/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -24,31 +23,21 @@ type createCluster struct { } func (d *createCluster) Handle(params operations.CreateClusterParams, principal *models.Principal) middleware.Responder { - name := *params.Body.Name + name := params.Body.Name + spec := params.Body.Spec if err := validate.UniqueItems("name", "body", params.Body.Spec.NodePools); err != nil { return NewErrorResponse(&operations.CreateClusterDefault{}, int(err.Code()), err.Error()) } - var nodePools []v1.NodePool - if params.Body.Spec.NodePools != nil { - nodePools = []v1.NodePool{} - for i, _ := range params.Body.Spec.NodePools { - nodePools = append(nodePools, v1.NodePool{ - Name: *params.Body.Spec.NodePools[i].Name, - Size: int(*params.Body.Spec.NodePools[i].Size), - Flavor: *params.Body.Spec.NodePools[i].Flavor, - Image: "coreos-stable-amd64", - }) + spec.Name = name + for i, pool := range spec.NodePools { + //Set default image + if pool.Image == "" { + spec.NodePools[i].Image = "coreos-stable-amd64" } } - - kluster, err := kubernikus.NewKlusterFactory().KlusterFor(v1.KlusterSpec{ - Name: name, - ServiceCIDR: params.Body.Spec.ServiceCIDR, - ClusterCIDR: params.Body.Spec.ClusterCIDR, - NodePools: nodePools, - }) + kluster, err := kubernikus.NewKlusterFactory().KlusterFor(spec) kluster.ObjectMeta = metav1.ObjectMeta{ Name: fmt.Sprintf("%s-%s", name, principal.Account), @@ -65,5 +54,5 @@ func (d *createCluster) Handle(params operations.CreateClusterParams, principal return NewErrorResponse(&operations.CreateClusterDefault{}, 500, err.Error()) } - return operations.NewCreateClusterCreated().WithPayload(clusterModelFromCRD(kluster)) + return operations.NewCreateClusterCreated().WithPayload(klusterFromCRD(kluster)) } diff --git a/pkg/api/handlers/get_cluster_info.go b/pkg/api/handlers/get_cluster_info.go index bbea78dc4aa..73df5f5eb10 100644 --- a/pkg/api/handlers/get_cluster_info.go +++ b/pkg/api/handlers/get_cluster_info.go @@ -18,12 +18,12 @@ type getClusterInfo struct { } func (d *getClusterInfo) Handle(params operations.GetClusterInfoParams, principal *models.Principal) middleware.Responder { - info := &models.ClusterInfo{ + info := &models.KlusterInfo{ SetupCommand: createSetupCommand(principal), - Binaries: []*models.ClusterInfoBinariesItems0{ + Binaries: []models.Binaries{ { Name: "kubernikusctl", - Links: []*models.ClusterInfoBinariesItems0LinksItems0{ + Links: []models.Link{ { Platform: "darwin", Link: "static/binaries/darwin/amd64/kubernikusctl", diff --git a/pkg/api/handlers/list_clusters.go b/pkg/api/handlers/list_clusters.go index b7c8fdf1920..0956fad847d 100644 --- a/pkg/api/handlers/list_clusters.go +++ b/pkg/api/handlers/list_clusters.go @@ -24,9 +24,9 @@ func (d *listClusters) Handle(params operations.ListClustersParams, principal *m return NewErrorResponse(&operations.ListClustersDefault{}, 500, err.Error()) } - clusters := make([]*models.Cluster, 0, len(klusterList.Items)) + clusters := make([]*models.Kluster, 0, len(klusterList.Items)) for _, kluster := range klusterList.Items { - clusters = append(clusters, clusterModelFromCRD(&kluster)) + clusters = append(clusters, klusterFromCRD(&kluster)) } return operations.NewListClustersOK().WithPayload(clusters) } diff --git a/pkg/api/handlers/show_cluster.go b/pkg/api/handlers/show_cluster.go index a8cccf6c0c0..5fa60bcb395 100644 --- a/pkg/api/handlers/show_cluster.go +++ b/pkg/api/handlers/show_cluster.go @@ -28,5 +28,5 @@ func (d *showCluster) Handle(params operations.ShowClusterParams, principal *mod return NewErrorResponse(&operations.ShowClusterDefault{}, 500, err.Error()) } - return operations.NewShowClusterOK().WithPayload(clusterModelFromCRD(kluster)) + return operations.NewShowClusterOK().WithPayload(klusterFromCRD(kluster)) } diff --git a/pkg/api/handlers/terminate_cluster.go b/pkg/api/handlers/terminate_cluster.go index 53aaac05445..e237165fd08 100644 --- a/pkg/api/handlers/terminate_cluster.go +++ b/pkg/api/handlers/terminate_cluster.go @@ -38,8 +38,8 @@ func (d *terminateCluster) Handle(params operations.TerminateClusterParams, prin } _, err = editCluster(kluster, principal, params.Name, func(kluster *v1.Kluster) { - kluster.Status.Kluster.State = v1.KlusterTerminating - kluster.Status.Kluster.Message = "Cluster terminating" + kluster.Status.State = models.KlusterStateTerminating + kluster.Status.Message = "Cluster terminating" }) if err != nil { return NewErrorResponse(&operations.TerminateClusterDefault{}, 500, err.Error()) diff --git a/pkg/api/handlers/update_cluster.go b/pkg/api/handlers/update_cluster.go index ed373feb57b..749c2f8db29 100644 --- a/pkg/api/handlers/update_cluster.go +++ b/pkg/api/handlers/update_cluster.go @@ -21,50 +21,15 @@ type updateCluster struct { func (d *updateCluster) Handle(params operations.UpdateClusterParams, principal *models.Principal) middleware.Responder { kluster, err := editCluster(d.Kubernikus.Kubernikus().Klusters(d.Namespace), principal, params.Name, func(kluster *v1.Kluster) { - // Update Sizes - for j, _ := range params.Body.Spec.NodePools { - isNewPool := true - - for i, _ := range kluster.Spec.NodePools { - if *params.Body.Spec.NodePools[j].Name == kluster.Spec.NodePools[i].Name { - kluster.Spec.NodePools[i].Size = int(*params.Body.Spec.NodePools[j].Size) - isNewPool = false - } - } - - if isNewPool { - kluster.Spec.NodePools = append(kluster.Spec.NodePools, v1.NodePool{ - Name: *params.Body.Spec.NodePools[j].Name, - Size: int(*params.Body.Spec.NodePools[j].Size), - Flavor: *params.Body.Spec.NodePools[j].Flavor, - Image: "coreos-stable-amd64", - }) - - kluster.Status.NodePools = append(kluster.Status.NodePools, v1.NodePoolInfo{ - Name: *params.Body.Spec.NodePools[j].Name, - Size: int(*params.Body.Spec.NodePools[j].Size), - Running: 0, - Healthy: 0, - Schedulable: 0, - }) + nodePools := params.Body.Spec.NodePools + //set default image + for i, pool := range nodePools { + if pool.Image == "" { + nodePools[i].Image = "coreos-stable-amd64" } } - - for i, _ := range kluster.Spec.NodePools { - isDeleted := true - for j, _ := range params.Body.Spec.NodePools { - if *params.Body.Spec.NodePools[j].Name == kluster.Spec.NodePools[i].Name { - isDeleted = false - break - } - } - if isDeleted { - // wtf? I want my ruby back... - kluster.Spec.NodePools[i] = kluster.Spec.NodePools[len(kluster.Spec.NodePools)-1] - kluster.Spec.NodePools = kluster.Spec.NodePools[:len(kluster.Spec.NodePools)-1] - } - } - + // Update nodepool + kluster.Spec.NodePools = nodePools }) if err != nil { if apierrors.IsNotFound(err) { @@ -72,5 +37,5 @@ func (d *updateCluster) Handle(params operations.UpdateClusterParams, principal } return NewErrorResponse(&operations.UpdateClusterDefault{}, 500, err.Error()) } - return operations.NewUpdateClusterOK().WithPayload(clusterModelFromCRD(kluster)) + return operations.NewUpdateClusterOK().WithPayload(klusterFromCRD(kluster)) } diff --git a/pkg/api/handlers/util.go b/pkg/api/handlers/util.go index b6182b8aacb..35618a118df 100644 --- a/pkg/api/handlers/util.go +++ b/pkg/api/handlers/util.go @@ -1,7 +1,6 @@ package handlers import ( - "github.com/go-openapi/swag" "github.com/sapcc/kubernikus/pkg/api/models" "github.com/sapcc/kubernikus/pkg/apis/kubernikus/v1" kubernikusv1 "github.com/sapcc/kubernikus/pkg/generated/clientset/typed/kubernikus/v1" @@ -40,47 +39,10 @@ func editCluster(client kubernikusv1.KlusterInterface, principal *models.Princip } -func clusterSpecNodePoolItemsFromCRD(k *v1.Kluster) []*models.ClusterSpecNodePoolsItems0 { - items := make([]*models.ClusterSpecNodePoolsItems0, int64(len(k.Spec.NodePools))) - for i, _ := range k.Spec.NodePools { - items[i] = &models.ClusterSpecNodePoolsItems0{ - Name: &k.Spec.NodePools[i].Name, - Image: k.Spec.NodePools[i].Image, - Flavor: &k.Spec.NodePools[i].Flavor, - Size: &[]int64{int64(k.Spec.NodePools[i].Size)}[0], - } - } - return items -} - -func clusterStatusNodePoolItemsFromCRD(k *v1.Kluster) []*models.ClusterStatusNodePoolsItems0 { - items := make([]*models.ClusterStatusNodePoolsItems0, int64(len(k.Status.NodePools))) - for i, _ := range k.Status.NodePools { - items[i] = &models.ClusterStatusNodePoolsItems0{ - Name: &k.Status.NodePools[i].Name, - Size: &[]int64{int64(k.Status.NodePools[i].Size)}[0], - Running: &[]int64{int64(k.Status.NodePools[i].Running)}[0], - Healthy: &[]int64{int64(k.Status.NodePools[i].Healthy)}[0], - Schedulable: &[]int64{int64(k.Status.NodePools[i].Schedulable)}[0], - } - } - return items -} - -func clusterModelFromCRD(k *v1.Kluster) *models.Cluster { - return &models.Cluster{ - Name: swag.String(k.Spec.Name), - Spec: models.ClusterSpec{ - ServiceCIDR: k.Spec.ServiceCIDR, - ClusterCIDR: k.Spec.ClusterCIDR, - NodePools: clusterSpecNodePoolItemsFromCRD(k), - }, - Status: &models.ClusterStatus{ - Kluster: &models.ClusterStatusKluster{ - State: string(k.Status.Kluster.State), - Message: k.Status.Kluster.Message, - }, - NodePools: clusterStatusNodePoolItemsFromCRD(k), - }, +func klusterFromCRD(k *v1.Kluster) *models.Kluster { + return &models.Kluster{ + Name: k.Spec.Name, + Spec: k.Spec, + Status: k.Status, } } diff --git a/pkg/api/models/cluster.go b/pkg/api/models/cluster.go deleted file mode 100644 index a9cc31c69cc..00000000000 --- a/pkg/api/models/cluster.go +++ /dev/null @@ -1,641 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "strconv" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// Cluster cluster -// swagger:model Cluster - -type Cluster struct { - - // name of the cluster - // Required: true - // Pattern: ^[a-z]([-a-z0-9]*[a-z0-9])?$ - Name *string `json:"name"` - - // spec - Spec ClusterSpec `json:"spec,omitempty"` - - // status - Status *ClusterStatus `json:"status,omitempty"` -} - -/* polymorph Cluster name false */ - -/* polymorph Cluster spec false */ - -/* polymorph Cluster status false */ - -// Validate validates this cluster -func (m *Cluster) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateName(formats); err != nil { - // prop - res = append(res, err) - } - - if err := m.validateSpec(formats); err != nil { - // prop - res = append(res, err) - } - - if err := m.validateStatus(formats); err != nil { - // prop - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *Cluster) validateName(formats strfmt.Registry) error { - - if err := validate.Required("name", "body", m.Name); err != nil { - return err - } - - if err := validate.Pattern("name", "body", string(*m.Name), `^[a-z]([-a-z0-9]*[a-z0-9])?$`); err != nil { - return err - } - - return nil -} - -func (m *Cluster) validateSpec(formats strfmt.Registry) error { - - if swag.IsZero(m.Spec) { // not required - return nil - } - - if err := m.Spec.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("spec") - } - return err - } - - return nil -} - -func (m *Cluster) validateStatus(formats strfmt.Registry) error { - - if swag.IsZero(m.Status) { // not required - return nil - } - - if m.Status != nil { - - if err := m.Status.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("status") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (m *Cluster) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *Cluster) UnmarshalBinary(b []byte) error { - var res Cluster - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} - -// ClusterSpec cluster spec -// swagger:model ClusterSpec - -type ClusterSpec struct { - - // CIDR Range for Pods in the cluster. Can not be updated. - // Pattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$ - ClusterCIDR string `json:"clusterCIDR,omitempty"` - - // node pools - NodePools []*ClusterSpecNodePoolsItems0 `json:"nodePools"` - - // CIDR Range for Services in the cluster. Can not be updated. - // Pattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$ - ServiceCIDR string `json:"serviceCIDR,omitempty"` -} - -/* polymorph ClusterSpec clusterCIDR false */ - -/* polymorph ClusterSpec nodePools false */ - -/* polymorph ClusterSpec serviceCIDR false */ - -// Validate validates this cluster spec -func (m *ClusterSpec) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateClusterCIDR(formats); err != nil { - // prop - res = append(res, err) - } - - if err := m.validateNodePools(formats); err != nil { - // prop - res = append(res, err) - } - - if err := m.validateServiceCIDR(formats); err != nil { - // prop - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *ClusterSpec) validateClusterCIDR(formats strfmt.Registry) error { - - if swag.IsZero(m.ClusterCIDR) { // not required - return nil - } - - if err := validate.Pattern("spec"+"."+"clusterCIDR", "body", string(m.ClusterCIDR), `^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$`); err != nil { - return err - } - - return nil -} - -func (m *ClusterSpec) validateNodePools(formats strfmt.Registry) error { - - if swag.IsZero(m.NodePools) { // not required - return nil - } - - for i := 0; i < len(m.NodePools); i++ { - - if swag.IsZero(m.NodePools[i]) { // not required - continue - } - - if m.NodePools[i] != nil { - - if err := m.NodePools[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("spec" + "." + "nodePools" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -func (m *ClusterSpec) validateServiceCIDR(formats strfmt.Registry) error { - - if swag.IsZero(m.ServiceCIDR) { // not required - return nil - } - - if err := validate.Pattern("spec"+"."+"serviceCIDR", "body", string(m.ServiceCIDR), `^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$`); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *ClusterSpec) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ClusterSpec) UnmarshalBinary(b []byte) error { - var res ClusterSpec - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} - -// ClusterSpecNodePoolsItems0 cluster spec node pools items0 -// swagger:model ClusterSpecNodePoolsItems0 - -type ClusterSpecNodePoolsItems0 struct { - - // flavor - // Required: true - Flavor *string `json:"flavor"` - - // image - Image string `json:"image,omitempty"` - - // name - // Required: true - // Pattern: ^[a-z]([a-z0-9]*)?$ - Name *string `json:"name"` - - // size - // Required: true - // Maximum: 127 - // Minimum: 0 - Size *int64 `json:"size"` -} - -/* polymorph ClusterSpecNodePoolsItems0 flavor false */ - -/* polymorph ClusterSpecNodePoolsItems0 image false */ - -/* polymorph ClusterSpecNodePoolsItems0 name false */ - -/* polymorph ClusterSpecNodePoolsItems0 size false */ - -// Validate validates this cluster spec node pools items0 -func (m *ClusterSpecNodePoolsItems0) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateFlavor(formats); err != nil { - // prop - res = append(res, err) - } - - if err := m.validateName(formats); err != nil { - // prop - res = append(res, err) - } - - if err := m.validateSize(formats); err != nil { - // prop - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *ClusterSpecNodePoolsItems0) validateFlavor(formats strfmt.Registry) error { - - if err := validate.Required("flavor", "body", m.Flavor); err != nil { - return err - } - - return nil -} - -func (m *ClusterSpecNodePoolsItems0) validateName(formats strfmt.Registry) error { - - if err := validate.Required("name", "body", m.Name); err != nil { - return err - } - - if err := validate.Pattern("name", "body", string(*m.Name), `^[a-z]([a-z0-9]*)?$`); err != nil { - return err - } - - return nil -} - -func (m *ClusterSpecNodePoolsItems0) validateSize(formats strfmt.Registry) error { - - if err := validate.Required("size", "body", m.Size); err != nil { - return err - } - - if err := validate.MinimumInt("size", "body", int64(*m.Size), 0, false); err != nil { - return err - } - - if err := validate.MaximumInt("size", "body", int64(*m.Size), 127, false); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *ClusterSpecNodePoolsItems0) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ClusterSpecNodePoolsItems0) UnmarshalBinary(b []byte) error { - var res ClusterSpecNodePoolsItems0 - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} - -// ClusterStatus cluster status -// swagger:model ClusterStatus - -type ClusterStatus struct { - - // kluster - Kluster *ClusterStatusKluster `json:"kluster,omitempty"` - - // node pools - NodePools []*ClusterStatusNodePoolsItems0 `json:"nodePools"` -} - -/* polymorph ClusterStatus kluster false */ - -/* polymorph ClusterStatus nodePools false */ - -// Validate validates this cluster status -func (m *ClusterStatus) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateKluster(formats); err != nil { - // prop - res = append(res, err) - } - - if err := m.validateNodePools(formats); err != nil { - // prop - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *ClusterStatus) validateKluster(formats strfmt.Registry) error { - - if swag.IsZero(m.Kluster) { // not required - return nil - } - - if m.Kluster != nil { - - if err := m.Kluster.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("status" + "." + "kluster") - } - return err - } - } - - return nil -} - -func (m *ClusterStatus) validateNodePools(formats strfmt.Registry) error { - - if swag.IsZero(m.NodePools) { // not required - return nil - } - - for i := 0; i < len(m.NodePools); i++ { - - if swag.IsZero(m.NodePools[i]) { // not required - continue - } - - if m.NodePools[i] != nil { - - if err := m.NodePools[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("status" + "." + "nodePools" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -// MarshalBinary interface implementation -func (m *ClusterStatus) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ClusterStatus) UnmarshalBinary(b []byte) error { - var res ClusterStatus - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} - -// ClusterStatusKluster cluster status kluster -// swagger:model ClusterStatusKluster - -type ClusterStatusKluster struct { - - // message - Message string `json:"message,omitempty"` - - // status of the cluster - State string `json:"state,omitempty"` -} - -/* polymorph ClusterStatusKluster message false */ - -/* polymorph ClusterStatusKluster state false */ - -// Validate validates this cluster status kluster -func (m *ClusterStatusKluster) Validate(formats strfmt.Registry) error { - var res []error - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// MarshalBinary interface implementation -func (m *ClusterStatusKluster) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ClusterStatusKluster) UnmarshalBinary(b []byte) error { - var res ClusterStatusKluster - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} - -// ClusterStatusNodePoolsItems0 cluster status node pools items0 -// swagger:model ClusterStatusNodePoolsItems0 - -type ClusterStatusNodePoolsItems0 struct { - - // healthy - // Required: true - Healthy *int64 `json:"healthy"` - - // name - // Required: true - Name *string `json:"name"` - - // running - // Required: true - Running *int64 `json:"running"` - - // schedulable - // Required: true - Schedulable *int64 `json:"schedulable"` - - // size - // Required: true - Size *int64 `json:"size"` -} - -/* polymorph ClusterStatusNodePoolsItems0 healthy false */ - -/* polymorph ClusterStatusNodePoolsItems0 name false */ - -/* polymorph ClusterStatusNodePoolsItems0 running false */ - -/* polymorph ClusterStatusNodePoolsItems0 schedulable false */ - -/* polymorph ClusterStatusNodePoolsItems0 size false */ - -// Validate validates this cluster status node pools items0 -func (m *ClusterStatusNodePoolsItems0) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateHealthy(formats); err != nil { - // prop - res = append(res, err) - } - - if err := m.validateName(formats); err != nil { - // prop - res = append(res, err) - } - - if err := m.validateRunning(formats); err != nil { - // prop - res = append(res, err) - } - - if err := m.validateSchedulable(formats); err != nil { - // prop - res = append(res, err) - } - - if err := m.validateSize(formats); err != nil { - // prop - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *ClusterStatusNodePoolsItems0) validateHealthy(formats strfmt.Registry) error { - - if err := validate.Required("healthy", "body", m.Healthy); err != nil { - return err - } - - return nil -} - -func (m *ClusterStatusNodePoolsItems0) validateName(formats strfmt.Registry) error { - - if err := validate.Required("name", "body", m.Name); err != nil { - return err - } - - return nil -} - -func (m *ClusterStatusNodePoolsItems0) validateRunning(formats strfmt.Registry) error { - - if err := validate.Required("running", "body", m.Running); err != nil { - return err - } - - return nil -} - -func (m *ClusterStatusNodePoolsItems0) validateSchedulable(formats strfmt.Registry) error { - - if err := validate.Required("schedulable", "body", m.Schedulable); err != nil { - return err - } - - return nil -} - -func (m *ClusterStatusNodePoolsItems0) validateSize(formats strfmt.Registry) error { - - if err := validate.Required("size", "body", m.Size); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *ClusterStatusNodePoolsItems0) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ClusterStatusNodePoolsItems0) UnmarshalBinary(b []byte) error { - var res ClusterStatusNodePoolsItems0 - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/api/models/cluster_info.go b/pkg/api/models/cluster_info.go deleted file mode 100644 index 518c04f427c..00000000000 --- a/pkg/api/models/cluster_info.go +++ /dev/null @@ -1,211 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "strconv" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" -) - -// ClusterInfo cluster info -// swagger:model ClusterInfo - -type ClusterInfo struct { - - // binaries - Binaries []*ClusterInfoBinariesItems0 `json:"binaries"` - - // setup command - SetupCommand string `json:"setupCommand,omitempty"` -} - -/* polymorph ClusterInfo binaries false */ - -/* polymorph ClusterInfo setupCommand false */ - -// Validate validates this cluster info -func (m *ClusterInfo) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateBinaries(formats); err != nil { - // prop - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *ClusterInfo) validateBinaries(formats strfmt.Registry) error { - - if swag.IsZero(m.Binaries) { // not required - return nil - } - - for i := 0; i < len(m.Binaries); i++ { - - if swag.IsZero(m.Binaries[i]) { // not required - continue - } - - if m.Binaries[i] != nil { - - if err := m.Binaries[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("binaries" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -// MarshalBinary interface implementation -func (m *ClusterInfo) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ClusterInfo) UnmarshalBinary(b []byte) error { - var res ClusterInfo - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} - -// ClusterInfoBinariesItems0 cluster info binaries items0 -// swagger:model ClusterInfoBinariesItems0 - -type ClusterInfoBinariesItems0 struct { - - // links - Links []*ClusterInfoBinariesItems0LinksItems0 `json:"links"` - - // name - Name string `json:"name,omitempty"` -} - -/* polymorph ClusterInfoBinariesItems0 links false */ - -/* polymorph ClusterInfoBinariesItems0 name false */ - -// Validate validates this cluster info binaries items0 -func (m *ClusterInfoBinariesItems0) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateLinks(formats); err != nil { - // prop - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *ClusterInfoBinariesItems0) validateLinks(formats strfmt.Registry) error { - - if swag.IsZero(m.Links) { // not required - return nil - } - - for i := 0; i < len(m.Links); i++ { - - if swag.IsZero(m.Links[i]) { // not required - continue - } - - if m.Links[i] != nil { - - if err := m.Links[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("links" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -// MarshalBinary interface implementation -func (m *ClusterInfoBinariesItems0) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ClusterInfoBinariesItems0) UnmarshalBinary(b []byte) error { - var res ClusterInfoBinariesItems0 - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} - -// ClusterInfoBinariesItems0LinksItems0 cluster info binaries items0 links items0 -// swagger:model ClusterInfoBinariesItems0LinksItems0 - -type ClusterInfoBinariesItems0LinksItems0 struct { - - // link - Link string `json:"link,omitempty"` - - // platform - Platform string `json:"platform,omitempty"` -} - -/* polymorph ClusterInfoBinariesItems0LinksItems0 link false */ - -/* polymorph ClusterInfoBinariesItems0LinksItems0 platform false */ - -// Validate validates this cluster info binaries items0 links items0 -func (m *ClusterInfoBinariesItems0LinksItems0) Validate(formats strfmt.Registry) error { - var res []error - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// MarshalBinary interface implementation -func (m *ClusterInfoBinariesItems0LinksItems0) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ClusterInfoBinariesItems0LinksItems0) UnmarshalBinary(b []byte) error { - var res ClusterInfoBinariesItems0LinksItems0 - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/api/models/kluster.go b/pkg/api/models/kluster.go new file mode 100644 index 00000000000..e9a7e7199ef --- /dev/null +++ b/pkg/api/models/kluster.go @@ -0,0 +1,125 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Kluster kluster +// swagger:model Kluster + +type Kluster struct { + + // name of the cluster + // Required: true + // Pattern: ^[a-z]([-a-z0-9]*[a-z0-9])?$ + Name string `json:"name"` + + // spec + Spec KlusterSpec `json:"spec,omitempty"` + + // status + Status KlusterStatus `json:"status,omitempty"` +} + +/* polymorph Kluster name false */ + +/* polymorph Kluster spec false */ + +/* polymorph Kluster status false */ + +// Validate validates this kluster +func (m *Kluster) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateName(formats); err != nil { + // prop + res = append(res, err) + } + + if err := m.validateSpec(formats); err != nil { + // prop + res = append(res, err) + } + + if err := m.validateStatus(formats); err != nil { + // prop + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Kluster) validateName(formats strfmt.Registry) error { + + if err := validate.RequiredString("name", "body", string(m.Name)); err != nil { + return err + } + + if err := validate.Pattern("name", "body", string(m.Name), `^[a-z]([-a-z0-9]*[a-z0-9])?$`); err != nil { + return err + } + + return nil +} + +func (m *Kluster) validateSpec(formats strfmt.Registry) error { + + if swag.IsZero(m.Spec) { // not required + return nil + } + + if err := m.Spec.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("spec") + } + return err + } + + return nil +} + +func (m *Kluster) validateStatus(formats strfmt.Registry) error { + + if swag.IsZero(m.Status) { // not required + return nil + } + + if err := m.Status.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("status") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Kluster) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Kluster) UnmarshalBinary(b []byte) error { + var res Kluster + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/api/models/kluster_info.go b/pkg/api/models/kluster_info.go new file mode 100644 index 00000000000..5caf780a888 --- /dev/null +++ b/pkg/api/models/kluster_info.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// KlusterInfo kluster info +// swagger:model KlusterInfo + +type KlusterInfo struct { + + // binaries + Binaries []Binaries `json:"binaries"` + + // setup command + SetupCommand string `json:"setupCommand,omitempty"` +} + +/* polymorph KlusterInfo binaries false */ + +/* polymorph KlusterInfo setupCommand false */ + +// Validate validates this kluster info +func (m *KlusterInfo) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateBinaries(formats); err != nil { + // prop + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *KlusterInfo) validateBinaries(formats strfmt.Registry) error { + + if swag.IsZero(m.Binaries) { // not required + return nil + } + + return nil +} + +// MarshalBinary interface implementation +func (m *KlusterInfo) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *KlusterInfo) UnmarshalBinary(b []byte) error { + var res KlusterInfo + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// Binaries binaries +// swagger:model Binaries + +type Binaries struct { + + // links + Links []Link `json:"links"` + + // name + Name string `json:"name,omitempty"` +} + +/* polymorph Binaries links false */ + +/* polymorph Binaries name false */ + +// Validate validates this binaries +func (m *Binaries) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateLinks(formats); err != nil { + // prop + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Binaries) validateLinks(formats strfmt.Registry) error { + + if swag.IsZero(m.Links) { // not required + return nil + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Binaries) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Binaries) UnmarshalBinary(b []byte) error { + var res Binaries + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// Link link +// swagger:model Link + +type Link struct { + + // link + Link string `json:"link,omitempty"` + + // platform + Platform string `json:"platform,omitempty"` +} + +/* polymorph Link link false */ + +/* polymorph Link platform false */ + +// Validate validates this link +func (m *Link) Validate(formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// MarshalBinary interface implementation +func (m *Link) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Link) UnmarshalBinary(b []byte) error { + var res Link + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/api/models/cluster_print.go b/pkg/api/models/kluster_print.go similarity index 52% rename from pkg/api/models/cluster_print.go rename to pkg/api/models/kluster_print.go index 42bccca5c56..27936c7cae3 100644 --- a/pkg/api/models/cluster_print.go +++ b/pkg/api/models/kluster_print.go @@ -7,7 +7,7 @@ import ( "github.com/sapcc/kubernikus/pkg/cmd/printers" ) -func (c *Cluster) GetFormats() map[printers.PrintFormat]struct{} { +func (k Kluster) GetFormats() map[printers.PrintFormat]struct{} { ret := map[printers.PrintFormat]struct{}{ printers.Table: struct{}{}, printers.Human: struct{}{}, @@ -15,34 +15,34 @@ func (c *Cluster) GetFormats() map[printers.PrintFormat]struct{} { return ret } -func (c *Cluster) Print(format printers.PrintFormat, options printers.PrintOptions) error { +func (k Kluster) Print(format printers.PrintFormat, options printers.PrintOptions) error { switch format { case printers.Table: - c.printTable(options) + k.printTable(options) case printers.Human: - c.printHuman(options) + k.printHuman(options) default: return errors.Errorf("Unknown printformat models.Cluster is unable to print in format: %v", format) } return nil } -func (c *Cluster) printHuman(options printers.PrintOptions) { - fmt.Println("Cluster name: ", *c.Name) - fmt.Println("Cluster state: ", (*c).Status.Kluster.State) - fmt.Println("Cluster CIDR: ", (*c).Spec.ClusterCIDR) - fmt.Println("Service CIDR: ", (*c).Spec.ServiceCIDR) - fmt.Println("Cluster node pools: ", len((*c).Spec.NodePools)) - for _, pool := range (*c).Spec.NodePools { +func (k Kluster) printHuman(options printers.PrintOptions) { + fmt.Println("Cluster name: ", k.Name) + fmt.Println("Cluster state: ", k.Status.State) + fmt.Println("Cluster CIDR: ", k.Spec.ClusterCIDR) + fmt.Println("Service CIDR: ", k.Spec.ServiceCIDR) + fmt.Println("Cluster node pools: ", len(k.Spec.NodePools)) + for _, pool := range k.Spec.NodePools { pool.printHuman(options) } fmt.Println("Cluster node pool status: ") - for _, pool := range (*c).Status.NodePools { + for _, pool := range k.Status.NodePools { pool.printHuman(options) } } -func (c *Cluster) printTable(options printers.PrintOptions) { +func (k *Kluster) printTable(options printers.PrintOptions) { if options.WithHeaders { fmt.Print("NAME") fmt.Print("\t") @@ -50,14 +50,14 @@ func (c *Cluster) printTable(options printers.PrintOptions) { fmt.Print("\t") fmt.Println("MESSAGE") } - fmt.Print(*c.Name) + fmt.Print(k.Name) fmt.Print("\t") - fmt.Print((*c).Status.Kluster.State) + fmt.Print(k.Status.State) fmt.Print("\t") - fmt.Println((*c).Status.Kluster.Message) + fmt.Println(k.Status.Message) } -func (p *ClusterSpecNodePoolsItems0) GetFormats() map[printers.PrintFormat]struct{} { +func (p NodePool) GetFormats() map[printers.PrintFormat]struct{} { ret := map[printers.PrintFormat]struct{}{ printers.Table: struct{}{}, printers.Human: struct{}{}, @@ -65,7 +65,7 @@ func (p *ClusterSpecNodePoolsItems0) GetFormats() map[printers.PrintFormat]struc return ret } -func (p *ClusterSpecNodePoolsItems0) Print(format printers.PrintFormat, options printers.PrintOptions) error { +func (p NodePool) Print(format printers.PrintFormat, options printers.PrintOptions) error { switch format { case printers.Human: p.printHuman(options) @@ -77,18 +77,18 @@ func (p *ClusterSpecNodePoolsItems0) Print(format printers.PrintFormat, options return nil } -func (p *ClusterSpecNodePoolsItems0) printHuman(options printers.PrintOptions) { +func (p NodePool) printHuman(options printers.PrintOptions) { fmt.Print("Name: ") - fmt.Println(*p.Name) + fmt.Println(p.Name) fmt.Print(" Flavor: \t") - fmt.Println(*p.Flavor) + fmt.Println(p.Flavor) fmt.Print(" Image: \t") fmt.Println(p.Image) fmt.Print(" Size: \t") - fmt.Println(*p.Size) + fmt.Println(p.Size) } -func (p *ClusterSpecNodePoolsItems0) printTable(options printers.PrintOptions) { +func (p NodePool) printTable(options printers.PrintOptions) { if options.WithHeaders { fmt.Print("NAME") fmt.Print("\t") @@ -98,24 +98,24 @@ func (p *ClusterSpecNodePoolsItems0) printTable(options printers.PrintOptions) { fmt.Print("\t") fmt.Println("SIZE") } - fmt.Print(*p.Name) + fmt.Print(p.Name) fmt.Print("\t") - fmt.Print(*p.Flavor) + fmt.Print(p.Flavor) fmt.Print("\t") fmt.Print(p.Image) fmt.Print("\t") - fmt.Println(*p.Size) + fmt.Println(p.Size) } -func (p *ClusterStatusNodePoolsItems0) printHuman(options printers.PrintOptions) { +func (p NodePoolInfo) printHuman(options printers.PrintOptions) { fmt.Print("Name: ") - fmt.Println(*p.Name) + fmt.Println(p.Name) fmt.Print(" Size: \t") - fmt.Println(*p.Size) + fmt.Println(p.Size) fmt.Print(" Running: \t") - fmt.Println(*p.Running) + fmt.Println(p.Running) fmt.Print(" Schedulable: \t") - fmt.Println(*p.Schedulable) + fmt.Println(p.Schedulable) fmt.Print(" Healthy: \t") - fmt.Println(*p.Healthy) + fmt.Println(p.Healthy) } diff --git a/pkg/api/models/kluster_spec.go b/pkg/api/models/kluster_spec.go new file mode 100644 index 00000000000..61466401c86 --- /dev/null +++ b/pkg/api/models/kluster_spec.go @@ -0,0 +1,172 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// KlusterSpec kluster spec +// swagger:model KlusterSpec + +type KlusterSpec struct { + + // advertise address + AdvertiseAddress string `json:"advertiseAddress,omitempty"` + + // CIDR Range for Pods in the cluster. Can not be updated. + // Pattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$ + ClusterCIDR string `json:"clusterCIDR,omitempty"` + + // cluster DNS + ClusterDNS string `json:"clusterDNS,omitempty"` + + // cluster DNS domain + ClusterDNSDomain string `json:"clusterDNSDomain,omitempty"` + + // domain + Domain string `json:"domain,omitempty"` + + // name + // Read Only: true + Name string `json:"name,omitempty"` + + // node pools + NodePools []NodePool `json:"nodePools"` + + // openstack + Openstack OpenstackSpec `json:"openstack,omitempty"` + + // CIDR Range for Services in the cluster. Can not be updated. + // Pattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$ + ServiceCIDR string `json:"serviceCIDR,omitempty"` + + // version + Version string `json:"version,omitempty"` +} + +/* polymorph KlusterSpec advertiseAddress false */ + +/* polymorph KlusterSpec clusterCIDR false */ + +/* polymorph KlusterSpec clusterDNS false */ + +/* polymorph KlusterSpec clusterDNSDomain false */ + +/* polymorph KlusterSpec domain false */ + +/* polymorph KlusterSpec name false */ + +/* polymorph KlusterSpec nodePools false */ + +/* polymorph KlusterSpec openstack false */ + +/* polymorph KlusterSpec serviceCIDR false */ + +/* polymorph KlusterSpec version false */ + +// Validate validates this kluster spec +func (m *KlusterSpec) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateClusterCIDR(formats); err != nil { + // prop + res = append(res, err) + } + + if err := m.validateNodePools(formats); err != nil { + // prop + res = append(res, err) + } + + if err := m.validateOpenstack(formats); err != nil { + // prop + res = append(res, err) + } + + if err := m.validateServiceCIDR(formats); err != nil { + // prop + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *KlusterSpec) validateClusterCIDR(formats strfmt.Registry) error { + + if swag.IsZero(m.ClusterCIDR) { // not required + return nil + } + + if err := validate.Pattern("clusterCIDR", "body", string(m.ClusterCIDR), `^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$`); err != nil { + return err + } + + return nil +} + +func (m *KlusterSpec) validateNodePools(formats strfmt.Registry) error { + + if swag.IsZero(m.NodePools) { // not required + return nil + } + + return nil +} + +func (m *KlusterSpec) validateOpenstack(formats strfmt.Registry) error { + + if swag.IsZero(m.Openstack) { // not required + return nil + } + + if err := m.Openstack.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("openstack") + } + return err + } + + return nil +} + +func (m *KlusterSpec) validateServiceCIDR(formats strfmt.Registry) error { + + if swag.IsZero(m.ServiceCIDR) { // not required + return nil + } + + if err := validate.Pattern("serviceCIDR", "body", string(m.ServiceCIDR), `^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$`); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *KlusterSpec) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *KlusterSpec) UnmarshalBinary(b []byte) error { + var res KlusterSpec + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/api/models/kluster_state.go b/pkg/api/models/kluster_state.go new file mode 100644 index 00000000000..e5294a501da --- /dev/null +++ b/pkg/api/models/kluster_state.go @@ -0,0 +1,68 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/validate" +) + +// KlusterState kluster state +// swagger:model KlusterState + +type KlusterState string + +const ( + // KlusterStatePending captures enum value "Pending" + KlusterStatePending KlusterState = "Pending" + // KlusterStateCreating captures enum value "Creating" + KlusterStateCreating KlusterState = "Creating" + // KlusterStateReady captures enum value "Ready" + KlusterStateReady KlusterState = "Ready" + // KlusterStateTerminating captures enum value "Terminating" + KlusterStateTerminating KlusterState = "Terminating" + // KlusterStateError captures enum value "Error" + KlusterStateError KlusterState = "Error" +) + +// for schema +var klusterStateEnum []interface{} + +func init() { + var res []KlusterState + if err := json.Unmarshal([]byte(`["Pending","Creating","Ready","Terminating","Error"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + klusterStateEnum = append(klusterStateEnum, v) + } +} + +func (m KlusterState) validateKlusterStateEnum(path, location string, value KlusterState) error { + if err := validate.Enum(path, location, value, klusterStateEnum); err != nil { + return err + } + return nil +} + +// Validate validates this kluster state +func (m KlusterState) Validate(formats strfmt.Registry) error { + var res []error + + // value enum + if err := m.validateKlusterStateEnum("", "body", m); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/api/models/kluster_status.go b/pkg/api/models/kluster_status.go new file mode 100644 index 00000000000..cc4130f4867 --- /dev/null +++ b/pkg/api/models/kluster_status.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// KlusterStatus kluster status +// swagger:model KlusterStatus + +type KlusterStatus struct { + + // apiserver + Apiserver string `json:"apiserver,omitempty"` + + // message + Message string `json:"message,omitempty"` + + // node pools + NodePools []NodePoolInfo `json:"nodePools"` + + // state + State KlusterState `json:"state,omitempty"` + + // wormhole + Wormhole string `json:"wormhole,omitempty"` +} + +/* polymorph KlusterStatus apiserver false */ + +/* polymorph KlusterStatus message false */ + +/* polymorph KlusterStatus nodePools false */ + +/* polymorph KlusterStatus state false */ + +/* polymorph KlusterStatus wormhole false */ + +// Validate validates this kluster status +func (m *KlusterStatus) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateNodePools(formats); err != nil { + // prop + res = append(res, err) + } + + if err := m.validateState(formats); err != nil { + // prop + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *KlusterStatus) validateNodePools(formats strfmt.Registry) error { + + if swag.IsZero(m.NodePools) { // not required + return nil + } + + return nil +} + +func (m *KlusterStatus) validateState(formats strfmt.Registry) error { + + if swag.IsZero(m.State) { // not required + return nil + } + + if err := m.State.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("state") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *KlusterStatus) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *KlusterStatus) UnmarshalBinary(b []byte) error { + var res KlusterStatus + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/api/models/node_pool.go b/pkg/api/models/node_pool.go new file mode 100644 index 00000000000..ab61f855672 --- /dev/null +++ b/pkg/api/models/node_pool.go @@ -0,0 +1,154 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NodePool node pool +// swagger:model NodePool + +type NodePool struct { + + // config + Config NodePoolConfig `json:"config,omitempty"` + + // flavor + // Required: true + Flavor string `json:"flavor"` + + // image + Image string `json:"image,omitempty"` + + // name + // Required: true + // Pattern: ^[a-z]([a-z0-9]*)?$ + Name string `json:"name"` + + // size + // Required: true + // Maximum: 127 + // Minimum: 0 + Size int64 `json:"size"` +} + +/* polymorph NodePool config false */ + +/* polymorph NodePool flavor false */ + +/* polymorph NodePool image false */ + +/* polymorph NodePool name false */ + +/* polymorph NodePool size false */ + +// Validate validates this node pool +func (m *NodePool) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateConfig(formats); err != nil { + // prop + res = append(res, err) + } + + if err := m.validateFlavor(formats); err != nil { + // prop + res = append(res, err) + } + + if err := m.validateName(formats); err != nil { + // prop + res = append(res, err) + } + + if err := m.validateSize(formats); err != nil { + // prop + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NodePool) validateConfig(formats strfmt.Registry) error { + + if swag.IsZero(m.Config) { // not required + return nil + } + + if err := m.Config.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("config") + } + return err + } + + return nil +} + +func (m *NodePool) validateFlavor(formats strfmt.Registry) error { + + if err := validate.RequiredString("flavor", "body", string(m.Flavor)); err != nil { + return err + } + + return nil +} + +func (m *NodePool) validateName(formats strfmt.Registry) error { + + if err := validate.RequiredString("name", "body", string(m.Name)); err != nil { + return err + } + + if err := validate.Pattern("name", "body", string(m.Name), `^[a-z]([a-z0-9]*)?$`); err != nil { + return err + } + + return nil +} + +func (m *NodePool) validateSize(formats strfmt.Registry) error { + + if err := validate.Required("size", "body", int64(m.Size)); err != nil { + return err + } + + if err := validate.MinimumInt("size", "body", int64(m.Size), 0, false); err != nil { + return err + } + + if err := validate.MaximumInt("size", "body", int64(m.Size), 127, false); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *NodePool) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *NodePool) UnmarshalBinary(b []byte) error { + var res NodePool + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/api/models/node_pool_config.go b/pkg/api/models/node_pool_config.go new file mode 100644 index 00000000000..d54e1d46586 --- /dev/null +++ b/pkg/api/models/node_pool_config.go @@ -0,0 +1,57 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// NodePoolConfig node pool config +// swagger:model NodePoolConfig + +type NodePoolConfig struct { + + // repair + Repair bool `json:"repair,omitempty"` + + // upgrade + Upgrade bool `json:"upgrade,omitempty"` +} + +/* polymorph NodePoolConfig repair false */ + +/* polymorph NodePoolConfig upgrade false */ + +// Validate validates this node pool config +func (m *NodePoolConfig) Validate(formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// MarshalBinary interface implementation +func (m *NodePoolConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *NodePoolConfig) UnmarshalBinary(b []byte) error { + var res NodePoolConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/api/models/node_pool_info.go b/pkg/api/models/node_pool_info.go new file mode 100644 index 00000000000..96624af9349 --- /dev/null +++ b/pkg/api/models/node_pool_info.go @@ -0,0 +1,72 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// NodePoolInfo node pool info +// swagger:model NodePoolInfo + +type NodePoolInfo struct { + + // healthy + Healthy int64 `json:"healthy,omitempty"` + + // name + Name string `json:"name,omitempty"` + + // running + Running int64 `json:"running,omitempty"` + + // schedulable + Schedulable int64 `json:"schedulable,omitempty"` + + // size + Size int64 `json:"size,omitempty"` +} + +/* polymorph NodePoolInfo healthy false */ + +/* polymorph NodePoolInfo name false */ + +/* polymorph NodePoolInfo running false */ + +/* polymorph NodePoolInfo schedulable false */ + +/* polymorph NodePoolInfo size false */ + +// Validate validates this node pool info +func (m *NodePoolInfo) Validate(formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// MarshalBinary interface implementation +func (m *NodePoolInfo) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *NodePoolInfo) UnmarshalBinary(b []byte) error { + var res NodePoolInfo + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/api/models/openstack_spec.go b/pkg/api/models/openstack_spec.go new file mode 100644 index 00000000000..d4aabcde05f --- /dev/null +++ b/pkg/api/models/openstack_spec.go @@ -0,0 +1,67 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// OpenstackSpec openstack spec +// swagger:model OpenstackSpec + +type OpenstackSpec struct { + + // l b subnet ID + LBSubnetID string `json:"lbSubnetID,omitempty"` + + // network ID + NetworkID string `json:"networkID,omitempty"` + + // project ID + ProjectID string `json:"projectID,omitempty"` + + // router ID + RouterID string `json:"routerID,omitempty"` +} + +/* polymorph OpenstackSpec LBSubnetID false */ + +/* polymorph OpenstackSpec networkID false */ + +/* polymorph OpenstackSpec projectID false */ + +/* polymorph OpenstackSpec routerID false */ + +// Validate validates this openstack spec +func (m *OpenstackSpec) Validate(formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// MarshalBinary interface implementation +func (m *OpenstackSpec) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *OpenstackSpec) UnmarshalBinary(b []byte) error { + var res OpenstackSpec + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/api/rest/operations/create_cluster_parameters.go b/pkg/api/rest/operations/create_cluster_parameters.go index 066ab19d877..664bedccb76 100644 --- a/pkg/api/rest/operations/create_cluster_parameters.go +++ b/pkg/api/rest/operations/create_cluster_parameters.go @@ -36,7 +36,7 @@ type CreateClusterParams struct { Required: true In: body */ - Body *models.Cluster + Body *models.Kluster } // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface @@ -47,7 +47,7 @@ func (o *CreateClusterParams) BindRequest(r *http.Request, route *middleware.Mat if runtime.HasBody(r) { defer r.Body.Close() - var body models.Cluster + var body models.Kluster if err := route.Consumer.Consume(r.Body, &body); err != nil { if err == io.EOF { res = append(res, errors.Required("body", "body")) diff --git a/pkg/api/rest/operations/create_cluster_responses.go b/pkg/api/rest/operations/create_cluster_responses.go index 14318494425..f159cf194e7 100644 --- a/pkg/api/rest/operations/create_cluster_responses.go +++ b/pkg/api/rest/operations/create_cluster_responses.go @@ -25,7 +25,7 @@ type CreateClusterCreated struct { /* In: Body */ - Payload *models.Cluster `json:"body,omitempty"` + Payload *models.Kluster `json:"body,omitempty"` } // NewCreateClusterCreated creates CreateClusterCreated with default headers values @@ -34,13 +34,13 @@ func NewCreateClusterCreated() *CreateClusterCreated { } // WithPayload adds the payload to the create cluster created response -func (o *CreateClusterCreated) WithPayload(payload *models.Cluster) *CreateClusterCreated { +func (o *CreateClusterCreated) WithPayload(payload *models.Kluster) *CreateClusterCreated { o.Payload = payload return o } // SetPayload sets the payload to the create cluster created response -func (o *CreateClusterCreated) SetPayload(payload *models.Cluster) { +func (o *CreateClusterCreated) SetPayload(payload *models.Kluster) { o.Payload = payload } diff --git a/pkg/api/rest/operations/get_cluster_info_responses.go b/pkg/api/rest/operations/get_cluster_info_responses.go index ce6eb9e4cd3..bf3398491b6 100644 --- a/pkg/api/rest/operations/get_cluster_info_responses.go +++ b/pkg/api/rest/operations/get_cluster_info_responses.go @@ -25,7 +25,7 @@ type GetClusterInfoOK struct { /* In: Body */ - Payload *models.ClusterInfo `json:"body,omitempty"` + Payload *models.KlusterInfo `json:"body,omitempty"` } // NewGetClusterInfoOK creates GetClusterInfoOK with default headers values @@ -34,13 +34,13 @@ func NewGetClusterInfoOK() *GetClusterInfoOK { } // WithPayload adds the payload to the get cluster info o k response -func (o *GetClusterInfoOK) WithPayload(payload *models.ClusterInfo) *GetClusterInfoOK { +func (o *GetClusterInfoOK) WithPayload(payload *models.KlusterInfo) *GetClusterInfoOK { o.Payload = payload return o } // SetPayload sets the payload to the get cluster info o k response -func (o *GetClusterInfoOK) SetPayload(payload *models.ClusterInfo) { +func (o *GetClusterInfoOK) SetPayload(payload *models.KlusterInfo) { o.Payload = payload } diff --git a/pkg/api/rest/operations/list_clusters_responses.go b/pkg/api/rest/operations/list_clusters_responses.go index 413e65c6bf6..ed1fb51622f 100644 --- a/pkg/api/rest/operations/list_clusters_responses.go +++ b/pkg/api/rest/operations/list_clusters_responses.go @@ -25,7 +25,7 @@ type ListClustersOK struct { /* In: Body */ - Payload []*models.Cluster `json:"body,omitempty"` + Payload []*models.Kluster `json:"body,omitempty"` } // NewListClustersOK creates ListClustersOK with default headers values @@ -34,13 +34,13 @@ func NewListClustersOK() *ListClustersOK { } // WithPayload adds the payload to the list clusters o k response -func (o *ListClustersOK) WithPayload(payload []*models.Cluster) *ListClustersOK { +func (o *ListClustersOK) WithPayload(payload []*models.Kluster) *ListClustersOK { o.Payload = payload return o } // SetPayload sets the payload to the list clusters o k response -func (o *ListClustersOK) SetPayload(payload []*models.Cluster) { +func (o *ListClustersOK) SetPayload(payload []*models.Kluster) { o.Payload = payload } @@ -50,7 +50,7 @@ func (o *ListClustersOK) WriteResponse(rw http.ResponseWriter, producer runtime. rw.WriteHeader(200) payload := o.Payload if payload == nil { - payload = make([]*models.Cluster, 0, 50) + payload = make([]*models.Kluster, 0, 50) } if err := producer.Produce(rw, payload); err != nil { diff --git a/pkg/api/rest/operations/show_cluster_responses.go b/pkg/api/rest/operations/show_cluster_responses.go index 3ab7f13a9e4..2cad951c0a4 100644 --- a/pkg/api/rest/operations/show_cluster_responses.go +++ b/pkg/api/rest/operations/show_cluster_responses.go @@ -25,7 +25,7 @@ type ShowClusterOK struct { /* In: Body */ - Payload *models.Cluster `json:"body,omitempty"` + Payload *models.Kluster `json:"body,omitempty"` } // NewShowClusterOK creates ShowClusterOK with default headers values @@ -34,13 +34,13 @@ func NewShowClusterOK() *ShowClusterOK { } // WithPayload adds the payload to the show cluster o k response -func (o *ShowClusterOK) WithPayload(payload *models.Cluster) *ShowClusterOK { +func (o *ShowClusterOK) WithPayload(payload *models.Kluster) *ShowClusterOK { o.Payload = payload return o } // SetPayload sets the payload to the show cluster o k response -func (o *ShowClusterOK) SetPayload(payload *models.Cluster) { +func (o *ShowClusterOK) SetPayload(payload *models.Kluster) { o.Payload = payload } diff --git a/pkg/api/rest/operations/update_cluster_parameters.go b/pkg/api/rest/operations/update_cluster_parameters.go index 1d262145787..7c2d5123137 100644 --- a/pkg/api/rest/operations/update_cluster_parameters.go +++ b/pkg/api/rest/operations/update_cluster_parameters.go @@ -38,7 +38,7 @@ type UpdateClusterParams struct { Required: true In: body */ - Body *models.Cluster + Body *models.Kluster /* Required: true Unique: true @@ -55,7 +55,7 @@ func (o *UpdateClusterParams) BindRequest(r *http.Request, route *middleware.Mat if runtime.HasBody(r) { defer r.Body.Close() - var body models.Cluster + var body models.Kluster if err := route.Consumer.Consume(r.Body, &body); err != nil { if err == io.EOF { res = append(res, errors.Required("body", "body")) diff --git a/pkg/api/rest/operations/update_cluster_responses.go b/pkg/api/rest/operations/update_cluster_responses.go index 75ffe860396..bfe1f8d8947 100644 --- a/pkg/api/rest/operations/update_cluster_responses.go +++ b/pkg/api/rest/operations/update_cluster_responses.go @@ -25,7 +25,7 @@ type UpdateClusterOK struct { /* In: Body */ - Payload *models.Cluster `json:"body,omitempty"` + Payload *models.Kluster `json:"body,omitempty"` } // NewUpdateClusterOK creates UpdateClusterOK with default headers values @@ -34,13 +34,13 @@ func NewUpdateClusterOK() *UpdateClusterOK { } // WithPayload adds the payload to the update cluster o k response -func (o *UpdateClusterOK) WithPayload(payload *models.Cluster) *UpdateClusterOK { +func (o *UpdateClusterOK) WithPayload(payload *models.Kluster) *UpdateClusterOK { o.Payload = payload return o } // SetPayload sets the payload to the update cluster o k response -func (o *UpdateClusterOK) SetPayload(payload *models.Cluster) { +func (o *UpdateClusterOK) SetPayload(payload *models.Kluster) { o.Payload = payload } diff --git a/pkg/api/spec/document.go b/pkg/api/spec/document.go new file mode 100644 index 00000000000..bcd8bc7a5b8 --- /dev/null +++ b/pkg/api/spec/document.go @@ -0,0 +1,62 @@ +package spec + +import ( + "fmt" + + "github.com/go-openapi/loads" +) + +var doc *loads.Document = nil + +//Spec returns the analyzed swagger document +func Spec() (*loads.Document, error) { + var err error + if doc == nil { + if doc, err = loads.Analyzed(SwaggerJSON, ""); err != nil { + doc = nil + return nil, err + } + } + return doc, nil +} + +func MustDefaultString(definition, property string) string { + d, err := DefaultString(definition, property) + if err != nil { + panic(err) + } + return d +} + +func DefaultString(definition, property string) (string, error) { + defaultVal, err := lookupDefault(definition, property) + if err != nil { + return "", err + } + defaultString, ok := defaultVal.(string) + if !ok { + return "", fmt.Errorf("default value is not of type string") + } + return defaultString, nil +} + +func lookupDefault(definition, property string) (interface{}, error) { + document, err := Spec() + if err != nil { + return "", err + } + + def, ok := document.Spec().Definitions[definition] + if !ok { + return nil, fmt.Errorf("definition %s not found", definition) + } + prop, ok := def.Properties[property] + if !ok { + return nil, fmt.Errorf("property %s not found in definition %s", property, definition) + } + fmt.Printf("prop = %#v\n", prop) + if prop.Default == nil { + return nil, fmt.Errorf("No default found for property %s", property) + } + return prop.Default, nil +} diff --git a/pkg/api/spec/document_test.go b/pkg/api/spec/document_test.go new file mode 100644 index 00000000000..92af3bab4a6 --- /dev/null +++ b/pkg/api/spec/document_test.go @@ -0,0 +1,13 @@ +package spec + +import "testing" + +func TestDefaulString(t *testing.T) { + value, err := DefaultString("KlusterSpec", "serviceCIDR") + if err != nil { + t.Fatal("returned an error ", err) + } + if value == "" { + t.Fatal("did not return a non-empty value") + } +} diff --git a/pkg/api/rest/embedded_spec.go b/pkg/api/spec/embedded_spec.go similarity index 64% rename from pkg/api/rest/embedded_spec.go rename to pkg/api/spec/embedded_spec.go index 58c130462c1..b8c0cb7776c 100644 --- a/pkg/api/rest/embedded_spec.go +++ b/pkg/api/spec/embedded_spec.go @@ -1,6 +1,6 @@ // Code generated by go-swagger; DO NOT EDIT. -package rest +package spec // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command @@ -55,7 +55,7 @@ func init() { "schema": { "type": "array", "items": { - "$ref": "#/definitions/Cluster" + "$ref": "#/definitions/Kluster" } } }, @@ -78,7 +78,7 @@ func init() { "in": "body", "required": true, "schema": { - "$ref": "#/definitions/Cluster" + "$ref": "#/definitions/Kluster" } } ], @@ -86,7 +86,7 @@ func init() { "201": { "description": "OK", "schema": { - "$ref": "#/definitions/Cluster" + "$ref": "#/definitions/Kluster" } }, "default": { @@ -108,7 +108,7 @@ func init() { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/Cluster" + "$ref": "#/definitions/Kluster" } }, "default": { @@ -130,7 +130,7 @@ func init() { "in": "body", "required": true, "schema": { - "$ref": "#/definitions/Cluster" + "$ref": "#/definitions/Kluster" } } ], @@ -138,7 +138,7 @@ func init() { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/Cluster" + "$ref": "#/definitions/Kluster" } }, "default": { @@ -220,7 +220,7 @@ func init() { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/ClusterInfo" + "$ref": "#/definitions/KlusterInfo" } }, "default": { @@ -268,7 +268,22 @@ func init() { } } }, - "Cluster": { + "Credentials": { + "type": "object", + "properties": { + "kubeconfig": { + "type": "string" + } + } + }, + "Info": { + "properties": { + "version": { + "type": "string" + } + } + }, + "Kluster": { "type": "object", "required": [ "name" @@ -277,105 +292,18 @@ func init() { "name": { "description": "name of the cluster", "type": "string", - "pattern": "^[a-z]([-a-z0-9]*[a-z0-9])?$" + "pattern": "^[a-z]([-a-z0-9]*[a-z0-9])?$", + "x-nullable": false }, "spec": { - "type": "object", - "properties": { - "clusterCIDR": { - "description": "CIDR Range for Pods in the cluster. Can not be updated.", - "type": "string", - "default": "198.19.0.0/16", - "pattern": "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/([0-9]|[1-2][0-9]|3[0-2]))$", - "x-nullable": false - }, - "nodePools": { - "type": "array", - "items": { - "type": "object", - "required": [ - "name", - "size", - "flavor" - ], - "properties": { - "flavor": { - "type": "string" - }, - "image": { - "type": "string" - }, - "name": { - "type": "string", - "pattern": "^[a-z]([a-z0-9]*)?$" - }, - "size": { - "type": "integer", - "maximum": 127, - "minimum": 0 - } - } - } - }, - "serviceCIDR": { - "description": "CIDR Range for Services in the cluster. Can not be updated.", - "type": "string", - "default": "198.18.128.0/17", - "pattern": "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/([0-9]|[1-2][0-9]|3[0-2]))$", - "x-nullable": false - } - }, - "x-nullable": false + "$ref": "#/definitions/KlusterSpec" }, "status": { - "type": "object", - "properties": { - "kluster": { - "properties": { - "message": { - "type": "string" - }, - "state": { - "description": "status of the cluster", - "type": "string" - } - } - }, - "nodePools": { - "type": "array", - "items": { - "required": [ - "name", - "size", - "running", - "healthy", - "schedulable" - ], - "properties": { - "healthy": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "running": { - "type": "integer" - }, - "schedulable": { - "type": "integer" - }, - "size": { - "type": "integer" - } - } - } - } - }, - "readOnly": true + "$ref": "#/definitions/KlusterStatus" } } }, - "ClusterInfo": { + "KlusterInfo": { "properties": { "binaries": { "type": "array", @@ -393,13 +321,17 @@ func init() { "platform": { "type": "string" } - } + }, + "x-go-name": "Link", + "x-nullable": false } }, "name": { "type": "string" } - } + }, + "x-go-name": "Binaries", + "x-nullable": false } }, "setupCommand": { @@ -407,20 +339,177 @@ func init() { } } }, - "Credentials": { + "KlusterSpec": { "type": "object", "properties": { - "kubeconfig": { + "advertiseAddress": { + "type": "string", + "default": "1.1.1.1", + "x-nullable": false + }, + "clusterCIDR": { + "description": "CIDR Range for Pods in the cluster. Can not be updated.", + "type": "string", + "default": "198.19.0.0/16", + "pattern": "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/([0-9]|[1-2][0-9]|3[0-2]))$", + "x-nullable": false + }, + "clusterDNS": { + "type": "string" + }, + "clusterDNSDomain": { + "type": "string" + }, + "domain": { + "type": "string" + }, + "name": { + "type": "string", + "readOnly": true + }, + "nodePools": { + "type": "array", + "items": { + "$ref": "#/definitions/NodePool" + }, + "x-omitempty": true + }, + "openstack": { + "$ref": "#/definitions/OpenstackSpec" + }, + "serviceCIDR": { + "description": "CIDR Range for Services in the cluster. Can not be updated.", + "type": "string", + "default": "198.18.128.0/17", + "pattern": "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/([0-9]|[1-2][0-9]|3[0-2]))$", + "x-nullable": false + }, + "version": { "type": "string" } - } + }, + "x-nullable": false }, - "Info": { + "KlusterState": { + "type": "string", + "enum": [ + "Pending", + "Creating", + "Ready", + "Terminating", + "Error" + ] + }, + "KlusterStatus": { + "type": "object", "properties": { - "version": { + "apiserver": { + "type": "string" + }, + "message": { + "type": "string" + }, + "nodePools": { + "type": "array", + "items": { + "$ref": "#/definitions/NodePoolInfo" + } + }, + "state": { + "$ref": "#/definitions/KlusterState" + }, + "wormhole": { "type": "string" } - } + }, + "x-nullable": false, + "readOnly": true + }, + "NodePool": { + "type": "object", + "required": [ + "name", + "size", + "flavor" + ], + "properties": { + "config": { + "$ref": "#/definitions/NodePoolConfig" + }, + "flavor": { + "type": "string", + "x-nullable": false + }, + "image": { + "type": "string", + "default": "coreos-stable-amd64", + "x-nullable": false + }, + "name": { + "type": "string", + "pattern": "^[a-z]([a-z0-9]*)?$", + "x-nullable": false + }, + "size": { + "type": "integer", + "maximum": 127, + "minimum": 0, + "x-nullable": false + } + }, + "x-nullable": false + }, + "NodePoolConfig": { + "type": "object", + "properties": { + "repair": { + "type": "boolean" + }, + "upgrade": { + "type": "boolean" + } + }, + "x-nullable": false + }, + "NodePoolInfo": { + "type": "object", + "properties": { + "healthy": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "running": { + "type": "integer" + }, + "schedulable": { + "type": "integer" + }, + "size": { + "type": "integer" + } + }, + "x-nullable": false + }, + "OpenstackSpec": { + "type": "object", + "properties": { + "lbSubnetID": { + "type": "string", + "x-go-name": "LBSubnetID" + }, + "networkID": { + "type": "string" + }, + "projectID": { + "type": "string" + }, + "routerID": { + "type": "string" + } + }, + "x-nullable": false }, "Principal": { "type": "object", @@ -455,7 +544,7 @@ func init() { } }, "error": { - "description": "the error model is a model for all the error responses coming from Kubernikus \n", + "description": "the error model is a model for all the error responses coming from Kubernikus\n", "type": "object", "required": [ "message", diff --git a/pkg/apis/kubernikus/factory.go b/pkg/apis/kubernikus/factory.go index 0118c7e6319..023bd125637 100644 --- a/pkg/apis/kubernikus/factory.go +++ b/pkg/apis/kubernikus/factory.go @@ -4,21 +4,23 @@ import ( "fmt" "net" + "github.com/sapcc/kubernikus/pkg/api/models" + "github.com/sapcc/kubernikus/pkg/api/spec" "github.com/sapcc/kubernikus/pkg/apis/kubernikus/v1" "github.com/sapcc/kubernikus/pkg/controller/ground/bootstrap/dns" "github.com/sapcc/kubernikus/pkg/util/ip" "github.com/sapcc/kubernikus/pkg/version" ) -const ( +var ( //Keep this in sync with the default in swagger.yaml - DEFAULT_CLUSTER_CIDR = "198.19.0.0/16" - DEFAULT_SERVICE_CIDR = "198.18.128.0/17" - DEFAULT_ADVERTISE_ADDRESS = "1.1.1.1" + DEFAULT_CLUSTER_CIDR = spec.MustDefaultString("KlusterSpec", "clusterCIDR") + DEFAULT_SERVICE_CIDR = spec.MustDefaultString("KlusterSpec", "serviceCIDR") + DEFAULT_ADVERTISE_ADDRESS = spec.MustDefaultString("KlusterSpec", "advertiseAddress") ) type KlusterFactory interface { - KlusterFor(v1.KlusterSpec) (*v1.Kluster, error) + KlusterFor(models.KlusterSpec) (*v1.Kluster, error) } type klusterFactory struct { @@ -28,18 +30,16 @@ func NewKlusterFactory() KlusterFactory { return &klusterFactory{} } -func (klusterFactory) KlusterFor(spec v1.KlusterSpec) (*v1.Kluster, error) { +func (klusterFactory) KlusterFor(spec models.KlusterSpec) (*v1.Kluster, error) { if spec.Name == "" { return nil, fmt.Errorf("unabled to create cluster. missing name") } k := &v1.Kluster{ Spec: spec, - Status: v1.KlusterStatus{ - Kluster: v1.KlusterInfo{ - State: v1.KlusterPending, - }, - NodePools: []v1.NodePoolInfo{}, + Status: models.KlusterStatus{ + State: models.KlusterStatePending, + NodePools: []models.NodePoolInfo{}, }, } @@ -80,7 +80,7 @@ func (klusterFactory) KlusterFor(spec v1.KlusterSpec) (*v1.Kluster, error) { } for _, nodePool := range k.Spec.NodePools { - k.Status.NodePools = append(k.Status.NodePools, v1.NodePoolInfo{ + k.Status.NodePools = append(k.Status.NodePools, models.NodePoolInfo{ Name: nodePool.Name, Size: nodePool.Size, Running: 0, diff --git a/pkg/apis/kubernikus/v1/kluster.go b/pkg/apis/kubernikus/v1/kluster.go index 2914922645a..14b63c46a80 100644 --- a/pkg/apis/kubernikus/v1/kluster.go +++ b/pkg/apis/kubernikus/v1/kluster.go @@ -3,81 +3,19 @@ package v1 import ( "net" + "github.com/sapcc/kubernikus/pkg/api/models" "github.com/sapcc/kubernikus/pkg/util/ip" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -type NodePoolConfig struct { - Upgrade bool `json:"upgrade"` - Repair bool `json:"repair"` -} - -type NodePool struct { - Name string `json:"name"` - Size int `json:"size"` - Flavor string `json:"flavor"` - Image string `json:"image"` - Config NodePoolConfig `json:"config"` -} - -type OpenstackSpec struct { - ProjectID string `json:"projectID"` - RouterID string `json:"routerID"` - NetworkID string `json:"networkID"` - LBSubnetID string `json:"lbSubnetID"` -} - -type KlusterSpec struct { - Name string `json:"name"` - Domain string `json:"domain"` - ClusterCIDR string `json:"clusterCIDR"` - ClusterDNS string `json:"clusterDNS"` - ClusterDNSDomain string `json:"clusterDNSDomain"` - ServiceCIDR string `json:"serviceCIDR"` - AdvertiseAddress string `json:"advertiseAddress"` - Version string `json:"version"` - NodePools []NodePool `json:"nodePools,omitempty"` - Openstack OpenstackSpec `json:"openstack,omitempty"` -} -type KlusterState string - -const ( - KlusterPending KlusterState = "Pending" - KlusterCreating KlusterState = "Creating" - KlusterReady KlusterState = "Ready" - KlusterTerminating KlusterState = "Terminating" - KlusterTerminated KlusterState = "Terminated" - KlusterError KlusterState = "Error" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -type KlusterStatus struct { - Kluster KlusterInfo `json:"kluster"` - Apiserver string `json:"apiserver"` - Wormhole string `json:"wormhole"` - NodePools []NodePoolInfo `json:"nodePools,omitempty"` -} - -type KlusterInfo struct { - State KlusterState `json:"state,omitempty"` - Message string `json:"message,omitempty"` -} - -type NodePoolInfo struct { - Name string `json:"name"` - Size int `json:size` - Running int `json:running` - Healthy int `json:healthy` - Schedulable int `json:schedulable` -} - // +genclient type Kluster struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata"` - Spec KlusterSpec `json:"spec"` - Status KlusterStatus `json:"status,omitempty"` + Spec models.KlusterSpec `json:"spec"` + Status models.KlusterStatus `json:"status,omitempty"` } type KlusterList struct { @@ -86,11 +24,6 @@ type KlusterList struct { Items []Kluster `json:"items"` } -func (spec KlusterSpec) Validate() error { - //Add some validation - return nil -} - func (spec Kluster) Account() string { return spec.ObjectMeta.Labels["account"] } diff --git a/pkg/client/openstack/client.go b/pkg/client/openstack/client.go index a79b5a2cb68..2647f13ba3d 100644 --- a/pkg/client/openstack/client.go +++ b/pkg/client/openstack/client.go @@ -24,6 +24,7 @@ import ( "k8s.io/client-go/pkg/api/v1" "k8s.io/client-go/tools/cache" + "github.com/sapcc/kubernikus/pkg/api/models" kubernikus_v1 "github.com/sapcc/kubernikus/pkg/apis/kubernikus/v1" "github.com/sapcc/kubernikus/pkg/client/openstack/domains" "github.com/sapcc/kubernikus/pkg/client/openstack/roles" @@ -49,9 +50,9 @@ type client struct { } type Client interface { - CreateNode(*kubernikus_v1.Kluster, *kubernikus_v1.NodePool, []byte) (string, error) + CreateNode(*kubernikus_v1.Kluster, *models.NodePool, []byte) (string, error) DeleteNode(*kubernikus_v1.Kluster, string) error - GetNodes(*kubernikus_v1.Kluster, *kubernikus_v1.NodePool) ([]Node, error) + GetNodes(*kubernikus_v1.Kluster, *models.NodePool) ([]Node, error) GetProject(id string) (*Project, error) GetRegion() (string, error) @@ -534,7 +535,7 @@ func getRouterNetworks(client *gophercloud.ServiceClient, routerID string) ([]st return networks, err } -func (c *client) GetNodes(kluster *kubernikus_v1.Kluster, pool *kubernikus_v1.NodePool) ([]Node, error) { +func (c *client) GetNodes(kluster *kubernikus_v1.Kluster, pool *models.NodePool) ([]Node, error) { pool_id := pool.Name provider, err := c.klusterClientFor(kluster) @@ -564,7 +565,7 @@ func (c *client) GetNodes(kluster *kubernikus_v1.Kluster, pool *kubernikus_v1.No return nodes, nil } -func (c *client) CreateNode(kluster *kubernikus_v1.Kluster, pool *kubernikus_v1.NodePool, userData []byte) (string, error) { +func (c *client) CreateNode(kluster *kubernikus_v1.Kluster, pool *models.NodePool, userData []byte) (string, error) { provider, err := c.klusterClientFor(kluster) if err != nil { return "", err diff --git a/pkg/cmd/kubernikus/certificates/files.go b/pkg/cmd/kubernikus/certificates/files.go index 24dd16a458a..eac0d4cb9a1 100644 --- a/pkg/cmd/kubernikus/certificates/files.go +++ b/pkg/cmd/kubernikus/certificates/files.go @@ -3,8 +3,8 @@ package certificates import ( "errors" + "github.com/sapcc/kubernikus/pkg/api/models" "github.com/sapcc/kubernikus/pkg/apis/kubernikus" - "github.com/sapcc/kubernikus/pkg/apis/kubernikus/v1" "github.com/sapcc/kubernikus/pkg/util" "github.com/sapcc/kubernikus/pkg/cmd" @@ -55,7 +55,7 @@ func (o *FilesOptions) Complete(args []string) error { } func (o *FilesOptions) Run(c *cobra.Command) error { - kluster, err := kubernikus.NewKlusterFactory().KlusterFor(v1.KlusterSpec{Name: o.Name}) + kluster, err := kubernikus.NewKlusterFactory().KlusterFor(models.KlusterSpec{Name: o.Name}) if err != nil { return err } diff --git a/pkg/cmd/kubernikus/certificates/plain.go b/pkg/cmd/kubernikus/certificates/plain.go index ff217a85886..b7367604a5e 100644 --- a/pkg/cmd/kubernikus/certificates/plain.go +++ b/pkg/cmd/kubernikus/certificates/plain.go @@ -3,8 +3,8 @@ package certificates import ( "errors" + "github.com/sapcc/kubernikus/pkg/api/models" "github.com/sapcc/kubernikus/pkg/apis/kubernikus" - "github.com/sapcc/kubernikus/pkg/apis/kubernikus/v1" "github.com/sapcc/kubernikus/pkg/util" "github.com/sapcc/kubernikus/pkg/cmd" @@ -49,7 +49,7 @@ func (o *PlainOptions) Complete(args []string) error { } func (o *PlainOptions) Run(c *cobra.Command) error { - kluster, err := kubernikus.NewKlusterFactory().KlusterFor(v1.KlusterSpec{Name: o.Name}) + kluster, err := kubernikus.NewKlusterFactory().KlusterFor(models.KlusterSpec{Name: o.Name}) if err != nil { return err } diff --git a/pkg/cmd/kubernikus/helm.go b/pkg/cmd/kubernikus/helm.go index 947d96638dc..6c792a2e089 100644 --- a/pkg/cmd/kubernikus/helm.go +++ b/pkg/cmd/kubernikus/helm.go @@ -6,8 +6,8 @@ import ( "os" "strings" + "github.com/sapcc/kubernikus/pkg/api/models" "github.com/sapcc/kubernikus/pkg/apis/kubernikus" - "github.com/sapcc/kubernikus/pkg/apis/kubernikus/v1" "github.com/sapcc/kubernikus/pkg/cmd" "github.com/sapcc/kubernikus/pkg/util" "github.com/sapcc/kubernikus/pkg/util/helm" @@ -97,9 +97,9 @@ func (o *HelmOptions) Complete(args []string) error { func (o *HelmOptions) Run(c *cobra.Command) error { nameA := strings.SplitN(o.Name, ".", 2) - kluster, err := kubernikus.NewKlusterFactory().KlusterFor(v1.KlusterSpec{ + kluster, err := kubernikus.NewKlusterFactory().KlusterFor(models.KlusterSpec{ Name: nameA[0], - Openstack: v1.OpenstackSpec{ + Openstack: models.OpenstackSpec{ ProjectID: o.ProjectID, }, }) diff --git a/pkg/cmd/kubernikusctl/auth/init.go b/pkg/cmd/kubernikusctl/auth/init.go index 8f0549ad332..dc8904e91e6 100644 --- a/pkg/cmd/kubernikusctl/auth/init.go +++ b/pkg/cmd/kubernikusctl/auth/init.go @@ -106,7 +106,7 @@ func (o *InitOptions) Run(c *cobra.Command) (err error) { if cluster, err := o.kubernikus.GetDefaultCluster(); err != nil { return errors.Wrapf(err, "You need to provide --name. Cluster Auto-Detection failed") } else { - o.name = *cluster.Name + o.name = cluster.Name glog.V(2).Infof("Detected cluster name: %v", o.name) } } diff --git a/pkg/cmd/kubernikusctl/common/kubernikus.go b/pkg/cmd/kubernikusctl/common/kubernikus.go index c42eeb2742e..d8f6ae9b7a3 100644 --- a/pkg/cmd/kubernikusctl/common/kubernikus.go +++ b/pkg/cmd/kubernikusctl/common/kubernikus.go @@ -56,7 +56,7 @@ func (k *KubernikusClient) GetCredentials(name string) (string, error) { return ok.Payload.Kubeconfig, nil } -func (k *KubernikusClient) CreateCluster(cluster *models.Cluster) error { +func (k *KubernikusClient) CreateCluster(cluster *models.Kluster) error { params := operations.NewCreateClusterParams().WithBody(cluster) _, err := k.client.Operations.CreateCluster(params, k.authFunc()) switch err.(type) { @@ -82,7 +82,7 @@ func (k *KubernikusClient) DeleteCluster(name string) error { return nil } -func (k *KubernikusClient) ShowCluster(name string) (*models.Cluster, error) { +func (k *KubernikusClient) ShowCluster(name string) (*models.Kluster, error) { params := operations.NewShowClusterParams() params.Name = name ok, err := k.client.Operations.ShowCluster(params, k.authFunc()) @@ -96,7 +96,7 @@ func (k *KubernikusClient) ShowCluster(name string) (*models.Cluster, error) { return ok.Payload, nil } -func (k *KubernikusClient) ListAllClusters() ([]*models.Cluster, error) { +func (k *KubernikusClient) ListAllClusters() ([]*models.Kluster, error) { ok, err := k.client.Operations.ListClusters(operations.NewListClustersParams(), k.authFunc()) switch err.(type) { case *operations.ListClustersDefault: @@ -114,7 +114,7 @@ func (k *KubernikusClient) ListAllClusters() ([]*models.Cluster, error) { return ok.Payload, nil } -func (k *KubernikusClient) ListNodePools(clusterName string) ([]*models.ClusterSpecNodePoolsItems0, error) { +func (k *KubernikusClient) ListNodePools(clusterName string) ([]models.NodePool, error) { ok, err := k.ShowCluster(clusterName) if err != nil { return nil, err @@ -122,20 +122,20 @@ func (k *KubernikusClient) ListNodePools(clusterName string) ([]*models.ClusterS return ok.Spec.NodePools, nil } -func (k *KubernikusClient) ShowNodePool(clusterName string, nodePoolName string) (*models.ClusterSpecNodePoolsItems0, error) { +func (k *KubernikusClient) ShowNodePool(clusterName string, nodePoolName string) (*models.NodePool, error) { ok, err := k.ShowCluster(clusterName) if err != nil { return nil, err } for _, nodePool := range ok.Spec.NodePools { - if *nodePool.Name == nodePoolName { - return nodePool, nil + if nodePool.Name == nodePoolName { + return &nodePool, nil } } return nil, nil } -func (k *KubernikusClient) GetDefaultCluster() (*models.Cluster, error) { +func (k *KubernikusClient) GetDefaultCluster() (*models.Kluster, error) { ok, err := k.client.Operations.ListClusters(operations.NewListClustersParams(), k.authFunc()) switch err.(type) { diff --git a/pkg/cmd/kubernikusctl/create/cluster.go b/pkg/cmd/kubernikusctl/create/cluster.go index 7c4a3a17053..d759181d9e0 100644 --- a/pkg/cmd/kubernikusctl/create/cluster.go +++ b/pkg/cmd/kubernikusctl/create/cluster.go @@ -48,11 +48,11 @@ func (o *CreateOptions) clusterRun(c *cobra.Command, args []string) { } } glog.V(2).Infof("Raw read: \n%v", string(raw)) - var cluster models.Cluster + var cluster models.Kluster cmd.CheckError(cluster.UnmarshalBinary(raw)) glog.V(2).Infof("cluster: %v", cluster) cmd.CheckError(o.Kubernikus.CreateCluster(&cluster)) - fmt.Printf("Cluster %v created.", *cluster.Name) + fmt.Printf("Cluster %v created.", cluster.Name) } func validateClusterCommandArgs(args []string) error { diff --git a/pkg/controller/ground.go b/pkg/controller/ground.go index c39a77b77f8..1a4bc8d681c 100644 --- a/pkg/controller/ground.go +++ b/pkg/controller/ground.go @@ -19,6 +19,7 @@ import ( "k8s.io/client-go/util/workqueue" "k8s.io/helm/pkg/helm" + "github.com/sapcc/kubernikus/pkg/api/models" "github.com/sapcc/kubernikus/pkg/apis/kubernikus/v1" "github.com/sapcc/kubernikus/pkg/client/kubernetes" "github.com/sapcc/kubernikus/pkg/controller/config" @@ -126,15 +127,15 @@ func (op *GroundControl) handler(key string) error { glog.Infof("kluster resource %s deleted", key) } else { kluster := obj.(*v1.Kluster) - glog.V(5).Infof("Handling kluster %v in state %q", kluster.Name, kluster.Status.Kluster.State) + glog.V(5).Infof("Handling kluster %v in state %q", kluster.Name, kluster.Status.State) - switch state := kluster.Status.Kluster.State; state { - case v1.KlusterPending: + switch state := kluster.Status.State; state { + case models.KlusterStatePending: { if op.requiresOpenstackInfo(kluster) { if err := op.discoverOpenstackInfo(kluster); err != nil { glog.Errorf("[%v] Discovery of openstack parameters failed: %s", kluster.GetName(), err) - if err := op.updateStatus(kluster, v1.KlusterError, err.Error()); err != nil { + if err := op.updateStatus(kluster, models.KlusterStateError, err.Error()); err != nil { glog.Errorf("Failed to update status of kluster %s:%s", kluster.GetName(), err) } return err @@ -145,7 +146,7 @@ func (op *GroundControl) handler(key string) error { if op.requiresKubernikusInfo(kluster) { if err := op.discoverKubernikusInfo(kluster); err != nil { glog.Errorf("[%v] Discovery of kubernikus parameters failed: %s", kluster.GetName(), err) - if err := op.updateStatus(kluster, v1.KlusterError, err.Error()); err != nil { + if err := op.updateStatus(kluster, models.KlusterStateError, err.Error()); err != nil { glog.Errorf("Failed to update status of kluster %s:%s", kluster.GetName(), err) } return err @@ -154,13 +155,13 @@ func (op *GroundControl) handler(key string) error { } glog.Infof("Creating Kluster %s", kluster.GetName()) - if err := op.updateStatus(kluster, v1.KlusterCreating, "Creating Cluster"); err != nil { + if err := op.updateStatus(kluster, models.KlusterStateCreating, "Creating Cluster"); err != nil { glog.Errorf("Failed to update status of kluster %s:%s", kluster.GetName(), err) } if err := op.createKluster(kluster); err != nil { glog.Errorf("Creating kluster %s failed: %s", kluster.GetName(), err) - if err := op.updateStatus(kluster, v1.KlusterError, err.Error()); err != nil { + if err := op.updateStatus(kluster, models.KlusterStateError, err.Error()); err != nil { glog.Errorf("Failed to update status of kluster %s:%s", kluster.GetName(), err) } //We are making this a permanent error for now to avoid stomping the parent kluster @@ -168,7 +169,7 @@ func (op *GroundControl) handler(key string) error { } glog.Infof("Kluster %s created", kluster.GetName()) } - case v1.KlusterCreating: + case models.KlusterStateCreating: pods, err := op.podInformer.GetIndexer().ByIndex("kluster", kluster.GetName()) if err != nil { return err @@ -188,12 +189,12 @@ func (op *GroundControl) handler(key string) error { if err := ground.SeedKluster(clientset, kluster); err != nil { return err } - if err := op.updateStatus(kluster, v1.KlusterReady, ""); err != nil { + if err := op.updateStatus(kluster, models.KlusterStateReady, ""); err != nil { glog.Errorf("Failed to update status of kluster %s:%s", kluster.GetName(), err) } glog.Infof("Kluster %s is ready!", kluster.GetName()) } - case v1.KlusterTerminating: + case models.KlusterStateTerminating: { glog.Infof("Terminating Kluster %s", kluster.GetName()) if err := op.terminateKluster(kluster); err != nil { @@ -241,15 +242,15 @@ func (op *GroundControl) klusterUpdate(cur, old interface{}) { } } -func (op *GroundControl) updateStatus(kluster *v1.Kluster, state v1.KlusterState, message string) error { +func (op *GroundControl) updateStatus(kluster *v1.Kluster, state models.KlusterState, message string) error { //Never modify the cache, at leasts thats what I've been told kluster, err := op.Clients.Kubernikus.Kubernikus().Klusters(kluster.Namespace).Get(kluster.Name, metav1.GetOptions{}) if err != nil { return err } - kluster.Status.Kluster.Message = message - kluster.Status.Kluster.State = state + kluster.Status.Message = message + kluster.Status.State = state _, err = op.Clients.Kubernikus.Kubernikus().Klusters(kluster.Namespace).Update(kluster) return err diff --git a/pkg/controller/launch.go b/pkg/controller/launch.go index 13a138cdec0..357b8f3873f 100644 --- a/pkg/controller/launch.go +++ b/pkg/controller/launch.go @@ -6,6 +6,7 @@ import ( "time" "github.com/golang/glog" + "github.com/sapcc/kubernikus/pkg/api/models" "github.com/sapcc/kubernikus/pkg/apis/kubernikus/v1" "github.com/sapcc/kubernikus/pkg/client/openstack" "github.com/sapcc/kubernikus/pkg/templates" @@ -129,7 +130,7 @@ func (launchctl *LaunchControl) reconcile(key string) error { kluster := obj.(*v1.Kluster) glog.V(5).Infof("[%v] Reconciling", kluster.Name) - if !(kluster.Status.Kluster.State == v1.KlusterReady || kluster.Status.Kluster.State == v1.KlusterTerminating) { + if !(kluster.Status.State == models.KlusterStateReady || kluster.Status.State == models.KlusterStateTerminating) { return fmt.Errorf("[%v] Kluster is not yet ready. Requeuing.", kluster.Name) } @@ -143,13 +144,13 @@ func (launchctl *LaunchControl) reconcile(key string) error { return nil } -func (launchctl *LaunchControl) syncPool(kluster *v1.Kluster, pool *v1.NodePool) error { +func (launchctl *LaunchControl) syncPool(kluster *v1.Kluster, pool *models.NodePool) error { nodes, err := launchctl.Clients.Openstack.GetNodes(kluster, pool) if err != nil { return fmt.Errorf("[%v] Couldn't list nodes for pool %v: %v", kluster.Name, pool.Name, err) } - if kluster.Status.Kluster.State == v1.KlusterTerminating { + if kluster.Status.State == models.KlusterStateTerminating { if toBeTerminated(nodes) > 0 { glog.V(3).Infof("[%v] Kluster is terminating. Terminating Nodes for Pool %v.", kluster.Name, pool.Name) for _, node := range nodes { @@ -185,7 +186,7 @@ func (launchctl *LaunchControl) syncPool(kluster *v1.Kluster, pool *v1.NodePool) return nil } -func (launchctl *LaunchControl) createNode(kluster *v1.Kluster, pool *v1.NodePool) error { +func (launchctl *LaunchControl) createNode(kluster *v1.Kluster, pool *models.NodePool) error { glog.V(2).Infof("[%v] Pool %v: Creating new node", kluster.Name, pool.Name) userdata, err := templates.Ignition.GenerateNode(kluster, launchctl.Clients.Kubernetes) @@ -207,7 +208,7 @@ func (launchctl *LaunchControl) createNode(kluster *v1.Kluster, pool *v1.NodePoo return nil } -func (launchctl *LaunchControl) terminateNode(kluster *v1.Kluster, pool *v1.NodePool, id string) error { +func (launchctl *LaunchControl) terminateNode(kluster *v1.Kluster, pool *models.NodePool, id string) error { err := launchctl.Clients.Openstack.DeleteNode(kluster, id) if err != nil { return err @@ -222,7 +223,7 @@ func (launchctl *LaunchControl) terminateNode(kluster *v1.Kluster, pool *v1.Node return nil } -func (launchctl *LaunchControl) updateNodePoolStatus(kluster *v1.Kluster, pool *v1.NodePool) error { +func (launchctl *LaunchControl) updateNodePoolStatus(kluster *v1.Kluster, pool *models.NodePool) error { nodes, err := launchctl.Clients.Openstack.GetNodes(kluster, pool) if err != nil { return fmt.Errorf("[%v] Couldn't list nodes for pool %v: %v", kluster.Name, pool.Name, err) @@ -231,7 +232,7 @@ func (launchctl *LaunchControl) updateNodePoolStatus(kluster *v1.Kluster, pool * running := running(nodes) starting := starting(nodes) - newInfo := v1.NodePoolInfo{ + newInfo := models.NodePoolInfo{ Name: pool.Name, Size: pool.Size, Running: running + starting, // Should be running only @@ -285,8 +286,8 @@ func (launchctl *LaunchControl) handleErr(err error, key interface{}) { glog.V(5).Infof("[%v] Dropping out of the queue. Too many retries...", key) } -func starting(nodes []openstack.Node) int { - count := 0 +func starting(nodes []openstack.Node) int64 { + var count int64 = 0 for _, n := range nodes { if n.Starting() { count = count + 1 @@ -296,8 +297,8 @@ func starting(nodes []openstack.Node) int { return count } -func running(nodes []openstack.Node) int { - count := 0 +func running(nodes []openstack.Node) int64 { + var count int64 = 0 for _, n := range nodes { if n.Running() { count = count + 1 @@ -307,8 +308,9 @@ func running(nodes []openstack.Node) int { return count } -func toBeTerminated(nodes []openstack.Node) int { - toBeTerminated := 0 +func toBeTerminated(nodes []openstack.Node) int64 { + var toBeTerminated int64 = 0 + for _, n := range nodes { if n.Stopping() { continue diff --git a/swagger.yml b/swagger.yml index a1e9a517411..b404cf3021e 100644 --- a/swagger.yml +++ b/swagger.yml @@ -47,7 +47,7 @@ paths: schema: type: array items: - $ref: '#/definitions/Cluster' + $ref: '#/definitions/Kluster' default: $ref: '#/responses/errorResponse' security: @@ -59,7 +59,7 @@ paths: '201': description: OK schema: - $ref: '#/definitions/Cluster' + $ref: '#/definitions/Kluster' default: $ref: '#/responses/errorResponse' parameters: @@ -67,7 +67,7 @@ paths: in: body required: true schema: - $ref: '#/definitions/Cluster' + $ref: '#/definitions/Kluster' security: - keystone: [] '/api/v1/clusters/{name}': @@ -84,7 +84,7 @@ paths: '200': description: OK schema: - $ref: '#/definitions/Cluster' + $ref: '#/definitions/Kluster' default: $ref: '#/responses/errorResponse' security: @@ -108,7 +108,7 @@ paths: '200': description: OK schema: - $ref: '#/definitions/Cluster' + $ref: '#/definitions/Kluster' default: $ref: '#/responses/errorResponse' security: @@ -118,7 +118,7 @@ paths: in: body required: true schema: - $ref: '#/definitions/Cluster' + $ref: '#/definitions/Kluster' '/api/v1/clusters/{name}/credentials': parameters: - uniqueItems: true @@ -152,17 +152,20 @@ paths: '200': description: OK schema: - $ref: '#/definitions/ClusterInfo' + $ref: '#/definitions/KlusterInfo' default: $ref: '#/responses/errorResponse' security: - keystone: [] definitions: + KlusterState: + type: string + enum: [Pending, Creating, Ready, Terminating, Error] Info: properties: version: type: string - ClusterInfo: + KlusterInfo: properties: setupCommand: type: string @@ -170,12 +173,16 @@ definitions: type: array items: type: object + x-go-name: Binaries + x-nullable: false properties: name: type: string links: type: array items: + x-go-name: Link + x-nullable: false type: object properties: platform: @@ -192,82 +199,139 @@ definitions: items: type: string - Cluster: + Kluster: type: object required: - name properties: name: + x-nullable: false description: name of the cluster type: string pattern: '^[a-z]([-a-z0-9]*[a-z0-9])?$' spec: - type: object - x-nullable: false - properties: - serviceCIDR: - x-nullable: false - description: CIDR Range for Services in the cluster. Can not be updated. - default: 198.18.128.0/17 - type: string - pattern: '^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$' - clusterCIDR: - x-nullable: false - description: CIDR Range for Pods in the cluster. Can not be updated. - default: 198.19.0.0/16 - type: string - pattern: '^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$' - nodePools: - type: array - items: - type: object - required: - - name - - size - - flavor - properties: - name: - type: string - pattern: '^[a-z]([a-z0-9]*)?$' - size: - type: integer - maximum: 127 - minimum: 0 - flavor: - type: string - image: - type: string + $ref: '#/definitions/KlusterSpec' + status: + $ref: '#/definitions/KlusterStatus' + KlusterSpec: + type: object + x-nullable: false + properties: + openstack: + $ref: '#/definitions/OpenstackSpec' + serviceCIDR: + description: CIDR Range for Services in the cluster. Can not be updated. + default: 198.18.128.0/17 + x-nullable: false + type: string + pattern: '^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$' + clusterCIDR: + description: CIDR Range for Pods in the cluster. Can not be updated. + default: 198.19.0.0/16 + type: string + x-nullable: false + pattern: '^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$' + nodePools: + type: array + x-omitempty: true #should work with go-swagger > 0.12.0 + items: + $ref: '#/definitions/NodePool' + version: + type: string + advertiseAddress: + x-nullable: false + default: 1.1.1.1 + type: string + clusterDNS: + type: string + clusterDNSDomain: + type: string + domain: + type: string + name: + type: string readOnly: true - type: object - properties: - kluster: - properties: - state: - description: status of the cluster - type: string - message: - type: string - nodePools: - type: array - items: - required: - - name - - size - - running - - healthy - - schedulable - properties: - name: - type: string - size: - type: integer - running: - type: integer - healthy: - type: integer - schedulable: - type: integer + OpenstackSpec: + type: object + x-nullable: false + properties: + projectID: + type: string + routerID: + type: string + networkID: + type: string + lbSubnetID: + x-go-name: LBSubnetID + type: string + + NodePool: + x-nullable: false + type: object + required: + - name + - size + - flavor + properties: + name: + x-nullable: false + type: string + pattern: '^[a-z]([a-z0-9]*)?$' + size: + x-nullable: false + type: integer + maximum: 127 + minimum: 0 + flavor: + type: string + x-nullable: false + image: + x-nullable: false + type: string + default: coreos-stable-amd64 + config: + $ref: '#/definitions/NodePoolConfig' + NodePoolConfig: + type: object + x-nullable: false + properties: + upgrade: + type: boolean + repair: + type: boolean + + KlusterStatus: + readOnly: true + x-nullable: false + type: object + properties: + state: + $ref: '#/definitions/KlusterState' + message: + type: string + nodePools: + type: array + items: + $ref: '#/definitions/NodePoolInfo' + apiserver: + type: string + wormhole: + type: string + NodePoolInfo: + x-nullable: false + type: object + properties: + name: + type: string + size: + type: integer + running: + type: integer + healthy: + type: integer + schedulable: + type: integer Credentials: type: object properties: