Skip to content

Commit 8371ab7

Browse files
Fix release group options on analyze commands (#1439)
* Fix release group options on analyze commands
1 parent bf4ca23 commit 8371ab7

File tree

4 files changed

+40
-25
lines changed

4 files changed

+40
-25
lines changed

Changelog.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# FOSSA CLI Changelog
22

3+
## 3.9.22
4+
- Fixes release group flags for `fossa analyze` and `fossa container analyze` ([#1439](https://github.com/fossas/fossa-cli/pull/1439))
5+
36
## 3.9.21
47
- Add support for analyzing SBOM files ([#1435](https://github.com/fossas/fossa-cli/pull/1435))
58
- License Scanning: Add the Llama-3-community license (No PR)

src/App/Fossa/Config/Analyze.hs

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ import App.Fossa.Config.Common (
3636
CacheAction (WriteOnly),
3737
CommonOpts (..),
3838
ScanDestination (..),
39+
applyReleaseGroupDeprecationWarning,
3940
baseDirArg,
4041
collectApiOpts,
4142
collectBaseDir,
4243
collectConfigFileFilters,
4344
collectConfigMavenScopeFilters,
4445
collectRevisionData',
4546
commonOpts,
46-
deprecateReleaseGroupMetadata,
4747
metadataOpts,
4848
pathOpt,
4949
targetOpt,
@@ -84,7 +84,7 @@ import Control.Effect.Diagnostics (
8484
recover,
8585
)
8686
import Control.Effect.Lift (Lift)
87-
import Control.Monad (when)
87+
import Control.Monad (void, when)
8888
import Data.Aeson (ToJSON (toEncoding), defaultOptions, genericToEncoding)
8989
import Data.Flag (Flag, flagOpt, fromFlag)
9090
import Data.Map qualified as Map
@@ -639,9 +639,9 @@ collectScanDestination maybeCfgFile envvars AnalyzeCliOpts{..} =
639639
else do
640640
apiOpts <- collectApiOpts maybeCfgFile envvars commons
641641
metaMerged <- maybe (pure analyzeMetadata) (mergeFileCmdMetadata analyzeMetadata) (maybeCfgFile)
642-
projectMetadataWithoutReleaseGroup <- deprecateReleaseGroupMetadata metaMerged
642+
void $ applyReleaseGroupDeprecationWarning metaMerged
643643
when (length (projectLabel metaMerged) > 5) $ fatalText "Projects are only allowed to have 5 associated project labels"
644-
pure $ UploadScan apiOpts projectMetadataWithoutReleaseGroup
644+
pure $ UploadScan apiOpts metaMerged
645645

646646
collectModeOptions ::
647647
( Has Diagnostics sig m

src/App/Fossa/Config/Common.hs

+30-18
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module App.Fossa.Config.Common (
4747
configHelp,
4848
titleHelp,
4949
-- Deprecation
50-
deprecateReleaseGroupMetadata,
50+
applyReleaseGroupDeprecationWarning,
5151
) where
5252

5353
import App.Fossa.Config.ConfigFile (
@@ -126,7 +126,6 @@ import Options.Applicative (
126126
argument,
127127
auto,
128128
eitherReader,
129-
internal,
130129
long,
131130
metavar,
132131
option,
@@ -144,7 +143,7 @@ import Options.Applicative.Help (AnsiStyle)
144143
import Path (Abs, Dir, File, Path, Rel, SomeBase (..), parseRelDir)
145144
import Path.Extra (SomePath (..))
146145
import Path.IO (resolveDir', resolveFile')
147-
import Prettyprinter (Doc, annotate)
146+
import Prettyprinter (Doc, Pretty (pretty), annotate)
148147
import Prettyprinter.Render.Terminal (Color (Green, Red), color)
149148
import Style (applyFossaStyle, boldItalicized, coloredBoldItalicized, formatDoc, stringToHelpDoc)
150149
import Text.Megaparsec (errorBundlePretty, runParser)
@@ -221,25 +220,38 @@ policyIdHelp =
221220
releaseGroupMetadataOpts :: Parser ReleaseGroupMetadata
222221
releaseGroupMetadataOpts =
223222
ReleaseGroupMetadata
224-
<$> strOption (applyFossaStyle <> long "release-group-name" <> stringToHelpDoc "The name of the release group to add this project to" <> internal)
225-
<*> strOption (applyFossaStyle <> long "release-group-release" <> stringToHelpDoc "The release of the release group to add this project to" <> internal)
223+
<$> strOption (applyFossaStyle <> long "release-group-name" <> helpDoc releaseGroupNameHelp)
224+
<*> strOption (applyFossaStyle <> long "release-group-release" <> helpDoc releaseGroupReleaseHelp)
226225

227-
deprecateReleaseGroupMetadata :: Has Diagnostics sig m => ProjectMetadata -> m ProjectMetadata
228-
deprecateReleaseGroupMetadata projectMetadata = do
226+
releaseGroupNameHelp :: Maybe (Doc AnsiStyle)
227+
releaseGroupNameHelp =
228+
Just . formatDoc $
229+
vsep
230+
[ "The name of the release group to add this project to"
231+
, boldItalicized "Note: " <> pretty releaseGroupDeprecationMessage
232+
]
233+
234+
releaseGroupReleaseHelp :: Maybe (Doc AnsiStyle)
235+
releaseGroupReleaseHelp =
236+
Just . formatDoc $
237+
vsep
238+
[ "The release of the release group to add this project to"
239+
, boldItalicized "Note: " <> pretty releaseGroupDeprecationMessage
240+
]
241+
242+
applyReleaseGroupDeprecationWarning :: Has Diagnostics sig m => ProjectMetadata -> m ()
243+
applyReleaseGroupDeprecationWarning projectMetadata = do
229244
case (projectReleaseGroup projectMetadata) of
230-
Nothing -> pure projectMetadata
245+
Nothing -> pure ()
231246
Just _ -> do
232-
warn deprecationMessage
233-
pure $ removeReleaseGroupMetadata projectMetadata
234-
where
235-
removeReleaseGroupMetadata :: ProjectMetadata -> ProjectMetadata
236-
removeReleaseGroupMetadata project = project{projectReleaseGroup = Nothing}
247+
warn releaseGroupDeprecationMessage
248+
pure ()
237249

238-
deprecationMessage :: Text
239-
deprecationMessage =
240-
renderIt $
241-
vsep
242-
[annotate (color Red) "Release group options for this command have been deprecated. Refer to `fossa release-group` subcommands to interact with FOSSA release groups."]
250+
releaseGroupDeprecationMessage :: Text
251+
releaseGroupDeprecationMessage =
252+
renderIt $
253+
vsep
254+
[annotate (color Red) "Release group options for this command will soon be deprecated. Refer to `fossa release-group` subcommands to interact with FOSSA release groups."]
243255

244256
pathOpt :: String -> Either String (Path Rel Dir)
245257
pathOpt = first show . parseRelDir

src/App/Fossa/Container/AnalyzeNative.hs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import App.Fossa.Analyze.Debug (collectDebugBundle)
1111
import App.Fossa.Analyze.Upload (emitBuildWarnings)
1212
import App.Fossa.Config.Common (
1313
ScanDestination (OutputStdout, UploadScan),
14-
deprecateReleaseGroupMetadata,
14+
applyReleaseGroupDeprecationWarning,
1515
)
1616
import App.Fossa.Config.Container.Analyze (
1717
ContainerAnalyzeConfig (..),
@@ -141,8 +141,8 @@ uploadScan revision projectMeta jsonOutput containerScan =
141141
if not supportsNativeScan
142142
then fatal (EndpointDoesNotSupportNativeContainerScan getSourceLocation)
143143
else do
144-
projectMetadataWithoutReleaseGroup <- deprecateReleaseGroupMetadata projectMeta
145-
resp <- uploadNativeContainerScan revision projectMetadataWithoutReleaseGroup containerScan
144+
void $ applyReleaseGroupDeprecationWarning projectMeta
145+
resp <- uploadNativeContainerScan revision projectMeta containerScan
146146
emitBuildWarnings resp
147147
let locator = uploadLocator resp
148148
buildUrl <- getFossaBuildUrl revision locator

0 commit comments

Comments
 (0)