func (client *APIECSClient) RegisterContainerInstance(containerInstanceArn string,
	attributes []*ecs.Attribute, tags []*ecs.Tag, registrationToken string, platformDevices []*ecs.PlatformDevice) (string, string, error) {
	clusterRef := client.config.Cluster
	// If our clusterRef is empty, we should try to create the default
	if clusterRef == "" {
		clusterRef = config.DefaultClusterName
		defer func() {
			// Update the config value to reflect the cluster we end up in
			client.config.Cluster = clusterRef
		}()
		// Attempt to register without checking existence of the cluster so we don't require
		// excess permissions in the case where the cluster already exists and is active
		containerInstanceArn, availabilityzone, err := client.registerContainerInstance(clusterRef, containerInstanceArn, attributes, tags, registrationToken, platformDevices)
		if err == nil {
			return containerInstanceArn, availabilityzone, nil
		}

		// If trying to register fails because the default cluster doesn't exist, try to create the cluster before calling
		// register again
		if apierrors.IsClusterNotFoundError(err) {
			clusterRef, err = client.CreateCluster(clusterRef)
			if err != nil {
				return "", "", err
			}
		}
	}
	return client.registerContainerInstance(clusterRef, containerInstanceArn, attributes, tags, registrationToken, platformDevices)
}
func (client *APIECSClient) RegisterContainerInstance(containerInstanceArn string,
	attributes []*ecs.Attribute, tags []*ecs.Tag, registrationToken string, platformDevices []*ecs.PlatformDevice) (string, string, error) {
	clusterRef := client.config.Cluster
	
	if clusterRef == "" {
		clusterRef = config.DefaultClusterName
		defer func() {
			
			client.config.Cluster = clusterRef
		}()
		
		
		containerInstanceArn, availabilityzone, err := client.registerContainerInstance(clusterRef, containerInstanceArn, attributes, tags, registrationToken, platformDevices)
		if err == nil {
			return containerInstanceArn, availabilityzone, nil
		}

		
		
		if apierrors.IsClusterNotFoundError(err) {
			clusterRef, err = client.CreateCluster(clusterRef)
			if err != nil {
				return "", "", err
			}
		}
	}
	return client.registerContainerInstance(clusterRef, containerInstanceArn, attributes, tags, registrationToken, platformDevices)
}
func ( client * APIECSClient ) RegisterContainerInstance ( containerInstanceArn string , attributes [ ] * ecs . Attribute , tags [ ] * ecs . Tag , registrationToken string , platformDevices [ ] * ecs . PlatformDevice ) ( string , string , error ) { clusterRef := client . config . Cluster // If our clusterRef is empty, we should try to create the default if clusterRef == " " { clusterRef = config . DefaultClusterName defer func ( ) { // Update the config value to reflect the cluster we end up in client . config . Cluster = clusterRef } ( ) // Attempt to register without checking existence of the cluster so we don't require // excess permissions in the case where the cluster already exists and is active containerInstanceArn , availabilityzone , err := client . registerContainerInstance ( clusterRef , containerInstanceArn , attributes , tags , registrationToken , platformDevices ) if err == nil { return containerInstanceArn , availabilityzone , nil } // If trying to register fails because the default cluster doesn't exist, try to create the cluster before calling // register again if apierrors . IsClusterNotFoundError ( err ) { clusterRef , err = client . CreateCluster ( clusterRef ) if err != nil { return " " , " " , err } } } return client . registerContainerInstance ( clusterRef , containerInstanceArn , attributes , tags , registrationToken , platformDevices ) }
// RegisterContainerInstance calculates the appropriate resources, creates
// the default cluster if necessary, and returns the registered
// ContainerInstanceARN if successful. Supplying a non-empty container
// instance ARN allows a container instance to update its registered
// resources.
RegisterContainerInstance calculates the appropriate resources creates the default cluster if necessary and returns the registered ContainerInstanceARN if successful . Supplying a non - empty container instance ARN allows a container instance to update its registered resources .