Repository: apigee/registry
Pull request #941 (2023-01-13 19:24:00)

Add support for exporting, getting, and applying receipts in YAML.
While running `registry export` on a project with a manifest, I noticed that we were logging warnings because receipts couldn't be exported. This registers the receipt type with the `registry` tool to allow it to be handled like other artifacts.

codecov[bot]: # [Codecov](https://codecov.io/gh/apigee/registry/pull/941?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apigee) Report
> Merging [#941](https://codecov.io/gh/apigee/registry/pull/941?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apigee) (9e6f0c5) into [main](https://codecov.io/gh/apigee/registry/commit/c09afa970e87a0466dd0d5a4c682da21a3119007?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apigee) (c09afa9) will **decrease** coverage by `0.00%`.
> The diff coverage is `0.00%`.

```diff
@@            Coverage Diff             @@
##             main     #941      +/-   ##
==========================================
- Coverage   64.03%   64.03%   -0.01%     
==========================================
  Files         113      113              
  Lines       10141    10142       +1     
==========================================
  Hits         6494     6494              
- Misses       3024     3025       +1     
  Partials      623      623              
```


| [Impacted Files](https://codecov.io/gh/apigee/registry/pull/941?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apigee) | Coverage Δ | |
|---|---|---|
| [cmd/registry/types/types.go](https://codecov.io/gh/apigee/registry/pull/941?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apigee#diff-Y21kL3JlZ2lzdHJ5L3R5cGVzL3R5cGVzLmdv) | `98.80% <0.00%> (-1.20%)` | :arrow_down: |

:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apigee)


Patch:
diff --git a/cmd/registry/types/types.go b/cmd/registry/types/types.go
index c555a05..8680c5c 100644
--- a/cmd/registry/types/types.go
+++ b/cmd/registry/types/types.go
@@ -153,6 +153,7 @@ var artifactMessageTypes map[string]messageFactory = map[string]messageFactory{
 	"google.cloud.apigeeregistry.v1.apihub.ReferenceList":        func() proto.Message { return new(rpc.ReferenceList) },
 	"google.cloud.apigeeregistry.v1.apihub.TaxonomyList":         func() proto.Message { return new(rpc.TaxonomyList) },
 	"google.cloud.apigeeregistry.v1.controller.Manifest":         func() proto.Message { return new(rpc.Manifest) },
+	"google.cloud.apigeeregistry.v1.controller.Receipt":          func() proto.Message { return new(rpc.Receipt) },
 	"google.cloud.apigeeregistry.v1.scoring.Score":               func() proto.Message { return new(rpc.Score) },
 	"google.cloud.apigeeregistry.v1.scoring.ScoreDefinition":     func() proto.Message { return new(rpc.ScoreDefinition) },
 	"google.cloud.apigeeregistry.v1.scoring.ScoreCard":           func() proto.Message { return new(rpc.ScoreCard) },


Test patch:
diff --git a/cmd/registry/patch/patch_test.go b/cmd/registry/patch/patch_test.go
index 2a9c7ad..326e63d 100644
--- a/cmd/registry/patch/patch_test.go
+++ b/cmd/registry/patch/patch_test.go
@@ -718,6 +718,19 @@ func TestMessageArtifactPatches(t *testing.T) {
 				},
 			},
 		},
+		{
+			artifactID: "receipt",
+			parent:     "apis/a/versions/v/specs/s",
+			yamlFile:   "testdata/artifacts/receipt.yaml",
+			message: &rpc.Receipt{
+				Id:          "receipt", // deprecated field
+				Kind:        "Receipt", // deprecated field
+				DisplayName: "Sample Receipt",
+				Action:      "registry compute scorecard RESOURCE",
+				Description: "Description",
+				ResultUri:   "https://example.com",
+			},
+		},
 		{
 			artifactID: "references",
 			parent:     "apis/a",
diff --git a/cmd/registry/patch/testdata/artifacts/receipt.yaml b/cmd/registry/patch/testdata/artifacts/receipt.yaml
new file mode 100755
index 0000000..cfcdcf5
--- /dev/null
+++ b/cmd/registry/patch/testdata/artifacts/receipt.yaml
@@ -0,0 +1,10 @@
+apiVersion: apigeeregistry/v1
+kind: Receipt
+metadata:
+  name: receipt
+  parent: apis/a/versions/v/specs/s
+data:
+  displayName: Sample Receipt
+  description: Description
+  action: registry compute scorecard RESOURCE
+  resultUri: https://example.com
diff --git a/cmd/registry/types/types_test.go b/cmd/registry/types/types_test.go
index 7cd9f1e..5369b9f 100644
--- a/cmd/registry/types/types_test.go
+++ b/cmd/registry/types/types_test.go
@@ -198,6 +198,11 @@ func TestProtobufMessageTypes(t *testing.T) {
 			messageType: "google.cloud.apigeeregistry.v1.controller.Manifest",
 			mimeType:    "application/octet-stream;type=google.cloud.apigeeregistry.v1.controller.Manifest",
 		},
+		{
+			kind:        "Receipt",
+			messageType: "google.cloud.apigeeregistry.v1.controller.Receipt",
+			mimeType:    "application/octet-stream;type=google.cloud.apigeeregistry.v1.controller.Receipt",
+		},
 		{
 			kind:        "Score",
 			messageType: "google.cloud.apigeeregistry.v1.scoring.Score",