use json to unmarshal json

Signed-off-by: Raffaele Di Fazio <difazio.raffaele@gmail.com>
This commit is contained in:
Raffaele Di Fazio 2025-04-15 09:30:37 +02:00
parent b38d6bc867
commit 3e9f4642e3

View File

@ -17,6 +17,7 @@ limitations under the License.
package azure package azure
import ( import (
"encoding/json"
"fmt" "fmt"
"os" "os"
"strings" "strings"
@ -25,7 +26,6 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/azidentity"
yaml "github.com/goccy/go-yaml"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
@ -50,9 +50,8 @@ func getConfig(configFile, subscriptionID, resourceGroup, userAssignedIdentityCl
return nil, fmt.Errorf("failed to read Azure config file '%s': %v", configFile, err) return nil, fmt.Errorf("failed to read Azure config file '%s': %v", configFile, err)
} }
cfg := &config{} cfg := &config{}
err = yaml.Unmarshal(contents, &cfg) if err := json.Unmarshal(contents, &cfg); err != nil {
if err != nil { return nil, fmt.Errorf("failed to parse Azure config file '%s': %v", configFile, err)
return nil, fmt.Errorf("failed to read Azure config file '%s': %v", configFile, err)
} }
// If a subscription ID was given, override what was present in the config file // If a subscription ID was given, override what was present in the config file
if subscriptionID != "" { if subscriptionID != "" {