Skip to content

Commit 56529d5

Browse files
committed
refactor package naming
1 parent 5e845ed commit 56529d5

2 files changed

Lines changed: 120 additions & 62 deletions

File tree

pkg/imageauthvalidator/validator.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,32 @@ import (
55
"fmt"
66
"strings"
77

8+
metal3api "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"
9+
"github.com/metal3-io/baremetal-operator/pkg/secretutils"
810
corev1 "k8s.io/api/core/v1"
9-
apierrors "k8s.io/apimachinery/pkg/api/errors"
11+
k8serrors "k8s.io/apimachinery/pkg/api/errors"
1012
"k8s.io/apimachinery/pkg/types"
1113
"k8s.io/client-go/tools/record"
1214
"sigs.k8s.io/controller-runtime/pkg/client"
13-
14-
metal3v1 "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"
15-
"github.com/metal3-io/baremetal-operator/pkg/secretutils"
1615
)
1716

1817
const (
19-
// Conditions
20-
CondImageAuthValid = "ImageAuthValid"
18+
// Conditions.
19+
ConditionImageAuthValid = "ImageAuthValid"
20+
ConditionImageAuthInUse = "ImageAuthInUse"
2121

22-
// Reasons
22+
// Reasons.
2323
ReasonUnknown = "Unknown"
2424
ReasonNotRequired = "NotRequired"
2525
ReasonValid = "Valid"
2626
ReasonSecretNotFound = "SecretNotFound"
2727
ReasonWrongType = "WrongType"
2828
ReasonParseError = "ParseError"
2929
ReasonRegistryEntryMissing = "RegistryEntryMissing"
30+
ReasonCredentialsInjected = "CredentialsInjected"
31+
ReasonNoOCIImage = "NoOCIImage"
3032

31-
// Events
33+
// Events.
3234
EventAuthSecretIrrelevant = "ImageAuthIrrelevant"
3335
EventAuthFormatUnsupported = "ImageAuthFormatUnsupported"
3436
)
@@ -46,7 +48,7 @@ type Result struct {
4648
}
4749

4850
type Validator interface {
49-
Validate(ctx context.Context, bmh *metal3v1.BareMetalHost) (*Result, error)
51+
Validate(ctx context.Context, bmh *metal3api.BareMetalHost) (*Result, error)
5052
}
5153

5254
type validator struct {
@@ -58,7 +60,7 @@ func New(c client.Client, recorder record.EventRecorder) Validator {
5860
return &validator{c: c, recorder: recorder}
5961
}
6062

61-
func (v *validator) Validate(ctx context.Context, bmh *metal3v1.BareMetalHost) (*Result, error) {
63+
func (v *validator) Validate(ctx context.Context, bmh *metal3api.BareMetalHost) (*Result, error) {
6264
res := &Result{Valid: false, Reason: ReasonUnknown}
6365

6466
img := bmh.Spec.Image
@@ -86,7 +88,7 @@ func (v *validator) Validate(ctx context.Context, bmh *metal3v1.BareMetalHost) (
8688
var sec corev1.Secret
8789
key := types.NamespacedName{Namespace: bmh.Namespace, Name: secretName}
8890
if err := v.c.Get(ctx, key, &sec); err != nil {
89-
if apierrors.IsNotFound(err) {
91+
if k8serrors.IsNotFound(err) {
9092
res.Reason = ReasonSecretNotFound
9193
res.Message = fmt.Sprintf("secret %q not found in namespace %q", secretName, bmh.Namespace)
9294
return res, nil

0 commit comments

Comments
 (0)