Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete PLUGIN_REGISTRY_TYPE_ARCHIVE #2849

Merged
merged 4 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions private/bufpkg/bufplugin/bufplugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ func PluginToProtoPluginRegistryType(plugin Plugin) registryv1alpha1.PluginRegis
registryType = registryv1alpha1.PluginRegistryType_PLUGIN_REGISTRY_TYPE_SWIFT
} else if plugin.Registry().Python != nil {
registryType = registryv1alpha1.PluginRegistryType_PLUGIN_REGISTRY_TYPE_PYTHON
} else if plugin.Registry().Archive != nil {
registryType = registryv1alpha1.PluginRegistryType_PLUGIN_REGISTRY_TYPE_ARCHIVE
}
}
return registryType
Expand Down Expand Up @@ -197,12 +195,6 @@ func PluginRegistryToProtoRegistryConfig(pluginRegistry *bufpluginconfig.Registr
return nil, err
}
registryConfig.RegistryConfig = &registryv1alpha1.RegistryConfig_PythonConfig{PythonConfig: pythonConfig}
} else if pluginRegistry.Archive != nil {
archiveConfig, err := ArchiveRegistryConfigToProtoArchiveConfig(pluginRegistry.Archive)
if err != nil {
return nil, err
}
registryConfig.RegistryConfig = &registryv1alpha1.RegistryConfig_ArchiveConfig{ArchiveConfig: archiveConfig}
}
return registryConfig, nil
}
Expand Down Expand Up @@ -272,12 +264,6 @@ func ProtoRegistryConfigToPluginRegistry(config *registryv1alpha1.RegistryConfig
return nil, err
}
registryConfig.Python = pythonConfig
} else if protoArchiveConfig := config.GetArchiveConfig(); protoArchiveConfig != nil {
archiveConfig, err := ProtoArchiveConfigToArchiveRegistryConfig(protoArchiveConfig)
if err != nil {
return nil, err
}
registryConfig.Archive = archiveConfig
}
return registryConfig, nil
}
Expand Down Expand Up @@ -320,14 +306,6 @@ func PythonRegistryConfigToProtoPythonConfig(pythonConfig *bufpluginconfig.Pytho
return protoPythonConfig, nil
}

func ProtoArchiveConfigToArchiveRegistryConfig(protoArchiveConfig *registryv1alpha1.ArchiveConfig) (*bufpluginconfig.ArchiveRegistryConfig, error) {
return &bufpluginconfig.ArchiveRegistryConfig{}, nil
}

func ArchiveRegistryConfigToProtoArchiveConfig(archiveConfig *bufpluginconfig.ArchiveRegistryConfig) (*registryv1alpha1.ArchiveConfig, error) {
return &registryv1alpha1.ArchiveConfig{}, nil
}

