-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into tdstein/release
- Loading branch information
Showing
21 changed files
with
1,452 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package api | ||
|
||
// Copyright (C) 2023 by Posit Software, PBC. | ||
|
||
import ( | ||
"encoding/json" | ||
"net/http" | ||
|
||
"github.com/rstudio/connect-client/internal/accounts" | ||
"github.com/rstudio/connect-client/internal/cli_types" | ||
"github.com/rstudio/connect-client/internal/logging" | ||
"github.com/rstudio/connect-client/internal/state" | ||
) | ||
|
||
type PublishReponse struct { | ||
LocalID state.LocalDeploymentID `json:"local_id"` // Unique ID of this publishing operation. Only valid for this run of the agent. | ||
} | ||
|
||
type ManifestFilesPublisher interface { | ||
PublishManifestFiles(lister accounts.AccountList, log logging.Logger) error | ||
} | ||
|
||
func PostPublishHandlerFunc(publisher ManifestFilesPublisher, publishArgs *cli_types.PublishArgs, lister accounts.AccountList, log logging.Logger) http.HandlerFunc { | ||
return func(w http.ResponseWriter, req *http.Request) { | ||
localID, err := state.NewLocalID() | ||
if err != nil { | ||
InternalError(w, req, log, err) | ||
return | ||
} | ||
publishArgs.State.LocalID = localID | ||
response := PublishReponse{ | ||
LocalID: localID, | ||
} | ||
w.Header().Set("content-type", "application/json") | ||
w.WriteHeader(http.StatusAccepted) | ||
json.NewEncoder(w).Encode(response) | ||
|
||
go func() { | ||
log = log.WithArgs("local_id", localID) | ||
err := publisher.PublishManifestFiles(lister, log) | ||
if err != nil { | ||
log.Error("Deployment failed", "error", err.Error()) | ||
} | ||
}() | ||
} | ||
} |
Oops, something went wrong.