mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-10-21 10:45:25 +02:00
Consolidate controller bootstrap login in run command (#38)
This commit is contained in:
@@ -19,7 +19,6 @@ const ctxServiceAccountKey = "service-account"
|
||||
var ErrUnauthorized = errors.New("unauthorized")
|
||||
|
||||
func (controller *Controller) initAPI() *gin.Engine {
|
||||
gin.SetMode(gin.DebugMode)
|
||||
ginEngine := gin.Default()
|
||||
|
||||
// v1 API
|
||||
|
||||
@@ -116,7 +116,8 @@ func (controller *Controller) EnsureServiceAccount(serviceAccount *v1.ServiceAcc
|
||||
}
|
||||
|
||||
if serviceAccount.Token == "" {
|
||||
serviceAccount.Token = uuid.New().String()
|
||||
return fmt.Errorf("%w: attempted to create a service account with an empty token",
|
||||
ErrAdminTaskFailed)
|
||||
}
|
||||
|
||||
serviceAccount.CreatedAt = time.Now()
|
||||
|
||||
@@ -70,6 +70,15 @@ func (dataDir *DataDir) DBPath() string {
|
||||
return filepath.Join(dataDir.path, "db")
|
||||
}
|
||||
|
||||
func (dataDir *DataDir) ControllerCertificateExists() bool {
|
||||
return fileExist(dataDir.ControllerCertificatePath()) && fileExist(dataDir.ControllerKeyPath())
|
||||
}
|
||||
|
||||
func fileExist(path string) bool {
|
||||
_, err := os.Stat(path)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func (dataDir *DataDir) ControllerCertificatePath() string {
|
||||
return filepath.Join(dataDir.path, "controller.crt")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user