From 5dbb48c5374514806de8a694af0ee0693965bb4f Mon Sep 17 00:00:00 2001 From: Jan Broer Date: Mon, 4 Apr 2016 16:57:39 +0200 Subject: [PATCH] Upgrade go-rancher lib, retry API connection on startup --- Dockerfile | 2 +- Godeps/Godeps.json | 4 +- .../go-rancher/client/generated_account.go | 2 + .../go-rancher/client/generated_client.go | 18 +- .../client/generated_compose_project.go | 246 ++++++++++++++++ .../client/generated_compose_service.go | 267 ++++++++++++++++++ .../go-rancher/client/generated_container.go | 24 ++ .../client/generated_container_proxy.go | 69 +++++ .../client/generated_dns_service.go | 8 +- .../client/generated_environment.go | 4 + .../client/generated_external_service.go | 6 +- .../go-rancher/client/generated_instance.go | 13 + .../client/generated_instance_stop.go | 2 - .../client/generated_kubernetes_service.go | 257 +++++++++++++++++ .../client/generated_launch_config.go | 26 ++ .../client/generated_load_balancer_service.go | 8 +- .../client/generated_local_auth_config.go | 2 +- .../client/generated_machine_driver.go | 36 +-- .../go-rancher/client/generated_port.go | 2 + .../client/generated_process_execution.go | 2 + .../go-rancher/client/generated_project.go | 2 + .../generated_secondary_launch_config.go | 26 ++ .../go-rancher/client/generated_service.go | 8 +- .../client/generated_service_proxy.go | 75 +++++ .../client/generated_virtual_machine.go | 24 ++ Makefile | 4 +- VERSION | 2 +- circle.yml | 2 +- context.go | 2 +- rancher/client.go | 23 +- 30 files changed, 1109 insertions(+), 57 deletions(-) create mode 100644 Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_compose_project.go create mode 100644 Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_compose_service.go create mode 100644 Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_container_proxy.go create mode 100644 Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_kubernetes_service.go create mode 100644 Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_service_proxy.go diff --git a/Dockerfile b/Dockerfile index 6d0e652..7f2ef5a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ MAINTAINER Jan Broer RUN apk add --no-cache ca-certificates -ENV LETSENCRYPT_RELEASE v0.2.6 +ENV LETSENCRYPT_RELEASE v0.2.7 ADD https://github.com/janeczku/rancher-letsencrypt/releases/download/${LETSENCRYPT_RELEASE}/rancher-letsencrypt-linux-amd64.tar.gz /tmp/rancher-letsencrypt.tar.gz diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 434e784..1a8589b 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -137,8 +137,8 @@ }, { "ImportPath": "github.com/rancher/go-rancher/client", - "Comment": "v0.1.0-143-g77690e2", - "Rev": "77690e2bf83b2c6227dbab555941894f2f76137a" + "Comment": "v0.1.0-151-gc21ad77", + "Rev": "c21ad7797bc727e5fe65ae85d1be714845ce415c" }, { "ImportPath": "github.com/weppos/dnsimple-go/dnsimple", diff --git a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_account.go b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_account.go index 4436dae..3e95989 100644 --- a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_account.go +++ b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_account.go @@ -17,6 +17,8 @@ type Account struct { ExternalIdType string `json:"externalIdType,omitempty" yaml:"external_id_type,omitempty"` + Identity string `json:"identity,omitempty" yaml:"identity,omitempty"` + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` diff --git a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_client.go b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_client.go index 0c9cc1c..7dcc162 100644 --- a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_client.go +++ b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_client.go @@ -25,12 +25,10 @@ type RancherClient struct { ServicesPortRange ServicesPortRangeOperations RecreateOnQuorumStrategyConfig RecreateOnQuorumStrategyConfigOperations AddOutputsInput AddOutputsInputOperations - AddRemoveClusterHostInput AddRemoveClusterHostInputOperations AddRemoveServiceLinkInput AddRemoveServiceLinkInputOperations ChangeSecretInput ChangeSecretInputOperations SetLabelsInput SetLabelsInputOperations ApiKey ApiKeyOperations - Cluster ClusterOperations ComposeConfigInput ComposeConfigInputOperations Container ContainerOperations InstanceConsole InstanceConsoleOperations @@ -47,6 +45,7 @@ type RancherClient struct { LoadBalancerService LoadBalancerServiceOperations ExternalService ExternalServiceOperations DnsService DnsServiceOperations + KubernetesService KubernetesServiceOperations LaunchConfig LaunchConfigOperations SecondaryLaunchConfig SecondaryLaunchConfigOperations AddRemoveLoadBalancerServiceLinkInput AddRemoveLoadBalancerServiceLinkInputOperations @@ -60,7 +59,8 @@ type RancherClient struct { ExternalDnsEvent ExternalDnsEventOperations ExternalHostEvent ExternalHostEventOperations LoadBalancerConfig LoadBalancerConfigOperations - MachineDriverUpdateInput MachineDriverUpdateInputOperations + ComposeService ComposeServiceOperations + ComposeProject ComposeProjectOperations MachineDriverErrorInput MachineDriverErrorInputOperations Account AccountOperations Agent AgentOperations @@ -107,6 +107,8 @@ type RancherClient struct { FieldDocumentation FieldDocumentationOperations ContainerExec ContainerExecOperations ContainerLogs ContainerLogsOperations + ContainerProxy ContainerProxyOperations + ServiceProxy ServiceProxyOperations HostAccess HostAccessOperations DockerBuild DockerBuildOperations ActiveSetting ActiveSettingOperations @@ -125,7 +127,6 @@ type RancherClient struct { HostApiProxyToken HostApiProxyTokenOperations Register RegisterOperations RegistrationToken RegistrationTokenOperations - Machine MachineOperations } func constructClient() *RancherClient { @@ -157,12 +158,10 @@ func constructClient() *RancherClient { client.ServicesPortRange = newServicesPortRangeClient(client) client.RecreateOnQuorumStrategyConfig = newRecreateOnQuorumStrategyConfigClient(client) client.AddOutputsInput = newAddOutputsInputClient(client) - client.AddRemoveClusterHostInput = newAddRemoveClusterHostInputClient(client) client.AddRemoveServiceLinkInput = newAddRemoveServiceLinkInputClient(client) client.ChangeSecretInput = newChangeSecretInputClient(client) client.SetLabelsInput = newSetLabelsInputClient(client) client.ApiKey = newApiKeyClient(client) - client.Cluster = newClusterClient(client) client.ComposeConfigInput = newComposeConfigInputClient(client) client.Container = newContainerClient(client) client.InstanceConsole = newInstanceConsoleClient(client) @@ -179,6 +178,7 @@ func constructClient() *RancherClient { client.LoadBalancerService = newLoadBalancerServiceClient(client) client.ExternalService = newExternalServiceClient(client) client.DnsService = newDnsServiceClient(client) + client.KubernetesService = newKubernetesServiceClient(client) client.LaunchConfig = newLaunchConfigClient(client) client.SecondaryLaunchConfig = newSecondaryLaunchConfigClient(client) client.AddRemoveLoadBalancerServiceLinkInput = newAddRemoveLoadBalancerServiceLinkInputClient(client) @@ -192,7 +192,8 @@ func constructClient() *RancherClient { client.ExternalDnsEvent = newExternalDnsEventClient(client) client.ExternalHostEvent = newExternalHostEventClient(client) client.LoadBalancerConfig = newLoadBalancerConfigClient(client) - client.MachineDriverUpdateInput = newMachineDriverUpdateInputClient(client) + client.ComposeService = newComposeServiceClient(client) + client.ComposeProject = newComposeProjectClient(client) client.MachineDriverErrorInput = newMachineDriverErrorInputClient(client) client.Account = newAccountClient(client) client.Agent = newAgentClient(client) @@ -239,6 +240,8 @@ func constructClient() *RancherClient { client.FieldDocumentation = newFieldDocumentationClient(client) client.ContainerExec = newContainerExecClient(client) client.ContainerLogs = newContainerLogsClient(client) + client.ContainerProxy = newContainerProxyClient(client) + client.ServiceProxy = newServiceProxyClient(client) client.HostAccess = newHostAccessClient(client) client.DockerBuild = newDockerBuildClient(client) client.ActiveSetting = newActiveSettingClient(client) @@ -257,7 +260,6 @@ func constructClient() *RancherClient { client.HostApiProxyToken = newHostApiProxyTokenClient(client) client.Register = newRegisterClient(client) client.RegistrationToken = newRegistrationTokenClient(client) - client.Machine = newMachineClient(client) return client } diff --git a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_compose_project.go b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_compose_project.go new file mode 100644 index 0000000..89445d1 --- /dev/null +++ b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_compose_project.go @@ -0,0 +1,246 @@ +package client + +const ( + COMPOSE_PROJECT_TYPE = "composeProject" +) + +type ComposeProject struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + Environment map[string]interface{} `json:"environment,omitempty" yaml:"environment,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + PreviousEnvironment map[string]interface{} `json:"previousEnvironment,omitempty" yaml:"previous_environment,omitempty"` + + PreviousExternalId string `json:"previousExternalId,omitempty" yaml:"previous_external_id,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Templates map[string]interface{} `json:"templates,omitempty" yaml:"templates,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` +} + +type ComposeProjectCollection struct { + Collection + Data []ComposeProject `json:"data,omitempty"` +} + +type ComposeProjectClient struct { + rancherClient *RancherClient +} + +type ComposeProjectOperations interface { + List(opts *ListOpts) (*ComposeProjectCollection, error) + Create(opts *ComposeProject) (*ComposeProject, error) + Update(existing *ComposeProject, updates interface{}) (*ComposeProject, error) + ById(id string) (*ComposeProject, error) + Delete(container *ComposeProject) error + + ActionActivateservices(*ComposeProject) (*Environment, error) + + ActionAddoutputs(*ComposeProject, *AddOutputsInput) (*Environment, error) + + ActionCancelrollback(*ComposeProject) (*Environment, error) + + ActionCancelupgrade(*ComposeProject) (*Environment, error) + + ActionCreate(*ComposeProject) (*Environment, error) + + ActionDeactivateservices(*ComposeProject) (*Environment, error) + + ActionError(*ComposeProject) (*Environment, error) + + ActionExportconfig(*ComposeProject, *ComposeConfigInput) (*ComposeConfig, error) + + ActionFinishupgrade(*ComposeProject) (*Environment, error) + + ActionRemove(*ComposeProject) (*Environment, error) + + ActionRollback(*ComposeProject) (*Environment, error) + + ActionUpdate(*ComposeProject) (*Environment, error) + + ActionUpgrade(*ComposeProject, *EnvironmentUpgrade) (*Environment, error) +} + +func newComposeProjectClient(rancherClient *RancherClient) *ComposeProjectClient { + return &ComposeProjectClient{ + rancherClient: rancherClient, + } +} + +func (c *ComposeProjectClient) Create(container *ComposeProject) (*ComposeProject, error) { + resp := &ComposeProject{} + err := c.rancherClient.doCreate(COMPOSE_PROJECT_TYPE, container, resp) + return resp, err +} + +func (c *ComposeProjectClient) Update(existing *ComposeProject, updates interface{}) (*ComposeProject, error) { + resp := &ComposeProject{} + err := c.rancherClient.doUpdate(COMPOSE_PROJECT_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ComposeProjectClient) List(opts *ListOpts) (*ComposeProjectCollection, error) { + resp := &ComposeProjectCollection{} + err := c.rancherClient.doList(COMPOSE_PROJECT_TYPE, opts, resp) + return resp, err +} + +func (c *ComposeProjectClient) ById(id string) (*ComposeProject, error) { + resp := &ComposeProject{} + err := c.rancherClient.doById(COMPOSE_PROJECT_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ComposeProjectClient) Delete(container *ComposeProject) error { + return c.rancherClient.doResourceDelete(COMPOSE_PROJECT_TYPE, &container.Resource) +} + +func (c *ComposeProjectClient) ActionActivateservices(resource *ComposeProject) (*Environment, error) { + + resp := &Environment{} + + err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "activateservices", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ComposeProjectClient) ActionAddoutputs(resource *ComposeProject, input *AddOutputsInput) (*Environment, error) { + + resp := &Environment{} + + err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "addoutputs", &resource.Resource, input, resp) + + return resp, err +} + +func (c *ComposeProjectClient) ActionCancelrollback(resource *ComposeProject) (*Environment, error) { + + resp := &Environment{} + + err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "cancelrollback", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ComposeProjectClient) ActionCancelupgrade(resource *ComposeProject) (*Environment, error) { + + resp := &Environment{} + + err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "cancelupgrade", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ComposeProjectClient) ActionCreate(resource *ComposeProject) (*Environment, error) { + + resp := &Environment{} + + err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ComposeProjectClient) ActionDeactivateservices(resource *ComposeProject) (*Environment, error) { + + resp := &Environment{} + + err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "deactivateservices", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ComposeProjectClient) ActionError(resource *ComposeProject) (*Environment, error) { + + resp := &Environment{} + + err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "error", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ComposeProjectClient) ActionExportconfig(resource *ComposeProject, input *ComposeConfigInput) (*ComposeConfig, error) { + + resp := &ComposeConfig{} + + err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "exportconfig", &resource.Resource, input, resp) + + return resp, err +} + +func (c *ComposeProjectClient) ActionFinishupgrade(resource *ComposeProject) (*Environment, error) { + + resp := &Environment{} + + err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "finishupgrade", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ComposeProjectClient) ActionRemove(resource *ComposeProject) (*Environment, error) { + + resp := &Environment{} + + err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ComposeProjectClient) ActionRollback(resource *ComposeProject) (*Environment, error) { + + resp := &Environment{} + + err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "rollback", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ComposeProjectClient) ActionUpdate(resource *ComposeProject) (*Environment, error) { + + resp := &Environment{} + + err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ComposeProjectClient) ActionUpgrade(resource *ComposeProject, input *EnvironmentUpgrade) (*Environment, error) { + + resp := &Environment{} + + err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "upgrade", &resource.Resource, input, resp) + + return resp, err +} diff --git a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_compose_service.go b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_compose_service.go new file mode 100644 index 0000000..22f401e --- /dev/null +++ b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_compose_service.go @@ -0,0 +1,267 @@ +package client + +const ( + COMPOSE_SERVICE_TYPE = "composeService" +) + +type ComposeService struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + EnvironmentId string `json:"environmentId,omitempty" yaml:"environment_id,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + Fqdn string `json:"fqdn,omitempty" yaml:"fqdn,omitempty"` + + HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + LaunchConfig *LaunchConfig `json:"launchConfig,omitempty" yaml:"launch_config,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + PublicEndpoints []interface{} `json:"publicEndpoints,omitempty" yaml:"public_endpoints,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + Scale int64 `json:"scale,omitempty" yaml:"scale,omitempty"` + + SelectorContainer string `json:"selectorContainer,omitempty" yaml:"selector_container,omitempty"` + + SelectorLink string `json:"selectorLink,omitempty" yaml:"selector_link,omitempty"` + + StartOnCreate bool `json:"startOnCreate,omitempty" yaml:"start_on_create,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` + + Vip string `json:"vip,omitempty" yaml:"vip,omitempty"` +} + +type ComposeServiceCollection struct { + Collection + Data []ComposeService `json:"data,omitempty"` +} + +type ComposeServiceClient struct { + rancherClient *RancherClient +} + +type ComposeServiceOperations interface { + List(opts *ListOpts) (*ComposeServiceCollection, error) + Create(opts *ComposeService) (*ComposeService, error) + Update(existing *ComposeService, updates interface{}) (*ComposeService, error) + ById(id string) (*ComposeService, error) + Delete(container *ComposeService) error + + ActionActivate(*ComposeService) (*Service, error) + + ActionAddservicelink(*ComposeService, *AddRemoveServiceLinkInput) (*Service, error) + + ActionCancelrollback(*ComposeService) (*Service, error) + + ActionCancelupgrade(*ComposeService) (*Service, error) + + ActionCreate(*ComposeService) (*Service, error) + + ActionDeactivate(*ComposeService) (*Service, error) + + ActionFinishupgrade(*ComposeService) (*Service, error) + + ActionRemove(*ComposeService) (*Service, error) + + ActionRemoveservicelink(*ComposeService, *AddRemoveServiceLinkInput) (*Service, error) + + ActionRestart(*ComposeService, *ServiceRestart) (*Service, error) + + ActionRollback(*ComposeService) (*Service, error) + + ActionSetservicelinks(*ComposeService, *SetServiceLinksInput) (*Service, error) + + ActionUpdate(*ComposeService) (*Service, error) + + ActionUpgrade(*ComposeService, *ServiceUpgrade) (*Service, error) +} + +func newComposeServiceClient(rancherClient *RancherClient) *ComposeServiceClient { + return &ComposeServiceClient{ + rancherClient: rancherClient, + } +} + +func (c *ComposeServiceClient) Create(container *ComposeService) (*ComposeService, error) { + resp := &ComposeService{} + err := c.rancherClient.doCreate(COMPOSE_SERVICE_TYPE, container, resp) + return resp, err +} + +func (c *ComposeServiceClient) Update(existing *ComposeService, updates interface{}) (*ComposeService, error) { + resp := &ComposeService{} + err := c.rancherClient.doUpdate(COMPOSE_SERVICE_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ComposeServiceClient) List(opts *ListOpts) (*ComposeServiceCollection, error) { + resp := &ComposeServiceCollection{} + err := c.rancherClient.doList(COMPOSE_SERVICE_TYPE, opts, resp) + return resp, err +} + +func (c *ComposeServiceClient) ById(id string) (*ComposeService, error) { + resp := &ComposeService{} + err := c.rancherClient.doById(COMPOSE_SERVICE_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ComposeServiceClient) Delete(container *ComposeService) error { + return c.rancherClient.doResourceDelete(COMPOSE_SERVICE_TYPE, &container.Resource) +} + +func (c *ComposeServiceClient) ActionActivate(resource *ComposeService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ComposeServiceClient) ActionAddservicelink(resource *ComposeService, input *AddRemoveServiceLinkInput) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "addservicelink", &resource.Resource, input, resp) + + return resp, err +} + +func (c *ComposeServiceClient) ActionCancelrollback(resource *ComposeService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "cancelrollback", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ComposeServiceClient) ActionCancelupgrade(resource *ComposeService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "cancelupgrade", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ComposeServiceClient) ActionCreate(resource *ComposeService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ComposeServiceClient) ActionDeactivate(resource *ComposeService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ComposeServiceClient) ActionFinishupgrade(resource *ComposeService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "finishupgrade", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ComposeServiceClient) ActionRemove(resource *ComposeService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ComposeServiceClient) ActionRemoveservicelink(resource *ComposeService, input *AddRemoveServiceLinkInput) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "removeservicelink", &resource.Resource, input, resp) + + return resp, err +} + +func (c *ComposeServiceClient) ActionRestart(resource *ComposeService, input *ServiceRestart) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "restart", &resource.Resource, input, resp) + + return resp, err +} + +func (c *ComposeServiceClient) ActionRollback(resource *ComposeService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "rollback", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ComposeServiceClient) ActionSetservicelinks(resource *ComposeService, input *SetServiceLinksInput) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "setservicelinks", &resource.Resource, input, resp) + + return resp, err +} + +func (c *ComposeServiceClient) ActionUpdate(resource *ComposeService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *ComposeServiceClient) ActionUpgrade(resource *ComposeService, input *ServiceUpgrade) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "upgrade", &resource.Resource, input, resp) + + return resp, err +} diff --git a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_container.go b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_container.go index bc75af6..f6fb03e 100644 --- a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_container.go +++ b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_container.go @@ -67,6 +67,8 @@ type Container struct { HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"` + HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"` + Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"` ImageUuid string `json:"imageUuid,omitempty" yaml:"image_uuid,omitempty"` @@ -174,12 +176,16 @@ type ContainerOperations interface { ActionDeallocate(*Container) (*Instance, error) + ActionError(*Container) (*Instance, error) + ActionExecute(*Container, *ContainerExec) (*HostAccess, error) ActionLogs(*Container, *ContainerLogs) (*HostAccess, error) ActionMigrate(*Container) (*Instance, error) + ActionProxy(*Container, *ContainerProxy) (*HostAccess, error) + ActionPurge(*Container) (*Instance, error) ActionRemove(*Container) (*Instance, error) @@ -278,6 +284,15 @@ func (c *ContainerClient) ActionDeallocate(resource *Container) (*Instance, erro return resp, err } +func (c *ContainerClient) ActionError(resource *Container) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(CONTAINER_TYPE, "error", &resource.Resource, nil, resp) + + return resp, err +} + func (c *ContainerClient) ActionExecute(resource *Container, input *ContainerExec) (*HostAccess, error) { resp := &HostAccess{} @@ -305,6 +320,15 @@ func (c *ContainerClient) ActionMigrate(resource *Container) (*Instance, error) return resp, err } +func (c *ContainerClient) ActionProxy(resource *Container, input *ContainerProxy) (*HostAccess, error) { + + resp := &HostAccess{} + + err := c.rancherClient.doAction(CONTAINER_TYPE, "proxy", &resource.Resource, input, resp) + + return resp, err +} + func (c *ContainerClient) ActionPurge(resource *Container) (*Instance, error) { resp := &Instance{} diff --git a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_container_proxy.go b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_container_proxy.go new file mode 100644 index 0000000..19bcfd5 --- /dev/null +++ b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_container_proxy.go @@ -0,0 +1,69 @@ +package client + +const ( + CONTAINER_PROXY_TYPE = "containerProxy" +) + +type ContainerProxy struct { + Resource + + Port int64 `json:"port,omitempty" yaml:"port,omitempty"` + + Scheme string `json:"scheme,omitempty" yaml:"scheme,omitempty"` +} + +type ContainerProxyCollection struct { + Collection + Data []ContainerProxy `json:"data,omitempty"` +} + +type ContainerProxyClient struct { + rancherClient *RancherClient +} + +type ContainerProxyOperations interface { + List(opts *ListOpts) (*ContainerProxyCollection, error) + Create(opts *ContainerProxy) (*ContainerProxy, error) + Update(existing *ContainerProxy, updates interface{}) (*ContainerProxy, error) + ById(id string) (*ContainerProxy, error) + Delete(container *ContainerProxy) error +} + +func newContainerProxyClient(rancherClient *RancherClient) *ContainerProxyClient { + return &ContainerProxyClient{ + rancherClient: rancherClient, + } +} + +func (c *ContainerProxyClient) Create(container *ContainerProxy) (*ContainerProxy, error) { + resp := &ContainerProxy{} + err := c.rancherClient.doCreate(CONTAINER_PROXY_TYPE, container, resp) + return resp, err +} + +func (c *ContainerProxyClient) Update(existing *ContainerProxy, updates interface{}) (*ContainerProxy, error) { + resp := &ContainerProxy{} + err := c.rancherClient.doUpdate(CONTAINER_PROXY_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ContainerProxyClient) List(opts *ListOpts) (*ContainerProxyCollection, error) { + resp := &ContainerProxyCollection{} + err := c.rancherClient.doList(CONTAINER_PROXY_TYPE, opts, resp) + return resp, err +} + +func (c *ContainerProxyClient) ById(id string) (*ContainerProxy, error) { + resp := &ContainerProxy{} + err := c.rancherClient.doById(CONTAINER_PROXY_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ContainerProxyClient) Delete(container *ContainerProxy) error { + return c.rancherClient.doResourceDelete(CONTAINER_PROXY_TYPE, &container.Resource) +} diff --git a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_dns_service.go b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_dns_service.go index ee04396..4ebfbc2 100644 --- a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_dns_service.go +++ b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_dns_service.go @@ -9,6 +9,8 @@ type DnsService struct { AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + AssignServiceIpAddress bool `json:"assignServiceIpAddress,omitempty" yaml:"assign_service_ip_address,omitempty"` + Created string `json:"created,omitempty" yaml:"created,omitempty"` Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` @@ -21,6 +23,8 @@ type DnsService struct { Fqdn string `json:"fqdn,omitempty" yaml:"fqdn,omitempty"` + HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"` + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` LaunchConfig *LaunchConfig `json:"launchConfig,omitempty" yaml:"launch_config,omitempty"` @@ -37,6 +41,8 @@ type DnsService struct { SelectorLink string `json:"selectorLink,omitempty" yaml:"selector_link,omitempty"` + StartOnCreate bool `json:"startOnCreate,omitempty" yaml:"start_on_create,omitempty"` + State string `json:"state,omitempty" yaml:"state,omitempty"` Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` @@ -45,7 +51,7 @@ type DnsService struct { TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` - Upgrade ServiceUpgrade `json:"upgrade,omitempty" yaml:"upgrade,omitempty"` + Upgrade *ServiceUpgrade `json:"upgrade,omitempty" yaml:"upgrade,omitempty"` Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` } diff --git a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_environment.go b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_environment.go index fd837bf..3439fb2 100644 --- a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_environment.go +++ b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_environment.go @@ -21,12 +21,16 @@ type Environment struct { ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"` + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` Outputs map[string]interface{} `json:"outputs,omitempty" yaml:"outputs,omitempty"` + PreviousEnvironment map[string]interface{} `json:"previousEnvironment,omitempty" yaml:"previous_environment,omitempty"` + PreviousExternalId string `json:"previousExternalId,omitempty" yaml:"previous_external_id,omitempty"` RancherCompose string `json:"rancherCompose,omitempty" yaml:"rancher_compose,omitempty"` diff --git a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_external_service.go b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_external_service.go index 411bde8..c683339 100644 --- a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_external_service.go +++ b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_external_service.go @@ -25,6 +25,8 @@ type ExternalService struct { HealthCheck *InstanceHealthCheck `json:"healthCheck,omitempty" yaml:"health_check,omitempty"` + HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"` + Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"` Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` @@ -39,6 +41,8 @@ type ExternalService struct { Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + StartOnCreate bool `json:"startOnCreate,omitempty" yaml:"start_on_create,omitempty"` + State string `json:"state,omitempty" yaml:"state,omitempty"` Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` @@ -47,7 +51,7 @@ type ExternalService struct { TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` - Upgrade ServiceUpgrade `json:"upgrade,omitempty" yaml:"upgrade,omitempty"` + Upgrade *ServiceUpgrade `json:"upgrade,omitempty" yaml:"upgrade,omitempty"` Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` } diff --git a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_instance.go b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_instance.go index 6487935..f43f6bd 100644 --- a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_instance.go +++ b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_instance.go @@ -17,6 +17,8 @@ type Instance struct { ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"` + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` @@ -60,6 +62,8 @@ type InstanceOperations interface { ActionDeallocate(*Instance) (*Instance, error) + ActionError(*Instance) (*Instance, error) + ActionMigrate(*Instance) (*Instance, error) ActionPurge(*Instance) (*Instance, error) @@ -158,6 +162,15 @@ func (c *InstanceClient) ActionDeallocate(resource *Instance) (*Instance, error) return resp, err } +func (c *InstanceClient) ActionError(resource *Instance) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(INSTANCE_TYPE, "error", &resource.Resource, nil, resp) + + return resp, err +} + func (c *InstanceClient) ActionMigrate(resource *Instance) (*Instance, error) { resp := &Instance{} diff --git a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_instance_stop.go b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_instance_stop.go index 9d5564f..d034bd6 100644 --- a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_instance_stop.go +++ b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_instance_stop.go @@ -7,8 +7,6 @@ const ( type InstanceStop struct { Resource - DeallocateFromHost bool `json:"deallocateFromHost,omitempty" yaml:"deallocate_from_host,omitempty"` - Remove bool `json:"remove,omitempty" yaml:"remove,omitempty"` Timeout int64 `json:"timeout,omitempty" yaml:"timeout,omitempty"` diff --git a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_kubernetes_service.go b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_kubernetes_service.go new file mode 100644 index 0000000..a7e6f2a --- /dev/null +++ b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_kubernetes_service.go @@ -0,0 +1,257 @@ +package client + +const ( + KUBERNETES_SERVICE_TYPE = "kubernetesService" +) + +type KubernetesService struct { + Resource + + AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + + Created string `json:"created,omitempty" yaml:"created,omitempty"` + + Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` + + Description string `json:"description,omitempty" yaml:"description,omitempty"` + + EnvironmentId string `json:"environmentId,omitempty" yaml:"environment_id,omitempty"` + + ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"` + + HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"` + + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` + + Name string `json:"name,omitempty" yaml:"name,omitempty"` + + RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"` + + Removed string `json:"removed,omitempty" yaml:"removed,omitempty"` + + SelectorContainer string `json:"selectorContainer,omitempty" yaml:"selector_container,omitempty"` + + State string `json:"state,omitempty" yaml:"state,omitempty"` + + Template interface{} `json:"template,omitempty" yaml:"template,omitempty"` + + Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` + + TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"` + + TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` + + Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` + + Vip string `json:"vip,omitempty" yaml:"vip,omitempty"` +} + +type KubernetesServiceCollection struct { + Collection + Data []KubernetesService `json:"data,omitempty"` +} + +type KubernetesServiceClient struct { + rancherClient *RancherClient +} + +type KubernetesServiceOperations interface { + List(opts *ListOpts) (*KubernetesServiceCollection, error) + Create(opts *KubernetesService) (*KubernetesService, error) + Update(existing *KubernetesService, updates interface{}) (*KubernetesService, error) + ById(id string) (*KubernetesService, error) + Delete(container *KubernetesService) error + + ActionActivate(*KubernetesService) (*Service, error) + + ActionAddservicelink(*KubernetesService, *AddRemoveServiceLinkInput) (*Service, error) + + ActionCancelrollback(*KubernetesService) (*Service, error) + + ActionCancelupgrade(*KubernetesService) (*Service, error) + + ActionCreate(*KubernetesService) (*Service, error) + + ActionDeactivate(*KubernetesService) (*Service, error) + + ActionFinishupgrade(*KubernetesService) (*Service, error) + + ActionRemove(*KubernetesService) (*Service, error) + + ActionRemoveservicelink(*KubernetesService, *AddRemoveServiceLinkInput) (*Service, error) + + ActionRestart(*KubernetesService, *ServiceRestart) (*Service, error) + + ActionRollback(*KubernetesService) (*Service, error) + + ActionSetservicelinks(*KubernetesService, *SetServiceLinksInput) (*Service, error) + + ActionUpdate(*KubernetesService) (*Service, error) + + ActionUpgrade(*KubernetesService, *ServiceUpgrade) (*Service, error) +} + +func newKubernetesServiceClient(rancherClient *RancherClient) *KubernetesServiceClient { + return &KubernetesServiceClient{ + rancherClient: rancherClient, + } +} + +func (c *KubernetesServiceClient) Create(container *KubernetesService) (*KubernetesService, error) { + resp := &KubernetesService{} + err := c.rancherClient.doCreate(KUBERNETES_SERVICE_TYPE, container, resp) + return resp, err +} + +func (c *KubernetesServiceClient) Update(existing *KubernetesService, updates interface{}) (*KubernetesService, error) { + resp := &KubernetesService{} + err := c.rancherClient.doUpdate(KUBERNETES_SERVICE_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *KubernetesServiceClient) List(opts *ListOpts) (*KubernetesServiceCollection, error) { + resp := &KubernetesServiceCollection{} + err := c.rancherClient.doList(KUBERNETES_SERVICE_TYPE, opts, resp) + return resp, err +} + +func (c *KubernetesServiceClient) ById(id string) (*KubernetesService, error) { + resp := &KubernetesService{} + err := c.rancherClient.doById(KUBERNETES_SERVICE_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *KubernetesServiceClient) Delete(container *KubernetesService) error { + return c.rancherClient.doResourceDelete(KUBERNETES_SERVICE_TYPE, &container.Resource) +} + +func (c *KubernetesServiceClient) ActionActivate(resource *KubernetesService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(KUBERNETES_SERVICE_TYPE, "activate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *KubernetesServiceClient) ActionAddservicelink(resource *KubernetesService, input *AddRemoveServiceLinkInput) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(KUBERNETES_SERVICE_TYPE, "addservicelink", &resource.Resource, input, resp) + + return resp, err +} + +func (c *KubernetesServiceClient) ActionCancelrollback(resource *KubernetesService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(KUBERNETES_SERVICE_TYPE, "cancelrollback", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *KubernetesServiceClient) ActionCancelupgrade(resource *KubernetesService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(KUBERNETES_SERVICE_TYPE, "cancelupgrade", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *KubernetesServiceClient) ActionCreate(resource *KubernetesService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(KUBERNETES_SERVICE_TYPE, "create", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *KubernetesServiceClient) ActionDeactivate(resource *KubernetesService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(KUBERNETES_SERVICE_TYPE, "deactivate", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *KubernetesServiceClient) ActionFinishupgrade(resource *KubernetesService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(KUBERNETES_SERVICE_TYPE, "finishupgrade", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *KubernetesServiceClient) ActionRemove(resource *KubernetesService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(KUBERNETES_SERVICE_TYPE, "remove", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *KubernetesServiceClient) ActionRemoveservicelink(resource *KubernetesService, input *AddRemoveServiceLinkInput) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(KUBERNETES_SERVICE_TYPE, "removeservicelink", &resource.Resource, input, resp) + + return resp, err +} + +func (c *KubernetesServiceClient) ActionRestart(resource *KubernetesService, input *ServiceRestart) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(KUBERNETES_SERVICE_TYPE, "restart", &resource.Resource, input, resp) + + return resp, err +} + +func (c *KubernetesServiceClient) ActionRollback(resource *KubernetesService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(KUBERNETES_SERVICE_TYPE, "rollback", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *KubernetesServiceClient) ActionSetservicelinks(resource *KubernetesService, input *SetServiceLinksInput) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(KUBERNETES_SERVICE_TYPE, "setservicelinks", &resource.Resource, input, resp) + + return resp, err +} + +func (c *KubernetesServiceClient) ActionUpdate(resource *KubernetesService) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(KUBERNETES_SERVICE_TYPE, "update", &resource.Resource, nil, resp) + + return resp, err +} + +func (c *KubernetesServiceClient) ActionUpgrade(resource *KubernetesService, input *ServiceUpgrade) (*Service, error) { + + resp := &Service{} + + err := c.rancherClient.doAction(KUBERNETES_SERVICE_TYPE, "upgrade", &resource.Resource, input, resp) + + return resp, err +} diff --git a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_launch_config.go b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_launch_config.go index a779196..29055a0 100644 --- a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_launch_config.go +++ b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_launch_config.go @@ -71,6 +71,8 @@ type LaunchConfig struct { HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"` + HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"` + Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"` ImageUuid string `json:"imageUuid,omitempty" yaml:"image_uuid,omitempty"` @@ -121,6 +123,8 @@ type LaunchConfig struct { RequestedHostId string `json:"requestedHostId,omitempty" yaml:"requested_host_id,omitempty"` + RequestedIpAddress string `json:"requestedIpAddress,omitempty" yaml:"requested_ip_address,omitempty"` + SecurityOpt []string `json:"securityOpt,omitempty" yaml:"security_opt,omitempty"` StartCount int64 `json:"startCount,omitempty" yaml:"start_count,omitempty"` @@ -182,12 +186,16 @@ type LaunchConfigOperations interface { ActionDeallocate(*LaunchConfig) (*Instance, error) + ActionError(*LaunchConfig) (*Instance, error) + ActionExecute(*LaunchConfig, *ContainerExec) (*HostAccess, error) ActionLogs(*LaunchConfig, *ContainerLogs) (*HostAccess, error) ActionMigrate(*LaunchConfig) (*Instance, error) + ActionProxy(*LaunchConfig, *ContainerProxy) (*HostAccess, error) + ActionPurge(*LaunchConfig) (*Instance, error) ActionRemove(*LaunchConfig) (*Instance, error) @@ -286,6 +294,15 @@ func (c *LaunchConfigClient) ActionDeallocate(resource *LaunchConfig) (*Instance return resp, err } +func (c *LaunchConfigClient) ActionError(resource *LaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(LAUNCH_CONFIG_TYPE, "error", &resource.Resource, nil, resp) + + return resp, err +} + func (c *LaunchConfigClient) ActionExecute(resource *LaunchConfig, input *ContainerExec) (*HostAccess, error) { resp := &HostAccess{} @@ -313,6 +330,15 @@ func (c *LaunchConfigClient) ActionMigrate(resource *LaunchConfig) (*Instance, e return resp, err } +func (c *LaunchConfigClient) ActionProxy(resource *LaunchConfig, input *ContainerProxy) (*HostAccess, error) { + + resp := &HostAccess{} + + err := c.rancherClient.doAction(LAUNCH_CONFIG_TYPE, "proxy", &resource.Resource, input, resp) + + return resp, err +} + func (c *LaunchConfigClient) ActionPurge(resource *LaunchConfig) (*Instance, error) { resp := &Instance{} diff --git a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_load_balancer_service.go b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_load_balancer_service.go index 118fcca..564da6f 100644 --- a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_load_balancer_service.go +++ b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_load_balancer_service.go @@ -9,6 +9,8 @@ type LoadBalancerService struct { AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + AssignServiceIpAddress bool `json:"assignServiceIpAddress,omitempty" yaml:"assign_service_ip_address,omitempty"` + CertificateIds []string `json:"certificateIds,omitempty" yaml:"certificate_ids,omitempty"` Created string `json:"created,omitempty" yaml:"created,omitempty"` @@ -25,6 +27,8 @@ type LoadBalancerService struct { Fqdn string `json:"fqdn,omitempty" yaml:"fqdn,omitempty"` + HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"` + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` LaunchConfig *LaunchConfig `json:"launchConfig,omitempty" yaml:"launch_config,omitempty"` @@ -47,6 +51,8 @@ type LoadBalancerService struct { SelectorLink string `json:"selectorLink,omitempty" yaml:"selector_link,omitempty"` + StartOnCreate bool `json:"startOnCreate,omitempty" yaml:"start_on_create,omitempty"` + State string `json:"state,omitempty" yaml:"state,omitempty"` Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"` @@ -55,7 +61,7 @@ type LoadBalancerService struct { TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` - Upgrade ServiceUpgrade `json:"upgrade,omitempty" yaml:"upgrade,omitempty"` + Upgrade *ServiceUpgrade `json:"upgrade,omitempty" yaml:"upgrade,omitempty"` Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` diff --git a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_local_auth_config.go b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_local_auth_config.go index fe223ef..16d9855 100644 --- a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_local_auth_config.go +++ b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_local_auth_config.go @@ -13,7 +13,7 @@ type LocalAuthConfig struct { Name string `json:"name,omitempty" yaml:"name,omitempty"` - Password Password `json:"password,omitempty" yaml:"password,omitempty"` + Password string `json:"password,omitempty" yaml:"password,omitempty"` Username string `json:"username,omitempty" yaml:"username,omitempty"` } diff --git a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_machine_driver.go b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_machine_driver.go index 0ecc12a..61f2bd4 100644 --- a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_machine_driver.go +++ b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_machine_driver.go @@ -15,8 +15,6 @@ type MachineDriver struct { Description string `json:"description,omitempty" yaml:"description,omitempty"` - ErrorMessage string `json:"errorMessage,omitempty" yaml:"error_message,omitempty"` - Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` Md5checksum string `json:"md5checksum,omitempty" yaml:"md5checksum,omitempty"` @@ -58,15 +56,11 @@ type MachineDriverOperations interface { ActionActivate(*MachineDriver) (*MachineDriver, error) - ActionCreate(*MachineDriver) (*MachineDriver, error) - - ActionError(*MachineDriver, *MachineDriverErrorInput) (*MachineDriver, error) - - ActionPurge(*MachineDriver) (*MachineDriver, error) + ActionError(*MachineDriver) (*MachineDriver, error) ActionRemove(*MachineDriver) (*MachineDriver, error) - ActionUpdate(*MachineDriver, *MachineDriverUpdateInput) (*MachineDriver, error) + ActionRetry(*MachineDriver) (*MachineDriver, error) } func newMachineDriverClient(rancherClient *RancherClient) *MachineDriverClient { @@ -117,29 +111,11 @@ func (c *MachineDriverClient) ActionActivate(resource *MachineDriver) (*MachineD return resp, err } -func (c *MachineDriverClient) ActionCreate(resource *MachineDriver) (*MachineDriver, error) { - - resp := &MachineDriver{} - - err := c.rancherClient.doAction(MACHINE_DRIVER_TYPE, "create", &resource.Resource, nil, resp) - - return resp, err -} - -func (c *MachineDriverClient) ActionError(resource *MachineDriver, input *MachineDriverErrorInput) (*MachineDriver, error) { - - resp := &MachineDriver{} - - err := c.rancherClient.doAction(MACHINE_DRIVER_TYPE, "error", &resource.Resource, input, resp) - - return resp, err -} - -func (c *MachineDriverClient) ActionPurge(resource *MachineDriver) (*MachineDriver, error) { +func (c *MachineDriverClient) ActionError(resource *MachineDriver) (*MachineDriver, error) { resp := &MachineDriver{} - err := c.rancherClient.doAction(MACHINE_DRIVER_TYPE, "purge", &resource.Resource, nil, resp) + err := c.rancherClient.doAction(MACHINE_DRIVER_TYPE, "error", &resource.Resource, nil, resp) return resp, err } @@ -153,11 +129,11 @@ func (c *MachineDriverClient) ActionRemove(resource *MachineDriver) (*MachineDri return resp, err } -func (c *MachineDriverClient) ActionUpdate(resource *MachineDriver, input *MachineDriverUpdateInput) (*MachineDriver, error) { +func (c *MachineDriverClient) ActionRetry(resource *MachineDriver) (*MachineDriver, error) { resp := &MachineDriver{} - err := c.rancherClient.doAction(MACHINE_DRIVER_TYPE, "update", &resource.Resource, input, resp) + err := c.rancherClient.doAction(MACHINE_DRIVER_TYPE, "retry", &resource.Resource, nil, resp) return resp, err } diff --git a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_port.go b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_port.go index 739fd83..3db9283 100644 --- a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_port.go +++ b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_port.go @@ -9,6 +9,8 @@ type Port struct { AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + BindAddress string `json:"bindAddress,omitempty" yaml:"bind_address,omitempty"` + Created string `json:"created,omitempty" yaml:"created,omitempty"` Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` diff --git a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_process_execution.go b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_process_execution.go index 7a04661..05e1291 100644 --- a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_process_execution.go +++ b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_process_execution.go @@ -7,6 +7,8 @@ const ( type ProcessExecution struct { Resource + Created string `json:"created,omitempty" yaml:"created,omitempty"` + Log map[string]interface{} `json:"log,omitempty" yaml:"log,omitempty"` ProcessInstanceId string `json:"processInstanceId,omitempty" yaml:"process_instance_id,omitempty"` diff --git a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_project.go b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_project.go index eb24acb..91f8fc7 100644 --- a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_project.go +++ b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_project.go @@ -7,6 +7,8 @@ const ( type Project struct { Resource + AllowSystemRole bool `json:"allowSystemRole,omitempty" yaml:"allow_system_role,omitempty"` + Created string `json:"created,omitempty" yaml:"created,omitempty"` Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"` diff --git a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_secondary_launch_config.go b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_secondary_launch_config.go index 9a90177..f81da83 100644 --- a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_secondary_launch_config.go +++ b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_secondary_launch_config.go @@ -71,6 +71,8 @@ type SecondaryLaunchConfig struct { HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"` + HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"` + Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"` ImageUuid string `json:"imageUuid,omitempty" yaml:"image_uuid,omitempty"` @@ -123,6 +125,8 @@ type SecondaryLaunchConfig struct { RequestedHostId string `json:"requestedHostId,omitempty" yaml:"requested_host_id,omitempty"` + RequestedIpAddress string `json:"requestedIpAddress,omitempty" yaml:"requested_ip_address,omitempty"` + SecurityOpt []string `json:"securityOpt,omitempty" yaml:"security_opt,omitempty"` StartCount int64 `json:"startCount,omitempty" yaml:"start_count,omitempty"` @@ -184,12 +188,16 @@ type SecondaryLaunchConfigOperations interface { ActionDeallocate(*SecondaryLaunchConfig) (*Instance, error) + ActionError(*SecondaryLaunchConfig) (*Instance, error) + ActionExecute(*SecondaryLaunchConfig, *ContainerExec) (*HostAccess, error) ActionLogs(*SecondaryLaunchConfig, *ContainerLogs) (*HostAccess, error) ActionMigrate(*SecondaryLaunchConfig) (*Instance, error) + ActionProxy(*SecondaryLaunchConfig, *ContainerProxy) (*HostAccess, error) + ActionPurge(*SecondaryLaunchConfig) (*Instance, error) ActionRemove(*SecondaryLaunchConfig) (*Instance, error) @@ -288,6 +296,15 @@ func (c *SecondaryLaunchConfigClient) ActionDeallocate(resource *SecondaryLaunch return resp, err } +func (c *SecondaryLaunchConfigClient) ActionError(resource *SecondaryLaunchConfig) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(SECONDARY_LAUNCH_CONFIG_TYPE, "error", &resource.Resource, nil, resp) + + return resp, err +} + func (c *SecondaryLaunchConfigClient) ActionExecute(resource *SecondaryLaunchConfig, input *ContainerExec) (*HostAccess, error) { resp := &HostAccess{} @@ -315,6 +332,15 @@ func (c *SecondaryLaunchConfigClient) ActionMigrate(resource *SecondaryLaunchCon return resp, err } +func (c *SecondaryLaunchConfigClient) ActionProxy(resource *SecondaryLaunchConfig, input *ContainerProxy) (*HostAccess, error) { + + resp := &HostAccess{} + + err := c.rancherClient.doAction(SECONDARY_LAUNCH_CONFIG_TYPE, "proxy", &resource.Resource, input, resp) + + return resp, err +} + func (c *SecondaryLaunchConfigClient) ActionPurge(resource *SecondaryLaunchConfig) (*Instance, error) { resp := &Instance{} diff --git a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_service.go b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_service.go index d6ba6ad..57d59a0 100644 --- a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_service.go +++ b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_service.go @@ -9,6 +9,8 @@ type Service struct { AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"` + AssignServiceIpAddress bool `json:"assignServiceIpAddress,omitempty" yaml:"assign_service_ip_address,omitempty"` + CreateIndex int64 `json:"createIndex,omitempty" yaml:"create_index,omitempty"` Created string `json:"created,omitempty" yaml:"created,omitempty"` @@ -23,6 +25,8 @@ type Service struct { Fqdn string `json:"fqdn,omitempty" yaml:"fqdn,omitempty"` + HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"` + Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` LaunchConfig *LaunchConfig `json:"launchConfig,omitempty" yaml:"launch_config,omitempty"` @@ -47,7 +51,7 @@ type Service struct { SelectorLink string `json:"selectorLink,omitempty" yaml:"selector_link,omitempty"` - ServiceSchemas map[string]interface{} `json:"serviceSchemas,omitempty" yaml:"service_schemas,omitempty"` + StartOnCreate bool `json:"startOnCreate,omitempty" yaml:"start_on_create,omitempty"` State string `json:"state,omitempty" yaml:"state,omitempty"` @@ -57,7 +61,7 @@ type Service struct { TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"` - Upgrade ServiceUpgrade `json:"upgrade,omitempty" yaml:"upgrade,omitempty"` + Upgrade *ServiceUpgrade `json:"upgrade,omitempty" yaml:"upgrade,omitempty"` Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"` diff --git a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_service_proxy.go b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_service_proxy.go new file mode 100644 index 0000000..fd6c328 --- /dev/null +++ b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_service_proxy.go @@ -0,0 +1,75 @@ +package client + +const ( + SERVICE_PROXY_TYPE = "serviceProxy" +) + +type ServiceProxy struct { + Resource + + Port int64 `json:"port,omitempty" yaml:"port,omitempty"` + + Scheme string `json:"scheme,omitempty" yaml:"scheme,omitempty"` + + Service string `json:"service,omitempty" yaml:"service,omitempty"` + + Token string `json:"token,omitempty" yaml:"token,omitempty"` + + Url string `json:"url,omitempty" yaml:"url,omitempty"` +} + +type ServiceProxyCollection struct { + Collection + Data []ServiceProxy `json:"data,omitempty"` +} + +type ServiceProxyClient struct { + rancherClient *RancherClient +} + +type ServiceProxyOperations interface { + List(opts *ListOpts) (*ServiceProxyCollection, error) + Create(opts *ServiceProxy) (*ServiceProxy, error) + Update(existing *ServiceProxy, updates interface{}) (*ServiceProxy, error) + ById(id string) (*ServiceProxy, error) + Delete(container *ServiceProxy) error +} + +func newServiceProxyClient(rancherClient *RancherClient) *ServiceProxyClient { + return &ServiceProxyClient{ + rancherClient: rancherClient, + } +} + +func (c *ServiceProxyClient) Create(container *ServiceProxy) (*ServiceProxy, error) { + resp := &ServiceProxy{} + err := c.rancherClient.doCreate(SERVICE_PROXY_TYPE, container, resp) + return resp, err +} + +func (c *ServiceProxyClient) Update(existing *ServiceProxy, updates interface{}) (*ServiceProxy, error) { + resp := &ServiceProxy{} + err := c.rancherClient.doUpdate(SERVICE_PROXY_TYPE, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ServiceProxyClient) List(opts *ListOpts) (*ServiceProxyCollection, error) { + resp := &ServiceProxyCollection{} + err := c.rancherClient.doList(SERVICE_PROXY_TYPE, opts, resp) + return resp, err +} + +func (c *ServiceProxyClient) ById(id string) (*ServiceProxy, error) { + resp := &ServiceProxy{} + err := c.rancherClient.doById(SERVICE_PROXY_TYPE, id, resp) + if apiError, ok := err.(*ApiError); ok { + if apiError.StatusCode == 404 { + return nil, nil + } + } + return resp, err +} + +func (c *ServiceProxyClient) Delete(container *ServiceProxy) error { + return c.rancherClient.doResourceDelete(SERVICE_PROXY_TYPE, &container.Resource) +} diff --git a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_virtual_machine.go b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_virtual_machine.go index db75cc7..2381ca8 100644 --- a/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_virtual_machine.go +++ b/Godeps/_workspace/src/github.com/rancher/go-rancher/client/generated_virtual_machine.go @@ -51,6 +51,8 @@ type VirtualMachine struct { HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"` + HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"` + Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"` ImageUuid string `json:"imageUuid,omitempty" yaml:"image_uuid,omitempty"` @@ -144,12 +146,16 @@ type VirtualMachineOperations interface { ActionDeallocate(*VirtualMachine) (*Instance, error) + ActionError(*VirtualMachine) (*Instance, error) + ActionExecute(*VirtualMachine, *ContainerExec) (*HostAccess, error) ActionLogs(*VirtualMachine, *ContainerLogs) (*HostAccess, error) ActionMigrate(*VirtualMachine) (*Instance, error) + ActionProxy(*VirtualMachine, *ContainerProxy) (*HostAccess, error) + ActionPurge(*VirtualMachine) (*Instance, error) ActionRemove(*VirtualMachine) (*Instance, error) @@ -248,6 +254,15 @@ func (c *VirtualMachineClient) ActionDeallocate(resource *VirtualMachine) (*Inst return resp, err } +func (c *VirtualMachineClient) ActionError(resource *VirtualMachine) (*Instance, error) { + + resp := &Instance{} + + err := c.rancherClient.doAction(VIRTUAL_MACHINE_TYPE, "error", &resource.Resource, nil, resp) + + return resp, err +} + func (c *VirtualMachineClient) ActionExecute(resource *VirtualMachine, input *ContainerExec) (*HostAccess, error) { resp := &HostAccess{} @@ -275,6 +290,15 @@ func (c *VirtualMachineClient) ActionMigrate(resource *VirtualMachine) (*Instanc return resp, err } +func (c *VirtualMachineClient) ActionProxy(resource *VirtualMachine, input *ContainerProxy) (*HostAccess, error) { + + resp := &HostAccess{} + + err := c.rancherClient.doAction(VIRTUAL_MACHINE_TYPE, "proxy", &resource.Resource, input, resp) + + return resp, err +} + func (c *VirtualMachineClient) ActionPurge(resource *VirtualMachine) (*Instance, error) { resp := &Instance{} diff --git a/Makefile b/Makefile index 6557c2f..76927e7 100644 --- a/Makefile +++ b/Makefile @@ -39,8 +39,8 @@ test: godep go test -v ./... release: - git tag `cat VERSION` - git push origin master --tags + git tag -f `cat VERSION` + git push -f origin master --tags clean: go clean diff --git a/VERSION b/VERSION index 400feeb..34707cb 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v0.2.6 +v0.2.7 diff --git a/circle.yml b/circle.yml index cacc83e..065f97d 100644 --- a/circle.yml +++ b/circle.yml @@ -41,7 +41,7 @@ deployment: commands: - make ci-release - curl --data "docker_tag=latest" -X POST ${DOCKER_HUB_URI}/${DOCKER_HUB_TOKEN}/ - - sleep 3 + - sleep 6 - curl --data "source_type=Tag&source_name=${CIRCLE_TAG}" -X POST ${DOCKER_HUB_URI}/${DOCKER_HUB_TOKEN}/ - echo `git name-rev --tags --name-only $(git rev-parse HEAD)` - echo tag ${CIRCLE_TAG} diff --git a/context.go b/context.go index 45d01bd..3c08743 100644 --- a/context.go +++ b/context.go @@ -86,7 +86,7 @@ func (c *Context) InitContext() { c.Rancher, err = rancher.NewClient(cattleUrl, cattleApiKey, cattleSecretKey) if err != nil { - logrus.Fatalf("Rancher client: %v", err) + logrus.Fatalf("Could not connect to Rancher API: %v", err) } providerOpts := letsencrypt.ProviderOpts{ diff --git a/rancher/client.go b/rancher/client.go index a92ae91..94d2179 100644 --- a/rancher/client.go +++ b/rancher/client.go @@ -1,6 +1,10 @@ package rancher -import rancherClient "github.com/rancher/go-rancher/client" +import ( + "time" + + rancherClient "github.com/rancher/go-rancher/client" +) type Client struct { client *rancherClient.RancherClient @@ -8,11 +12,24 @@ type Client struct { // NewClient returns a new client for the Rancher/Cattle API func NewClient(rancherUrl string, rancherAccessKey string, rancherSecretKey string) (*Client, error) { - apiClient, err := rancherClient.NewRancherClient(&rancherClient.ClientOpts{ + opts := &rancherClient.ClientOpts{ Url: rancherUrl, AccessKey: rancherAccessKey, SecretKey: rancherSecretKey, - }) + Timeout: time.Second * 5, + } + + var err error + var apiClient *rancherClient.RancherClient + maxTime := 10 * time.Second + + for i := 1 * time.Second; i < maxTime; i *= time.Duration(2) { + apiClient, err = rancherClient.NewRancherClient(opts) + if err == nil { + break + } + time.Sleep(i) + } if err != nil { return nil, err