Skip to content

Commit

Permalink
feat: convert config struct to proto message
Browse files Browse the repository at this point in the history
  • Loading branch information
christophwitzko committed Oct 24, 2023
1 parent dddfd54 commit 1d1e036
Show file tree
Hide file tree
Showing 18 changed files with 588 additions and 56 deletions.
4 changes: 2 additions & 2 deletions cmd/semantic-release/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,14 @@ func cliHandler(cmd *cobra.Command, _ []string) {

exitIfError(hooksExecutor.Init(hooksConfig))

if !conf.NoCI {
if !conf.NoCi {
logger.Println("running CI condition...")
conditionConfig := map[string]string{
"token": conf.Token,
"defaultBranch": repoInfo.DefaultBranch,
"private": fmt.Sprintf("%t", repoInfo.Private),
}
mergeConfigWithDefaults(conditionConfig, conf.CIConditionOpts)
mergeConfigWithDefaults(conditionConfig, conf.CiConditionOpts)

err = ci.RunCondition(conditionConfig)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/commit_analyzer.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/analyzer/commit_analyzer_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/condition/ci_condition.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/condition/ci_condition_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 3 additions & 39 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,6 @@ import (
"github.com/spf13/viper"
)

// Config is a complete set of app configuration
type Config struct {
Token string
ProviderPlugin string
ProviderOpts map[string]string
CommitAnalyzerPlugin string
CommitAnalyzerOpts map[string]string
CIConditionPlugin string
CIConditionOpts map[string]string
ChangelogGeneratorPlugin string
ChangelogGeneratorOpts map[string]string
Changelog string
FilesUpdaterPlugins []string
FilesUpdaterOpts map[string]string
HooksPlugins []string
HooksOpts map[string]string
UpdateFiles []string
Match string
VersionFile bool
Prerelease bool
Ghr bool
NoCI bool
Dry bool
AllowInitialDevelopmentVersions bool
AllowNoChanges bool
ForceBumpPatchVersion bool
MaintainedVersion string
PrependChangelog bool
DownloadPlugins bool
ShowProgress bool
AllowMaintainedVersionOnDefaultBranch bool
PluginResolver string
PluginResolverEndpoint string
PluginResolverDisableBatchPrefetch bool
}

func mustGetString(cmd *cobra.Command, name string) string {
res, err := cmd.Flags().GetString(name)
if err != nil {
Expand Down Expand Up @@ -110,8 +74,8 @@ func NewConfig(cmd *cobra.Command) (*Config, error) {
ProviderOpts: provOpts,
CommitAnalyzerPlugin: viper.GetString("plugins.commit-analyzer.name"),
CommitAnalyzerOpts: caOpts,
CIConditionPlugin: viper.GetString("plugins.ci-condition.name"),
CIConditionOpts: ciOpts,
CiConditionPlugin: viper.GetString("plugins.ci-condition.name"),
CiConditionOpts: ciOpts,
ChangelogGeneratorPlugin: viper.GetString("plugins.changelog-generator.name"),
ChangelogGeneratorOpts: cgOpts,
Changelog: mustGetString(cmd, "changelog"),
Expand All @@ -124,7 +88,7 @@ func NewConfig(cmd *cobra.Command) (*Config, error) {
VersionFile: mustGetBool(cmd, "version-file"),
Prerelease: mustGetBool(cmd, "prerelease"),
Ghr: mustGetBool(cmd, "ghr"),
NoCI: mustGetBool(cmd, "no-ci"),
NoCi: mustGetBool(cmd, "no-ci"),
Dry: mustGetBool(cmd, "dry"),
AllowInitialDevelopmentVersions: mustGetBool(cmd, "allow-initial-development-versions"),
AllowNoChanges: mustGetBool(cmd, "allow-no-changes"),
Expand Down
Loading

0 comments on commit 1d1e036

Please sign in to comment.