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
13 changes: 4 additions & 9 deletions controllers/dataplane/openstackdataplanenodeset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package dataplane
import (
"context"
"fmt"
"maps"
"slices"
"strings"
"time"
Expand Down Expand Up @@ -555,15 +556,9 @@ func checkDeployment(ctx context.Context, helper *helper.Helper,
continue
}
isDeploymentReady = true
for k, v := range deployment.Status.ConfigMapHashes {
instance.Status.ConfigMapHashes[k] = v
}
for k, v := range deployment.Status.SecretHashes {
instance.Status.SecretHashes[k] = v
}
for k, v := range deployment.Status.ContainerImages {
instance.Status.ContainerImages[k] = v
}
maps.Copy(instance.Status.ConfigMapHashes, deployment.Status.ConfigMapHashes)
maps.Copy(instance.Status.SecretHashes, deployment.Status.SecretHashes)
maps.Copy(instance.Status.ContainerImages, deployment.Status.ContainerImages)
instance.Status.DeployedConfigHash = deployment.Status.NodeSetHashes[instance.Name]

// Get list of services by name, either from ServicesOverride or
Expand Down
2 changes: 1 addition & 1 deletion controllers/operator/openstack_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ func (r *OpenStackReconciler) postCleanupObsoleteResources(ctx context.Context,
// The horizon-operator.openstack-operators has references to old roles/bindings
// the code below will delete those references before continuing
for _, ref := range refs {
refData := ref.(map[string]interface{})
refData := ref.(map[string]any)
Log.Info("Deleting operator reference", "Reference", ref)
obj := uns.Unstructured{}
obj.SetName(refData["name"].(string))
Expand Down
2 changes: 1 addition & 1 deletion pkg/dataplane/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func (d *Deployer) addCertMounts(
projectedVolumeSource := corev1.ProjectedVolumeSource{
Sources: []corev1.VolumeProjection{},
}
for i := 0; i < numberOfSecrets; i++ {
for i := range numberOfSecrets {
secretName := GetServiceCertsSecretName(d.NodeSet, service.Name, certKey, i)
certSecret := &corev1.Secret{}
err := client.Get(d.Ctx, types.NamespacedName{Name: secretName, Namespace: service.Namespace}, certSecret)
Expand Down
21 changes: 8 additions & 13 deletions pkg/dataplane/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"encoding/json"
"fmt"
"maps"
"net"
"strconv"
"strings"
Expand All @@ -37,8 +38,8 @@ import (
)

// getAnsibleVarsFrom gets ansible vars from ConfigMap/Secret
func getAnsibleVarsFrom(ctx context.Context, helper *helper.Helper, namespace string, ansible *dataplanev1.AnsibleOpts) (map[string]interface{}, error) {
result := make(map[string]interface{})
func getAnsibleVarsFrom(ctx context.Context, helper *helper.Helper, namespace string, ansible *dataplanev1.AnsibleOpts) (map[string]any, error) {
result := make(map[string]any)

for _, dataSource := range ansible.AnsibleVarsFrom {
configMap, secret, err := util.GetDataSourceCmSecret(ctx, helper, namespace, dataSource)
Expand Down Expand Up @@ -123,9 +124,7 @@ func GenerateNodeSetInventory(ctx context.Context, helper *helper.Helper,
utils.LogErrorForObject(helper, err, "could not get ansible group vars from configMap/secret", instance)
return "", err
}
for k, v := range groupVars {
nodeSetGroup.Vars[k] = v
}
maps.Copy(nodeSetGroup.Vars, groupVars)
err = resolveGroupAnsibleVars(&instance.Spec.NodeTemplate,
&nodeSetGroup, containerImages, netServiceNetMap)
if err != nil {
Expand Down Expand Up @@ -184,9 +183,7 @@ func GenerateNodeSetInventory(ctx context.Context, helper *helper.Helper,
utils.LogErrorForObject(helper, err, "could not get ansible host vars from configMap/secret", instance)
return "", err
}
for k, v := range hostVars {
host.Vars[k] = v
}
maps.Copy(host.Vars, hostVars)
// Use ansible_host if provided else use hostname. Fall back to
// nodeName if all else fails.
if node.Ansible.AnsibleHost != "" {
Expand Down Expand Up @@ -223,9 +220,7 @@ func GenerateNodeSetInventory(ctx context.Context, helper *helper.Helper,
"openstackdataplanenodeset": instance.Name,
"inventory": "true",
}
for key, val := range instance.Labels {
labels[key] = val
}
maps.Copy(labels, instance.Labels)
template := []utils.Template{
// Secret
{
Expand Down Expand Up @@ -399,10 +394,10 @@ func resolveHostAnsibleVars(node *dataplanev1.NodeSection,

// unmarshal raw strings into an ansible vars dictionary
func unmarshalAnsibleVars(ansibleVars map[string]json.RawMessage,
parsedVars map[string]interface{},
parsedVars map[string]any,
) error {
for key, val := range ansibleVars {
var v interface{}
var v any
err := yaml.Unmarshal(val, &v)
if err != nil {
return err
Expand Down
20 changes: 10 additions & 10 deletions pkg/dataplane/inventory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func TestProcessConfigMapData_NumbersAsInts(t *testing.T) {
name string
data map[string]string
prefix string
expected map[string]interface{}
expected map[string]any
expectedType any
}{
{
Expand All @@ -21,7 +21,7 @@ func TestProcessConfigMapData_NumbersAsInts(t *testing.T) {
"foo": "bar",
},
prefix: "",
expected: map[string]interface{}{
expected: map[string]any{
"foo": "bar",
},
expectedType: "",
Expand All @@ -32,7 +32,7 @@ func TestProcessConfigMapData_NumbersAsInts(t *testing.T) {
"intVal": "123",
},
prefix: "",
expected: map[string]interface{}{
expected: map[string]any{
"intVal": json.Number("123"),
},
expectedType: json.Number("1"),
Expand All @@ -43,7 +43,7 @@ func TestProcessConfigMapData_NumbersAsInts(t *testing.T) {
"floatVal": "123.45",
},
prefix: "",
expected: map[string]interface{}{
expected: map[string]any{
"floatVal": json.Number("123.45"),
},
expectedType: json.Number("1"),
Expand All @@ -54,7 +54,7 @@ func TestProcessConfigMapData_NumbersAsInts(t *testing.T) {
"somekey": "42",
},
prefix: "myprefix-",
expected: map[string]interface{}{
expected: map[string]any{
"myprefix-somekey": json.Number("42"),
},
expectedType: json.Number("1"),
Expand Down Expand Up @@ -91,7 +91,7 @@ func TestProcessSecretData_NumbersAsInts(t *testing.T) {
name string
data map[string][]byte
prefix string
expected map[string]interface{}
expected map[string]any
expectedType any
}{
{
Expand All @@ -100,7 +100,7 @@ func TestProcessSecretData_NumbersAsInts(t *testing.T) {
"foo": []byte("bar"),
},
prefix: "",
expected: map[string]interface{}{
expected: map[string]any{
"foo": "bar",
},
expectedType: "",
Expand All @@ -111,7 +111,7 @@ func TestProcessSecretData_NumbersAsInts(t *testing.T) {
"intVal": []byte("123"),
},
prefix: "",
expected: map[string]interface{}{
expected: map[string]any{
"intVal": json.Number("123"),
},
expectedType: json.Number("1"),
Expand All @@ -122,7 +122,7 @@ func TestProcessSecretData_NumbersAsInts(t *testing.T) {
"floatVal": []byte("123.45"),
},
prefix: "",
expected: map[string]interface{}{
expected: map[string]any{
"floatVal": json.Number("123.45"),
},
expectedType: json.Number("1"),
Expand All @@ -133,7 +133,7 @@ func TestProcessSecretData_NumbersAsInts(t *testing.T) {
"somekey": []byte("42"),
},
prefix: "myprefix-",
expected: map[string]interface{}{
expected: map[string]any{
"myprefix-somekey": json.Number("42"),
},
expectedType: json.Number("1"),
Expand Down
8 changes: 4 additions & 4 deletions pkg/dataplane/util/ansible_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,16 +269,16 @@ func (a *EEJob) FormatAEEExtraVars(
if service.Spec.DeployOnAllNodeSets {
a.ExtraVars["edpm_override_hosts"] = json.RawMessage([]byte("\"all\""))
} else {
a.ExtraVars["edpm_override_hosts"] = json.RawMessage([]byte(fmt.Sprintf("\"%s\"", nodeSet.GetName())))
a.ExtraVars["edpm_override_hosts"] = json.RawMessage(fmt.Appendf(nil, "\"%s\"", nodeSet.GetName()))
}
if service.Spec.EDPMServiceType != "" {
a.ExtraVars["edpm_service_type"] = json.RawMessage([]byte(fmt.Sprintf("\"%s\"", service.Spec.EDPMServiceType)))
a.ExtraVars["edpm_service_type"] = json.RawMessage(fmt.Appendf(nil, "\"%s\"", service.Spec.EDPMServiceType))
} else {
a.ExtraVars["edpm_service_type"] = json.RawMessage([]byte(fmt.Sprintf("\"%s\"", service.Name)))
a.ExtraVars["edpm_service_type"] = json.RawMessage(fmt.Appendf(nil, "\"%s\"", service.Name))
}

if len(deployment.Spec.ServicesOverride) > 0 {
a.ExtraVars["edpm_services_override"] = json.RawMessage([]byte(fmt.Sprintf("\"%s\"", deployment.Spec.ServicesOverride)))
a.ExtraVars["edpm_services_override"] = json.RawMessage(fmt.Appendf(nil, "\"%s\"", deployment.Spec.ServicesOverride))
}
}

Expand Down
7 changes: 3 additions & 4 deletions pkg/dataplane/util/ansibleee.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package util //nolint:revive // util is an acceptable package name in this conte
import (
"encoding/json"
"fmt"
"maps"
"sort"

"github.com/openstack-k8s-operators/lib-common/modules/storage"
Expand Down Expand Up @@ -183,7 +184,7 @@ func (a *EEJob) JobForOpenStackAnsibleEE(h *helper.Helper) (*batchv1.Job, error)
parsedExtraVars := ""
// unmarshal nested data structures
for _, variable := range keys {
var tmp interface{}
var tmp any
err := yaml.Unmarshal(a.ExtraVars[variable], &tmp)
if err != nil {
return nil, err
Expand All @@ -203,9 +204,7 @@ func labelsForOpenStackAnsibleEE(labels map[string]string) map[string]string {
ls := map[string]string{
"app": "openstackansibleee",
}
for key, val := range labels {
ls[key] = val
}
maps.Copy(ls, labels)
return ls
}

Expand Down
20 changes: 10 additions & 10 deletions pkg/lightspeed/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ func PatchOLSConfig(
indexID string,
) error {
// 1. Patch the Providers section
providersPatch := []interface{}{
map[string]interface{}{
"credentialsSecretRef": map[string]interface{}{
providersPatch := []any{
map[string]any{
"credentialsSecretRef": map[string]any{
"name": instance.Spec.LLMCredentials,
},
"models": []interface{}{
map[string]interface{}{
"models": []any{
map[string]any{
"name": instance.Spec.ModelName,
"parameters": map[string]interface{}{},
"parameters": map[string]any{},
},
},
"name": OpenStackLightspeedDefaultProvider,
Expand All @@ -141,8 +141,8 @@ func PatchOLSConfig(
}

// 2. Patch the RAG section
openstackRAG := []interface{}{
map[string]interface{}{
openstackRAG := []any{
map[string]any{
"image": instance.Spec.RAGImage,
"indexID": indexID,
"indexPath": OpenStackLightspeedVectorDBPath,
Expand Down Expand Up @@ -174,7 +174,7 @@ func PatchOLSConfig(

// 3. Add info which OpenStackLightspeed instance owns the OLSConfig
labels := olsConfig.GetLabels()
updatedLabels := map[string]interface{}{
updatedLabels := map[string]any{
OpenStackLightspeedOwnerIDLabel: string(instance.GetUID()),
}
for k, v := range labels {
Expand Down Expand Up @@ -299,7 +299,7 @@ func extractEnvFromPodLogs(ctx context.Context, pod *corev1.Pod, envVarName stri
}

logs := buf.String()
for _, envLine := range strings.Split(logs, "\n") {
for envLine := range strings.SplitSeq(logs, "\n") {
parts := strings.Split(envLine, "=")
if len(parts) != 2 {
continue
Expand Down
2 changes: 1 addition & 1 deletion pkg/openstack/ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ func patchIssuer(
return err
}
// 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 err
}
Expand Down
15 changes: 6 additions & 9 deletions pkg/operator/bindata/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package bindata
import (
"github.com/pkg/errors"
uns "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"maps"
)

const (
Expand Down Expand Up @@ -61,11 +62,11 @@ func MergeWebhookConfigurationForUpdate(current, updated *uns.Unstructured) erro

if gvk.Group == "admissionregistration.k8s.io" && (gvk.Kind == "MutatingWebhookConfiguration" || gvk.Kind == "ValidatingWebhookConfiguration") {

for i, webhook := range updated.Object["webhooks"].([]interface{}) {
for i, webhook := range updated.Object["webhooks"].([]any) {

currentClientConfig := current.Object["webhooks"].([]interface{})[i].(map[string]interface{})["clientConfig"].(map[string]interface{})
currentClientConfig := current.Object["webhooks"].([]any)[i].(map[string]any)["clientConfig"].(map[string]any)
if currentClientConfig != nil {
webhook.(map[string]interface{})["clientConfig"] = currentClientConfig
webhook.(map[string]any)["clientConfig"] = currentClientConfig
}

}
Expand Down Expand Up @@ -172,9 +173,7 @@ func mergeAnnotations(current, updated *uns.Unstructured) {
curAnnotations = map[string]string{}
}

for k, v := range updatedAnnotations {
curAnnotations[k] = v
}
maps.Copy(curAnnotations, updatedAnnotations)

updated.SetAnnotations(curAnnotations)
}
Expand All @@ -189,9 +188,7 @@ func mergeLabels(current, updated *uns.Unstructured) {
curLabels = map[string]string{}
}

for k, v := range updatedLabels {
curLabels[k] = v
}
maps.Copy(curLabels, updatedLabels)

// add a label for openstack.openstack.org/crd to identify CRDs we install
gvk := updated.GroupVersionKind()
Expand Down
4 changes: 2 additions & 2 deletions pkg/operator/bindata/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ import (
// RenderData -
type RenderData struct {
Funcs template.FuncMap
Data map[string]interface{}
Data map[string]any
}

// MakeRenderData -
func MakeRenderData() RenderData {
return RenderData{
Funcs: template.FuncMap{},
Data: map[string]interface{}{},
Data: map[string]any{},
}
}

Expand Down
Loading