Skip to content

Commit

Permalink
Make generate config types/files/variables consistent with naming (#3241
Browse files Browse the repository at this point in the history
)
  • Loading branch information
bufdev authored Aug 15, 2024
1 parent 3aaecdc commit c11801c
Show file tree
Hide file tree
Showing 4 changed files with 277 additions and 277 deletions.
62 changes: 31 additions & 31 deletions private/bufpkg/bufconfig/generate_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,95 +42,95 @@ type GenerateConfig interface {
// NewGenerateConfig returns a validated GenerateConfig.
func NewGenerateConfig(
cleanPluginOuts bool,
pluginConfigs []GeneratePluginConfig,
managedConfig GenerateManagedConfig,
typeConfig GenerateTypeConfig,
generatePluginConfigs []GeneratePluginConfig,
generateManagedConfig GenerateManagedConfig,
generateTypeConfig GenerateTypeConfig,
) (GenerateConfig, error) {
if len(pluginConfigs) == 0 {
if len(generatePluginConfigs) == 0 {
return nil, newNoPluginsError()
}
return &generateConfig{
cleanPluginOuts: cleanPluginOuts,
pluginConfigs: pluginConfigs,
managedConfig: managedConfig,
typeConfig: typeConfig,
cleanPluginOuts: cleanPluginOuts,
generatePluginConfigs: generatePluginConfigs,
generateManagedConfig: generateManagedConfig,
generateTypeConfig: generateTypeConfig,
}, nil
}

// *** PRIVATE ***

type generateConfig struct {
cleanPluginOuts bool
pluginConfigs []GeneratePluginConfig
managedConfig GenerateManagedConfig
typeConfig GenerateTypeConfig
cleanPluginOuts bool
generatePluginConfigs []GeneratePluginConfig
generateManagedConfig GenerateManagedConfig
generateTypeConfig GenerateTypeConfig
}

func newGenerateConfigFromExternalFileV1Beta1(
externalFile externalBufGenYAMLFileV1Beta1,
) (GenerateConfig, error) {
managedConfig, err := newManagedConfigFromExternalV1Beta1(externalFile.Managed, externalFile.Options)
generateManagedConfig, err := newGenerateManagedConfigFromExternalV1Beta1(externalFile.Managed, externalFile.Options)
if err != nil {
return nil, err
}
if len(externalFile.Plugins) == 0 {
return nil, newNoPluginsError()
}
pluginConfigs, err := slicesext.MapError(
generatePluginConfigs, err := slicesext.MapError(
externalFile.Plugins,
newPluginConfigFromExternalV1Beta1,
newGeneratePluginConfigFromExternalV1Beta1,
)
if err != nil {
return nil, err
}
return &generateConfig{
pluginConfigs: pluginConfigs,
managedConfig: managedConfig,
generatePluginConfigs: generatePluginConfigs,
generateManagedConfig: generateManagedConfig,
}, nil
}

func newGenerateConfigFromExternalFileV1(
externalFile externalBufGenYAMLFileV1,
) (GenerateConfig, error) {
managedConfig, err := newManagedConfigFromExternalV1(externalFile.Managed)
generateManagedConfig, err := newGenerateManagedConfigFromExternalV1(externalFile.Managed)
if err != nil {
return nil, err
}
if len(externalFile.Plugins) == 0 {
return nil, newNoPluginsError()
}
pluginConfigs, err := slicesext.MapError(
generatePluginConfigs, err := slicesext.MapError(
externalFile.Plugins,
newPluginConfigFromExternalV1,
newGeneratePluginConfigFromExternalV1,
)
if err != nil {
return nil, err
}
return &generateConfig{
pluginConfigs: pluginConfigs,
managedConfig: managedConfig,
typeConfig: newGenerateTypeConfig(externalFile.Types.Include),
generatePluginConfigs: generatePluginConfigs,
generateManagedConfig: generateManagedConfig,
generateTypeConfig: newGenerateTypeConfig(externalFile.Types.Include),
}, nil
}

func newGenerateConfigFromExternalFileV2(
externalFile externalBufGenYAMLFileV2,
) (GenerateConfig, error) {
managedConfig, err := newManagedConfigFromExternalV2(externalFile.Managed)
generateManagedConfig, err := newGenerateManagedConfigFromExternalV2(externalFile.Managed)
if err != nil {
return nil, err
}
pluginConfigs, err := slicesext.MapError(
generatePluginConfigs, err := slicesext.MapError(
externalFile.Plugins,
newPluginConfigFromExternalV2,
)
if err != nil {
return nil, err
}
return &generateConfig{
cleanPluginOuts: externalFile.Clean,
managedConfig: managedConfig,
pluginConfigs: pluginConfigs,
cleanPluginOuts: externalFile.Clean,
generateManagedConfig: generateManagedConfig,
generatePluginConfigs: generatePluginConfigs,
}, nil
}

Expand All @@ -139,15 +139,15 @@ func (g *generateConfig) CleanPluginOuts() bool {
}

func (g *generateConfig) GeneratePluginConfigs() []GeneratePluginConfig {
return g.pluginConfigs
return g.generatePluginConfigs
}

func (g *generateConfig) GenerateManagedConfig() GenerateManagedConfig {
return g.managedConfig
return g.generateManagedConfig
}

func (g *generateConfig) GenerateTypeConfig() GenerateTypeConfig {
return g.typeConfig
return g.generateTypeConfig
}

func (*generateConfig) isGenerateConfig() {}
Expand Down
Loading

0 comments on commit c11801c

Please sign in to comment.