func ProtoSwiftConfigToSwiftRegistryConfig(protoSwiftConfig *registryv1alpha1.SwiftConfig) (*bufpluginconfig.SwiftRegistryConfig, error) {
swiftConfig := &bufpluginconfig.SwiftRegistryConfig{}
runtimeLibs := protoSwiftConfig.GetRuntimeLibraries()
Expand Down
28 changes: 11 additions & 17 deletions private/bufpkg/bufplugin/bufpluginconfig/bufpluginconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,11 @@ type Config struct {
//
// Only one field will be set.
type RegistryConfig struct {
Go *GoRegistryConfig
NPM *NPMRegistryConfig
Maven *MavenRegistryConfig
Swift *SwiftRegistryConfig
Python *PythonRegistryConfig
Archive *ArchiveRegistryConfig
Go *GoRegistryConfig
NPM *NPMRegistryConfig
Maven *MavenRegistryConfig
Swift *SwiftRegistryConfig
Python *PythonRegistryConfig
// Options is the set of options passed into the plugin for the
// remote registry.
//
Expand Down Expand Up @@ -242,8 +241,6 @@ type PythonRegistryConfig struct {
PackageType string
}

type ArchiveRegistryConfig struct{}

// ConfigOption is an optional option used when loading a Config.
type ConfigOption func(*configOptions)

Expand Down Expand Up @@ -369,13 +366,12 @@ type ExternalDependency struct {
// ExternalRegistryConfig is the external configuration for the registry
// of a plugin.
type ExternalRegistryConfig struct {
Go *ExternalGoRegistryConfig `json:"go,omitempty" yaml:"go,omitempty"`
NPM *ExternalNPMRegistryConfig `json:"npm,omitempty" yaml:"npm,omitempty"`
Maven *ExternalMavenRegistryConfig `json:"maven,omitempty" yaml:"maven,omitempty"`
Swift *ExternalSwiftRegistryConfig `json:"swift,omitempty" yaml:"swift,omitempty"`
Python *ExternalPythonRegistryConfig `json:"python,omitempty" yaml:"python,omitempty"`
Archive *ExternalArchiveRegistryConfig `json:"archive,omitempty" yaml:"archive,omitempty"`
Opts []string `json:"opts,omitempty" yaml:"opts,omitempty"`
Go *ExternalGoRegistryConfig `json:"go,omitempty" yaml:"go,omitempty"`
NPM *ExternalNPMRegistryConfig `json:"npm,omitempty" yaml:"npm,omitempty"`
Maven *ExternalMavenRegistryConfig `json:"maven,omitempty" yaml:"maven,omitempty"`
Swift *ExternalSwiftRegistryConfig `json:"swift,omitempty" yaml:"swift,omitempty"`
Python *ExternalPythonRegistryConfig `json:"python,omitempty" yaml:"python,omitempty"`
Opts []string `json:"opts,omitempty" yaml:"opts,omitempty"`
}

// ExternalGoRegistryConfig is the external registry configuration for a Go plugin.
Expand Down Expand Up @@ -493,8 +489,6 @@ type ExternalPythonRegistryConfig struct {
PackageType string `json:"package_type,omitempty" yaml:"package_type,omitempty"`
}

type ExternalArchiveRegistryConfig struct{}

type externalConfigVersion struct {
Version string `json:"version,omitempty" yaml:"version,omitempty"`
}
Expand Down
23 changes: 0 additions & 23 deletions private/bufpkg/bufplugin/bufpluginconfig/bufpluginconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,29 +328,6 @@ func TestParsePluginConfigPythonYAML(t *testing.T) {
)
}

func TestParsePluginConfigArchiveYAML(t *testing.T) {
t.Parallel()
pluginConfig, err := ParseConfig(filepath.Join("testdata", "success", "archive", "buf.plugin.yaml"))
require.NoError(t, err)
pluginIdentity, err := bufpluginref.PluginIdentityForString("buf.build/community/pseudomuto-doc")
require.NoError(t, err)
require.Equal(
t,
&Config{
Name: pluginIdentity,
PluginVersion: "v1.5.1",
SourceURL: "https://github.com/pseudomuto/protoc-gen-doc",
Description: "Documentation generator plugin for Google Protocol Buffers.",
SPDXLicenseID: "MIT",
LicenseURL: "https://github.com/pseudomuto/protoc-gen-doc/blob/v1.5.1/LICENSE.md",
Registry: &RegistryConfig{
Archive: &ArchiveRegistryConfig{},
},
},
pluginConfig,
)
}

func TestParsePluginConfigOptionsYAML(t *testing.T) {
t.Parallel()
pluginConfig, err := ParseConfig(filepath.Join("testdata", "success", "options", "buf.plugin.yaml"))
Expand Down
25 changes: 5 additions & 20 deletions private/bufpkg/bufplugin/bufpluginconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,11 @@ func newConfig(externalConfig ExternalConfig, options []ConfigOption) (*Config,

func newRegistryConfig(externalRegistryConfig ExternalRegistryConfig) (*RegistryConfig, error) {
var (
isGoEmpty = externalRegistryConfig.Go == nil
isNPMEmpty = externalRegistryConfig.NPM == nil
isMavenEmpty = externalRegistryConfig.Maven == nil
isSwiftEmpty = externalRegistryConfig.Swift == nil
isPythonEmpty = externalRegistryConfig.Python == nil
isArchiveEmpty = externalRegistryConfig.Archive == nil
isGoEmpty = externalRegistryConfig.Go == nil
isNPMEmpty = externalRegistryConfig.NPM == nil
isMavenEmpty = externalRegistryConfig.Maven == nil
isSwiftEmpty = externalRegistryConfig.Swift == nil
isPythonEmpty = externalRegistryConfig.Python == nil
)
var registryCount int
for _, isEmpty := range []bool{
Expand All @@ -101,7 +100,6 @@ func newRegistryConfig(externalRegistryConfig ExternalRegistryConfig) (*Registry
isMavenEmpty,
isSwiftEmpty,
isPythonEmpty,
isArchiveEmpty,
} {
if !isEmpty {
registryCount++
Expand Down Expand Up @@ -163,15 +161,6 @@ func newRegistryConfig(externalRegistryConfig ExternalRegistryConfig) (*Registry
Python: pythonRegistryConfig,
Options: options,
}, nil
case !isArchiveEmpty:
archiveRegistryConfig, err := newArchiveRegistryConfig(externalRegistryConfig.Archive)
if err != nil {
return nil, err
}
return &RegistryConfig{
Archive: archiveRegistryConfig,
Options: options,
}, nil
default:
return nil, errors.New("unknown registry configuration")
}
Expand Down Expand Up @@ -368,10 +357,6 @@ func newPythonRegistryConfig(externalPythonRegistryConfig *ExternalPythonRegistr
}, nil
}

func newArchiveRegistryConfig(externalArchiveRegistryConfig *ExternalArchiveRegistryConfig) (*ArchiveRegistryConfig, error) {
return &ArchiveRegistryConfig{}, nil
}

func pluginIdentityForStringWithOverrideRemote(identityStr string, overrideRemote string) (bufpluginref.PluginIdentity, error) {
identity, err := bufpluginref.PluginIdentityForString(identityStr)
if err != nil {
Expand Down
Loading
Loading