From 536f815df2b1b9de32af761a5ea6d42732259c2c Mon Sep 17 00:00:00 2001 From: Bernd Ahlers Date: Thu, 13 Jun 2024 11:36:35 +0200 Subject: [PATCH] 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. --- cmd/apply_manifest.go | 10 ++++++++++ manifest/manifest.go | 1 + project/project.go | 3 +++ 3 files changed, 14 insertions(+) diff --git a/cmd/apply_manifest.go b/cmd/apply_manifest.go index e3bb608a..e1285f30 100644 --- a/cmd/apply_manifest.go +++ b/cmd/apply_manifest.go @@ -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" @@ -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" @@ -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) { diff --git a/manifest/manifest.go b/manifest/manifest.go index dea7ffce..c974f655 100644 --- a/manifest/manifest.go +++ b/manifest/manifest.go @@ -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 { diff --git a/project/project.go b/project/project.go index abac5fe4..ccd85f9a 100644 --- a/project/project.go +++ b/project/project.go @@ -41,6 +41,7 @@ type Module struct { Submodules []Module apply Apply ApplyExecute bool + SkipRelease bool } func (module *Module) IsMavenModule() bool { @@ -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, }) } @@ -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,