Skip to content
Open
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
12 changes: 6 additions & 6 deletions modules/ansible/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ import "gopkg.in/yaml.v3"
// Host represents ansible host
type Host struct {
name string
Vars map[string]interface{} `yaml:",inline"`
Vars map[string]any `yaml:",inline"`
}

// MakeHost instatiates an Host object
func MakeHost(name string) Host {
return Host{
name: name,
Vars: make(map[string]interface{}),
Vars: make(map[string]any),
}
}

// Group represents ansible group
type Group struct {
name string
Vars map[string]interface{} `yaml:",omitempty"`
Hosts map[string]Host `yaml:",omitempty"`
Children map[string]Group `yaml:",omitempty"`
Vars map[string]any `yaml:",omitempty"`
Hosts map[string]Host `yaml:",omitempty"`
Children map[string]Group `yaml:",omitempty"`
}

// AddHost adds a host to the current group
Expand All @@ -51,7 +51,7 @@ func (group Group) AddHost(name string) Host {
func MakeGroup(name string) Group {
return Group{
name: name,
Vars: make(map[string]interface{}),
Vars: make(map[string]any),
Hosts: make(map[string]Host),
Children: make(map[string]Group),
}
Expand Down
8 changes: 4 additions & 4 deletions modules/certmanager/test/helpers/certmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ func (tc *TestHelper) AssertIssuerDoesNotExist(name types.NamespacedName) {
//
// cm := th.CreateIssuer(types.NamespacedName{Namespace: "default", Name: "example-configmap"})
func (tc *TestHelper) CreateIssuer(name types.NamespacedName) client.Object {
raw := map[string]interface{}{
raw := map[string]any{
"apiVersion": "cert-manager.io/v1",
"kind": "Issuer",
"metadata": map[string]interface{}{
"metadata": map[string]any{
"name": name.Name,
"namespace": name.Namespace,
},
"spec": map[string]interface{}{
"ca": map[string]interface{}{
"spec": map[string]any{
"ca": map[string]any{
"secretName": name.Name,
},
},
Expand Down
12 changes: 6 additions & 6 deletions modules/common/condition/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,17 @@ func (conditions *Conditions) Has(t Type) bool {
}

// MarkTrue sets Status=True for the condition with the given type.
func (conditions *Conditions) MarkTrue(t Type, messageFormat string, messageArgs ...interface{}) {
func (conditions *Conditions) MarkTrue(t Type, messageFormat string, messageArgs ...any) {
conditions.Set(TrueCondition(t, messageFormat, messageArgs...))
}

// MarkFalse sets Status=False for the condition with the given type.
func (conditions *Conditions) MarkFalse(t Type, reason Reason, severity Severity, messageFormat string, messageArgs ...interface{}) {
func (conditions *Conditions) MarkFalse(t Type, reason Reason, severity Severity, messageFormat string, messageArgs ...any) {
conditions.Set(FalseCondition(t, reason, severity, messageFormat, messageArgs...))
}

// MarkUnknown sets Status=Unknown for the condition with the given type.
func (conditions *Conditions) MarkUnknown(t Type, reason Reason, messageFormat string, messageArgs ...interface{}) {
func (conditions *Conditions) MarkUnknown(t Type, reason Reason, messageFormat string, messageArgs ...any) {
conditions.Set(UnknownCondition(t, reason, messageFormat, messageArgs...))
}

Expand Down Expand Up @@ -225,7 +225,7 @@ func HasSameState(i, j *Condition) bool {
}

// TrueCondition returns a condition with Status=True and the given type.
func TrueCondition(t Type, messageFormat string, messageArgs ...interface{}) *Condition {
func TrueCondition(t Type, messageFormat string, messageArgs ...any) *Condition {
return &Condition{
Type: t,
Status: corev1.ConditionTrue,
Expand All @@ -236,7 +236,7 @@ func TrueCondition(t Type, messageFormat string, messageArgs ...interface{}) *Co
}

// FalseCondition returns a condition with Status=False and the given type.
func FalseCondition(t Type, reason Reason, severity Severity, messageFormat string, messageArgs ...interface{}) *Condition {
func FalseCondition(t Type, reason Reason, severity Severity, messageFormat string, messageArgs ...any) *Condition {
return &Condition{
Type: t,
Status: corev1.ConditionFalse,
Expand All @@ -247,7 +247,7 @@ func FalseCondition(t Type, reason Reason, severity Severity, messageFormat stri
}

// UnknownCondition returns a condition with Status=Unknown and the given type.
func UnknownCondition(t Type, reason Reason, messageFormat string, messageArgs ...interface{}) *Condition {
func UnknownCondition(t Type, reason Reason, messageFormat string, messageArgs ...any) *Condition {
return &Condition{
Type: t,
Status: corev1.ConditionUnknown,
Expand Down
12 changes: 6 additions & 6 deletions modules/common/condition/funcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ type conditionsMatcher struct {
Expected Conditions
}

func (matcher *conditionsMatcher) Match(actual interface{}) (success bool, err error) {
func (matcher *conditionsMatcher) Match(actual any) (success bool, err error) {
actualConditions, ok := actual.(Conditions)
if !ok {
return false, errors.New("Value should be a conditions list")
Expand All @@ -705,11 +705,11 @@ 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)
}

Expand All @@ -724,7 +724,7 @@ type conditionMatcher struct {
Expected *Condition
}

func (matcher *conditionMatcher) Match(actual interface{}) (success bool, err error) {
func (matcher *conditionMatcher) Match(actual any) (success bool, err error) {
actualCondition, ok := actual.(*Condition)
if !ok {
return false, errors.New("value should be a condition")
Expand All @@ -733,10 +733,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)
}
2 changes: 1 addition & 1 deletion modules/common/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (h *Helper) calculateChanges(after client.Object) (map[string]bool, error)
}

// Unmarshal patch data into a local map.
patchDiff := map[string]interface{}{}
patchDiff := map[string]any{}
if err := json.Unmarshal(diff, &patchDiff); err != nil {
return nil, errors.Wrapf(err, "failed to unmarshal patch data into a map")
}
Expand Down
6 changes: 3 additions & 3 deletions modules/common/helper/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ func TestToUnstructured(t *testing.T) {
g := NewWithT(t)

obj := &unstructured.Unstructured{
Object: map[string]interface{}{
Object: map[string]any{
"apiVersion": "test.x.y.z/v1",
"metadata": map[string]interface{}{
"metadata": map[string]any{
"name": "keystone",
"namespace": "openstack",
},
"spec": map[string]interface{}{
"spec": map[string]any{
"databaseHostname": "dbhost",
},
},
Expand Down
4 changes: 2 additions & 2 deletions modules/common/networkattachment/networkattachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func EnsureNetworksAnnotation(
gatewayReq := []net.IP{}
if nad.Spec.Config != "" {

var data interface{}
var data any
if err := json.Unmarshal([]byte(nad.Spec.Config), &data); err != nil {
return nil, fmt.Errorf("failed to unmarshal JSON data: %w", err)
}
Expand Down Expand Up @@ -213,7 +213,7 @@ func EnsureNetworksAnnotation(
// if the NAD has no config, an empty string is returned.
// The jsonPath must be in the format e.g. ".ipam"
func GetJSONPathFromConfig(netAtt networkv1.NetworkAttachmentDefinition, path string) (string, error) {
var data interface{}
var data any
buf := new(bytes.Buffer)

if netAtt.Spec.Config == "" {
Expand Down
4 changes: 2 additions & 2 deletions modules/common/object/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func PatchOwnerRef(
owner client.Object,
object client.Object,
scheme *runtime.Scheme,
) (map[string]interface{}, client.Patch, error) {
) (map[string]any, client.Patch, error) {
beforeObject := object.DeepCopyObject().(client.Object)

// add owner ref to the object
Expand All @@ -70,7 +70,7 @@ func PatchOwnerRef(
}

// Unmarshal patch data into a local map for logging
patchDiff := map[string]interface{}{}
patchDiff := map[string]any{}
if err := json.Unmarshal(diff, &patchDiff); err != nil {
return nil, nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion modules/common/ocp/ocp.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func IsFipsCluster(ctx context.Context, h *helper.Helper) (bool, error) {
return false, err
}

var installConfig map[string]interface{}
var installConfig map[string]any
installConfigYAML := configMap.Data["install-config"]
err = yaml.Unmarshal([]byte(installConfigYAML), &installConfig)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions modules/common/test/functional/object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var _ = Describe("object package", func() {
Name: "test-cm",
}

cm := th.CreateConfigMap(cmName, map[string]interface{}{})
cm := th.CreateConfigMap(cmName, map[string]any{})

err := object.EnsureOwnerRef(th.Ctx, h, cm, cm)
Expect(err).ShouldNot(HaveOccurred())
Expand All @@ -59,14 +59,14 @@ var _ = Describe("object package", func() {
Namespace: namespace,
Name: "test-owner",
}
ownerCM := th.CreateConfigMap(owner, map[string]interface{}{})
ownerCM := th.CreateConfigMap(owner, map[string]any{})

// create target obj we add the owner ref to
cmName := types.NamespacedName{
Namespace: namespace,
Name: "test-cm",
}
cm := th.CreateConfigMap(cmName, map[string]interface{}{})
cm := th.CreateConfigMap(cmName, map[string]any{})

err := object.EnsureOwnerRef(th.Ctx, h, ownerCM, cm)
Expect(err).ShouldNot(HaveOccurred())
Expand Down
2 changes: 1 addition & 1 deletion modules/common/test/helpers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func getTestTimeout(defaultTimeout time.Duration) time.Duration {
// ...
// }
// unstructuredObj := tc.CreateUnstructured(rawObj)
func (tc *TestHelper) CreateUnstructured(rawObj map[string]interface{}) *unstructured.Unstructured {
func (tc *TestHelper) CreateUnstructured(rawObj map[string]any) *unstructured.Unstructured {
tc.Logger.Info("Creating", "raw", rawObj)
unstructuredObj := &unstructured.Unstructured{Object: rawObj}
_, err := controllerutil.CreateOrPatch(
Expand Down
6 changes: 3 additions & 3 deletions modules/common/test/helpers/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ func (tc *TestHelper) DeleteConfigMap(name types.NamespacedName) {
//
// data := map[string]interface{}{"key": "value"}
// cm := th.CreateConfigMap(types.NamespacedName{Namespace: "default", Name: "example-configmap"}, data)
func (tc *TestHelper) CreateConfigMap(name types.NamespacedName, data map[string]interface{}) client.Object {
raw := map[string]interface{}{
func (tc *TestHelper) CreateConfigMap(name types.NamespacedName, data map[string]any) client.Object {
raw := map[string]any{
"apiVersion": "v1",
"kind": "ConfigMap",
"metadata": map[string]interface{}{
"metadata": map[string]any{
"name": name.Name,
"namespace": name.Namespace,
},
Expand Down
6 changes: 3 additions & 3 deletions modules/common/test/helpers/nad.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ func (tc *TestHelper) GetNAD(name types.NamespacedName) *networkv1.NetworkAttach
//
// spec := map[string]interface{}{"key": "value"}
// p := th.CreateNAD(types.NamespacedName{Namespace: "default", Name: "example"}, spec)
func (tc *TestHelper) CreateNAD(name types.NamespacedName, spec map[string]interface{}) client.Object {
raw := map[string]interface{}{
func (tc *TestHelper) CreateNAD(name types.NamespacedName, spec map[string]any) client.Object {
raw := map[string]any{
"apiVersion": "k8s.cni.cncf.io/v1",
"kind": "NetworkAttachmentDefinition",
"metadata": map[string]interface{}{
"metadata": map[string]any{
"name": name.Name,
"namespace": name.Namespace,
},
Expand Down
6 changes: 3 additions & 3 deletions modules/common/test/helpers/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ func (tc *TestHelper) SimulatePodReady(name types.NamespacedName) {
// annotations := map[string]string{}{"key": "value"}
// spec := map[string]interface{}{"key": "value"}
// p := th.CreatePod(types.NamespacedName{Namespace: "default", Name: "example"}, annotations, spec)
func (tc *TestHelper) CreatePod(name types.NamespacedName, annotations map[string]string, spec map[string]interface{}) client.Object {
raw := map[string]interface{}{
func (tc *TestHelper) CreatePod(name types.NamespacedName, annotations map[string]string, spec map[string]any) client.Object {
raw := map[string]any{
"apiVersion": "v1",
"kind": "Pod",
"metadata": map[string]interface{}{
"metadata": map[string]any{
"annotations": annotations,
"name": name.Name,
"namespace": name.Namespace,
Expand Down
4 changes: 2 additions & 2 deletions modules/common/tls/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ type APIService struct {
// +kubebuilder:validation:optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
// Public GenericService - holds the secret for the public endpoint
Public GenericService `json:"public,omitempty"`
Public GenericService `json:"public"`

// +kubebuilder:validation:optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
// Internal GenericService - holds the secret for the internal endpoint
Internal GenericService `json:"internal,omitempty"`
Internal GenericService `json:"internal"`
}

// GenericService contains server-specific TLS secret or issuer
Expand Down
6 changes: 3 additions & 3 deletions modules/common/util/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import "encoding/json"
// GetOr returns the value of m[key] if it exists, fallback otherwise.
// As a special case, it also returns fallback if the value of m[key] is
// the empty string
func GetOr(m map[string]interface{}, key, fallback string) interface{} {
func GetOr(m map[string]any, key, fallback string) any {
val, ok := m[key]
if !ok {
return fallback
Expand All @@ -37,7 +37,7 @@ func GetOr(m map[string]interface{}, key, fallback string) interface{} {

// IsSet returns the value of m[key] if key exists, otherwise false
// Different from getOr because it will return zero values.
func IsSet(m map[string]interface{}, key string) interface{} {
func IsSet(m map[string]any, key string) any {
val, ok := m[key]
if !ok {
return false
Expand All @@ -47,7 +47,7 @@ func IsSet(m map[string]interface{}, key string) interface{} {

// IsJSON check if string is json format
func IsJSON(s string) error {
var js map[string]interface{}
var js map[string]any
return json.Unmarshal([]byte(s), &js)
}

Expand Down
18 changes: 9 additions & 9 deletions modules/common/util/funcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,25 @@ func TestGetOr(t *testing.T) {

tests := []struct {
name string
data map[string]interface{}
data map[string]any
key string
want interface{}
want any
}{
{
name: "Key exists with value 111, returns 111",
data: map[string]interface{}{"one": "111"},
data: map[string]any{"one": "111"},
key: "one",
want: "111",
},
{
name: "Key exists and empty string value, returns fallback",
data: map[string]interface{}{"one": ""},
data: map[string]any{"one": ""},
key: "one",
want: "fallback",
},
{
name: "Key does not exist, returns the fallback",
data: map[string]interface{}{"one": "111"},
data: map[string]any{"one": "111"},
key: "four",
want: "fallback",
},
Expand All @@ -66,19 +66,19 @@ func TestIsSet(t *testing.T) {

tests := []struct {
name string
data map[string]interface{}
data map[string]any
key string
want interface{}
want any
}{
{
name: "Key exists, returns 111",
data: map[string]interface{}{"one": "111"},
data: map[string]any{"one": "111"},
key: "one",
want: "111",
},
{
name: "Key does not exist, returns false",
data: map[string]interface{}{"one": "111"},
data: map[string]any{"one": "111"},
key: "four",
want: false,
},
Expand Down
Loading