Skip to content

Commit

Permalink
add option to set a fixed installation ID
Browse files Browse the repository at this point in the history
  • Loading branch information
guy-har committed Oct 15, 2020
1 parent a38f158 commit e26816a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 9 additions & 2 deletions auth/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/google/uuid"
"github.com/jmoiron/sqlx"
"github.com/treeverse/lakefs/config"
"github.com/treeverse/lakefs/db"
"github.com/treeverse/lakefs/logging"
)
Expand All @@ -32,9 +33,15 @@ func NewDBMetadataManager(version string, database db.Database) *DBMetadataManag
db: database,
}
}

func generateInstallationID() string {
installationID := config.GetFixedInstallationID()
if installationID == "" {
installationID = uuid.New().String()
}
return installationID
}
func insertOrGetInstallationID(tx db.Tx) (string, error) {
newInstallationID := uuid.New().String()
newInstallationID := generateInstallationID()
res, err := tx.Exec(`INSERT INTO auth_installation_metadata (key_name, key_value)
VALUES ($1,$2)
ON CONFLICT DO NOTHING`,
Expand Down
4 changes: 4 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,7 @@ func GetMetastoreGlueCatalogID() string {
func GetMetastoreType() string {
return viper.GetString(MetaStoreType)
}

func GetFixedInstallationID() string {
return viper.GetString("installation.fixed-id")
}

0 comments on commit e26816a

Please sign in to comment.