Skip to content

Commit ba2270b

Browse files
[POA-2701] Add --repro-mode flag (#62)
* Added a new flag, `--repro-mode`, which is the equivalent to `--send-witness-payload` flag. * The `--send-witness-payload` flag will be removed in the future. * Renamed variables wherever possible. However, the variable name was not changed in `backend_collection.go` because `sendWitnessPayloads` is more appropriate there, as it better reflects its functionality.
1 parent 15c3a1a commit ba2270b

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

apidump/apidump.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ type Args struct {
139139
// The port to be used by the Docker Extension for health checks
140140
HealthCheckPort int
141141

142-
// Whether to include request/response payloads when uploading witnesses.
143-
SendWitnessPayloads bool
142+
// Whether to enable repro mode and include request/response payloads when uploading witnesses.
143+
ReproMode bool
144144
}
145145

146146
// TODO: either remove write-to-local-HAR-file completely,
@@ -689,7 +689,7 @@ func (a *apidump) Run() error {
689689
} else {
690690
var backendCollector trace.Collector
691691
if args.Out.AkitaURI != nil {
692-
backendCollector = trace.NewBackendCollector(a.backendSvc, backendLrn, a.learnClient, optionals.Some(a.MaxWitnessSize_bytes), summary, args.SendWitnessPayloads, args.Plugins)
692+
backendCollector = trace.NewBackendCollector(a.backendSvc, backendLrn, a.learnClient, optionals.Some(a.MaxWitnessSize_bytes), summary, args.ReproMode, args.Plugins)
693693
collector = backendCollector
694694
} else {
695695
return errors.Errorf("invalid output location")

cmd/internal/apidump/apidump.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ func apidumpRunInternal(cmd *cobra.Command, _ []string) error {
220220
MaxWitnessSize_bytes: maxWitnessSize_bytes,
221221
DockerExtensionMode: dockerExtensionMode,
222222
HealthCheckPort: healthCheckPort,
223-
SendWitnessPayloads: commonApidumpFlags.SendWitnessPayloads,
223+
224+
// TODO: remove the SendWitnessPayloads flag once all existing users are migrated to new flag.
225+
ReproMode: commonApidumpFlags.EnableReproMode || commonApidumpFlags.SendWitnessPayloads,
224226
}
225227
if err := apidump.Run(args); err != nil {
226228
return cmderr.AkitaErr{Err: err}

cmd/internal/apidump/common_flags.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type CommonApidumpFlags struct {
1717
RandomizedStart int
1818
RateLimit float64
1919
SendWitnessPayloads bool
20+
EnableReproMode bool
2021
}
2122

2223
func AddCommonApiDumpFlags(cmd *cobra.Command) *CommonApidumpFlags {
@@ -87,6 +88,14 @@ func AddCommonApiDumpFlags(cmd *cobra.Command) *CommonApidumpFlags {
8788
)
8889
_ = cmd.PersistentFlags().MarkHidden("send-witness-payloads")
8990

91+
cmd.PersistentFlags().BoolVar(
92+
&flags.EnableReproMode,
93+
"repro-mode",
94+
false,
95+
"Enable repro mode to send request and response payloads to Postman.",
96+
)
97+
_ = cmd.PersistentFlags().MarkHidden("repro-mode")
98+
9099
return flags
91100
}
92101

@@ -109,6 +118,10 @@ func ConvertCommonApiDumpFlagsToArgs(flags *CommonApidumpFlags) []string {
109118
commonApidumpArgs = append(commonApidumpArgs, "--send-witness-payloads")
110119
}
111120

121+
if flags.EnableReproMode {
122+
commonApidumpArgs = append(commonApidumpArgs, "--repro-mode")
123+
}
124+
112125
// Add slice type flags to the entry point.
113126
// Flags: --host-allow, --host-exclusions, --interfaces, --path-allow, --path-exclusions
114127
// Added them separately instead of joining with comma(,) to avoid any regex parsing issues.

0 commit comments

Comments
 (0)