diff --git a/core/pkg/adapters/grpc/resources_grpc.go b/core/pkg/adapters/grpc/resources_grpc.go index 6f010df28..626925575 100644 --- a/core/pkg/adapters/grpc/resources_grpc.go +++ b/core/pkg/adapters/grpc/resources_grpc.go @@ -58,26 +58,30 @@ func (rs *ResourcesServiceServer) Declare(ctx context.Context, req *v1.ResourceD return &v1.ResourceDeclareResponse{}, nil } -type resourceDetailsType interface { - // Add union type here to exhaust possible ResourceDetailTypes - *v1.ResourceDetailsResponse_Api -} - -func convertDetails[T resourceDetailsType](details *resource.DetailsResponse[any]) (T, error) { +func populateDetails(details *resource.DetailsResponse[any], response *v1.ResourceDetailsResponse) error { switch det := details.Detail.(type) { case resource.ApiDetails: - return &v1.ResourceDetailsResponse_Api{ + response.Details = &v1.ResourceDetailsResponse_Api{ Api: &v1.ApiResourceDetails{ Url: det.URL, }, - }, nil + } + return nil + case resource.WebsocketDetails: + response.Details = &v1.ResourceDetailsResponse_Websocket{ + Websocket: &v1.WebsocketResourceDetails{ + Url: det.URL, + }, + } + return nil default: - return nil, fmt.Errorf("unsupported details type") + return fmt.Errorf("unsupported details type") } } var resourceTypeMap = map[v1.ResourceType]resource.ResourceType{ - v1.ResourceType_Api: resource.ResourceType_Api, + v1.ResourceType_Api: resource.ResourceType_Api, + v1.ResourceType_Websocket: resource.ResourceType_Websocket, } func (rs *ResourcesServiceServer) Details(ctx context.Context, req *v1.ResourceDetailsRequest) (*v1.ResourceDetailsResponse, error) { @@ -95,17 +99,18 @@ func (rs *ResourcesServiceServer) Details(ctx context.Context, req *v1.ResourceD return nil, err } - details, err := convertDetails(d) + resp := &v1.ResourceDetailsResponse{ + Id: d.Id, + Provider: d.Provider, + Service: d.Service, + } + + err = populateDetails(d, resp) if err != nil { return nil, err } - return &v1.ResourceDetailsResponse{ - Id: d.Id, - Provider: d.Provider, - Service: d.Service, - Details: details, - }, nil + return resp, nil } func NewResourcesServiceServer(opts ...ResourceServiceOption) v1.ResourceServiceServer { diff --git a/core/pkg/plugins/resource/plugin.go b/core/pkg/plugins/resource/plugin.go index 6db6e6aa6..1648d4371 100644 --- a/core/pkg/plugins/resource/plugin.go +++ b/core/pkg/plugins/resource/plugin.go @@ -26,7 +26,8 @@ type ResourceType = string type ResourceDeclareRequest = *v1.ResourceDeclareRequest const ( - ResourceType_Api = "api" + ResourceType_Api = "api" + ResourceType_Websocket = "websocket" ) type DetailsResponse[T any] struct { @@ -40,6 +41,10 @@ type ApiDetails struct { URL string } +type WebsocketDetails struct { + URL string +} + // ResourceService - Base resource service interface for providers type ResourceService interface { // Details - The details endpoint diff --git a/go.work.sum b/go.work.sum index 1a575dffe..8a729ee7e 100644 --- a/go.work.sum +++ b/go.work.sum @@ -968,6 +968,8 @@ github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+Gx github.com/prometheus/tsdb v0.7.1 h1:YZcsG11NqnK4czYLrWd9mpEuAJIHVQLwdrleYfszMAA= github.com/pseudomuto/protoc-gen-doc v1.3.2/go.mod h1:y5+P6n3iGrbKG+9O04V5ld71in3v/bX88wUwgt+U8EA= github.com/pseudomuto/protokit v0.2.0/go.mod h1:2PdH30hxVHsup8KpBTOXTBeMVhJZVio3Q8ViKSAXT0Q= +github.com/pulumi/pulumi-aws/sdk/v5 v5.26.0 h1:VviljcCRZPl8+PNEbgS1AsodW/ubFHXlVfWF88q//Vk= +github.com/pulumi/pulumi-aws/sdk/v5 v5.26.0/go.mod h1:axXtUAYEclH+SVqr/QmWFzMfJchxrrPiyMrywCcMF9A= github.com/pulumi/pulumi-azure-native-sdk v1.87.0 h1:Jt6Jkw2Y5GYXIv6YmkzwdQfkDpAzXpwbtwwV6qBDu8c= github.com/pulumi/pulumi-azure-native-sdk/apimanagement v1.87.0 h1:NGWnQRyJBc51y2bPLSXOpTJWqIShAsLyuQOsn2ilVs0= github.com/pulumi/pulumi-azure-native-sdk/app v1.87.0 h1:FCFNeMBTRJbFcPzQI3kBfCPhS5kvcHFg4HVdkC4PL9U= @@ -1008,6 +1010,8 @@ github.com/remyoudompheng/go-liblzma v0.0.0-20190506200333-81bf2d431b96 h1:J8J/c github.com/remyoudompheng/go-liblzma v0.0.0-20190506200333-81bf2d431b96/go.mod h1:90HvCY7+oHHUKkbeMCiHt1WuFR2/hPJ9QrljDG+v6ls= github.com/remyoudompheng/go-misc v0.0.0-20190427085024-2d6ac652a50e h1:eTWZyPUnHcuGRDiryS/l2I7FfKjbU3IBx3IjqHPxuKU= github.com/remyoudompheng/go-misc v0.0.0-20190427085024-2d6ac652a50e/go.mod h1:80FQABjoFzZ2M5uEa6FUaJYEmqU2UOKojlFVak1UAwI= +github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= +github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rogpeppe/fastuuid v1.2.0 h1:Ppwyp6VYCF1nvBTXL3trRso7mXMlRrw9ooo375wvi2s= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= @@ -1040,6 +1044,10 @@ github.com/securego/gosec/v2 v2.10.0/go.mod h1:PVq8Ewh/nCN8l/kKC6zrGXSr7m2NmEK6I github.com/securego/gosec/v2 v2.13.1/go.mod h1:EO1sImBMBWFjOTFzMWfTRrZW6M15gm60ljzrmy/wtHo= github.com/securego/gosec/v2 v2.14.0 h1:U1hfs0oBackChXA72plCYVA4cOlQ4gO+209dHiSNZbI= github.com/securego/gosec/v2 v2.14.0/go.mod h1:Ff03zEi5NwSOfXj9nFpBfhbWTtROCkg9N+9goggrYn4= +github.com/segmentio/asm v1.1.3 h1:WM03sfUOENvvKexOLp+pCqgb/WDjsi7EK8gIsICtzhc= +github.com/segmentio/asm v1.1.3/go.mod h1:Ld3L4ZXGNcSLRg4JBsZ3//1+f/TjYl0Mzen/DQy1EJg= +github.com/segmentio/encoding v0.3.6 h1:E6lVLyDPseWEulBmCmAKPanDd3jiyGDo5gMcugCRwZQ= +github.com/segmentio/encoding v0.3.6/go.mod h1:n0JeuIqEQrQoPDGsjo8UNd1iA0U8d8+oHAA4E3G3OxM= github.com/shirou/gopsutil/v3 v3.22.9 h1:yibtJhIVEMcdw+tCTbOPiF1VcsuDeTE4utJ8Dm4c5eA= github.com/shirou/gopsutil/v3 v3.22.9/go.mod h1:bBYl1kjgEJpWpxeHmLI+dVHWtyAwfcmSBLDsp2TNT8A= github.com/shirou/gopsutil/v3 v3.23.1/go.mod h1:NN6mnm5/0k8jw4cBfCnJtr5L7ErOTg18tMNpgFkn0hA= @@ -1170,8 +1178,14 @@ go.etcd.io/etcd/client/v3 v3.5.6 h1:coLs69PWCXE9G4FKquzNaSHrRyMCAXwF+IX1tAPVO8E= go.etcd.io/etcd/client/v3 v3.5.6/go.mod h1:f6GRinRMCsFVv9Ht42EyY7nfsVGwrNO0WEoS2pRKzQk= go.mozilla.org/mozlog v0.0.0-20170222151521-4bb13139d403/go.mod h1:jHoPAGnDrCy6kaI2tAze5Prf0Nr0w/oNkROt2lw3n3o= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= +go.opentelemetry.io/contrib/detectors/aws/lambda v0.36.3 h1:Joa3ioM69WggvQgSvr7ZRbcrI1mMCl30sjbSGglAUMU= +go.opentelemetry.io/contrib/detectors/aws/lambda v0.36.3/go.mod h1:DVT7ZIQ4/NA8BmwOLDpRADMmNoAozODhEMOdK7MQ1xY= +go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws v0.36.4 h1:E85NvhZcKfJtiCI+E2sNjrBHE/anyA3MjbTTiRngGoQ= +go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws v0.36.4/go.mod h1:sNHaxla2G+y6M3/Jfb3N06CVn/kAZf+8yFwxkIVa/pI= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.37.0 h1:+uFejS4DCfNH6d3xODVIGsdhzgzhh45p9gpbHQMbdZI= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.37.0/go.mod h1:HSmzQvagH8pS2/xrK7ScWsk0vAMtRTGbMFgInXCi8Tc= +go.opentelemetry.io/contrib/propagators/aws v1.11.0 h1:PQH+ds9TdfJv/kVge4ohedKCxmUzkaFLgxd3Fp7vEx4= +go.opentelemetry.io/contrib/propagators/aws v1.11.0/go.mod h1:evz2eVSJ9amYUKHQ7KBf1htk/iKt+xAkYiTYEF72Jik= go.opentelemetry.io/otel/metric v0.34.0 h1:MCPoQxcg/26EuuJwpYN1mZTeCYAUGx8ABxfW07YkjP8= go.opentelemetry.io/otel/metric v0.34.0/go.mod h1:ZFuI4yQGNCupurTXCwkeD/zHBt+C2bR7bw5JqUm/AP8= go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= @@ -1281,6 +1295,7 @@ golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211110154304-99a53858aa08/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=