Skip to content

Commit 91789ac

Browse files
committed
Merge branch 'feature/transactionize'
2 parents 71e60fc + fd12b5e commit 91789ac

File tree

7 files changed

+491
-292
lines changed

7 files changed

+491
-292
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Restore assessment data to a VECTR instance from an encrypted, compressed file:
8080
- `--target-assessment-name`: Overrides the name of the assessment being restored in the target instance. Required when using `--source-campaign-name`.
8181
- `--source-campaign-name`: Name of a specific campaign to restore from the input file. If set, `--target-assessment-name` must be an existing assessment.
8282
- `--override-template-assessment`: Overrides any set template name in the serialized data and loads template test cases anyway.
83+
- `--delete-on-failure`: In the case of a failure, delete the created assessment from VECTR. (Note: this does not affect single campaign transfers)
8384
- `-k`: Allow insecure connections (e.g., ignore TLS certificate errors).
8485
- `--client-cert-file`: Path to the client certificate file for mTLS.
8586
- `--client-key-file`: Path to the client key file for mTLS.
@@ -143,6 +144,7 @@ Transfer an assessment from one VECTR instance directly to another:
143144
#### Optional Options
144145
- `--target-assessment-name`: Overrides the name of the assessment in the target instance.
145146
- `--override-template-assessment`: Overrides the template assessment set in the serialized data and uses the saved template data (lower fidelity).
147+
- `--delete-on-failure`: In the case of a failure, delete the created assessment from VECTR. (Note: this does not affect single campaign transfers)
146148
- `-k`: Allow insecure connections (e.g., ignore TLS certificate errors). (will be applied for both source and dest)
147149
- `--client-cert-file`: Path to the client certificate file for mTLS. (will be applied for both source and dest)
148150
- `--client-key-file`: Path to the client key file for mTLS. (will be applied for both source and dest)

cmd/cmd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var (
1515
insecure bool
1616
targetAssessmentName string
1717
overrideAssessmentTemplate bool
18+
deleteOnFailure bool
1819
clientCertFile string
1920
clientKeyFile string
2021
caCertFiles []string

cmd/restorer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ var restoreCmd = &cobra.Command{
9696
client, vectrVersionHandler, err := util.SetupVectrClient(hostname, strings.TrimSpace(string(credentials)), tlsParams)
9797
if err != nil {
9898
slog.ErrorContext(ctx, "could not set up connection to vectr", "hostname", hostname, "error", err)
99+
os.Exit(1)
99100
}
100101

101102
// get the VECTR version (side effect - check the creds as well)
@@ -115,6 +116,7 @@ var restoreCmd = &cobra.Command{
115116
optionalParams := &vat.RestoreOptionalParams{
116117
AssessmentName: targetAssessmentName,
117118
OverrideAssessmentTemplate: overrideAssessmentTemplate,
119+
DeleteOnFailure: deleteOnFailure,
118120
}
119121

120122
// Restore the assessment
@@ -148,6 +150,7 @@ func init() {
148150
restoreCmd.Flags().StringVar(&passphraseFile, "passphrase-file", "", "Path to the file containing the decryption passphrase")
149151
restoreCmd.Flags().StringVar(&targetAssessmentName, "target-assessment-name", "", "The assessment name to set in the new instance. Required when using --source-campaign-name.")
150152
restoreCmd.Flags().BoolVar(&overrideAssessmentTemplate, "override-template-assessment", false, "Override any set template name in the serialized data and load template test cases anyway")
153+
restoreCmd.Flags().BoolVar(&deleteOnFailure, "delete-on-failure", false, "In the case of a failure, delete the created assessment from VECTR (does not delete template information). Does not affect single campaign inserts.")
151154
restoreCmd.Flags().StringVar(&sourceCampaignName, "source-campaign-name", "", "Name of a specific campaign to restore from the input file. If set, --target-assessment-name must be an existing assessment.")
152155

153156
// Mark flags as required

cmd/transfer.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ var transferCmd = &cobra.Command{
5858
// Set up the source VECTR client
5959
sourceClient, sourceVectrVersionHandler, err := util.SetupVectrClient(sourceHostname, strings.TrimSpace(string(sourceCredentials)), tlsParams)
6060
if err != nil {
61-
slog.ErrorContext(ctx, "could not set up connection to vectr", "hostname", hostname, "error", err)
61+
slog.ErrorContext(ctx, "could not set up connection to vectr", "hostname", sourceHostname, "error", err)
62+
os.Exit(1)
6263
}
6364

6465
// get the VECTR version (side effect - check the creds as well)
@@ -78,6 +79,7 @@ var transferCmd = &cobra.Command{
7879
targetClient, targetVectrVersionHandler, err := util.SetupVectrClient(targetHostname, strings.TrimSpace(string(targetCredentials)), tlsParams)
7980
if err != nil {
8081
slog.ErrorContext(ctx, "could not set up connection to vectr", "hostname", targetHostname, "error", err)
82+
os.Exit(1)
8183
}
8284
// get the VECTR version (side effect - check the creds as well)
8385
targetVectrVersion, err := targetVectrVersionHandler.GetVersion(ctx)
@@ -104,6 +106,7 @@ var transferCmd = &cobra.Command{
104106
optionalParams := &vat.RestoreOptionalParams{
105107
AssessmentName: targetAssessmentName,
106108
OverrideAssessmentTemplate: overrideAssessmentTemplate,
109+
DeleteOnFailure: deleteOnFailure,
107110
}
108111
// Original full assessment transfer logic
109112
slog.InfoContext(targetVersionContext, "Transferring assessment data to target instance", "hostname", targetHostname, "db", targetDB)
@@ -141,6 +144,7 @@ func init() {
141144
transferCmd.Flags().StringVar(&assessmentName, "assessment-name", "", "Name of the assessment to transfer (required)")
142145
transferCmd.Flags().StringVar(&targetAssessmentName, "target-assessment-name", "", "The assessment name to set in the new instance")
143146
transferCmd.Flags().BoolVar(&overrideAssessmentTemplate, "override-template-assessment", false, "Ignore the template name in the serialized data and load template test cases anyway")
147+
transferCmd.Flags().BoolVar(&deleteOnFailure, "delete-on-failure", false, "In the case of a failure, delete the created assessment from VECTR (does not delete template information). Does not affect single campaign inserts.")
144148
transferCmd.Flags().StringVar(&sourceCampaignName, "source-campaign-name", "", "Name of a specific campaign to transfer. If set, --target-assessment-name must be an existing assessment.")
145149

146150
// Mark flags as required
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
mutation DeleteAssessment($db: String!, $ids: [String!]!) {
2+
assessment {
3+
delete(input: { db: $db, ids: $ids }) {
4+
deletedIds
5+
}
6+
}
7+
}

0 commit comments

Comments
 (0)