Skip to content

Commit 536f815

Browse files
committed
Add "skip_release" module attribute
If a module has "skip_release" set to true, the apply-manifest command removes the module from the project before starting a release build.
1 parent 866bd24 commit 536f815

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

cmd/apply_manifest.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cmd
22

33
import (
4+
"fmt"
45
"github.com/Graylog2/graylog-project-cli/apply"
56
"github.com/Graylog2/graylog-project-cli/git"
67
"github.com/Graylog2/graylog-project-cli/logger"
@@ -11,6 +12,7 @@ import (
1112
"github.com/Graylog2/graylog-project-cli/utils"
1213
"github.com/fatih/color"
1314
"github.com/hashicorp/go-version"
15+
"github.com/samber/lo"
1416
"github.com/spf13/cobra"
1517
"github.com/spf13/viper"
1618
"os"
@@ -79,6 +81,14 @@ func applyManifestCommand(cmd *cobra.Command, args []string) {
7981
logger.ColorInfo(color.FgYellow, "===> %s", message)
8082
}
8183

84+
// Remove modules that should not be part of the release build.
85+
proj.Modules = lo.Filter(proj.Modules, func(item project.Module, index int) bool {
86+
if item.SkipRelease {
87+
msg(fmt.Sprintf("Skipping release for module %s", item.Name))
88+
}
89+
return !item.SkipRelease
90+
})
91+
8292
msg("Sanity check for apply manifest")
8393
applyManifestErrors := 0
8494
apply.ForEachModule(proj, false, func(module project.Module) {

manifest/manifest.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type ManifestModule struct {
3030
Server bool `json:"server,omitempty"`
3131
SubModules []ManifestModule `json:"submodules,omitempty"`
3232
Apply ManifestApply `json:"apply,omitempty"`
33+
SkipRelease bool `json:"skip_release,ommitempty"`
3334
}
3435

3536
func (mod ManifestModule) HasSubmodules() bool {

project/project.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type Module struct {
4141
Submodules []Module
4242
apply Apply
4343
ApplyExecute bool
44+
SkipRelease bool
4445
}
4546

4647
func (module *Module) IsMavenModule() bool {
@@ -214,6 +215,7 @@ func New(config config.Config, manifestFiles []string, options ...projectOption)
214215
Revision: module.Revision,
215216
Assemblies: submodule.Assemblies,
216217
AssemblyAttachment: submodule.AssemblyAttachment,
218+
SkipRelease: submodule.SkipRelease,
217219
apply: submoduleApply,
218220
})
219221
}
@@ -234,6 +236,7 @@ func New(config config.Config, manifestFiles []string, options ...projectOption)
234236
BaseRevision: module.Revision,
235237
Assemblies: module.Assemblies,
236238
AssemblyAttachment: module.AssemblyAttachment,
239+
SkipRelease: module.SkipRelease,
237240
Server: module.Server,
238241
Submodules: submodules,
239242
apply: moduleApply,

0 commit comments

Comments
 (0)