agent/containermetadata/manager.go
func (manager *metadataManager) Update(ctx context.Context, dockerID string, task *apitask.Task, containerName string) error {
	// Get docker container information through api call
	dockerContainer, err := manager.client.InspectContainer(ctx, dockerID, dockerclient.InspectContainerTimeout)
	if err != nil {
		return err
	}

	// Ensure we do not update a container that is invalid or is not running
	if dockerContainer == nil || !dockerContainer.State.Running {
		return fmt.Errorf("container metadata update for container %s in task %s: container not running or invalid", containerName, task.Arn)
	}

	// Acquire the metadata then write it in JSON format to the file
	metadata := manager.parseMetadata(dockerContainer, task, containerName)
	return manager.marshalAndWrite(metadata, task.Arn, containerName)
}
func (manager *metadataManager) Update(ctx context.Context, dockerID string, task *apitask.Task, containerName string) error {
	// Get docker container information through api call
	dockerContainer, err := manager.client.InspectContainer(ctx, dockerID, dockerclient.InspectContainerTimeout)
	if err != nil {
		return err
	}

	// Ensure we do not update a container that is invalid or is not running
	if dockerContainer == nil || !dockerContainer.State.Running {
		return fmt.Errorf("container metadata update for container %s in task %s: container not running or invalid", containerName, task.Arn)
	}

	// Acquire the metadata then write it in JSON format to the file
	metadata := manager.parseMetadata(dockerContainer, task, containerName)
	return manager.marshalAndWrite(metadata, task.Arn, containerName)
}
func ( manager * metadataManager ) Update ( ctx context . Context , dockerID string , task * apitask . Task , containerName string ) error { // Get docker container information through api call dockerContainer , err := manager . client . InspectContainer ( ctx , dockerID , dockerclient . InspectContainerTimeout ) if err != nil { return err } // Ensure we do not update a container that is invalid or is not running if dockerContainer == nil || ! dockerContainer . State . Running { return fmt . Errorf ( " " , containerName , task . Arn ) } // Acquire the metadata then write it in JSON format to the file metadata := manager . parseMetadata ( dockerContainer , task , containerName ) return manager . marshalAndWrite ( metadata , task . Arn , containerName ) }
// Update updates the metadata file after container starts and dynamic metadata is available
Update updates the metadata file after container starts and dynamic metadata is available