diff --git a/pkg/cli/cli.go b/pkg/cli/cli.go index 19cb0abfb..5b0eb8aee 100644 --- a/pkg/cli/cli.go +++ b/pkg/cli/cli.go @@ -4,14 +4,15 @@ import ( "bufio" "context" "encoding/base64" - "encoding/json" "fmt" "os" "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap" "github.com/spf13/cobra" "go.uber.org/zap" + "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/anypb" "github.com/conductorone/baton-sdk/internal/connector" v2 "github.com/conductorone/baton-sdk/pb/c1/connector/v2" @@ -288,7 +289,18 @@ func NewCmd[T any, PtrT *T]( return fmt.Errorf("connector does not support capabilities") } - outBytes, err := json.MarshalIndent(md.Metadata.Capabilities, "", " ") + protoMarshaller := protojson.MarshalOptions{ + Multiline: true, + Indent: " ", + } + + a := &anypb.Any{} + err = anypb.MarshalFrom(a, md.Metadata.Capabilities, proto.MarshalOptions{Deterministic: true}) + if err != nil { + return err + } + + outBytes, err := protoMarshaller.Marshal(a) if err != nil { return err } diff --git a/pkg/connectorbuilder/connectorbuilder.go b/pkg/connectorbuilder/connectorbuilder.go index b17586bb3..0ad2ee65a 100644 --- a/pkg/connectorbuilder/connectorbuilder.go +++ b/pkg/connectorbuilder/connectorbuilder.go @@ -3,7 +3,6 @@ package connectorbuilder import ( "context" "fmt" - "sort" "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap" "go.uber.org/zap" @@ -266,9 +265,7 @@ func getCapabilities(ctx context.Context, b *builderImpl) *v2.ConnectorCapabilit } resourceTypeCapabilities = append(resourceTypeCapabilities, resourceTypeCapability) } - sort.Slice(resourceTypeCapabilities, func(i, j int) bool { - return resourceTypeCapabilities[i].ResourceType.GetId() < resourceTypeCapabilities[j].ResourceType.GetId() - }) + return &v2.ConnectorCapabilities{ResourceTypeCapabilities: resourceTypeCapabilities} }