diff --git a/.golangci.yml b/.golangci.yml index 54d14bb08e..43f04003e6 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -276,3 +276,9 @@ issues: # This greatly simplifies creation of descriptors, and it's safe enough since # it's just test code. path: private/bufpkg/bufimage/source_retention_options_test\.go + - linters: + - paralleltest + path: private/buf/cmd/buf/buf_test.go + # The LsModules tests call chdir and cannot be parallelized. + text: "LsModules" + diff --git a/CHANGELOG.md b/CHANGELOG.md index dc5491d2fa..a5eff3a5e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [Unreleased] +- Add `buf config ls-modules` command to list configured modules. - Fix issue where `buf generate` would succeed on missing insertion points and panic on empty insertion point files. - Update `buf generate` to allow the use of Editions syntax when doing local code diff --git a/private/buf/bufcli/buf_work_yaml_file.go b/private/buf/bufcli/buf_work_yaml_file.go new file mode 100644 index 0000000000..f9c0d6ff10 --- /dev/null +++ b/private/buf/bufcli/buf_work_yaml_file.go @@ -0,0 +1,33 @@ +// Copyright 2020-2024 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package bufcli + +import ( + "context" + + "github.com/bufbuild/buf/private/bufpkg/bufconfig" +) + +// GetBufWorkYAMLFileForDirPath gets the buf.work.yaml file for the directory path. +func GetBufWorkYAMLFileForDirPath( + ctx context.Context, + dirPath string, +) (bufconfig.BufWorkYAMLFile, error) { + bucket, err := newOSReadWriteBucketWithSymlinks(dirPath) + if err != nil { + return nil, err + } + return bufconfig.GetBufWorkYAMLFileForPrefix(ctx, bucket, ".") +} diff --git a/private/buf/cmd/buf/buf.go b/private/buf/cmd/buf/buf.go index 10b453282c..5166d9148c 100644 --- a/private/buf/cmd/buf/buf.go +++ b/private/buf/cmd/buf/buf.go @@ -60,6 +60,7 @@ import ( "github.com/bufbuild/buf/private/buf/cmd/buf/command/config/configinit" "github.com/bufbuild/buf/private/buf/cmd/buf/command/config/configlsbreakingrules" "github.com/bufbuild/buf/private/buf/cmd/buf/command/config/configlslintrules" + "github.com/bufbuild/buf/private/buf/cmd/buf/command/config/configlsmodules" "github.com/bufbuild/buf/private/buf/cmd/buf/command/config/configmigrate" "github.com/bufbuild/buf/private/buf/cmd/buf/command/convert" "github.com/bufbuild/buf/private/buf/cmd/buf/command/curl" @@ -137,6 +138,7 @@ func NewRootCommand(name string) *appcmd.Command { configmigrate.NewCommand("migrate", builder), configlslintrules.NewCommand("ls-lint-rules", builder), configlsbreakingrules.NewCommand("ls-breaking-rules", builder), + configlsmodules.NewCommand("ls-modules", builder), }, }, { diff --git a/private/buf/cmd/buf/buf_test.go b/private/buf/cmd/buf/buf_test.go index 0707b2ddd7..a4626cc06c 100644 --- a/private/buf/cmd/buf/buf_test.go +++ b/private/buf/cmd/buf/buf_test.go @@ -36,6 +36,7 @@ import ( imagev1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/image/v1" "github.com/bufbuild/buf/private/pkg/app/appcmd" "github.com/bufbuild/buf/private/pkg/app/appcmd/appcmdtesting" + "github.com/bufbuild/buf/private/pkg/osext" "github.com/bufbuild/buf/private/pkg/slicesext" "github.com/bufbuild/buf/private/pkg/storage/storageos" "github.com/bufbuild/buf/private/pkg/storage/storagetesting" @@ -1027,6 +1028,549 @@ func TestCheckLsBreakingRulesFromConfigExceptDeprecated(t *testing.T) { } } +func TestLsModulesWorkspaceV1(t *testing.T) { + // Cannot be parallel since we chdir. + pwd, err := osext.Getwd() + require.NoError(t, err) + defer func() { + r := recover() + assert.NoError(t, osext.Chdir(pwd)) + if r != nil { + panic(r) + } + }() + + require.NoError(t, osext.Chdir(filepath.Join(pwd, "testdata", "lsmodules", "workspacev1"))) + testRunStdout( + t, + nil, + 0, + // default format is path + ` +a_v1 +b_no_name_v1 +c_v1beta1 +d_no_file +e_no_file +f_no_name_v1beta1 +`, + "config", + "ls-modules", + ) + testRunStdout( + t, + nil, + 0, + // format as path + ` +a_v1 +b_no_name_v1 +c_v1beta1 +d_no_file +e_no_file +f_no_name_v1beta1 +`, + "config", + "ls-modules", + "--format", + "path", + ) + testRunStdout( + t, + nil, + 0, + // format as name + ` +buf.build/bar/baz +buf.build/foo/bar +`, + "config", + "ls-modules", + "--format", + "name", + ) + testRunStdout( + t, + nil, + 0, + // format as json, sort by path + ` +{"path":"a_v1","name":"buf.build/foo/bar"} +{"path":"b_no_name_v1","name":""} +{"path":"c_v1beta1","name":"buf.build/bar/baz"} +{"path":"d_no_file","name":""} +{"path":"e_no_file","name":""} +{"path":"f_no_name_v1beta1","name":""} +`, + "config", + "ls-modules", + "--format", + "json", + ) +} + +func TestLsModulesWorkspaceV2(t *testing.T) { + // Cannot be parallel since we chdir. + pwd, err := osext.Getwd() + require.NoError(t, err) + defer func() { + r := recover() + assert.NoError(t, osext.Chdir(pwd)) + if r != nil { + panic(r) + } + }() + + require.NoError(t, osext.Chdir(filepath.Join(pwd, "testdata", "lsmodules", "workspacev2"))) + testRunStdout( + t, + nil, + 0, + // default format is path + ` +a +b_no_name +c +d_no_name +`, + "config", + "ls-modules", + ) + testRunStdout( + t, + nil, + 0, + // format as path + ` +a +b_no_name +c +d_no_name +`, + "config", + "ls-modules", + "--format", + "path", + ) + testRunStdout( + t, + nil, + 0, + // format as name + ` +buf.build/bar/baz +buf.build/foo/bar +`, + "config", + "ls-modules", + "--format", + "name", + ) + testRunStdout( + t, + nil, + 0, + // format as json, sort by path + ` +{"path":"a","name":"buf.build/foo/bar"} +{"path":"b_no_name","name":""} +{"path":"c","name":"buf.build/bar/baz"} +{"path":"d_no_name","name":""} +`, + "config", + "ls-modules", + "--format", + "json", + ) +} + +func TestLsModulesModuleV1(t *testing.T) { + // Cannot be parallel since we chdir. + pwd, err := osext.Getwd() + require.NoError(t, err) + defer func() { + r := recover() + assert.NoError(t, osext.Chdir(pwd)) + if r != nil { + panic(r) + } + }() + + // with name + require.NoError(t, osext.Chdir(filepath.Join(pwd, "testdata", "lsmodules", "workspacev1", "a_v1"))) + testRunStdout( + t, + nil, + 0, + // default format is path + ".", + "config", + "ls-modules", + ) + testRunStdout( + t, + nil, + 0, + ".", + "config", + "ls-modules", + "--format", + "path", + ) + testRunStdout( + t, + nil, + 0, + ` +buf.build/foo/bar +`, + "config", + "ls-modules", + "--format", + "name", + ) + testRunStdout( + t, + nil, + 0, + `{"path":".","name":"buf.build/foo/bar"}`, + "config", + "ls-modules", + "--format", + "json", + ) + // without name + require.NoError(t, osext.Chdir(filepath.Join(pwd, "testdata", "lsmodules", "workspacev1", "b_no_name_v1"))) + testRunStdout( + t, + nil, + 0, + // default format is path + ".", + "config", + "ls-modules", + ) + testRunStdout( + t, + nil, + 0, + ".", + "config", + "ls-modules", + "--format", + "path", + ) + testRunStdout( + t, + nil, + 0, + "", // empty output + "config", + "ls-modules", + "--format", + "name", + ) + testRunStdout( + t, + nil, + 0, + `{"path":".","name":""}`, + "config", + "ls-modules", + "--format", + "json", + ) +} + +func TestLsModulesModuleV1Beta1(t *testing.T) { + // Cannot be parallel since we chdir. + pwd, err := osext.Getwd() + require.NoError(t, err) + defer func() { + r := recover() + assert.NoError(t, osext.Chdir(pwd)) + if r != nil { + panic(r) + } + }() + + // with name + require.NoError(t, osext.Chdir(filepath.Join(pwd, "testdata", "lsmodules", "workspacev1", "c_v1beta1"))) + testRunStdout( + t, + nil, + 0, + // default format is path + ".", + "config", + "ls-modules", + ) + testRunStdout( + t, + nil, + 0, + ".", + "config", + "ls-modules", + "--format", + "path", + ) + testRunStdout( + t, + nil, + 0, + "buf.build/bar/baz", + "config", + "ls-modules", + "--format", + "name", + ) + testRunStdout( + t, + nil, + 0, + `{"path":".","name":"buf.build/bar/baz"}`, + "config", + "ls-modules", + "--format", + "json", + ) + // without name + require.NoError(t, osext.Chdir(filepath.Join(pwd, "testdata", "lsmodules", "workspacev1", "f_no_name_v1beta1"))) + testRunStdout( + t, + nil, + 0, + // default format is path + ".", + "config", + "ls-modules", + ) + testRunStdout( + t, + nil, + 0, + ".", + "config", + "ls-modules", + "--format", + "path", + ) + testRunStdout( + t, + nil, + 0, + "", // empty output + "config", + "ls-modules", + "--format", + "name", + ) + testRunStdout( + t, + nil, + 0, + `{"path":".","name":""}`, + "config", + "ls-modules", + "--format", + "json", + ) +} + +func TestLsModulesNoConfig(t *testing.T) { + // Cannot be parallel since we chdir. + pwd, err := osext.Getwd() + require.NoError(t, err) + defer func() { + r := recover() + assert.NoError(t, osext.Chdir(pwd)) + if r != nil { + panic(r) + } + }() + + // with name + require.NoError(t, osext.Chdir(t.TempDir())) + testRunStdout( + t, + nil, + 0, + // default format is path + ".", + "config", + "ls-modules", + ) + testRunStdout( + t, + nil, + 0, + ".", + "config", + "ls-modules", + "--format", + "path", + ) + testRunStdout( + t, + nil, + 0, + "", + "config", + "ls-modules", + "--format", + "name", + ) + testRunStdout( + t, + nil, + 0, + `{"path":".","name":""}`, + "config", + "ls-modules", + "--format", + "json", + ) +} + +func TestLsModulesBothConfig(t *testing.T) { + // Cannot be parallel since we chdir. + pwd, err := osext.Getwd() + require.NoError(t, err) + defer func() { + r := recover() + assert.NoError(t, osext.Chdir(pwd)) + if r != nil { + panic(r) + } + }() + + require.NoError(t, osext.Chdir(filepath.Join(pwd, "testdata", "lsmodules", "extraconfigv1"))) + testRunStderrContainsNoWarn( + t, + nil, + 1, + []string{"buf.yaml", "buf.work.yaml"}, + "config", + "ls-modules", + ) + + require.NoError(t, osext.Chdir(filepath.Join(pwd, "testdata", "lsmodules", "extraconfigv2"))) + testRunStderrContainsNoWarn( + t, + nil, + 1, + []string{"buf.yaml", "buf.work.yaml"}, + "config", + "ls-modules", + ) +} + +func TestLsModulesInvalidVersion(t *testing.T) { + // Cannot be parallel since we chdir. + pwd, err := osext.Getwd() + require.NoError(t, err) + defer func() { + r := recover() + assert.NoError(t, osext.Chdir(pwd)) + if r != nil { + panic(r) + } + }() + + require.NoError(t, osext.Chdir(filepath.Join(pwd, "testdata", "lsmodules", "workspaceinvalid"))) + testRunStderr( + t, + nil, + 1, + `Failure: buf.work.yaml pointed to directory "proto" which has a v2 buf.yaml file`, + "config", + "ls-modules", + ) +} + +func TestLsModulesConfigFlag(t *testing.T) { + t.Parallel() + + // v1beta1 + testRunStdout( + t, + nil, + 0, + `{"path":".","name":"buf.build/bar/baz"}`, + "config", + "ls-modules", + "--config", + filepath.Join("testdata", "lsmodules", "workspacev1", "c_v1beta1", "buf.yaml"), + "--format", + "json", + ) + + // v1 + testRunStdout( + t, + nil, + 0, + `{"path":".","name":"buf.build/foo/bar"}`, + "config", + "ls-modules", + "--config", + filepath.Join("testdata", "lsmodules", "workspacev1", "a_v1", "buf.yaml"), + "--format", + "json", + ) + + // v2 + testRunStdout( + t, + nil, + 0, + ` +{"path":"a","name":"buf.build/foo/bar"} +{"path":"b_no_name","name":""} +{"path":"c","name":"buf.build/bar/baz"} +{"path":"d_no_name","name":""} +`, + "config", + "ls-modules", + "--config", + filepath.Join("testdata", "lsmodules", "workspacev2", "buf.yaml"), + "--format", + "json", + ) +} + +func TestLsModulesConfigPrecedence(t *testing.T) { + // Cannot be parallel since we chdir. + pwd, err := osext.Getwd() + require.NoError(t, err) + defer func() { + r := recover() + assert.NoError(t, osext.Chdir(pwd)) + if r != nil { + panic(r) + } + }() + + require.NoError(t, osext.Chdir(filepath.Join(pwd, "testdata", "lsmodules", "workspacev1"))) + testRunStdout( + t, + nil, + 0, + // default format is path + ` +a +b_no_name +c +d_no_name +`, + "config", + "ls-modules", + "--config", + filepath.Join(pwd, "testdata", "lsmodules", "workspacev2", "buf.yaml"), + ) +} + func TestLsBreakingRulesDeprecated(t *testing.T) { t.Parallel() diff --git a/private/buf/cmd/buf/command/config/configlsmodules/configlsmodules.go b/private/buf/cmd/buf/command/config/configlsmodules/configlsmodules.go new file mode 100644 index 0000000000..ebe075f35a --- /dev/null +++ b/private/buf/cmd/buf/command/config/configlsmodules/configlsmodules.go @@ -0,0 +1,294 @@ +// Copyright 2020-2024 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package configlsmodules + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "io/fs" + "sort" + + "github.com/bufbuild/buf/private/buf/bufcli" + "github.com/bufbuild/buf/private/bufpkg/bufconfig" + "github.com/bufbuild/buf/private/pkg/app" + "github.com/bufbuild/buf/private/pkg/app/appcmd" + "github.com/bufbuild/buf/private/pkg/app/appext" + "github.com/bufbuild/buf/private/pkg/stringutil" + "github.com/bufbuild/buf/private/pkg/syserror" + "github.com/spf13/pflag" +) + +const ( + configFlagName = "config" + formatFlagName = "format" + + formatPath = "path" + formatName = "name" + formatJSON = "json" + + defaultFormat = formatPath +) + +var ( + allFormats = []string{ + formatPath, + formatName, + formatJSON, + } +) + +// NewCommand returns a new Command. +func NewCommand( + name string, + builder appext.SubCommandBuilder, +) *appcmd.Command { + flags := newFlags() + return &appcmd.Command{ + Use: name, + Short: "List configured modules", + Args: appcmd.NoArgs, + Run: builder.NewRunFunc( + func(ctx context.Context, container appext.Container) error { + return run(ctx, container, flags) + }, + ), + BindFlags: flags.Bind, + } +} + +type flags struct { + Config string + Format string +} + +func newFlags() *flags { + return &flags{} +} + +func (f *flags) Bind(flagSet *pflag.FlagSet) { + flagSet.StringVar( + &f.Config, + configFlagName, + "", + `The buf.yaml file or data to use for configuration.`, + ) + flagSet.StringVar( + &f.Format, + formatFlagName, + defaultFormat, + fmt.Sprintf( + "The format to print rules as. Must be one of %s", + stringutil.SliceToString(allFormats), + ), + ) +} + +func run( + ctx context.Context, + container appext.Container, + flags *flags, +) error { + externalModules, err := getExternalModules(ctx, flags.Config) + if err != nil { + return err + } + return printExternalModules(ctx, container, flags.Format, externalModules) +} + +func getExternalModules( + ctx context.Context, + configOverride string, +) ([]*externalModule, error) { + // If an override is specified, read buf.yaml from it. + if configOverride != "" { + bufYAMLFile, err := bufconfig.GetBufYAMLFileForOverride(configOverride) + if err != nil { + return nil, err + } + return getExternalModulesForBufYAMLFile(ctx, bufYAMLFile) + } + // First, look for a buf.work.yaml file. + bufWorkYAMLFile, err := bufcli.GetBufWorkYAMLFileForDirPath(ctx, ".") + if err != nil { + if !errors.Is(err, fs.ErrNotExist) { + return nil, err + } + // We do not have a buf.work.yaml file, attempt to read a buf.yaml file. + bufYAMLFile, err := bufcli.GetBufYAMLFileForDirPath(ctx, ".") + if err != nil { + if !errors.Is(err, fs.ErrNotExist) { + return nil, err + } + // We do not have a buf.work.yaml or buf.yaml file, use the default. + bufYAMLFile, err = bufconfig.NewBufYAMLFile( + bufconfig.FileVersionV2, + []bufconfig.ModuleConfig{ + bufconfig.DefaultModuleConfigV2, + }, + nil, + ) + if err != nil { + return nil, err + } + } + // This handles both buf.yaml file and no file courtesy of the above logic. + return getExternalModulesForBufYAMLFile(ctx, bufYAMLFile) + } + // We did have a buf.work.yaml file, but before handling it, check there is not a buf.yaml. + _, err = bufcli.GetBufYAMLFileForDirPath(ctx, ".") + if err != nil && !errors.Is(err, fs.ErrNotExist) { + return nil, err + } + if err == nil { + return nil, errors.New("Both buf.work.yaml and buf.yaml found. It is not valid to have a buf.work.yaml and buf.yaml in the same directory, buf.work.yaml specifies a workspace of modules, while buf.yaml either specifies a single module or a workspace of modules itself.") + } + // Handle the buf.work.yaml. + return getExternalModulesForBufWorkYAMLFile(ctx, bufWorkYAMLFile) +} + +func getExternalModulesForBufWorkYAMLFile( + ctx context.Context, + bufWorkYAMLFile bufconfig.BufWorkYAMLFile, +) ([]*externalModule, error) { + var externalModules []*externalModule + for _, dirPath := range bufWorkYAMLFile.DirPaths() { + bufYAMLFile, err := bufcli.GetBufYAMLFileForDirPath(ctx, dirPath) + if err != nil { + if !errors.Is(err, fs.ErrNotExist) { + return nil, err + } + externalModules = append( + externalModules, + newExternalModule(dirPath, ""), + ) + continue + } + // This is a sanity check. Make sure we have what we expect. + switch bufYAMLFile.FileVersion() { + case bufconfig.FileVersionV1Beta1, bufconfig.FileVersionV1: + moduleConfigs := bufYAMLFile.ModuleConfigs() + if len(moduleConfigs) != 1 { + return nil, syserror.Newf("got BufYAMLFile at %q with FileVersion %v with %d ModuleConfigs", dirPath, bufYAMLFile.FileVersion(), len(moduleConfigs)) + } + moduleConfig := moduleConfigs[0] + if moduleConfig.DirPath() != "." { + return nil, syserror.Newf("got BufYAMLFile at %q with FileVersion %v with ModuleConfig that had non-root DirPath %q", dirPath, bufYAMLFile.FileVersion(), moduleConfig.DirPath()) + } + var name string + if moduleFullName := moduleConfig.ModuleFullName(); moduleFullName != nil { + name = moduleFullName.String() + } + externalModules = append( + externalModules, + // The dirPath is the path specified in the buf.work.yaml. + // The DirPath for v1/v1beta1 ModuleConfigs is always ".". + newExternalModule(dirPath, name), + ) + case bufconfig.FileVersionV2: + return nil, fmt.Errorf("buf.work.yaml pointed to directory %q which has a v2 buf.yaml file", dirPath) + default: + return nil, syserror.Newf("unknown FileVersion: %v", bufYAMLFile.FileVersion()) + } + } + return externalModules, nil +} + +func getExternalModulesForBufYAMLFile( + ctx context.Context, + bufYAMLFile bufconfig.BufYAMLFile, +) ([]*externalModule, error) { + moduleConfigs := bufYAMLFile.ModuleConfigs() + externalModules := make([]*externalModule, len(moduleConfigs)) + for i, moduleConfig := range moduleConfigs { + var name string + if moduleFullName := moduleConfig.ModuleFullName(); moduleFullName != nil { + name = moduleFullName.String() + } + externalModules[i] = newExternalModule(moduleConfig.DirPath(), name) + } + return externalModules, nil +} + +func printExternalModules( + ctx context.Context, + container app.StdoutContainer, + format string, + externalModules []*externalModule, +) error { + switch format { + case formatPath: + sort.Slice( + externalModules, + func(i int, j int) bool { + return externalModules[i].Path < externalModules[j].Path + }, + ) + for _, externalModule := range externalModules { + if _, err := container.Stdout().Write([]byte(externalModule.Path + "\n")); err != nil { + return err + } + } + return nil + case formatName: + sort.Slice( + externalModules, + func(i int, j int) bool { + return externalModules[i].Name < externalModules[j].Name + }, + ) + for _, externalModule := range externalModules { + if externalModule.Name == "" { + continue + } + if _, err := container.Stdout().Write([]byte(externalModule.Name + "\n")); err != nil { + return err + } + } + return nil + case formatJSON: + sort.Slice( + externalModules, + func(i int, j int) bool { + return externalModules[i].Path < externalModules[j].Path + }, + ) + for _, externalModule := range externalModules { + data, err := json.Marshal(externalModule) + if err != nil { + return err + } + if _, err := container.Stdout().Write([]byte(string(data) + "\n")); err != nil { + return err + } + } + return nil + default: + return appcmd.NewInvalidArgumentErrorf("unknown value for --%s: %s", formatFlagName, format) + } +} + +type externalModule struct { + Path string `json:"path" yaml:"path"` + Name string `json:"name" yaml:"name"` +} + +func newExternalModule(path string, name string) *externalModule { + return &externalModule{ + Path: path, + Name: name, + } +} diff --git a/private/buf/cmd/buf/command/config/configlsmodules/usage.gen.go b/private/buf/cmd/buf/command/config/configlsmodules/usage.gen.go new file mode 100644 index 0000000000..3287ac9e6b --- /dev/null +++ b/private/buf/cmd/buf/command/config/configlsmodules/usage.gen.go @@ -0,0 +1,19 @@ +// Copyright 2020-2024 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated. DO NOT EDIT. + +package configlsmodules + +import _ "github.com/bufbuild/buf/private/usage" diff --git a/private/buf/cmd/buf/testdata/lsmodules/extraconfigv1/buf.work.yaml b/private/buf/cmd/buf/testdata/lsmodules/extraconfigv1/buf.work.yaml new file mode 100644 index 0000000000..7a18eb0259 --- /dev/null +++ b/private/buf/cmd/buf/testdata/lsmodules/extraconfigv1/buf.work.yaml @@ -0,0 +1,3 @@ +version: v1 +directories: + - proto \ No newline at end of file diff --git a/private/buf/cmd/buf/testdata/lsmodules/extraconfigv1/buf.yaml b/private/buf/cmd/buf/testdata/lsmodules/extraconfigv1/buf.yaml new file mode 100644 index 0000000000..5830b70ead --- /dev/null +++ b/private/buf/cmd/buf/testdata/lsmodules/extraconfigv1/buf.yaml @@ -0,0 +1 @@ +version: v1 \ No newline at end of file diff --git a/private/buf/cmd/buf/testdata/lsmodules/extraconfigv1/proto/a.proto b/private/buf/cmd/buf/testdata/lsmodules/extraconfigv1/proto/a.proto new file mode 100644 index 0000000000..e69de29bb2 diff --git a/private/buf/cmd/buf/testdata/lsmodules/extraconfigv2/buf.work.yaml b/private/buf/cmd/buf/testdata/lsmodules/extraconfigv2/buf.work.yaml new file mode 100644 index 0000000000..7a18eb0259 --- /dev/null +++ b/private/buf/cmd/buf/testdata/lsmodules/extraconfigv2/buf.work.yaml @@ -0,0 +1,3 @@ +version: v1 +directories: + - proto \ No newline at end of file diff --git a/private/buf/cmd/buf/testdata/lsmodules/extraconfigv2/buf.yaml b/private/buf/cmd/buf/testdata/lsmodules/extraconfigv2/buf.yaml new file mode 100644 index 0000000000..448778b4af --- /dev/null +++ b/private/buf/cmd/buf/testdata/lsmodules/extraconfigv2/buf.yaml @@ -0,0 +1,3 @@ +version: v2 +modules: + - path: proto \ No newline at end of file diff --git a/private/buf/cmd/buf/testdata/lsmodules/extraconfigv2/proto/a.proto b/private/buf/cmd/buf/testdata/lsmodules/extraconfigv2/proto/a.proto new file mode 100644 index 0000000000..e69de29bb2 diff --git a/private/buf/cmd/buf/testdata/lsmodules/workspaceinvalid/buf.work.yaml b/private/buf/cmd/buf/testdata/lsmodules/workspaceinvalid/buf.work.yaml new file mode 100644 index 0000000000..7a18eb0259 --- /dev/null +++ b/private/buf/cmd/buf/testdata/lsmodules/workspaceinvalid/buf.work.yaml @@ -0,0 +1,3 @@ +version: v1 +directories: + - proto \ No newline at end of file diff --git a/private/buf/cmd/buf/testdata/lsmodules/workspaceinvalid/proto/buf.yaml b/private/buf/cmd/buf/testdata/lsmodules/workspaceinvalid/proto/buf.yaml new file mode 100644 index 0000000000..fa019b09e9 --- /dev/null +++ b/private/buf/cmd/buf/testdata/lsmodules/workspaceinvalid/proto/buf.yaml @@ -0,0 +1,2 @@ +# invalid because this directory is pointed to by a workspace +version: v2 diff --git a/private/buf/cmd/buf/testdata/lsmodules/workspacev1/a_v1/buf.yaml b/private/buf/cmd/buf/testdata/lsmodules/workspacev1/a_v1/buf.yaml new file mode 100644 index 0000000000..1eb35a3da9 --- /dev/null +++ b/private/buf/cmd/buf/testdata/lsmodules/workspacev1/a_v1/buf.yaml @@ -0,0 +1,2 @@ +version: v1 +name: buf.build/foo/bar \ No newline at end of file diff --git a/private/buf/cmd/buf/testdata/lsmodules/workspacev1/b_no_name_v1/buf.yaml b/private/buf/cmd/buf/testdata/lsmodules/workspacev1/b_no_name_v1/buf.yaml new file mode 100644 index 0000000000..5830b70ead --- /dev/null +++ b/private/buf/cmd/buf/testdata/lsmodules/workspacev1/b_no_name_v1/buf.yaml @@ -0,0 +1 @@ +version: v1 \ No newline at end of file diff --git a/private/buf/cmd/buf/testdata/lsmodules/workspacev1/buf.work.yaml b/private/buf/cmd/buf/testdata/lsmodules/workspacev1/buf.work.yaml new file mode 100644 index 0000000000..58ffc4376c --- /dev/null +++ b/private/buf/cmd/buf/testdata/lsmodules/workspacev1/buf.work.yaml @@ -0,0 +1,8 @@ +version: v1 +directories: + - e_no_file + - c_v1beta1 + - f_no_name_v1beta1 + - a_v1 + - d_no_file + - b_no_name_v1 \ No newline at end of file diff --git a/private/buf/cmd/buf/testdata/lsmodules/workspacev1/c_v1beta1/buf.yaml b/private/buf/cmd/buf/testdata/lsmodules/workspacev1/c_v1beta1/buf.yaml new file mode 100644 index 0000000000..2f43162480 --- /dev/null +++ b/private/buf/cmd/buf/testdata/lsmodules/workspacev1/c_v1beta1/buf.yaml @@ -0,0 +1,2 @@ +version: v1beta1 +name: buf.build/bar/baz \ No newline at end of file diff --git a/private/buf/cmd/buf/testdata/lsmodules/workspacev1/f_no_name_v1beta1/buf.yaml b/private/buf/cmd/buf/testdata/lsmodules/workspacev1/f_no_name_v1beta1/buf.yaml new file mode 100644 index 0000000000..fed041e0d2 --- /dev/null +++ b/private/buf/cmd/buf/testdata/lsmodules/workspacev1/f_no_name_v1beta1/buf.yaml @@ -0,0 +1 @@ +version: v1beta1 \ No newline at end of file diff --git a/private/buf/cmd/buf/testdata/lsmodules/workspacev1/not_pointed_by_workspace/buf.yaml b/private/buf/cmd/buf/testdata/lsmodules/workspacev1/not_pointed_by_workspace/buf.yaml new file mode 100644 index 0000000000..80b107f3f7 --- /dev/null +++ b/private/buf/cmd/buf/testdata/lsmodules/workspacev1/not_pointed_by_workspace/buf.yaml @@ -0,0 +1,2 @@ +version: v1 +name: buf.build/acme/weather \ No newline at end of file diff --git a/private/buf/cmd/buf/testdata/lsmodules/workspacev2/buf.yaml b/private/buf/cmd/buf/testdata/lsmodules/workspacev2/buf.yaml new file mode 100644 index 0000000000..b7847897bd --- /dev/null +++ b/private/buf/cmd/buf/testdata/lsmodules/workspacev2/buf.yaml @@ -0,0 +1,8 @@ +version: v2 +modules: + - path: d_no_name + - path: c + name: buf.build/bar/baz + - path: a + name: buf.build/foo/bar + - path: b_no_name \ No newline at end of file