+14
-3
lines changedFilter options
+14
-3
lines changed Original file line number Diff line number Diff line change
@@ -88,7 +88,12 @@ func ToProto(e *event.Event) (*pb.CloudEvent, error) {
88
88
container.Attributes[datacontenttype], _ = attributeFor(e.DataContentType())
89
89
}
90
90
if e.DataSchema() != "" {
91
-
container.Attributes[dataschema], _ = attributeFor(e.DataSchema())
91
+
dataSchemaStr := e.DataSchema()
92
+
uri, err := url.Parse(dataSchemaStr)
93
+
if err != nil {
94
+
return nil, fmt.Errorf("failed to url.Parse %s: %s", dataSchemaStr, err)
95
+
}
96
+
container.Attributes[dataschema], _ = attributeFor(uri)
92
97
}
93
98
if e.Subject() != "" {
94
99
container.Attributes[subject], _ = attributeFor(e.Subject())
@@ -251,8 +256,8 @@ func FromProto(container *pb.CloudEvent) (*event.Event, error) {
251
256
vs, _ := v.(string)
252
257
e.SetDataContentType(vs)
253
258
case dataschema:
254
-
vs, _ := v.(string)
255
-
e.SetDataSchema(vs)
259
+
vs, _ := v.(types.URI)
260
+
e.SetDataSchema(vs.String())
256
261
case subject:
257
262
vs, _ := v.(string)
258
263
e.SetSubject(vs)
Original file line number Diff line number Diff line change
@@ -109,6 +109,7 @@ func TestFromProto(t *testing.T) {
109
109
Type: "some.type",
110
110
Attributes: map[string]*pb.CloudEventAttributeValue{
111
111
"datacontenttype": {Attr: &pb.CloudEventAttributeValue_CeString{CeString: "application/json"}},
112
+
"dataschema": {Attr: &pb.CloudEventAttributeValue_CeUri{CeUri: "link"}},
112
113
"extra1": {Attr: &pb.CloudEventAttributeValue_CeString{CeString: "extra1 value"}},
113
114
"extra2": {Attr: &pb.CloudEventAttributeValue_CeInteger{CeInteger: 2}},
114
115
"extra3": {Attr: &pb.CloudEventAttributeValue_CeBoolean{CeBoolean: true}},
@@ -124,6 +125,7 @@ func TestFromProto(t *testing.T) {
124
125
out.SetSource("/source")
125
126
out.SetType("some.type")
126
127
_ = out.SetData("application/json", map[string]interface{}{"unit": "test"})
128
+
out.SetDataSchema("link")
127
129
out.SetExtension("extra1", "extra1 value")
128
130
out.SetExtension("extra2", 2)
129
131
out.SetExtension("extra3", true)
@@ -140,6 +142,7 @@ func TestFromProto(t *testing.T) {
140
142
Type: "some.type",
141
143
Attributes: map[string]*pb.CloudEventAttributeValue{
142
144
"datacontenttype": {Attr: &pb.CloudEventAttributeValue_CeString{CeString: "text/plain"}},
145
+
"dataschema": {Attr: &pb.CloudEventAttributeValue_CeUri{CeUri: "link"}},
143
146
"extra1": {Attr: &pb.CloudEventAttributeValue_CeString{CeString: "extra1 value"}},
144
147
"extra2": {Attr: &pb.CloudEventAttributeValue_CeInteger{CeInteger: 2}},
145
148
"extra3": {Attr: &pb.CloudEventAttributeValue_CeBoolean{CeBoolean: true}},
@@ -155,6 +158,7 @@ func TestFromProto(t *testing.T) {
155
158
out.SetSource("/source")
156
159
out.SetType("some.type")
157
160
_ = out.SetData("text/plain", `this is some text with a "quote"`)
161
+
out.SetDataSchema("link")
158
162
out.SetExtension("extra1", "extra1 value")
159
163
out.SetExtension("extra2", 2)
160
164
out.SetExtension("extra3", true)
@@ -171,6 +175,7 @@ func TestFromProto(t *testing.T) {
171
175
Type: "some.type",
172
176
Attributes: map[string]*pb.CloudEventAttributeValue{
173
177
"datacontenttype": {Attr: &pb.CloudEventAttributeValue_CeString{CeString: "application/json"}},
178
+
"dataschema": {Attr: &pb.CloudEventAttributeValue_CeUri{CeUri: "link"}},
174
179
"extra1": {Attr: &pb.CloudEventAttributeValue_CeString{CeString: "extra1 value"}},
175
180
"extra2": {Attr: &pb.CloudEventAttributeValue_CeInteger{CeInteger: 2}},
176
181
"extra3": {Attr: &pb.CloudEventAttributeValue_CeBoolean{CeBoolean: true}},
@@ -186,6 +191,7 @@ func TestFromProto(t *testing.T) {
186
191
out.SetSource("/source")
187
192
out.SetType("some.type")
188
193
_ = out.SetData("application/json", `{"unit":"test"}`)
194
+
out.SetDataSchema("link")
189
195
out.SetExtension("extra1", "extra1 value")
190
196
out.SetExtension("extra2", 2)
191
197
out.SetExtension("extra3", true)
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4