func (manager *metadataManager) Create(config *dockercontainer.Config, hostConfig *dockercontainer.HostConfig, task *apitask.Task, containerName string) error {
	// Create task and container directories if they do not yet exist
	metadataDirectoryPath, err := getMetadataFilePath(task.Arn, containerName, manager.dataDir)
	// Stop metadata creation if path is malformed for any reason
	if err != nil {
		return fmt.Errorf("container metadata create for task %s container %s: %v", task.Arn, containerName, err)
	}

	err = manager.osWrap.MkdirAll(metadataDirectoryPath, os.ModePerm)
	if err != nil {
		return fmt.Errorf("creating metadata directory for task %s: %v", task.Arn, err)
	}

	// Acquire the metadata then write it in JSON format to the file
	metadata := manager.parseMetadataAtContainerCreate(task, containerName)
	err = manager.marshalAndWrite(metadata, task.Arn, containerName)
	if err != nil {
		return err
	}

	// Add the directory of this container's metadata to the container's mount binds
	// Then add the destination directory as an environment variable in the container $METADATA
	binds, env := createBindsEnv(hostConfig.Binds, config.Env, manager.dataDirOnHost, metadataDirectoryPath)
	config.Env = env
	hostConfig.Binds = binds
	return nil
}
func (manager *metadataManager) Create(config *dockercontainer.Config, hostConfig *dockercontainer.HostConfig, task *apitask.Task, containerName string) error {
	
	metadataDirectoryPath, err := getMetadataFilePath(task.Arn, containerName, manager.dataDir)
	
	if err != nil {
		return fmt.Errorf("container metadata create for task %s container %s: %v", task.Arn, containerName, err)
	}

	err = manager.osWrap.MkdirAll(metadataDirectoryPath, os.ModePerm)
	if err != nil {
		return fmt.Errorf("creating metadata directory for task %s: %v", task.Arn, err)
	}

	
	metadata := manager.parseMetadataAtContainerCreate(task, containerName)
	err = manager.marshalAndWrite(metadata, task.Arn, containerName)
	if err != nil {
		return err
	}

	
	
	binds, env := createBindsEnv(hostConfig.Binds, config.Env, manager.dataDirOnHost, metadataDirectoryPath)
	config.Env = env
	hostConfig.Binds = binds
	return nil
}
func ( manager * metadataManager ) Create ( config * dockercontainer . Config , hostConfig * dockercontainer . HostConfig , task * apitask . Task , containerName string ) error { // Create task and container directories if they do not yet exist metadataDirectoryPath , err := getMetadataFilePath ( task . Arn , containerName , manager . dataDir ) // Stop metadata creation if path is malformed for any reason if err != nil { return fmt . Errorf ( " " , task . Arn , containerName , err ) } err = manager . osWrap . MkdirAll ( metadataDirectoryPath , os . ModePerm ) if err != nil { return fmt . Errorf ( " " , task . Arn , err ) } // Acquire the metadata then write it in JSON format to the file metadata := manager . parseMetadataAtContainerCreate ( task , containerName ) err = manager . marshalAndWrite ( metadata , task . Arn , containerName ) if err != nil { return err } // Add the directory of this container's metadata to the container's mount binds // Then add the destination directory as an environment variable in the container $METADATA binds , env := createBindsEnv ( hostConfig . Binds , config . Env , manager . dataDirOnHost , metadataDirectoryPath ) config . Env = env hostConfig . Binds = binds return nil }
// Create creates the metadata file and adds the metadata directory to
// the container's mounted host volumes
// Pointer hostConfig is modified directly so there is risk of concurrency errors.
Create creates the metadata file and adds the metadata directory to the container s mounted host volumes Pointer hostConfig is modified directly so there is risk of concurrency errors .