Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into 3414-buf-registry-whoami
Browse files Browse the repository at this point in the history
  • Loading branch information
doriable committed Oct 29, 2024
2 parents ae4bee4 + b5f41e3 commit 9ad3f2e
Show file tree
Hide file tree
Showing 51 changed files with 637 additions and 318 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/1-bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ body:
value: |
Thanks for helping us improve Buf by filing bugs, we really appreciate it! For us to investigate your issue efficiently, we need a minimal reproducible example. We get lots of support requests, so please help us help you. We find that the easiest way to do this is by linking to a GitHub repository with the setup of the example, as well as a set of commands for us to run on this GitHub repository to reproduce the issue. You can use an existing GitHub repository, or a temporary GitHub repository you create.
**If you do not provide a minimal reproducible example in a GitHub repository, we may have to close your issue. We apologize, but we have to be efficient with our support requests, and we appreciate your help.**
**If you do not provide a minimal reproducible example in a GitHub repository, we will likely close your issue until a reproducible example is provided. We apologize, but we have to be efficient with our support requests, and we appreciate your help.**
[This article](https://stackoverflow.com/help/minimal-reproducible-example) on minimal reproducible examples may be of use!
- type: input
id: github-repository
attributes:
label: GitHub repository with your minimal reproducible example (do not fill out this field with "github.com/bufbuild/buf" or we will automatically close your issue, see the instructions above!)
label: GitHub repository with your minimal reproducible example (do not leave this field blank or fill out this field with "github.com/bufbuild/buf" or we will automatically close your issue, see the instructions above!)
description: Provide us with a link to the GitHub repository that contains the setup needed to reproduce the issue. This is a repository you create, and is required for us to investigate your issue.
placeholder: https://github.com/you/temp-repo-with-repro
validations:
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/3-other.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ body:
If this is a question about some behavior you are witnessing, we will need a minimal reproducible example. We get lots of support requests, so please help us help you. We find that the easiest way to do this is by linking to a GitHub repository with the setup of the example, as well as a set of commands for us to run on this GitHub repository to reproduce the issue. You can use an existing GitHub repository, or a temporary GitHub repository you create.
**If this is a question about some behavior you are witnessing, and you do not provide a minimal reproducible example in a GitHub repository, we may have to close your issue. We apologize, but we have to be efficient with our support requests, and we appreciate your help.**
**If this is a question about some behavior you are witnessing, and you do not provide a minimal reproducible example in a GitHub repository, we will likely close your issue until a reproducible example is provided. We apologize, but we have to be efficient with our support requests, and we appreciate your help.**
[This article](https://stackoverflow.com/help/minimal-reproducible-example) on minimal reproducible examples may be of use!
- type: input
id: github-repository
attributes:
label: GitHub repository with your minimal reproducible example (do not fill out this field with "github.com/bufbuild/buf" or we will automatically close your issue, see the instructions above!)
label: GitHub repository with your minimal reproducible example (do not leave this field blank or fill out this field with "github.com/bufbuild/buf" or we will automatically close your issue, see the instructions above!)
description: If this is a question about some behavior you are witnessing, provide us with a link to the GitHub repository that contains the setup needed to reproduce the issue. This is a repository you create, and is required for us to investigate your issue.
placeholder: https://github.com/you/temp-repo-with-repro
- type: textarea
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ go 1.22.0
toolchain go1.23.2

require (
buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.34.2-20240928190436-5e8abcfd7a7e.2
buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.35.1-20241023225133-42bdb4b67625.1
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.35.1-20240920164238-5a7b106cbb87.1
buf.build/gen/go/bufbuild/registry/connectrpc/go v1.17.0-20241007185750-f2282fe532fe.1
buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.35.1-20241007185750-f2282fe532fe.1
buf.build/go/bufplugin v0.5.0
buf.build/gen/go/bufbuild/registry/connectrpc/go v1.17.0-20241025140216-aa40f2c93090.1
buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.35.1-20241025140216-aa40f2c93090.1
buf.build/go/bufplugin v0.6.0
buf.build/go/protoyaml v0.2.0
buf.build/go/spdx v0.2.0
connectrpc.com/connect v1.17.0
connectrpc.com/otelconnect v0.7.1
github.com/bufbuild/protocompile v0.14.1
github.com/bufbuild/protoplugin v0.0.0-20240911180120-7bb73e41a54a
github.com/bufbuild/protovalidate-go v0.7.2
github.com/bufbuild/protovalidate-go v0.7.3-0.20241015162221-1446f1e1d576
github.com/docker/docker v27.3.1+incompatible
github.com/go-chi/chi/v5 v5.1.0
github.com/gofrs/flock v0.12.1
Expand All @@ -30,7 +30,7 @@ require (
github.com/klauspost/pgzip v1.2.6
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
github.com/pkg/profile v1.7.0
github.com/quic-go/quic-go v0.48.0
github.com/quic-go/quic-go v0.48.1
github.com/rs/cors v1.11.1
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
Expand All @@ -55,7 +55,7 @@ require (
)

require (
buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.34.2-20241007202033-cf42259fcbfc.2 // indirect
buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.35.1-20241007202033-cf42259fcbfc.1 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/Microsoft/hcsshim v0.12.7 // indirect
Expand Down
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.34.2-20240928190436-5e8abcfd7a7e.2 h1:BQVQ0fcYgqpe6F/2ZPJUR1rTN+nwdrj2z7IAbAu9XAQ=
buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.34.2-20240928190436-5e8abcfd7a7e.2/go.mod h1:B+9TKHRYqoAUW57pLjhkLOnBCu0DQYMV+f7imQ9nXwI=
buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.35.1-20241023225133-42bdb4b67625.1 h1:O31Hu5Oho5suEWOD7FuMU9vfzeQT07ukTu4YuBVjLbw=
buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.35.1-20241023225133-42bdb4b67625.1/go.mod h1:rYPnjsUZ2lGpoQ/T322HWZQil9/MIZF2njP+/u/0GKg=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.35.1-20240920164238-5a7b106cbb87.1 h1:9wP6ZZYWnF2Z0TxmII7m3XNykxnP4/w8oXeth6ekcRI=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.35.1-20240920164238-5a7b106cbb87.1/go.mod h1:Duw/9JoXkXIydyASnLYIiufkzySThoqavOsF+IihqvM=
buf.build/gen/go/bufbuild/registry/connectrpc/go v1.17.0-20241007185750-f2282fe532fe.1 h1:tVBsEQVsOz3Xsoy90GOefAgn6siKtfFZxsst39/hJNU=
buf.build/gen/go/bufbuild/registry/connectrpc/go v1.17.0-20241007185750-f2282fe532fe.1/go.mod h1:of6bEOQJUQbBMVsPiLQiyD+yPRze0FClQv2u1CmgDdQ=
buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.35.1-20241007185750-f2282fe532fe.1 h1:jvB3uNDZnP89xIFy8WHeYgCz86vv7mWRyv2Wgp+8hoI=
buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.35.1-20241007185750-f2282fe532fe.1/go.mod h1:wDNiJdkMLOTfEL3o1lBgh+9EVhwGORcz+Aoq6hGk33Y=
buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.34.2-20241007202033-cf42259fcbfc.2 h1:QPJpr4Jtj5AN+LXVz+r+pT8dvPkznkRPotxYSN4zXYE=
buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.34.2-20241007202033-cf42259fcbfc.2/go.mod h1:GjH0gjlY/ns16X8d6eaXV2W+6IFwsO5Ly9WVnzyd1E0=
buf.build/go/bufplugin v0.5.0 h1:pmK1AloAMp+4woH5hEisK9qVmDdLySzIKexUUVZLJ2Q=
buf.build/go/bufplugin v0.5.0/go.mod h1:r7Y8tpqpErLtUXUecEgwAHnjihY03YbN0IaBFNJF/x0=
buf.build/gen/go/bufbuild/registry/connectrpc/go v1.17.0-20241025140216-aa40f2c93090.1 h1:FHQXg3T7S2jp8yc7/bQJgqEH1yza/rrDHXITUK2Tm0g=
buf.build/gen/go/bufbuild/registry/connectrpc/go v1.17.0-20241025140216-aa40f2c93090.1/go.mod h1:5iwF5l+9lKCnvr1zLvDgUHrv6X+vU5nNPjvig1sbnao=
buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.35.1-20241025140216-aa40f2c93090.1 h1:PyqnJojY+BXNuJHp5aEfN9wPiP1dzrobXVmgLrUMe+A=
buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.35.1-20241025140216-aa40f2c93090.1/go.mod h1:x5Mti5bhMO87zJxCkcEbr7Lz+bHiFsqpxnpqSB1okG0=
buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.35.1-20241007202033-cf42259fcbfc.1 h1:rPi3qs3qpDIXIl5QW2IPOaYZhppRkvuVKwEZrfhpy78=
buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.35.1-20241007202033-cf42259fcbfc.1/go.mod h1:4IVMTaeh4JIjBYcGFLlTorfWpKVEXDjDfHAgKTeR0Ds=
buf.build/go/bufplugin v0.6.0 h1:3lhoh+0z+IUPS3ZajTPn/27LaLIkero2BDVnV7yXD1s=
buf.build/go/bufplugin v0.6.0/go.mod h1:hWCjxxv24xdR6F5pNlQavZV2oo0J3uF4Ff1XEoyV6vU=
buf.build/go/protoyaml v0.2.0 h1:2g3OHjtLDqXBREIOjpZGHmQ+U/4mkN1YiQjxNB68Ip8=
buf.build/go/protoyaml v0.2.0/go.mod h1:L/9QvTDkTWcDTzAL6HMfN+mYC6CmZRm2KnsUA054iL0=
buf.build/go/spdx v0.2.0 h1:IItqM0/cMxvFJJumcBuP8NrsIzMs/UYjp/6WSpq8LTw=
Expand All @@ -34,8 +34,8 @@ github.com/bufbuild/protocompile v0.14.1 h1:iA73zAf/fyljNjQKwYzUHD6AD4R8KMasmwa/
github.com/bufbuild/protocompile v0.14.1/go.mod h1:ppVdAIhbr2H8asPk6k4pY7t9zB1OU5DoEw9xY/FUi1c=
github.com/bufbuild/protoplugin v0.0.0-20240911180120-7bb73e41a54a h1:l3RhVoG0RtC61h6TVWnkniGj4TgBebuyPQRdleFAmTg=
github.com/bufbuild/protoplugin v0.0.0-20240911180120-7bb73e41a54a/go.mod h1:c5D8gWRIZ2HLWO3gXYTtUfw/hbJyD8xikv2ooPxnklQ=
github.com/bufbuild/protovalidate-go v0.7.2 h1:UuvKyZHl5p7u3ztEjtRtqtDxOjRKX5VUOgKFq6p6ETk=
github.com/bufbuild/protovalidate-go v0.7.2/go.mod h1:PHV5pFuWlRzdDW02/cmVyNzdiQ+RNNwo7idGxdzS7o4=
github.com/bufbuild/protovalidate-go v0.7.3-0.20241015162221-1446f1e1d576 h1:A4TfjZJqApnAvGKDgxHqA1rG6BK1OswyNcTcnSrDbJc=
github.com/bufbuild/protovalidate-go v0.7.3-0.20241015162221-1446f1e1d576/go.mod h1:R/UFeIPyFAh0eH7Ic/JJbO2ABdkxFuZZKDbzsI5UiwM=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
Expand Down Expand Up @@ -223,8 +223,8 @@ github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0leargg
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI=
github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg=
github.com/quic-go/quic-go v0.48.0 h1:2TCyvBrMu1Z25rvIAlnp2dPT4lgh/uTqLqiXVpp5AeU=
github.com/quic-go/quic-go v0.48.0/go.mod h1:yBgs3rWBOADpga7F+jJsb6Ybg1LSYiQvwWlLX+/6HMs=
github.com/quic-go/quic-go v0.48.1 h1:y/8xmfWI9qmGTc+lBr4jKRUWLGSlSigv847ULJ4hYXA=
github.com/quic-go/quic-go v0.48.1/go.mod h1:yBgs3rWBOADpga7F+jJsb6Ybg1LSYiQvwWlLX+/6HMs=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA=
Expand Down
25 changes: 17 additions & 8 deletions private/buf/bufcli/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ import (
"path/filepath"

"github.com/bufbuild/buf/private/buf/bufwkt/bufwktstore"
"github.com/bufbuild/buf/private/bufpkg/bufapi"
"github.com/bufbuild/buf/private/bufpkg/bufmodule"
"github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleapi"
"github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulecache"
"github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulestore"
"github.com/bufbuild/buf/private/bufpkg/bufregistryapi/bufregistryapimodule"
"github.com/bufbuild/buf/private/bufpkg/bufregistryapi/bufregistryapiowner"
"github.com/bufbuild/buf/private/pkg/app/appext"
"github.com/bufbuild/buf/private/pkg/command"
"github.com/bufbuild/buf/private/pkg/filelock"
Expand Down Expand Up @@ -119,7 +120,10 @@ func NewModuleDataProvider(container appext.Container) (bufmodule.ModuleDataProv
}
return newModuleDataProvider(
container,
bufapi.NewClientProvider(
bufregistryapimodule.NewClientProvider(
clientConfig,
),
bufregistryapiowner.NewClientProvider(
clientConfig,
),
)
Expand All @@ -134,7 +138,10 @@ func NewCommitProvider(container appext.Container) (bufmodule.CommitProvider, er
}
return newCommitProvider(
container,
bufapi.NewClientProvider(
bufregistryapimodule.NewClientProvider(
clientConfig,
),
bufregistryapiowner.NewClientProvider(
clientConfig,
),
)
Expand Down Expand Up @@ -174,16 +181,17 @@ func NewWKTStore(container appext.Container) (bufwktstore.Store, error) {

func newModuleDataProvider(
container appext.Container,
clientProvider bufapi.ClientProvider,
moduleClientProvider bufregistryapimodule.ClientProvider,
ownerClientProvider bufregistryapiowner.ClientProvider,
) (bufmodule.ModuleDataProvider, error) {
if err := createCacheDir(container.CacheDirPath(), v3CacheModuleRelDirPath); err != nil {
return nil, err
}
fullCacheDirPath := normalpath.Join(container.CacheDirPath(), v3CacheModuleRelDirPath)
delegateModuleDataProvider := bufmoduleapi.NewModuleDataProvider(
container.Logger(),
clientProvider,
newGraphProvider(container, clientProvider),
moduleClientProvider,
newGraphProvider(container, moduleClientProvider, ownerClientProvider),
)
// No symlinks.
storageosProvider := storageos.NewProvider()
Expand Down Expand Up @@ -211,13 +219,14 @@ func newModuleDataProvider(

func newCommitProvider(
container appext.Container,
clientProvider bufapi.ClientProvider,
moduleClientProvider bufregistryapimodule.ClientProvider,
ownerClientProvider bufregistryapiowner.ClientProvider,
) (bufmodule.CommitProvider, error) {
if err := createCacheDir(container.CacheDirPath(), v3CacheCommitsRelDirPath); err != nil {
return nil, err
}
fullCacheDirPath := normalpath.Join(container.CacheDirPath(), v3CacheCommitsRelDirPath)
delegateReader := bufmoduleapi.NewCommitProvider(container.Logger(), clientProvider)
delegateReader := bufmoduleapi.NewCommitProvider(container.Logger(), moduleClientProvider, ownerClientProvider)
// No symlinks.
storageosProvider := storageos.NewProvider()
cacheBucket, err := storageosProvider.NewReadWriteBucket(fullCacheDirPath)
Expand Down
14 changes: 8 additions & 6 deletions private/buf/bufcli/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ package bufcli

import (
"github.com/bufbuild/buf/private/buf/bufctl"
"github.com/bufbuild/buf/private/bufpkg/bufapi"
"github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleapi"
"github.com/bufbuild/buf/private/bufpkg/bufregistryapi/bufregistryapimodule"
"github.com/bufbuild/buf/private/bufpkg/bufregistryapi/bufregistryapiowner"
"github.com/bufbuild/buf/private/pkg/app/appext"
)

Expand All @@ -36,12 +37,13 @@ func NewController(
if err != nil {
return nil, err
}
clientProvider := bufapi.NewClientProvider(clientConfig)
moduleDataProvider, err := newModuleDataProvider(container, clientProvider)
moduleClientProvider := bufregistryapimodule.NewClientProvider(clientConfig)
ownerClientProvider := bufregistryapiowner.NewClientProvider(clientConfig)
moduleDataProvider, err := newModuleDataProvider(container, moduleClientProvider, ownerClientProvider)
if err != nil {
return nil, err
}
commitProvider, err := newCommitProvider(container, clientProvider)
commitProvider, err := newCommitProvider(container, moduleClientProvider, ownerClientProvider)
if err != nil {
return nil, err
}
Expand All @@ -52,8 +54,8 @@ func NewController(
return bufctl.NewController(
container.Logger(),
container,
newGraphProvider(container, clientProvider),
bufmoduleapi.NewModuleKeyProvider(container.Logger(), clientProvider),
newGraphProvider(container, moduleClientProvider, ownerClientProvider),
bufmoduleapi.NewModuleKeyProvider(container.Logger(), moduleClientProvider),
moduleDataProvider,
commitProvider,
wktStore,
Expand Down
15 changes: 11 additions & 4 deletions private/buf/bufcli/graph_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
package bufcli

import (
"github.com/bufbuild/buf/private/bufpkg/bufapi"
"github.com/bufbuild/buf/private/bufpkg/bufmodule"
"github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleapi"
"github.com/bufbuild/buf/private/bufpkg/bufregistryapi/bufregistryapimodule"
"github.com/bufbuild/buf/private/bufpkg/bufregistryapi/bufregistryapiowner"
"github.com/bufbuild/buf/private/pkg/app/appext"
)

Expand All @@ -27,16 +28,22 @@ func NewGraphProvider(container appext.Container) (bufmodule.GraphProvider, erro
if err != nil {
return nil, err
}
return newGraphProvider(container, bufapi.NewClientProvider(clientConfig)), nil
return newGraphProvider(
container,
bufregistryapimodule.NewClientProvider(clientConfig),
bufregistryapiowner.NewClientProvider(clientConfig),
), nil
}

func newGraphProvider(
container appext.Container,
clientProvider bufapi.ClientProvider,
moduleClientProvider bufregistryapimodule.ClientProvider,
ownerClientProvider bufregistryapiowner.ClientProvider,
) bufmodule.GraphProvider {
return bufmoduleapi.NewGraphProvider(
container.Logger(),
clientProvider,
moduleClientProvider,
ownerClientProvider,
// OK if empty
bufmoduleapi.GraphProviderWithLegacyFederationRegistry(container.Env(legacyFederationRegistryEnvKey)),
// OK if empty
Expand Down
4 changes: 2 additions & 2 deletions private/buf/bufcli/module_key_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
package bufcli

import (
"github.com/bufbuild/buf/private/bufpkg/bufapi"
"github.com/bufbuild/buf/private/bufpkg/bufmodule"
"github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleapi"
"github.com/bufbuild/buf/private/bufpkg/bufregistryapi/bufregistryapimodule"
"github.com/bufbuild/buf/private/pkg/app/appext"
)

Expand All @@ -29,7 +29,7 @@ func NewModuleKeyProvider(container appext.Container) (bufmodule.ModuleKeyProvid
}
return bufmoduleapi.NewModuleKeyProvider(
container.Logger(),
bufapi.NewClientProvider(
bufregistryapimodule.NewClientProvider(
clientConfig,
),
), nil
Expand Down
6 changes: 3 additions & 3 deletions private/buf/bufcli/uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
package bufcli

import (
"github.com/bufbuild/buf/private/bufpkg/bufapi"
"github.com/bufbuild/buf/private/bufpkg/bufmodule"
"github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleapi"
"github.com/bufbuild/buf/private/bufpkg/bufregistryapi/bufregistryapimodule"
"github.com/bufbuild/buf/private/pkg/app/appext"
)

Expand All @@ -27,12 +27,12 @@ func NewUploader(container appext.Container) (bufmodule.Uploader, error) {
if err != nil {
return nil, err
}
return newUploader(container, bufapi.NewClientProvider(clientConfig)), nil
return newUploader(container, bufregistryapimodule.NewClientProvider(clientConfig)), nil
}

func newUploader(
container appext.Container,
clientProvider bufapi.ClientProvider,
clientProvider bufregistryapimodule.ClientProvider,
) bufmodule.Uploader {
return bufmoduleapi.NewUploader(
container.Logger(),
Expand Down
25 changes: 24 additions & 1 deletion private/buf/buflsp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,32 @@ func (s *server) Formatting(
return nil, err
}

// XXX: The current compiler does not expose a span for the full file. Instead of
// potentially undershooting the correct span (which can cause comments at the
// start and end of the file to be duplicated), we instead manually count up the
// number of lines in the file. This is comparatively cheap, compared to sending the
// entire file over a domain socket.
var lastLine, lastLineStart int
for i := 0; i < len(file.text); i++ {
// NOTE: we are iterating over bytes, not runes.
if file.text[i] == '\n' {
lastLine++
lastLineStart = i + 1 // Skip the \n.
}
}
lastChar := len(file.text[lastLineStart:]) - 1 // Bytes, not runes!
return []protocol.TextEdit{
{
Range: infoToRange(file.fileNode.NodeInfo(file.fileNode)),
Range: protocol.Range{
Start: protocol.Position{
Line: 0,
Character: 0,
},
End: protocol.Position{
Line: uint32(lastLine),
Character: uint32(lastChar),
},
},
NewText: out.String(),
},
}, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ func createCuratedPluginRequest(
LicenseUrl: pluginConfig.LicenseURL,
Visibility: visibility,
IntegrationGuideUrl: pluginConfig.IntegrationGuideURL,
Deprecated: pluginConfig.Deprecated,
}, nil
}

Expand Down
Loading

0 comments on commit 9ad3f2e

Please sign in to comment.