Skip to content

Commit 3d347e9

Browse files
committed
add option to disable checking of checksums for included files
1 parent 7a06187 commit 3d347e9

File tree

1 file changed

+34
-22
lines changed

1 file changed

+34
-22
lines changed

lib/app/workflow.go

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ type WorkflowInclude struct {
6161
type WorkflowSettings struct {
6262
Defaults *WorkflowSettingsDefaults `yaml:"defaults"`
6363
ExitOnChecksumMismatch bool `yaml:"exit-on-checksum-mismatch"`
64+
ChecksumVerification *bool `yaml:"checksum-verification"`
6465
DotEnvFiles []string `yaml:"dotenv"`
6566
Cache *WorkflowSettingsCache `yaml:"cache"`
6667
Domains struct {
@@ -355,9 +356,11 @@ func (workflow *StackupWorkflow) Initialize() {
355356

356357
// no default settings were provided, so create sensible defaults
357358
if workflow.Settings == nil {
359+
verifyChecksums := true
358360
workflow.Settings = &WorkflowSettings{
359-
DotEnvFiles: []string{".env"},
360-
Cache: &WorkflowSettingsCache{TtlMinutes: 5},
361+
DotEnvFiles: []string{".env"},
362+
Cache: &WorkflowSettingsCache{TtlMinutes: 5},
363+
ChecksumVerification: &verifyChecksums,
361364
Defaults: &WorkflowSettingsDefaults{
362365
Tasks: &WorkflowSettingsDefaultsTasks{
363366
Silent: false,
@@ -368,6 +371,11 @@ func (workflow *StackupWorkflow) Initialize() {
368371
}
369372
}
370373

374+
if workflow.Settings.ChecksumVerification == nil {
375+
verifyChecksums := true
376+
workflow.Settings.ChecksumVerification = &verifyChecksums
377+
}
378+
371379
if workflow.Settings.Cache.TtlMinutes <= 0 {
372380
workflow.Settings.Cache.TtlMinutes = 5
373381
}
@@ -486,7 +494,9 @@ func (workflow *StackupWorkflow) ProcessInclude(include *WorkflowInclude) bool {
486494
workflow.Cache.Set(include.DisplayName(), item, App.Workflow.Settings.Cache.TtlMinutes)
487495
}
488496

489-
include.ChecksumValidated, include.FoundChecksum, _ = include.ValidateChecksum(include.Contents)
497+
if workflow.Settings.ChecksumVerification != nil && *workflow.Settings.ChecksumVerification {
498+
include.ChecksumValidated, include.FoundChecksum, _ = include.ValidateChecksum(include.Contents)
499+
}
490500

491501
if err != nil {
492502
fmt.Println(err)
@@ -495,25 +505,27 @@ func (workflow *StackupWorkflow) ProcessInclude(include *WorkflowInclude) bool {
495505

496506
include.ValidationState = "verification skipped"
497507

498-
if include.IsRemoteUrl() {
499-
if *include.VerifyChecksum == true || include.VerifyChecksum == nil {
500-
if include.ChecksumValidated {
501-
include.ValidationState = "verified"
502-
}
503-
504-
if !include.ChecksumValidated && include.FoundChecksum != "" {
505-
include.ValidationState = "verification failed"
506-
}
507-
508-
// if err != nil {
509-
// fmt.Println(err)
510-
// return false
511-
// }
512-
513-
if !include.ChecksumValidated && App.Workflow.Settings.ExitOnChecksumMismatch {
514-
support.FailureMessageWithXMark("Exiting due to checksum mismatch.")
515-
App.exitApp()
516-
return false
508+
if workflow.Settings.ChecksumVerification != nil && *workflow.Settings.ChecksumVerification {
509+
if include.IsRemoteUrl() {
510+
if *include.VerifyChecksum == true || include.VerifyChecksum == nil {
511+
if include.ChecksumValidated {
512+
include.ValidationState = "verified"
513+
}
514+
515+
if !include.ChecksumValidated && include.FoundChecksum != "" {
516+
include.ValidationState = "verification failed"
517+
}
518+
519+
// if err != nil {
520+
// fmt.Println(err)
521+
// return false
522+
// }
523+
524+
if !include.ChecksumValidated && App.Workflow.Settings.ExitOnChecksumMismatch {
525+
support.FailureMessageWithXMark("Exiting due to checksum mismatch.")
526+
App.exitApp()
527+
return false
528+
}
517529
}
518530
}
519531
}

0 commit comments

Comments
 (0)