| 1234567891011121314151617181920212223242526272829303132 |
- package gitinstallation
- import (
- "net/http"
- "github.com/porter-dev/porter/api/server/authz"
- "github.com/porter-dev/porter/api/server/handlers"
- "github.com/porter-dev/porter/api/server/shared"
- "github.com/porter-dev/porter/api/types"
- "github.com/porter-dev/porter/internal/models/integrations"
- )
- type GitInstallationGetHandler struct {
- handlers.PorterHandlerWriter
- authz.KubernetesAgentGetter
- }
- func NewGitInstallationGetHandler(
- config *shared.Config,
- writer shared.ResultWriter,
- ) *GitInstallationGetHandler {
- return &GitInstallationGetHandler{
- PorterHandlerWriter: handlers.NewDefaultPorterHandler(config, nil, writer),
- KubernetesAgentGetter: authz.NewOutOfClusterAgentGetter(config),
- }
- }
- func (c *GitInstallationGetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- ga, _ := r.Context().Value(types.GitInstallationScope).(*integrations.GithubAppInstallation)
- c.WriteResult(w, ga.ToGitInstallationType())
- }
|