func run(
	ctx context.Context,
	container appflag.Container,
	flags *flags,
) error {
	directoryInput, err := bufcli.GetInputValue(container, "", ".")
	if err != nil {
		return err
	}
	storageosProvider := storageos.NewProvider(storageos.ProviderWithSymlinks())
	readWriteBucket, err := storageosProvider.NewReadWriteBucket(
		directoryInput,
		storageos.ReadWriteBucketWithSymlinksIfSupported(),
	)
	if err != nil {
		return bufcli.NewInternalError(err)
	}
	existingConfigFilePath, err := bufconfig.ExistingConfigFilePath(ctx, readWriteBucket)
	if err != nil {
		return bufcli.NewInternalError(err)
	}
	if existingConfigFilePath == "" {
		return bufcli.ErrNoConfigFile
	}
	moduleConfig, err := bufconfig.GetConfigForBucket(ctx, readWriteBucket)
	if err != nil {
		return err
	}

	remote := bufrpc.DefaultRemote
	if moduleConfig.ModuleIdentity != nil && moduleConfig.ModuleIdentity.Remote() != "" {
		remote = moduleConfig.ModuleIdentity.Remote()
	} else {
		for _, moduleReference := range moduleConfig.Build.DependencyModuleReferences {
			if strings.HasSuffix(moduleReference.Remote(), bufTeamsRemote) && !strings.HasSuffix(bufrpc.DefaultRemote, bufTeamsRemote) {
				warnMsg := fmt.Sprintf(
					`%q does not specify a "name", so Buf is defaulting to using remote %q for dependency resolution. This remote may be unable to resolve %q if it's an enterprise BSR module. Did you mean to specify a "name: %s/..." on this module?`,
					existingConfigFilePath,
					bufrpc.DefaultRemote,
					moduleReference.IdentityString(),
					moduleReference.Remote(),
				)
				container.Logger().Warn(warnMsg)
				break
			}
		}
	}

	pinnedRepositories, err := getDependencies(
		ctx,
		container,
		flags,
		remote,
		moduleConfig,
		readWriteBucket,
	)
	if err != nil {
		return err
	}

	dependencyModulePins := make([]bufmoduleref.ModulePin, len(pinnedRepositories))
	for i := range pinnedRepositories {
		dependencyModulePins[i] = pinnedRepositories[i].modulePin
		modulePin := pinnedRepositories[i].modulePin
		repository := pinnedRepositories[i].repository
		if !repository.Deprecated {
			continue
		}
		warnMsg := fmt.Sprintf(
			`Repository "%s/%s/%s" is deprecated`,
			modulePin.Remote(),
			modulePin.Owner(),
			modulePin.Repository(),
		)
		if repository.DeprecationMessage != "" {
			warnMsg = fmt.Sprintf("%s: %s", warnMsg, repository.DeprecationMessage)
		}
		container.Logger().Warn(warnMsg)
	}

	if err := bufmoduleref.PutDependencyModulePinsToBucket(ctx, readWriteBucket, dependencyModulePins); err != nil {
		return bufcli.NewInternalError(err)
	}
	return nil
}
// run update the buf.lock file for a specific module.
run update the buf.lock file for a specific module.
// run update the buf . lock file for a specific module .
func run(
	ctx context.Context,
	container appflag.Container,
	flags *flags,
) error {
	directoryInput, err := bufcli.GetInputValue(container, "", ".")
	if err != nil {
		return err
	}
	storageosProvider := storageos.NewProvider(storageos.ProviderWithSymlinks())
	readWriteBucket, err := storageosProvider.NewReadWriteBucket(
		directoryInput,
		storageos.ReadWriteBucketWithSymlinksIfSupported(),
	)
	if err != nil {
		return bufcli.NewInternalError(err)
	}
	existingConfigFilePath, err := bufconfig.ExistingConfigFilePath(ctx, readWriteBucket)
	if err != nil {
		return bufcli.NewInternalError(err)
	}
	if existingConfigFilePath == "" {
		return bufcli.ErrNoConfigFile
	}
	moduleConfig, err := bufconfig.GetConfigForBucket(ctx, readWriteBucket)
	if err != nil {
		return err
	}
	remote := bufrpc.DefaultRemote
	if moduleConfig.ModuleIdentity != nil && moduleConfig.ModuleIdentity.Remote() != "" {
		remote = moduleConfig.ModuleIdentity.Remote()
	} else {
		for _, moduleReference := range moduleConfig.Build.DependencyModuleReferences {
			if strings.HasSuffix(moduleReference.Remote(), bufTeamsRemote) && !strings.HasSuffix(bufrpc.DefaultRemote, bufTeamsRemote) {
				warnMsg := fmt.Sprintf(
					`%q does not specify a "name", so Buf is defaulting to using remote %q for dependency resolution. This remote may be unable to resolve %q if it's an enterprise BSR module. Did you mean to specify a "name: %s/..." on this module?`,
					existingConfigFilePath,
					bufrpc.DefaultRemote,
					moduleReference.IdentityString(),
					moduleReference.Remote(),
				)
				container.Logger().Warn(warnMsg)
				break
			}
		}
	}
	pinnedRepositories, err := getDependencies(
		ctx,
		container,
		flags,
		remote,
		moduleConfig,
		readWriteBucket,
	)
	if err != nil {
		return err
	}
	dependencyModulePins := make([]bufmoduleref.ModulePin, len(pinnedRepositories))
	for i := range pinnedRepositories {
		dependencyModulePins[i] = pinnedRepositories[i].modulePin
		modulePin := pinnedRepositories[i].modulePin
		repository := pinnedRepositories[i].repository
		if !repository.Deprecated {
			continue
		}
		warnMsg := fmt.Sprintf(
			`Repository "%s/%s/%s" is deprecated`,
			modulePin.Remote(),
			modulePin.Owner(),
			modulePin.Repository(),
		)
		if repository.DeprecationMessage != "" {
			warnMsg = fmt.Sprintf("%s: %s", warnMsg, repository.DeprecationMessage)
		}
		container.Logger().Warn(warnMsg)
	}
	if err := bufmoduleref.PutDependencyModulePinsToBucket(ctx, readWriteBucket, dependencyModulePins); err != nil {
		return bufcli.NewInternalError(err)
	}
	return nil
}
func run ( ctx context . Context , container appflag . Container , flags * flags , ) error { directoryInput , err := bufcli . GetInputValue ( container , " " , " " ) if err != nil { return err } storageosProvider := storageos . NewProvider ( storageos . ProviderWithSymlinks ( ) ) readWriteBucket , err := storageosProvider . NewReadWriteBucket ( directoryInput , storageos . ReadWriteBucketWithSymlinksIfSupported ( ) , ) if err != nil { return bufcli . NewInternalError ( err ) } existingConfigFilePath , err := bufconfig . ExistingConfigFilePath ( ctx , readWriteBucket ) if err != nil { return bufcli . NewInternalError ( err ) } if existingConfigFilePath == " " { return bufcli . ErrNoConfigFile } moduleConfig , err := bufconfig . GetConfigForBucket ( ctx , readWriteBucket ) if err != nil { return err } remote := bufrpc . DefaultRemote if moduleConfig . ModuleIdentity != nil && moduleConfig . ModuleIdentity . Remote ( ) != " " { remote = moduleConfig . ModuleIdentity . Remote ( ) } else { for _ , moduleReference := range moduleConfig . Build . DependencyModuleReferences { if strings . HasSuffix ( moduleReference . Remote ( ) , bufTeamsRemote ) && ! strings . HasSuffix ( bufrpc . DefaultRemote , bufTeamsRemote ) { warnMsg := fmt . Sprintf ( `%q does not specify a "name", so Buf is defaulting to using remote %q for dependency resolution. This remote may be unable to resolve %q if it's an enterprise BSR module. Did you mean to specify a "name: %s/..." on this module?` , existingConfigFilePath , bufrpc . DefaultRemote , moduleReference . IdentityString ( ) , moduleReference . Remote ( ) , ) container . Logger ( ) . Warn ( warnMsg ) break } } } pinnedRepositories , err := getDependencies ( ctx , container , flags , remote , moduleConfig , readWriteBucket , ) if err != nil { return err } dependencyModulePins := make ( [ ] bufmoduleref . ModulePin , len ( pinnedRepositories ) ) for i := range pinnedRepositories { dependencyModulePins [ i ] = pinnedRepositories [ i ] . modulePin modulePin := pinnedRepositories [ i ] . modulePin repository := pinnedRepositories [ i ] . repository if ! repository . Deprecated { continue } warnMsg := fmt . Sprintf ( `Repository "%s/%s/%s" is deprecated` , modulePin . Remote ( ) , modulePin . Owner ( ) , modulePin . Repository ( ) , ) if repository . DeprecationMessage != " " { warnMsg = fmt . Sprintf ( " " , warnMsg , repository . DeprecationMessage ) } container . Logger ( ) . Warn ( warnMsg ) } if err := bufmoduleref . PutDependencyModulePinsToBucket ( ctx , readWriteBucket , dependencyModulePins ) ; err != nil { return bufcli . NewInternalError ( err ) } return nil }
run update the buf.lock file for a specific module.
run update the buf . lock file for a specific module .