Skip to content

Commit

Permalink
chore: Minor refactoring, change fcli ssc av create --from option v…
Browse files Browse the repository at this point in the history
…alues`
  • Loading branch information
rsenden committed Jun 29, 2024
1 parent f2eab9c commit c02ae4e
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
package com.fortify.cli.common.progress.cli.mixin;

import com.fortify.cli.common.cli.mixin.CommandHelperMixin;
import com.fortify.cli.common.progress.cli.mixin.ProgressWriterTypeConverter.ProgressWriterTypeIterable;
import com.fortify.cli.common.progress.helper.IProgressWriterI18n;
import com.fortify.cli.common.progress.helper.ProgressWriterI18n;
import com.fortify.cli.common.progress.helper.ProgressWriterType;
Expand All @@ -24,7 +23,7 @@

public class ProgressWriterFactoryMixin {
@Mixin private CommandHelperMixin commandHelper;
@Getter @Option(names="--progress", defaultValue = "auto", completionCandidates = ProgressWriterTypeIterable.class, converter = ProgressWriterTypeConverter.class )
@Getter @Option(names="--progress", defaultValue = "auto")
private ProgressWriterType type;

public final IProgressWriterI18n create() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ public enum ProgressWriterType {
single_line(SingleLineProgressWriter::new),
ansi(AnsiProgressWriter::new);

@Override
public String toString() {
// Show and accept dashes instead of underscores when this
// enum is used in picocli options.
return name().replace('_', '-');
}

private final Supplier<IProgressWriter> factory;

public IProgressWriter create() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private final SSCAppVersionUserUpdateBuilder getAuthUpdateBuilder(UnirestInstanc
}

private Set<String> getUsersFromSource(UnirestInstance unirest, SSCAppVersionCopyFromDescriptor copyFromDescriptor) {
if ( copyFromDescriptor.isCopyRequested() && copyFromDescriptor.getCopyOptions().contains(SSCAppVersionCopyOption.Users) ) {
if ( copyFromDescriptor.isCopyRequested() && copyFromDescriptor.getCopyOptions().contains(SSCAppVersionCopyOption.users) ) {
return getUsersSet(unirest, copyFromDescriptor.getAppVersionDescriptor());
}
return null;
Expand All @@ -144,7 +144,7 @@ private final SSCAttributeUpdateBuilder getAttrUpdateBuilder(UnirestInstance uni
}

private Map<String, String> getAttributesFromSource(UnirestInstance unirest, SSCAppVersionCopyFromDescriptor copyFromDescriptor) {
if ( copyFromDescriptor.isCopyRequested() && copyFromDescriptor.getCopyOptions().contains(SSCAppVersionCopyOption.Attributes) ) {
if ( copyFromDescriptor.isCopyRequested() && copyFromDescriptor.getCopyOptions().contains(SSCAppVersionCopyOption.attributes) ) {
return getAttributesMap(unirest, copyFromDescriptor.getAppVersionDescriptor());
}
return null;
Expand Down Expand Up @@ -225,7 +225,7 @@ private HttpRequest<?> buildCopyFromPartialRequest(UnirestInstance unirest, SSCA

private HttpRequest<?> buildCopyStateRequest(UnirestInstance unirest, SSCAppVersionDescriptor copyTo, SSCAppVersionCopyFromDescriptor copyFromDescriptor) {
if ( !copyFromDescriptor.isCopyRequested()
|| !copyFromDescriptor.getCopyOptions().contains(SSCAppVersionCopyOption.State)) {
|| !copyFromDescriptor.getCopyOptions().contains(SSCAppVersionCopyOption.state)) {
return null;
}
return unirest.post(SSCUrls.PROJECT_VERSIONS_ACTION_COPY_CURRENT_STATE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,24 @@ public boolean isCopyRequested() {
*/
@RequiredArgsConstructor @Getter
public static enum SSCAppVersionCopyOption {
CustomTags("copyCustomTags", null),
BugTracker("copyBugTrackerConfiguration", null),
BugTrackerConfiguration("copyBugTrackerConfiguration", BugTracker), // Deprecated
ProcessingRules("copyAnalysisProcessingRules", null),
AnalysisProcessingRules("copyAnalysisProcessingRules", ProcessingRules), // Deprecated
custom_tags("copyCustomTags", null),
bugtracker("copyBugTrackerConfiguration", null),
BugTrackerConfiguration("copyBugTrackerConfiguration", bugtracker), // Deprecated
processing_rules("copyAnalysisProcessingRules", null),
AnalysisProcessingRules("copyAnalysisProcessingRules", processing_rules), // Deprecated
// Contrary to what's sent by SSC UI, attributes are not supported on COPY_FROM_PARTIAL
Attributes(null, null),
attributes(null, null),
// Contrary to what's sent by SSC UI, auth entities are not supported on COPY_FROM_PARTIAL
Users(null, null),
users(null, null),
// Requires separate call to COPY_CURRENT_STATE action
State(null, null);
state(null, null);

@Override
public String toString() {
// Show and accept dashes instead of underscores when this
// enum is used in picocli options.
return name().replace('_', '-');
}

private static final Logger LOG = LoggerFactory.getLogger(SSCAppVersionCopyOption.class);
private final String copyFromPartialProperty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ fcli.ssc.appversion.create.skip-if-exists = Skip application version creation if
fcli.ssc.appversion.create.refresh = By default, this command will refresh the source application version's metrics when copying from it. \
Note that for large applications this can lead to an error if the timeout expires.
fcli.ssc.appversion.create.copy-options = Comma separated list of elements to copy (Requires --copy-from). By default, all are copied. \
Allowed values: ${COMPLETION-CANDIDATES}.
Allowed values: ${COMPLETION-CANDIDATES}. The BugTrackerConfiguration and AnalysisProcessingRules values are deprecated and will \
be removed in a future fcli version.
fcli.ssc.appversion.delete.usage.header = Delete an application version.
fcli.ssc.appversion.copy-from.usage.header = Copy from options
fcli.ssc.appversion.copy-state.usage.header = (PREVIEW) Copy application version state.
Expand Down

0 comments on commit c02ae4e

Please sign in to comment.