Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable proto or yaml archive contents #202

Merged
merged 3 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/artifact-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"net/http"
"strings"

"github.com/apigee/registry/cmd/registry/patch"
"github.com/apigee/registry/pkg/application/apihub"
"github.com/apigee/registry/pkg/application/controller"
"github.com/apigee/registry/pkg/application/scoring"
Expand Down Expand Up @@ -91,7 +92,7 @@ func handleRequest(w http.ResponseWriter, req *http.Request) {
writeError(w, err, http.StatusInternalServerError)
return
}
if err := proto.Unmarshal(contents.GetData(), message); err != nil {
if err := patch.UnmarshalContents(contents.GetData(), contents.GetContentType(), message); err != nil {
writeError(w, err, http.StatusInternalServerError)
return
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/registry-connect/publish/backstage/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ import (
"strings"

"github.com/apigee/registry-experimental/cmd/registry-connect/publish/backstage/encoding"
"github.com/apigee/registry/cmd/registry/patch"
"github.com/apigee/registry/pkg/application/apihub"
"github.com/apigee/registry/pkg/connection"
"github.com/apigee/registry/pkg/log"
"github.com/apigee/registry/pkg/mime"
"github.com/apigee/registry/pkg/names"
"github.com/apigee/registry/pkg/visitor"
"github.com/apigee/registry/rpc"
"google.golang.org/protobuf/proto"
"gopkg.in/yaml.v3"
)

Expand Down Expand Up @@ -138,7 +138,7 @@ func (c *catalog) createGroups(ctx context.Context) error {
if err != nil {
return err
}
if err := proto.Unmarshal(a.GetContents(), message); err != nil {
if err := patch.UnmarshalContents(a.GetContents(), a.GetMimeType(), message); err != nil {
return err
}
artifactName, _ := names.ParseArtifact(a.Name)
Expand Down
5 changes: 2 additions & 3 deletions cmd/registry-experimental/cmd/bleve/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"sync"

"github.com/apigee/registry/cmd/registry/compress"
"github.com/apigee/registry/cmd/registry/patch"
"github.com/apigee/registry/cmd/registry/tasks"
"github.com/apigee/registry/pkg/connection"
"github.com/apigee/registry/pkg/log"
Expand All @@ -28,7 +29,6 @@ import (
"github.com/apigee/registry/rpc"
"github.com/blevesearch/bleve"
"github.com/spf13/cobra"
"google.golang.org/protobuf/proto"
)

var bleveMutex sync.Mutex
Expand Down Expand Up @@ -194,8 +194,7 @@ func (task *indexArtifactTask) Run(ctx context.Context) error {
if err != nil {
return nil
}
err = proto.Unmarshal(artifact.GetContents(), message)
if err != nil {
if err := patch.UnmarshalContents(artifact.GetContents(), artifact.GetMimeType(), message); err != nil {
return nil
}
// The bleve index requires serialized updates.
Expand Down
6 changes: 3 additions & 3 deletions cmd/registry-experimental/cmd/vocabulary/similarity.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"fmt"

"github.com/apigee/registry/cmd/registry/patch"
"github.com/apigee/registry/pkg/connection"
"github.com/apigee/registry/pkg/log"
"github.com/apigee/registry/pkg/mime"
Expand All @@ -26,7 +27,6 @@ import (
"github.com/apigee/registry/rpc"
metrics "github.com/google/gnostic/metrics"
"github.com/spf13/cobra"
"google.golang.org/protobuf/proto"
)

var filter string
Expand Down Expand Up @@ -76,7 +76,7 @@ func similarityCommand() *cobra.Command {
fmt.Fprintf(cmd.OutOrStdout(), "\n")
for i := 0; i < len(vocabularyArtifacts); i++ {
vi := &metrics.Vocabulary{}
if err := proto.Unmarshal(vocabularyArtifacts[i].GetContents(), vi); err != nil {
if err := patch.UnmarshalContents(vocabularyArtifacts[i].GetContents(), vocabularyArtifacts[i].GetMimeType(), vi); err != nil {
log.FromContext(ctx).WithError(err).Debug("Failed to unmarshal contents")
return nil
}
Expand All @@ -86,7 +86,7 @@ func similarityCommand() *cobra.Command {
}
for j := i; j < len(vocabularyArtifacts); j++ {
vj := &metrics.Vocabulary{}
if err := proto.Unmarshal(vocabularyArtifacts[j].GetContents(), vj); err != nil {
if err := patch.UnmarshalContents(vocabularyArtifacts[j].GetContents(), vocabularyArtifacts[j].GetMimeType(), vi); err != nil {
log.FromContext(ctx).WithError(err).Debug("Failed to unmarshal contents")
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/registry-experimental/cmd/vocabulary/stems.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"sort"
"strings"

"github.com/apigee/registry/cmd/registry/patch"
"github.com/apigee/registry/pkg/connection"
"github.com/apigee/registry/pkg/log"
"github.com/apigee/registry/pkg/mime"
Expand All @@ -31,7 +32,6 @@ import (
"github.com/kljensen/snowball"
"github.com/spf13/cobra"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
)

func stemsCommand() *cobra.Command {
Expand Down Expand Up @@ -74,7 +74,7 @@ func stemsCommand() *cobra.Command {
}

vocab := &metrics.Vocabulary{}
if err := proto.Unmarshal(artifact.GetContents(), vocab); err != nil {
if err := patch.UnmarshalContents(artifact.GetContents(), artifact.GetMimeType(), vocab); err != nil {
log.FromContext(ctx).WithError(err).Debug("Failed to unmarshal contents")
return nil
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/registry-experimental/cmd/vocabulary/vocabulary.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"strings"

"github.com/apigee/registry/cmd/registry/compress"
"github.com/apigee/registry/cmd/registry/patch"
"github.com/apigee/registry/pkg/connection"
"github.com/apigee/registry/pkg/log"
"github.com/apigee/registry/pkg/mime"
Expand Down Expand Up @@ -72,7 +73,7 @@ func collectInputVocabularies(ctx context.Context, client connection.RegistryCli
}

vocab := &metrics.Vocabulary{}
if err := proto.Unmarshal(artifact.GetContents(), vocab); err != nil {
if err := patch.UnmarshalContents(artifact.GetContents(), artifact.GetMimeType(), vocab); err != nil {
log.FromContext(ctx).WithError(err).Debug("Failed to unmarshal contents")
return nil
}
Expand Down
26 changes: 13 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ module github.com/apigee/registry-experimental
go 1.18

require (
cloud.google.com/go/cloudtasks v1.8.0
cloud.google.com/go/cloudtasks v1.9.0
cloud.google.com/go/compute/metadata v0.2.3
cloud.google.com/go/longrunning v0.4.1
cloud.google.com/go/pubsub v1.27.1
cloud.google.com/go/pubsub v1.30.0
github.com/GoogleCloudPlatform/cloudsql-proxy v1.32.0
github.com/apex/log v1.9.0
github.com/apigee/registry v0.6.10-0.20230323234945-81552578775e
github.com/apigee/registry v0.6.13-0.20230607165826-f3ddf3b7a75e
github.com/blevesearch/bleve v1.0.14
github.com/envoyproxy/go-control-plane v0.10.3
github.com/fatih/camelcase v1.0.0
Expand All @@ -19,7 +19,7 @@ require (
github.com/google/gnostic v0.6.9
github.com/google/go-cmp v0.5.9
github.com/google/uuid v1.3.0
github.com/googleapis/gax-go/v2 v2.7.0
github.com/googleapis/gax-go/v2 v2.7.1
github.com/graphql-go/graphql v0.8.0
github.com/graphql-go/handler v0.2.3
github.com/kljensen/snowball v0.6.0
Expand All @@ -28,12 +28,12 @@ require (
github.com/spf13/viper v1.13.0
github.com/tufin/oasdiff v1.0.9
golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2
golang.org/x/net v0.7.0
golang.org/x/oauth2 v0.5.0
google.golang.org/api v0.110.0
google.golang.org/genproto v0.0.0-20230209215440-0dfe4f8abfcc
golang.org/x/net v0.8.0
golang.org/x/oauth2 v0.6.0
google.golang.org/api v0.114.0
google.golang.org/genproto v0.0.0-20230320184635-7606e756e683
google.golang.org/grpc v1.53.0
google.golang.org/protobuf v1.28.1
google.golang.org/protobuf v1.29.1
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
gorm.io/driver/postgres v1.3.10
Expand Down Expand Up @@ -63,7 +63,7 @@ require (
require (
cloud.google.com/go v0.110.0 // indirect
cloud.google.com/go/compute v1.18.0 // indirect
cloud.google.com/go/iam v0.8.0 // indirect
cloud.google.com/go/iam v0.12.0 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/invopop/yaml v0.2.0 // indirect
Expand Down Expand Up @@ -133,9 +133,9 @@ require (
go.uber.org/zap v1.23.0 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/time v0.1.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gorm.io/driver/sqlite v1.4.3 // indirect
Expand Down
Loading