Documentation ¶
Index ¶
- Constants
- Variables
- type AuthToken
- type Github
- type Options
- type Service
- func (s *Service) Close() error
- func (s *Service) CreateOrUpdateUser(ctx context.Context, email, name, photoURL string) (*database.User, error)
- func (s *Service) CreateOrganizationForUser(ctx context.Context, userID, orgName, description string) (*database.Organization, error)
- func (s *Service) CreateProject(ctx context.Context, org *database.Organization, userID string, ...) (*database.Project, error)
- func (s *Service) GetGithubInstallation(ctx context.Context, githubURL string) (int64, error)
- func (s *Service) HibernateDeployments(ctx context.Context) error
- func (s *Service) IssueDeviceAuthCode(ctx context.Context, clientID string) (*database.DeviceAuthCode, error)
- func (s *Service) IssueServiceAuthToken(ctx context.Context, serviceID string, ttl *time.Duration) (AuthToken, error)
- func (s *Service) IssueUserAuthToken(ctx context.Context, userID, clientID, displayName string, ...) (AuthToken, error)
- func (s *Service) LookupGithubRepoForUser(ctx context.Context, installationID int64, githubURL, gitUsername string) (*github.Repository, error)
- func (s *Service) ProcessGithubEvent(ctx context.Context, rawEvent any) error
- func (s *Service) RevokeAuthToken(ctx context.Context, token string) error
- func (s *Service) TeardownProject(ctx context.Context, p *database.Project) error
- func (s *Service) TriggerReconcile(ctx context.Context, depl *database.Deployment) error
- func (s *Service) TriggerRedeploy(ctx context.Context, proj *database.Project, prevDepl *database.Deployment) error
- func (s *Service) TriggerRefreshSources(ctx context.Context, depl *database.Deployment, sources []string) error
- func (s *Service) UnsafeWaitForReconciles()
- func (s *Service) UpdateDeploymentAnnotations(ctx context.Context, projID string, annotations deploymentAnnotations) error
- func (s *Service) UpdateOrgDeploymentAnnotations(ctx context.Context, orgID, orgNewName string) error
- func (s *Service) UpdateProject(ctx context.Context, proj *database.Project, ...) (*database.Project, error)
- func (s *Service) UpdateProjectVariables(ctx context.Context, proj *database.Project, variables map[string]string) (*database.Project, error)
- func (s *Service) ValidateAuthToken(ctx context.Context, token string) (AuthToken, error)
Constants ¶
const DeviceAuthCodeTTL = 10 * time.Minute
Variables ¶
var ( ErrUserIsNotCollaborator = fmt.Errorf("user is not a collaborator for the repository") ErrGithubInstallationNotFound = fmt.Errorf("github installation not found") )
Functions ¶
This section is empty.
Types ¶
type AuthToken ¶ added in v0.23.0
AuthToken is the interface package admin uses to provide a consolidated view of a token string and its DB model.
type Github ¶ added in v0.25.0
type Github interface { AppClient() *github.Client InstallationClient(installationID int64) (*github.Client, error) InstallationToken(ctx context.Context, installationID int64) (string, error) }
Github exposes the features we require from the Github API.
type Service ¶
type Service struct { DB database.DB Provisioner *provisioner.StaticProvisioner Email *email.Client Used *usedFlusher Github Github // contains filtered or unexported fields }
func (*Service) CreateOrUpdateUser ¶ added in v0.23.0
func (*Service) CreateOrganizationForUser ¶ added in v0.24.0
func (*Service) CreateProject ¶ added in v0.23.0
func (s *Service) CreateProject(ctx context.Context, org *database.Organization, userID string, opts *database.InsertProjectOptions) (*database.Project, error)
CreateProject creates a new project and provisions and reconciles a prod deployment for it.
func (*Service) GetGithubInstallation ¶ added in v0.24.0
GetGithubInstallation returns a non zero Github installation ID if the Github App is installed on the repository and is not in suspended state The githubURL should be a HTTPS URL for a Github repository without the .git suffix.
func (*Service) HibernateDeployments ¶ added in v0.29.1
HibernateDeployments tears down unused deployments
func (*Service) IssueDeviceAuthCode ¶ added in v0.24.0
func (*Service) IssueServiceAuthToken ¶ added in v0.31.0
func (s *Service) IssueServiceAuthToken(ctx context.Context, serviceID string, ttl *time.Duration) (AuthToken, error)
IssueServiceAuthToken generates and persists a new auth token for a service.
func (*Service) IssueUserAuthToken ¶ added in v0.23.0
func (s *Service) IssueUserAuthToken(ctx context.Context, userID, clientID, displayName string, representingUserID *string, ttl *time.Duration) (AuthToken, error)
IssueUserAuthToken generates and persists a new auth token for a user.
func (*Service) LookupGithubRepoForUser ¶ added in v0.24.0
func (s *Service) LookupGithubRepoForUser(ctx context.Context, installationID int64, githubURL, gitUsername string) (*github.Repository, error)
LookupGithubRepoForUser returns a Github repository iff the Github App is installed on the repository and user is a collaborator of the project. The githubURL should be a HTTPS URL for a Github repository without the .git suffix.
func (*Service) ProcessGithubEvent ¶ added in v0.23.0
ProcessGithubEvent processes a Github event (usually received over webhooks). After validating that the event is a valid Github event, it moves further processing to the background and returns a nil error.
func (*Service) RevokeAuthToken ¶ added in v0.23.0
RevokeAuthToken removes an auth token from persistent storage.
func (*Service) TeardownProject ¶ added in v0.23.0
TeardownProject tears down a project and all its deployments.
func (*Service) TriggerReconcile ¶ added in v0.23.0
TriggerReconcile triggers a reconcile for a deployment.
func (*Service) TriggerRedeploy ¶ added in v0.24.3
func (s *Service) TriggerRedeploy(ctx context.Context, proj *database.Project, prevDepl *database.Deployment) error
TriggerRedeploy de-provisions and re-provisions a project's prod deployment.
func (*Service) TriggerRefreshSources ¶ added in v0.24.3
func (s *Service) TriggerRefreshSources(ctx context.Context, depl *database.Deployment, sources []string) error
TriggerRefreshSource triggers refresh of a deployment's sources. If the sources slice is nil, it will refresh all sources.f
func (*Service) UnsafeWaitForReconciles ¶ added in v0.27.0
func (s *Service) UnsafeWaitForReconciles()
UnsafeWaitForReconciles waits for all background reconciles to finish. It is unsafe because while it is running, no new reconciles should be started. It's a temporary solution until the runtime is able to reconcile asynchronously. Unlike s.Close(), it does not cancel currently running reconciles, it just waits for them to finish.
func (*Service) UpdateDeploymentAnnotations ¶ added in v0.32.0
func (s *Service) UpdateDeploymentAnnotations(ctx context.Context, projID string, annotations deploymentAnnotations) error
UpdateDeploymentAnnotations pushes the updated annotations to deployments. NOTE : this does not trigger reconcile.
func (*Service) UpdateOrgDeploymentAnnotations ¶ added in v0.32.0
func (s *Service) UpdateOrgDeploymentAnnotations(ctx context.Context, orgID, orgNewName string) error
UpdateOrgDeploymentAnnotations iterates over projects of the given org and updates annotations of corresponding deployments with the new organization name NOTE : this does not trigger reconcile.
func (*Service) UpdateProject ¶ added in v0.23.0
func (s *Service) UpdateProject(ctx context.Context, proj *database.Project, opts *database.UpdateProjectOptions) (*database.Project, error)
UpdateProject updates a project and any impacted deployments. It runs a reconcile if deployment parameters (like branch or variables) have been changed and reconcileDeployment is set.
func (*Service) UpdateProjectVariables ¶ added in v0.28.0
func (s *Service) UpdateProjectVariables(ctx context.Context, proj *database.Project, variables map[string]string) (*database.Project, error)
UpdateProjectVariables updates project's variables and pushes the updated variables to deployments. NOTE : this does not trigger reconcile.