Skip to content
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
27 changes: 27 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: "2"
linters:
default: standard
enable:
- unparam

formatters:
enable:
- gofmt
- goimports
settings:
gofmt:
rewrite-rules:
- pattern: 'interface{}'
replacement: 'any'

issues:
max-same-issues: 100

exclude-files:
- generated.*\\.go

exclude-dirs:
- vendor

run:
timeout: 10m
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,6 @@ test: $(BUILD_DIRS)
./hack/test.sh $(SRC_PKGS) \
"

ADDTL_LINTERS := gofmt,goimports,unparam

.PHONY: lint
lint: $(BUILD_DIRS)
@echo "running linter"
Expand All @@ -261,7 +259,7 @@ lint: $(BUILD_DIRS)
--env GO111MODULE=on \
--env GOFLAGS="-mod=vendor" \
$(BUILD_IMAGE) \
golangci-lint run --enable $(ADDTL_LINTERS) --timeout=10m --exclude-files="generated.*\.go$\" --exclude-dirs-use-default
golangci-lint run

$(BUILD_DIRS):
@mkdir -p $@
Expand Down
2 changes: 1 addition & 1 deletion admissionregistration/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func init() {
var (
ErrMissingKind = errors.New("test object missing kind")
ErrMissingVersion = errors.New("test object missing version")
ErrWebhookNotActivated = errors.New("Admission webhooks are not activated. Enable it by configuring --enable-admission-plugins flag of kube-apiserver. For details, visit: https://appsco.de/kube-apiserver-webhooks")
ErrWebhookNotActivated = errors.New("admission webhooks are not activated. Enable it by configuring --enable-admission-plugins flag of kube-apiserver. For details, visit: https://appsco.de/kube-apiserver-webhooks")
)

func BypassValidatingWebhookXray() bool {
Expand Down
4 changes: 2 additions & 2 deletions api/v1/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ func MustParseObjectID(key OID) *ObjectID {
return oid
}

func ObjectIDMap(key OID) (map[string]interface{}, error) {
id := map[string]interface{}{
func ObjectIDMap(key OID) (map[string]any, error) {
id := map[string]any{
"group": "",
"kind": "",
"namespace": "",
Expand Down
6 changes: 3 additions & 3 deletions api/v1/timeofday.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (t TimeOfDay) MarshalJSON() ([]byte, error) {
}

// ToUnstructured implements the value.UnstructuredConverter interface.
func (t TimeOfDay) ToUnstructured() interface{} {
func (t TimeOfDay) ToUnstructured() any {
if t.IsZero() {
return nil
}
Expand All @@ -177,11 +177,11 @@ func (t TimeOfDay) ToUnstructured() interface{} {
// the OpenAPI spec of this type.
//
// See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators
func (_ TimeOfDay) OpenAPISchemaType() []string { return []string{"string"} }
func (TimeOfDay) OpenAPISchemaType() []string { return []string{"string"} }

// OpenAPISchemaFormat is used by the kube-openapi generator when constructing
// the OpenAPI spec of this type.
func (_ TimeOfDay) OpenAPISchemaFormat() string { return "time" }
func (TimeOfDay) OpenAPISchemaFormat() string { return "time" }

// MarshalQueryParameter converts to a URL query parameter value
func (t TimeOfDay) MarshalQueryParameter() (string, error) {
Expand Down
4 changes: 2 additions & 2 deletions cluster/host_detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ func TestGKE() (string, error) {
if err != nil {
return "", err
}
defer resp.Body.Close()
defer resp.Body.Close() // nolint:errcheck
body, err := io.ReadAll(resp.Body)
if err != nil {
return "", err
}
content := make(map[string]interface{})
content := make(map[string]any)
err = yaml.Unmarshal(body, &content)
if err != nil {
return "", err
Expand Down
4 changes: 2 additions & 2 deletions conditions/getter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ var (
func newConditioned(name string) *conditioned { // nolint: errcheck
return &conditioned{
Unstructured: &unstructured.Unstructured{
Object: map[string]interface{}{
Object: map[string]any{
"kind": "Foo",
"metadata": map[string]interface{}{
"metadata": map[string]any{
"name": name,
},
},
Expand Down
14 changes: 7 additions & 7 deletions conditions/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ type matchConditions struct {
expected kmapi.Conditions
}

func (m matchConditions) Match(actual interface{}) (success bool, err error) {
elems := []interface{}{}
func (m matchConditions) Match(actual any) (success bool, err error) {
elems := []any{}
for _, condition := range m.expected {
elems = append(elems, MatchCondition(condition))
}

return gomega.ConsistOf(elems).Match(actual)
}

func (m matchConditions) FailureMessage(actual interface{}) (message string) {
func (m matchConditions) FailureMessage(actual any) (message string) {
return fmt.Sprintf("expected\n\t%#v\nto match\n\t%#v\n", actual, m.expected)
}

func (m matchConditions) NegatedFailureMessage(actual interface{}) (message string) {
func (m matchConditions) NegatedFailureMessage(actual any) (message string) {
return fmt.Sprintf("expected\n\t%#v\nto not match\n\t%#v\n", actual, m.expected)
}

Expand All @@ -64,7 +64,7 @@ type matchCondition struct {
expected kmapi.Condition
}

func (m matchCondition) Match(actual interface{}) (success bool, err error) {
func (m matchCondition) Match(actual any) (success bool, err error) {
actualCondition, ok := actual.(kmapi.Condition)
if !ok {
return false, fmt.Errorf("actual should be of type Condition")
Expand Down Expand Up @@ -94,10 +94,10 @@ func (m matchCondition) Match(actual interface{}) (success bool, err error) {
return ok, err
}

func (m matchCondition) FailureMessage(actual interface{}) (message string) {
func (m matchCondition) FailureMessage(actual any) (message string) {
return fmt.Sprintf("expected\n\t%#v\nto match\n\t%#v\n", actual, m.expected)
}

func (m matchCondition) NegatedFailureMessage(actual interface{}) (message string) {
func (m matchCondition) NegatedFailureMessage(actual any) (message string) {
return fmt.Sprintf("expected\n\t%#v\nto not match\n\t%#v\n", actual, m.expected)
}
4 changes: 2 additions & 2 deletions conditions/matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
func TestMatchConditions(t *testing.T) {
testCases := []struct {
name string
actual interface{}
actual any
expected kmapi.Conditions
expectMatch bool
}{
Expand Down Expand Up @@ -151,7 +151,7 @@ func TestMatchConditions(t *testing.T) {
func TestMatchCondition(t *testing.T) {
testCases := []struct {
name string
actual interface{}
actual any
expected kmapi.Condition
expectMatch bool
}{
Expand Down
6 changes: 3 additions & 3 deletions conditions/matchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type conditionMatcher struct {
Expected *kmapi.Condition
}

func (matcher *conditionMatcher) Match(actual interface{}) (success bool, err error) {
func (matcher *conditionMatcher) Match(actual any) (success bool, err error) {
actualCondition, ok := actual.(*kmapi.Condition)
if !ok {
return false, errors.New("value should be a condition")
Expand All @@ -45,10 +45,10 @@ func (matcher *conditionMatcher) Match(actual interface{}) (success bool, err er
return hasSameState(actualCondition, matcher.Expected), nil
}

func (matcher *conditionMatcher) FailureMessage(actual interface{}) (message string) {
func (matcher *conditionMatcher) FailureMessage(actual any) (message string) {
return format.Message(actual, "to have the same state of", matcher.Expected)
}

func (matcher *conditionMatcher) NegatedFailureMessage(actual interface{}) (message string) {
func (matcher *conditionMatcher) NegatedFailureMessage(actual any) (message string) {
return format.Message(actual, "not to have the same state of", matcher.Expected)
}
8 changes: 4 additions & 4 deletions conditions/merge_strategies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ func TestLocalizeReason(t *testing.T) {

getter := &conditioned{
Unstructured: &unstructured.Unstructured{
Object: map[string]interface{}{
Object: map[string]any{
"kind": "Foo",
"metadata": map[string]interface{}{
"metadata": map[string]any{
"name": "test-cluster",
},
},
Expand All @@ -74,9 +74,9 @@ func TestGetFirstReasonAndMessage(t *testing.T) {

getter := &conditioned{
Unstructured: &unstructured.Unstructured{
Object: map[string]interface{}{
Object: map[string]any{
"kind": "Foo",
"metadata": map[string]interface{}{
"metadata": map[string]any{
"name": "test-cluster",
},
},
Expand Down
4 changes: 2 additions & 2 deletions conditions/patch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ func TestApplyDoesNotAlterLastTransitionTime(t *testing.T) {
before := newConditioned("test")
after := &conditioned{
Unstructured: &unstructured.Unstructured{
Object: map[string]interface{}{
"status": map[string]interface{}{
Object: map[string]any{
"status": map[string]any{
"conditions": kmapi.Conditions{
kmapi.Condition{
Type: "foo",
Expand Down
8 changes: 4 additions & 4 deletions conditions/setter.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TrueCondition(t kmapi.ConditionType) *kmapi.Condition {
}

// FalseCondition returns a condition with Status=False and the given type.
func FalseCondition(t kmapi.ConditionType, reason string, severity kmapi.ConditionSeverity, messageFormat string, messageArgs ...interface{}) *kmapi.Condition {
func FalseCondition(t kmapi.ConditionType, reason string, severity kmapi.ConditionSeverity, messageFormat string, messageArgs ...any) *kmapi.Condition {
return &kmapi.Condition{
Type: t,
Status: metav1.ConditionFalse,
Expand All @@ -99,7 +99,7 @@ func FalseCondition(t kmapi.ConditionType, reason string, severity kmapi.Conditi
}

// UnknownCondition returns a condition with Status=Unknown and the given type.
func UnknownCondition(t kmapi.ConditionType, reason string, messageFormat string, messageArgs ...interface{}) *kmapi.Condition {
func UnknownCondition(t kmapi.ConditionType, reason string, messageFormat string, messageArgs ...any) *kmapi.Condition {
return &kmapi.Condition{
Type: t,
Status: metav1.ConditionUnknown,
Expand All @@ -114,12 +114,12 @@ func MarkTrue(to Setter, t kmapi.ConditionType) {
}

// MarkUnknown sets Status=Unknown for the condition with the given type.
func MarkUnknown(to Setter, t kmapi.ConditionType, reason, messageFormat string, messageArgs ...interface{}) {
func MarkUnknown(to Setter, t kmapi.ConditionType, reason, messageFormat string, messageArgs ...any) {
Set(to, UnknownCondition(t, reason, messageFormat, messageArgs...))
}

// MarkFalse sets Status=False for the condition with the given type.
func MarkFalse(to Setter, t kmapi.ConditionType, reason string, severity kmapi.ConditionSeverity, messageFormat string, messageArgs ...interface{}) {
func MarkFalse(to Setter, t kmapi.ConditionType, reason string, severity kmapi.ConditionSeverity, messageFormat string, messageArgs ...any) {
Set(to, FalseCondition(t, reason, severity, messageFormat, messageArgs...))
}

Expand Down
6 changes: 3 additions & 3 deletions conditions/setter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ type ConditionsMatcher struct {
Expected kmapi.Conditions
}

func (matcher *ConditionsMatcher) Match(actual interface{}) (success bool, err error) {
func (matcher *ConditionsMatcher) Match(actual any) (success bool, err error) {
actualConditions, ok := actual.(kmapi.Conditions)
if !ok {
return false, errors.New("value should be a conditions list")
Expand All @@ -288,10 +288,10 @@ func (matcher *ConditionsMatcher) Match(actual interface{}) (success bool, err e
return true, nil
}

func (matcher *ConditionsMatcher) FailureMessage(actual interface{}) (message string) {
func (matcher *ConditionsMatcher) FailureMessage(actual any) (message string) {
return format.Message(actual, "to have the same conditions of", matcher.Expected)
}

func (matcher *ConditionsMatcher) NegatedFailureMessage(actual interface{}) (message string) {
func (matcher *ConditionsMatcher) NegatedFailureMessage(actual any) (message string) {
return format.Message(actual, "not to have the same conditions of", matcher.Expected)
}
10 changes: 5 additions & 5 deletions dynamic/conditions/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (do *DynamicOptions) SetCondition(newCond kmapi.Condition) error {
}
conds = conditions.SetCondition(conds, newCond)

unstrConds := make([]interface{}, len(conds))
unstrConds := make([]any, len(conds))
for i := range conds {
cond, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&conds[i])
if err != nil {
Expand All @@ -87,7 +87,7 @@ func (do *DynamicOptions) RemoveCondition(condType string) error {
}
conds = conditions.RemoveCondition(conds, condType)

unstrConds := make([]interface{}, len(conds))
unstrConds := make([]any, len(conds))
for i := range conds {
cond, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&conds[i])
if err != nil {
Expand Down Expand Up @@ -147,7 +147,7 @@ func (do *DynamicOptions) UpdateConditions(conditions []kmapi.Condition) error {
return err
}

unstrConds := make([]interface{}, len(conditions))
unstrConds := make([]any, len(conditions))
for i := range conditions {
cond, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&conditions[i])
if err != nil {
Expand All @@ -170,8 +170,8 @@ func stringToTimeHookFunc(layout string) mapstructure.DecodeHookFunc {
return func(
f reflect.Type,
t reflect.Type,
data interface{},
) (interface{}, error) {
data any,
) (any, error) {
if f.Kind() != reflect.String {
return data, nil
}
Expand Down
10 changes: 5 additions & 5 deletions dynamic/conditions/conditions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var conds = []kmapi.Condition{
}

func newFoo() (*unstructured.Unstructured, error) {
unstrConds := make([]interface{}, len(conds))
unstrConds := make([]any, len(conds))
for i := range conds {
cond, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&conds[i])
if err != nil {
Expand All @@ -68,17 +68,17 @@ func newFoo() (*unstructured.Unstructured, error) {
unstrConds[i] = cond
}
return &unstructured.Unstructured{
Object: map[string]interface{}{
Object: map[string]any{
"apiVersion": "foo/v1",
"kind": "Foo",
"metadata": map[string]interface{}{
"metadata": map[string]any{
"name": "foo-test",
"namespace": "bar",
},
"spec": map[string]interface{}{
"spec": map[string]any{
"foo": "bar",
},
"status": map[string]interface{}{
"status": map[string]any{
"conditions": unstrConds,
},
},
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ require (
go.uber.org/zap v1.27.0 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/crypto v0.36.0 // indirect
golang.org/x/crypto v0.45.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/net v0.38.0 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/oauth2 v0.30.0 // indirect
golang.org/x/sync v0.15.0 // indirect
golang.org/x/sys v0.33.0 // indirect
golang.org/x/term v0.30.0 // indirect
golang.org/x/text v0.23.0 // indirect
golang.org/x/sync v0.18.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/term v0.37.0 // indirect
golang.org/x/text v0.31.0 // indirect
gomodules.xyz/homedir v0.1.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb // indirect
Expand Down
Loading
Loading