-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Retry deploy from URL in case of errors
Skip ssl validation if the option is already provided
- Loading branch information
1 parent
5b43ea2
commit 6ca6993
Showing
8 changed files
with
132 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package retrier | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/cloudfoundry-incubator/multiapps-cli-plugin/log" | ||
) | ||
|
||
func Execute[T any](attempts int, callback func() (T, error), shouldRetry func(result T, err error) bool) (T, error) { | ||
var result T | ||
var err error | ||
for i := 0; i < attempts; i++ { | ||
result, err = callback() | ||
if shouldRetry(result, err) { | ||
logError[T](result, err) | ||
time.Sleep(3 * time.Second) | ||
continue | ||
} | ||
return result, nil | ||
} | ||
return callback() | ||
} | ||
|
||
func logError[T any](result T, err error) { | ||
if err != nil { | ||
log.Tracef("retrying an operation that failed with: %v", err) | ||
} | ||
log.Tracef("result of the callback %v", result) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package commands | ||
|
||
type UploadFromUrlStatus struct { | ||
FileId string | ||
MtaId string | ||
ClientActions []string | ||
ExecutionStatus ExecutionStatus | ||
} |