Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lint issues by importas linter #115

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions api/v1alpha1/eventingauth_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ limitations under the License.

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
import kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

type State string

Expand Down Expand Up @@ -48,7 +46,7 @@ type EventingAuthStatus struct {
AuthSecret *AuthSecret `json:"secret,omitempty"`

// Conditions associated with EventingAuthStatus.
Conditions []metav1.Condition `json:"conditions,omitempty"`
Conditions []kmetav1.Condition `json:"conditions,omitempty"`
}

type IASApplication struct {
Expand All @@ -71,8 +69,8 @@ type AuthSecret struct {

// EventingAuth is the Schema for the eventingauths API.
type EventingAuth struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
kmetav1.TypeMeta `json:",inline"`
kmetav1.ObjectMeta `json:"metadata,omitempty"`

Spec EventingAuthSpec `json:"spec,omitempty"`
Status EventingAuthStatus `json:"status,omitempty"`
Expand All @@ -82,9 +80,9 @@ type EventingAuth struct {

// EventingAuthList contains a list of EventingAuth.
type EventingAuthList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []EventingAuth `json:"items"`
kmetav1.TypeMeta `json:",inline"`
kmetav1.ListMeta `json:"metadata,omitempty"`
Items []EventingAuth `json:"items"`
}

func init() {
Expand Down
36 changes: 18 additions & 18 deletions api/v1alpha1/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"reflect"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type ConditionType string
Expand Down Expand Up @@ -51,19 +51,19 @@ func UpdateConditionAndState(eventingAuth *EventingAuth, conditionType Condition
}

// MakeApplicationReadyCondition updates the ConditionApplicationActive condition based on the given error value.
func MakeApplicationReadyCondition(eventingAuth *EventingAuth, err error) []metav1.Condition {
applicationReadyCondition := metav1.Condition{
func MakeApplicationReadyCondition(eventingAuth *EventingAuth, err error) []kmetav1.Condition {
applicationReadyCondition := kmetav1.Condition{
Type: string(ConditionApplicationReady),
LastTransitionTime: metav1.Now(),
LastTransitionTime: kmetav1.Now(),
}
if err == nil {
applicationReadyCondition.Status = metav1.ConditionTrue
applicationReadyCondition.Status = kmetav1.ConditionTrue
applicationReadyCondition.Reason = ConditionReasonApplicationCreated
applicationReadyCondition.Message = ConditionMessageApplicationCreated
} else {
applicationReadyCondition.Message = err.Error()
applicationReadyCondition.Reason = ConditionReasonApplicationCreationFailed
applicationReadyCondition.Status = metav1.ConditionFalse
applicationReadyCondition.Status = kmetav1.ConditionFalse
}
for ix, activeCond := range eventingAuth.Status.Conditions {
if activeCond.Type == string(ConditionApplicationReady) {
Expand All @@ -81,19 +81,19 @@ func MakeApplicationReadyCondition(eventingAuth *EventingAuth, err error) []meta
}

// MakeSecretReadyCondition updates the ConditionSecretReady condition based on the given error value.
func MakeSecretReadyCondition(eventingAuth *EventingAuth, err error) []metav1.Condition {
secretReadyCondition := metav1.Condition{
func MakeSecretReadyCondition(eventingAuth *EventingAuth, err error) []kmetav1.Condition {
secretReadyCondition := kmetav1.Condition{
Type: string(ConditionSecretReady),
LastTransitionTime: metav1.Now(),
LastTransitionTime: kmetav1.Now(),
}
if err == nil {
secretReadyCondition.Status = metav1.ConditionTrue
secretReadyCondition.Status = kmetav1.ConditionTrue
secretReadyCondition.Reason = ConditionReasonSecretCreated
secretReadyCondition.Message = ConditionMessageSecretCreated
} else {
secretReadyCondition.Message = err.Error()
secretReadyCondition.Reason = ConditionReasonSecretCreationFailed
secretReadyCondition.Status = metav1.ConditionFalse
secretReadyCondition.Status = kmetav1.ConditionFalse
}
for ix, activeCond := range eventingAuth.Status.Conditions {
if activeCond.Type == string(ConditionSecretReady) {
Expand All @@ -111,14 +111,14 @@ func MakeSecretReadyCondition(eventingAuth *EventingAuth, err error) []metav1.Co
}

// ConditionsEqual checks if two list of conditions are equal.
func ConditionsEqual(existing, expected []metav1.Condition) bool {
func ConditionsEqual(existing, expected []kmetav1.Condition) bool {
// not equal if length is different
if len(existing) != len(expected) {
return false
}

// compile map of Conditions per ConditionType
existingMap := make(map[string]metav1.Condition, len(existing))
existingMap := make(map[string]kmetav1.Condition, len(existing))
for _, value := range existing {
existingMap[value.Type] = value
}
Expand All @@ -133,7 +133,7 @@ func ConditionsEqual(existing, expected []metav1.Condition) bool {
}

// ConditionEquals checks if two conditions are equal.
func ConditionEquals(existing, expected metav1.Condition) bool {
func ConditionEquals(existing, expected kmetav1.Condition) bool {
isTypeEqual := existing.Type == expected.Type
isStatusEqual := existing.Status == expected.Status
isReasonEqual := existing.Reason == expected.Reason
Expand All @@ -147,8 +147,8 @@ func IsEventingAuthStatusEqual(oldStatus, newStatus EventingAuthStatus) bool {
newStatusWithoutCond := newStatus.DeepCopy()

// remove conditions, so that we don't compare them
oldStatusWithoutCond.Conditions = []metav1.Condition{}
newStatusWithoutCond.Conditions = []metav1.Condition{}
oldStatusWithoutCond.Conditions = []kmetav1.Condition{}
newStatusWithoutCond.Conditions = []kmetav1.Condition{}

return reflect.DeepEqual(oldStatusWithoutCond, newStatusWithoutCond) &&
ConditionsEqual(oldStatus.Conditions, newStatus.Conditions)
Expand All @@ -159,10 +159,10 @@ func determineEventingAuthState(status EventingAuthStatus) State {
var applicationReady, secretReady bool
for _, cond := range status.Conditions {
if cond.Type == string(ConditionApplicationReady) {
applicationReady = cond.Status == metav1.ConditionTrue
applicationReady = cond.Status == kmetav1.ConditionTrue
}
if cond.Type == string(ConditionSecretReady) {
secretReady = cond.Status == metav1.ConditionTrue
secretReady = cond.Status == kmetav1.ConditionTrue
}
}
if applicationReady && secretReady {
Expand Down
Loading
Loading