-
Notifications
You must be signed in to change notification settings - Fork 2
/
errors.go
45 lines (35 loc) · 1.14 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package batch
import (
"fmt"
radixv1 "github.com/equinor/radix-operator/pkg/apis/radix/v1"
)
const (
invalidDeploymentReferenceReason = "InvalidDeploymentReference"
)
type reconcileStatus interface {
Status() radixv1.RadixBatchCondition
}
type reconcileError struct {
status radixv1.RadixBatchCondition
}
func (rc *reconcileError) Error() string {
return rc.status.Message
}
func (rc *reconcileError) Status() radixv1.RadixBatchCondition {
return rc.status
}
func newReconcileWaitingError(reason, message string) *reconcileError {
return &reconcileError{
status: radixv1.RadixBatchCondition{
Type: radixv1.BatchConditionTypeWaiting,
Reason: reason,
Message: message,
},
}
}
func newReconcileRadixDeploymentNotFoundError(rdName string) *reconcileError {
return newReconcileWaitingError(invalidDeploymentReferenceReason, fmt.Sprintf("radixdeployment '%s' not found", rdName))
}
func newReconcileRadixDeploymentJobSpecNotFoundError(rdName, jobName string) *reconcileError {
return newReconcileWaitingError(invalidDeploymentReferenceReason, fmt.Sprintf("radixdeployment '%s' does not contain a job with name '%s'", rdName, jobName))
}