Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 8 of 8 for ApplyJSON (0.13 sec)

  1. pkg/util/gogoprotomarshal/protomarshal.go

    import (
    	"strings"
    
    	"github.com/gogo/protobuf/jsonpb" // nolint: depguard
    	"github.com/gogo/protobuf/proto"  // nolint: depguard
    
    	"istio.io/istio/pkg/log"
    )
    
    // ApplyJSON unmarshals a JSON string into a proto message. Unknown fields are allowed
    func ApplyJSON(js string, pb proto.Message) error {
    	reader := strings.NewReader(js)
    	m := jsonpb.Unmarshaler{}
    	if err := m.Unmarshal(reader, pb); err != nil {
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Tue May 23 17:08:31 UTC 2023
    - 1.4K bytes
    - Viewed (0)
  2. pkg/util/protomarshal/protomarshal.go

    	var data map[string]any
    	err = json.Unmarshal([]byte(js), &data)
    	if err != nil {
    		return nil, err
    	}
    
    	return data, nil
    }
    
    // ApplyJSON unmarshals a JSON string into a proto message.
    func ApplyJSON(js string, pb proto.Message) error {
    	reader := strings.NewReader(js)
    	m := jsonpb.Unmarshaler{}
    	if err := m.Unmarshal(reader, legacyproto.MessageV1(pb)); err != nil {
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Tue Mar 12 10:02:09 UTC 2024
    - 6.6K bytes
    - Viewed (0)
  3. pkg/config/model.go

    	return d.Decode(&s)
    }
    
    func ApplyJSON(s Spec, js string) error {
    	// golang protobuf. Use protoreflect.ProtoMessage to distinguish from gogo
    	// golang/protobuf 1.4+ will have this interface. Older golang/protobuf are gogo compatible
    	// but also not used by Istio at all.
    	if _, ok := s.(protoreflect.ProtoMessage); ok {
    		if pb, ok := s.(proto.Message); ok {
    			err := protomarshal.ApplyJSON(js, pb)
    			return err
    		}
    	}
    
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Wed May 29 15:31:09 UTC 2024
    - 12.6K bytes
    - Viewed (0)
  4. tests/fuzz/config_validation_fuzzer.go

    	spec, err := r.NewInstance()
    	if err != nil {
    		return 0
    	}
    	jsonData, err := f.GetString()
    	if err != nil {
    		return 0
    	}
    	err = config.ApplyJSON(spec, jsonData)
    	if err != nil {
    		return 0
    	}
    
    	m := config.Meta{}
    	err = f.GenerateStruct(&m)
    	if err != nil {
    		return 0
    	}
    
    	gvk := r.GroupVersionKind()
    	m.GroupVersionKind = gvk
    
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Sat Mar 30 00:31:03 UTC 2024
    - 5.3K bytes
    - Viewed (0)
  5. pilot/pkg/config/kube/crd/conversion.go

    )
    
    // FromJSON converts a canonical JSON to a proto message
    func FromJSON(s resource.Schema, js string) (config.Spec, error) {
    	c, err := s.NewInstance()
    	if err != nil {
    		return nil, err
    	}
    	if err = config.ApplyJSON(c, js); err != nil {
    		return nil, err
    	}
    	return c, nil
    }
    
    func StatusJSONFromMap(schema resource.Schema, jsonMap *json.RawMessage) (config.Status, error) {
    	if jsonMap == nil {
    		return nil, nil
    	}
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Thu Apr 25 18:26:16 UTC 2024
    - 6.3K bytes
    - Viewed (0)
  6. pilot/pkg/model/conversion_test.go

    			want: &meshconfig.MeshConfig{EnableTracing: true},
    		},
    	}
    	for i, c := range cases {
    		t.Run(fmt.Sprintf("[%v]", i), func(tt *testing.T) {
    			var got meshconfig.MeshConfig
    			err := protomarshal.ApplyJSON(c.in, &got)
    			if err != nil {
    				if !c.wantErr {
    					tt.Fatalf("got unexpected error: %v", err)
    				}
    			} else {
    				if c.wantErr {
    					tt.Fatal("unexpected success, expected error")
    				}
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Thu Mar 02 20:50:14 UTC 2023
    - 5.1K bytes
    - Viewed (0)
  7. pkg/config/model_test.go

    			json:   `{"name":"foobar","fake-field":1}`,
    			output: &TestStruct{Name: "foobar"},
    		},
    	}
    	for _, tt := range cases {
    		t.Run(fmt.Sprintf("%T", tt.input), func(t *testing.T) {
    			if err := ApplyJSON(tt.input, tt.json); err != nil {
    				t.Fatal(err)
    			}
    			if diff := cmp.Diff(tt.input, tt.output, protocmp.Transform()); diff != "" {
    				t.Fatalf("Diff: %v", diff)
    			}
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Fri Apr 12 17:37:32 UTC 2024
    - 7.9K bytes
    - Viewed (0)
  8. pkg/config/mesh/mesh.go

    func DeepCopyMeshConfig(mc *meshconfig.MeshConfig) (*meshconfig.MeshConfig, error) {
    	j, err := protomarshal.ToJSON(mc)
    	if err != nil {
    		return nil, err
    	}
    	nmc := &meshconfig.MeshConfig{}
    	if err := protomarshal.ApplyJSON(j, nmc); err != nil {
    		return nil, err
    	}
    	return nmc, nil
    }
    
    // EmptyMeshNetworks configuration with no networks
    func EmptyMeshNetworks() meshconfig.MeshNetworks {
    	return meshconfig.MeshNetworks{
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Wed Apr 17 20:06:41 UTC 2024
    - 12K bytes
    - Viewed (0)
Back to top