Skip to main content

14 Push Workspace Modules

Workspaces make it easy to work with and modify multiple local modules at the same time. Once you're satisfied with your changes and are ready to push them to the BSR, there's a couple extra things you'll need to keep in mind to make sure everything works as you expect.

14.1 Try to Push#

The Go/gRPC client and server stubs were successfully generated, but if you try to push the petapis module to the BSR, you'll notice the following:

$ cd petapis$ buf pushFailure: pet/v1/pet.proto:5:8:payment/v1alpha1/payment.proto: does not exist.

However, we can sucessfully build the module locally:

$ buf build

Recall that we can only build the module because of the located in the start directory. Without the file, the petapis module doesn't have access to the files provided by the paymentapis module.

This is because workspaces only apply to local operations. When you are ready to push any updates you've made in a local workspace, you'll need to push each module independently, starting with the upstream modules first. Once the upstream module's changes are published, you can update the downstream module to fetch the latest version, and continue to push each of your modules until all of your local changes are published to the BSR.

For the PetStoreService, the order in which we need to publish updates is shown below:

googleapis -> paymentapis -> petapis

14.2 Push the paymentapis Module#

We didn't make any changes to the module, so we don't need to push a new version of that module. However, we just introduced the$BUF_USER/paymentapis module, so we first need to create the$BUF_USER/paymentapis repository so that we have somewhere to push it:

$ buf beta registry repository create$BUF_USER/paymentapis --visibility publicFull name              $BUF_USER/paymentapis  ...

Now that the repository exists, change into the paymentapis directory and push the module:

$ cd ../paymentapis$ buf push2675d6a595ac4e0fb45cedc62edfc611

14.3 Push the petapis Module#

The$BUF_USER/paymentapis repository now contains the same content we have locally, so we can add it as a dependency to the local petapis module:

$ cd ../petapis
 version: v1 deps:   -  -$BUF_USER/paymentapis lint:   use:     - DEFAULT breaking:   use:     - FILE

Update your dependencies with following:

$ buf mod update

Your buf.lock should contain a reference to both googleapis and paymentapis:

# Generated by buf. DO NOT EDIT.version: v1deps:  - remote:    owner: $BUF_USER    repository: paymentapis    branch: main    commit: dac7c0d731d74ee78aea6f5f812e6997    digest: b1-jrrTlZyx9gYfpWv9KoSkEJmzheEMQMvvaa4UtGOxzCo=    create_time: ...  - remote:    owner: googleapis    repository: googleapis    branch: main    commit: 1c473ad9220a49bca9320f4cc690eba5    digest: b1-unlhrcI3tnJd0JEGuOb692LZ_tY_gCGq6mK1bgCn1Pg=    create_time: ...

With this, we can successfully push the petapis module:

$ buf pushdda6041ec265455d813f037c36c30349