github_app.go 919 B

123456789101112131415161718192021222324252627282930313233
  1. package integrations
  2. import "gorm.io/gorm"
  3. // GithubAppInstallation is an instance of the porter github app
  4. // we need to store account/installation id pairs in order to authenticate as the installation
  5. type GithubAppInstallation struct {
  6. gorm.Model
  7. // Can belong to either a user or an organization
  8. AccountID int64 `json:"account_id" gorm:"unique"`
  9. // Installation ID (used for authentication)
  10. InstallationID int64 `json:"installation_id"`
  11. }
  12. type GithubAppInstallationExternal struct {
  13. ID uint `json:"id"`
  14. // Can belong to either a user or an organization
  15. AccountID int64 `json:"account_id"`
  16. // Installation ID (used for authentication)
  17. InstallationID int64 `json:"installation_id"`
  18. }
  19. func (r *GithubAppInstallation) Externalize() *GithubAppInstallationExternal {
  20. return &GithubAppInstallationExternal{
  21. ID: r.ID,
  22. AccountID: r.AccountID,
  23. InstallationID: r.InstallationID,
  24. }
  25. }