Use database for github creds
Add database models that deal with github credentials. This change adds models for github endpoints (github.com, GHES, etc). This change also adds code to migrate config credntials to the DB. Tests need to be fixed and new tests need to be written. This will come in a later commit. Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
834c3bb798
commit
90870c11be
22 changed files with 1312 additions and 77 deletions
|
|
@ -241,6 +241,14 @@ type GithubApp struct {
|
|||
InstallationID int64 `toml:"installation_id" json:"installation-id"`
|
||||
}
|
||||
|
||||
func (a *GithubApp) PrivateKeyBytes() ([]byte, error) {
|
||||
keyBytes, err := os.ReadFile(a.PrivateKeyPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("reading private_key_path: %w", err)
|
||||
}
|
||||
return keyBytes, nil
|
||||
}
|
||||
|
||||
func (a *GithubApp) Validate() error {
|
||||
if a.AppID == 0 {
|
||||
return fmt.Errorf("missing app_id")
|
||||
|
|
@ -472,6 +480,11 @@ type Database struct {
|
|||
// Don't lose or change this. It will invalidate all encrypted data
|
||||
// in the DB. This field must be set and must be exactly 32 characters.
|
||||
Passphrase string `toml:"passphrase"`
|
||||
|
||||
// MigrateCredentials is a list of github credentials that need to be migrated
|
||||
// from the config file to the database. This field will be removed once GARM
|
||||
// reaches version 0.2.x. It's only meant to be used for the migration process.
|
||||
MigrateCredentials []Github `toml:"-"`
|
||||
}
|
||||
|
||||
// GormParams returns the database type and connection URI
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue