func (m *v1beta1Migrator) writeV1GenTemplate(
	configPath string,
	config bufgen.ExternalConfigV1,
) (retErr error) {
	v1ConfigData, err := encoding.MarshalYAML(&config)
	if err != nil {
		return fmt.Errorf("failed to marshal new config: %w", err)
	}
	header := fmt.Sprintf(bufGenHeader, m.commandName)
	v1ConfigData = append([]byte(header), v1ConfigData...)
	return os.WriteFile(configPath, v1ConfigData, 0600)
}
// writeV1GenTemplate atomically replaces the old configuration file by first writing
// the new config to a temporary file and then moving it to the old config file path.
// If we fail to marshal or write, the old config file is not touched.
writeV1GenTemplate atomically replaces the old configuration file by first writing
the new config to a temporary file and then moving it to the old config file path.
If we fail to marshal or write, the old config file is not touched.
// writeV1GenTemplate atomically replaces the old configuration file by first writing // the new config to a temporary file and then moving it to the old config file path . // If we fail to marshal or write the old config file is not touched .
func (m *v1beta1Migrator) writeV1GenTemplate(
	configPath string,
	config bufgen.ExternalConfigV1,
) (retErr error) {
	v1ConfigData, err := encoding.MarshalYAML(&config)
	if err != nil {
		return fmt.Errorf("failed to marshal new config: %w", err)
	}
	header := fmt.Sprintf(bufGenHeader, m.commandName)
	v1ConfigData = append([]byte(header), v1ConfigData...)
	return os.WriteFile(configPath, v1ConfigData, 0600)
}
func ( m * v1beta1Migrator ) writeV1GenTemplate ( configPath string , config bufgen . ExternalConfigV1 , ) ( retErr error ) { v1ConfigData , err := encoding . MarshalYAML ( & config ) if err != nil { return fmt . Errorf ( " " , err ) } header := fmt . Sprintf ( bufGenHeader , m . commandName ) v1ConfigData = append ( [ ] byte ( header ) , v1ConfigData ... ) return os . WriteFile ( configPath , v1ConfigData , 0600 ) }
writeV1GenTemplate atomically replaces the old configuration file by first writing
the new config to a temporary file and then moving it to the old config file path.
writeV1GenTemplate atomically replaces the old configuration file by first writing the new config to a temporary file and then moving it to the old config file path .