mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 02:54:20 +00:00
fix(import): import json marshal to jsonpb (#4580)
* fix(import): import json marshal to jsonpb * fix: add unmarshaloptions discard unknown Co-authored-by: Livio Spring <livio.a@gmail.com> * fix(import): import json marshal to jsonpb Co-authored-by: Livio Spring <livio.a@gmail.com>
This commit is contained in:
parent
d2eb0b0d2a
commit
2bfa51da1c
@ -3,16 +3,17 @@ package admin
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"cloud.google.com/go/storage"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
"google.golang.org/api/option"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
"google.golang.org/protobuf/types/known/durationpb"
|
||||
|
||||
"github.com/zitadel/logging"
|
||||
@ -229,9 +230,14 @@ func (s *Server) transportDataFromFile(ctx context.Context, v1Transformation boo
|
||||
data = localData
|
||||
}
|
||||
|
||||
jsonpb := &runtime.JSONPb{
|
||||
UnmarshalOptions: protojson.UnmarshalOptions{
|
||||
DiscardUnknown: true,
|
||||
},
|
||||
}
|
||||
if v1Transformation {
|
||||
dataImportV1 := new(v1_pb.ImportDataOrg)
|
||||
if err := json.Unmarshal(data, dataImportV1); err != nil {
|
||||
if err := jsonpb.Unmarshal(data, dataImportV1); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -242,7 +248,7 @@ func (s *Server) transportDataFromFile(ctx context.Context, v1Transformation boo
|
||||
dataOrgs = dataImport.Orgs
|
||||
} else {
|
||||
dataImport := new(admin_pb.ImportDataOrg)
|
||||
if err := json.Unmarshal(data, dataImport); err != nil {
|
||||
if err := jsonpb.Unmarshal(data, dataImport); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dataOrgs = dataImport.Orgs
|
||||
|
Loading…
Reference in New Issue
Block a user