agent/containermetadata/write_metadata_unix.go
func writeToMetadataFile(osWrap oswrapper.OS, ioutilWrap ioutilwrapper.IOUtil, data []byte, taskARN string, containerName string, dataDir string) error {
	metadataFileDir, err := getMetadataFilePath(taskARN, containerName, dataDir)
	// Boundary case if file path is bad (Such as if task arn is incorrectly formatted)
	if err != nil {
		return fmt.Errorf("write to metadata file for task %s container %s: %v", taskARN, containerName, err)
	}
	metadataFileName := filepath.Join(metadataFileDir, metadataFile)

	temp, err := ioutilWrap.TempFile(metadataFileDir, tempFile)
	if err != nil {
		return err
	}
	defer temp.Close()
	_, err = temp.Write(data)
	if err != nil {
		return err
	}
	err = temp.Chmod(metadataPerm)
	if err != nil {
		return err
	}
	return osWrap.Rename(temp.Name(), metadataFileName)
}
func writeToMetadataFile(osWrap oswrapper.OS, ioutilWrap ioutilwrapper.IOUtil, data []byte, taskARN string, containerName string, dataDir string) error {
	metadataFileDir, err := getMetadataFilePath(taskARN, containerName, dataDir)
	// Boundary case if file path is bad (Such as if task arn is incorrectly formatted)
	if err != nil {
		return fmt.Errorf("write to metadata file for task %s container %s: %v", taskARN, containerName, err)
	}
	metadataFileName := filepath.Join(metadataFileDir, metadataFile)

	temp, err := ioutilWrap.TempFile(metadataFileDir, tempFile)
	if err != nil {
		return err
	}
	defer temp.Close()
	_, err = temp.Write(data)
	if err != nil {
		return err
	}
	err = temp.Chmod(metadataPerm)
	if err != nil {
		return err
	}
	return osWrap.Rename(temp.Name(), metadataFileName)
}
func writeToMetadataFile ( osWrap oswrapper . OS , ioutilWrap ioutilwrapper . IOUtil , data [ ] byte , taskARN string , containerName string , dataDir string ) error { metadataFileDir , err := getMetadataFilePath ( taskARN , containerName , dataDir ) // Boundary case if file path is bad (Such as if task arn is incorrectly formatted) if err != nil { return fmt . Errorf ( " " , taskARN , containerName , err ) } metadataFileName := filepath . Join ( metadataFileDir , metadataFile ) temp , err := ioutilWrap . TempFile ( metadataFileDir , tempFile ) if err != nil { return err } defer temp . Close ( ) _ , err = temp . Write ( data ) if err != nil { return err } err = temp . Chmod ( metadataPerm ) if err != nil { return err } return osWrap . Rename ( temp . Name ( ) , metadataFileName ) }
// writeToMetadata puts the metadata into JSON format and writes into
// the metadata file
writeToMetadata puts the metadata into JSON format and writes into the metadata file