Skip to content

Commit

Permalink
Add "skip_release" module attribute
Browse files Browse the repository at this point in the history
If a module has "skip_release" set to true, the apply-manifest command
removes the module from the project before starting a release build.
  • Loading branch information
bernd committed Jun 13, 2024
1 parent 866bd24 commit 536f815
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/apply_manifest.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"fmt"
"github.com/Graylog2/graylog-project-cli/apply"
"github.com/Graylog2/graylog-project-cli/git"
"github.com/Graylog2/graylog-project-cli/logger"
Expand All @@ -11,6 +12,7 @@ import (
"github.com/Graylog2/graylog-project-cli/utils"
"github.com/fatih/color"
"github.com/hashicorp/go-version"
"github.com/samber/lo"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"os"
Expand Down Expand Up @@ -79,6 +81,14 @@ func applyManifestCommand(cmd *cobra.Command, args []string) {
logger.ColorInfo(color.FgYellow, "===> %s", message)
}

// Remove modules that should not be part of the release build.
proj.Modules = lo.Filter(proj.Modules, func(item project.Module, index int) bool {
if item.SkipRelease {
msg(fmt.Sprintf("Skipping release for module %s", item.Name))
}
return !item.SkipRelease
})

msg("Sanity check for apply manifest")
applyManifestErrors := 0
apply.ForEachModule(proj, false, func(module project.Module) {
Expand Down
1 change: 1 addition & 0 deletions manifest/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type ManifestModule struct {
Server bool `json:"server,omitempty"`
SubModules []ManifestModule `json:"submodules,omitempty"`
Apply ManifestApply `json:"apply,omitempty"`
SkipRelease bool `json:"skip_release,ommitempty"`
}

func (mod ManifestModule) HasSubmodules() bool {
Expand Down
3 changes: 3 additions & 0 deletions project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Module struct {
Submodules []Module
apply Apply
ApplyExecute bool
SkipRelease bool
}

func (module *Module) IsMavenModule() bool {
Expand Down Expand Up @@ -214,6 +215,7 @@ func New(config config.Config, manifestFiles []string, options ...projectOption)
Revision: module.Revision,
Assemblies: submodule.Assemblies,
AssemblyAttachment: submodule.AssemblyAttachment,
SkipRelease: submodule.SkipRelease,
apply: submoduleApply,
})
}
Expand All @@ -234,6 +236,7 @@ func New(config config.Config, manifestFiles []string, options ...projectOption)
BaseRevision: module.Revision,
Assemblies: module.Assemblies,
AssemblyAttachment: module.AssemblyAttachment,
SkipRelease: module.SkipRelease,
Server: module.Server,
Submodules: submodules,
apply: moduleApply,
Expand Down

0 comments on commit 536f815

Please # to comment.