From f3c441b33089e9479f093629b297c36242790a5e Mon Sep 17 00:00:00 2001 From: Michael Marchetti Date: Wed, 21 Aug 2024 15:04:18 -0400 Subject: [PATCH 1/3] populate logs_url on deployment --- internal/deployment/deployment.go | 2 +- internal/publish/publish.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/deployment/deployment.go b/internal/deployment/deployment.go index 29fd1abdb..0d3121f83 100644 --- a/internal/deployment/deployment.go +++ b/internal/deployment/deployment.go @@ -106,7 +106,7 @@ func FromFile(path util.AbsolutePath) (*Deployment, error) { } if d.LogsURL == "" && d.DashboardURL != "" { // Migration - d.LogsURL = d.DashboardURL + "/logs" + d.LogsURL = util.URLJoin(d.DashboardURL, "logs") } return d, nil } diff --git a/internal/publish/publish.go b/internal/publish/publish.go index a6ad681fc..bca77a9ed 100644 --- a/internal/publish/publish.go +++ b/internal/publish/publish.go @@ -268,6 +268,7 @@ func (p *defaultPublisher) createDeploymentRecord( BundleID: "", DashboardURL: getDashboardURL(p.Account.URL, contentID), DirectURL: getDirectURL(p.Account.URL, contentID), + LogsURL: getLogsURL(p.Account.URL, contentID), Error: nil, } From 683e85c1e5cda697fe72c7ef00e604ae19bcc66a Mon Sep 17 00:00:00 2001 From: Michael Marchetti Date: Wed, 21 Aug 2024 15:15:39 -0400 Subject: [PATCH 2/3] add logs_url to the schema --- .../schemas/draft/posit-publishing-record-schema-v3.json | 8 ++++++++ internal/schema/schemas/draft/record.toml | 1 + .../schema/schemas/posit-publishing-record-schema-v3.json | 8 ++++++++ internal/schema/schemas/record.toml | 1 + 4 files changed, 18 insertions(+) diff --git a/internal/schema/schemas/draft/posit-publishing-record-schema-v3.json b/internal/schema/schemas/draft/posit-publishing-record-schema-v3.json index 91481470c..f680e6005 100644 --- a/internal/schema/schemas/draft/posit-publishing-record-schema-v3.json +++ b/internal/schema/schemas/draft/posit-publishing-record-schema-v3.json @@ -108,6 +108,14 @@ "https://connect.example.com/content/de2e7bdb-b085-401e-a65c-443e40009749/" ] }, + "logs_url": { + "type": "string", + "format": "uri", + "description": "URL to the logs for this deployment in the Connect dashboard.", + "examples": [ + "https://connect.example.com/connect/#/apps/de2e7bdb-b085-401e-a65c-443e40009749/logs" + ] + }, "deployment_error": { "type": "object", "description": "Error from the deployment operation. Will be omitted if no error occurred.", diff --git a/internal/schema/schemas/draft/record.toml b/internal/schema/schemas/draft/record.toml index 560a36aa9..4f1629fa1 100644 --- a/internal/schema/schemas/draft/record.toml +++ b/internal/schema/schemas/draft/record.toml @@ -10,6 +10,7 @@ bundle_id = '123' bundle_url = 'https://connect.example.com/__api__/v1/content/de2e7bdb-b085-401e-a65c-443e40009749/bundles/123/download' dashboard_url = 'https://connect.example.com/connect/#/apps/de2e7bdb-b085-401e-a65c-443e40009749/' direct_url = 'https://connect.example.com/content/de2e7bdb-b085-401e-a65c-443e40009749/' +logs_url = 'https://connect.example.com/connect/#/apps/de2e7bdb-b085-401e-a65c-443e40009749/logs' [configuration] "$schema" = "https://cdn.posit.co/publisher/schemas/draft/posit-publishing-schema-v3.json" diff --git a/internal/schema/schemas/posit-publishing-record-schema-v3.json b/internal/schema/schemas/posit-publishing-record-schema-v3.json index a350fd7ee..06447f104 100644 --- a/internal/schema/schemas/posit-publishing-record-schema-v3.json +++ b/internal/schema/schemas/posit-publishing-record-schema-v3.json @@ -108,6 +108,14 @@ "https://connect.example.com/content/de2e7bdb-b085-401e-a65c-443e40009749/" ] }, + "logs_url": { + "type": "string", + "format": "uri", + "description": "URL to the logs for this deployment in the Connect dashboard.", + "examples": [ + "https://connect.example.com/connect/#/apps/de2e7bdb-b085-401e-a65c-443e40009749/logs" + ] + }, "deployment_error": { "type": "object", "description": "Error from the deployment operation. Will be omitted if no error occurred.", diff --git a/internal/schema/schemas/record.toml b/internal/schema/schemas/record.toml index 5d8bd7538..c06afd35e 100644 --- a/internal/schema/schemas/record.toml +++ b/internal/schema/schemas/record.toml @@ -10,6 +10,7 @@ bundle_id = '123' bundle_url = 'https://connect.example.com/__api__/v1/content/de2e7bdb-b085-401e-a65c-443e40009749/bundles/123/download' dashboard_url = 'https://connect.example.com/connect/#/apps/de2e7bdb-b085-401e-a65c-443e40009749' direct_url = 'https://connect.example.com/content/de2e7bdb-b085-401e-a65c-443e40009749/' +logs_url = 'https://connect.example.com/connect/#/apps/de2e7bdb-b085-401e-a65c-443e40009749/logs' [configuration] "$schema" = "https://cdn.posit.co/publisher/schemas/posit-publishing-schema-v3.json" From 6d95a46140266907e4a71ca1283f0345fbebf693 Mon Sep 17 00:00:00 2001 From: Michael Marchetti Date: Wed, 21 Aug 2024 16:37:29 -0400 Subject: [PATCH 3/3] update tests --- internal/publish/publish_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/publish/publish_test.go b/internal/publish/publish_test.go index bff517f09..cc33a30e7 100644 --- a/internal/publish/publish_test.go +++ b/internal/publish/publish_test.go @@ -335,6 +335,10 @@ func (s *PublishSuite) publishWithClient( if couldCreateDeployment { logs := s.logBuffer.String() s.Contains(logs, "content_id="+myContentID) + s.Equal("https://connect.example.com/connect/#/apps/myContentID", record.DashboardURL) + s.Equal("https://connect.example.com/content/myContentID/", record.DirectURL) + s.Equal("https://connect.example.com/connect/#/apps/myContentID/logs", record.LogsURL) + // Files are written after upload. if uploadErr == nil { s.Contains(record.Files, "app.py") @@ -405,6 +409,7 @@ func (s *PublishSuite) TestEmitErrorEventsWithTarget() { s.Equal(expectedErr.Error(), event.Data["message"]) s.Equal(getDashboardURL("connect.example.com", targetID), event.Data["dashboardUrl"]) s.Equal(getDirectURL("connect.example.com", targetID), event.Data["url"]) + s.Equal(getLogsURL("connect.example.com", targetID), event.Data["logsUrl"]) } s.Equal("publish/failure", emitter.Events[1].Type) } @@ -419,6 +424,11 @@ func (s *PublishSuite) TestGetDirectURL() { s.Equal(expected, getDirectURL("https://connect.example.com:1234", "d0e5c94a-d37f-4f26-bfc5-515c4c5ea50f")) } +func (s *PublishSuite) TestGetLogsURL() { + expected := "https://connect.example.com:1234/connect/#/apps/d0e5c94a-d37f-4f26-bfc5-515c4c5ea50f/logs" + s.Equal(expected, getLogsURL("https://connect.example.com:1234", "d0e5c94a-d37f-4f26-bfc5-515c4c5ea50f")) +} + func (s *PublishSuite) TestLogAppInfo() { accountURL := "https://connect.example.com:1234" contentID := types.ContentID("myContentID")