Skip to content

Commit

Permalink
Remove unnecessary json marshal/unmarshal
Browse files Browse the repository at this point in the history
  • Loading branch information
crobby committed Aug 16, 2023
1 parent df0307e commit df507b5
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions pkg/agent/clean/adunmigration/ldap.go
Expand Up @@ -3,7 +3,6 @@ package adunmigration
import (
"bytes"
"crypto/x509"
"encoding/json"
"fmt"
"os"
"regexp"
Expand Down Expand Up @@ -265,17 +264,9 @@ func updateADConfigMigrationStatus(status map[string]string, sc *config.ScaledCo
return err
}

authConfigJSON, err := json.Marshal(authConfigObj)
if err != nil {
return fmt.Errorf("failed to marshal authConfig object to JSON: %v", err)
}

// Create an empty unstructured object to hold the decoded JSON
storedADConfig := &unstructured.Unstructured{}

// Decode the JSON string into the unstructured object because mapstructure is dropping the metadata
if err := json.Unmarshal(authConfigJSON, storedADConfig); err != nil {
return fmt.Errorf("failed to unmarshal JSON into storedADConfig: %v", err)
storedADConfig, ok := authConfigObj.(*unstructured.Unstructured)
if !ok {
return fmt.Errorf("[%v] expected unstructured authconfig, got %T", migrateAdUserOperation, authConfigObj)
}

// Update annotations with migration status
Expand Down

0 comments on commit df507b5

Please sign in to comment.