Skip to content

Commit

Permalink
Merge pull request #2148 from posit-dev/mm-logs-url2
Browse files Browse the repository at this point in the history
Set logs URL immediately upon deployment
  • Loading branch information
sagerb authored Aug 21, 2024
2 parents 4f21f22 + 6d95a46 commit 61a4ff0
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions internal/publish/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
10 changes: 10 additions & 0 deletions internal/publish/publish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
}
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
1 change: 1 addition & 0 deletions internal/schema/schemas/draft/record.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
1 change: 1 addition & 0 deletions internal/schema/schemas/record.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 61a4ff0

Please sign in to comment.