fix: resolve AX_TOKEN before config user in getNodeService
Build and Publish Arch Package / build-arch (amd64, x86_64) (push) Successful in 44s
Build and Publish Arch Package / build-arch (arm64, aarch64) (push) Successful in 49s
Build and Publish Docker Image / build-apk (amd64, x86_64) (push) Successful in 44s
Build and Publish Docker Image / build-apk (arm64, aarch64) (push) Successful in 44s
Build and Publish Docker Image / build-and-push-docker (push) Successful in 10m47s
Build and Publish Arch Package / build-arch (amd64, x86_64) (push) Successful in 44s
Build and Publish Arch Package / build-arch (arm64, aarch64) (push) Successful in 49s
Build and Publish Docker Image / build-apk (amd64, x86_64) (push) Successful in 44s
Build and Publish Docker Image / build-apk (arm64, aarch64) (push) Successful in 44s
Build and Publish Docker Image / build-and-push-docker (push) Successful in 10m47s
This commit is contained in:
@@ -12,6 +12,21 @@ import (
|
||||
)
|
||||
|
||||
func getNodeService() (service.NodeService, error) {
|
||||
if token := os.Getenv("AX_TOKEN"); token != "" {
|
||||
if cfg.Remote.Host != "" {
|
||||
base := fmt.Sprintf("http://%s:%d", cfg.Remote.Host, cfg.Remote.Port)
|
||||
return service.NewRemoteNodeService(base, ""), nil
|
||||
}
|
||||
st, err := store.FindAndOpenSQLiteStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
agentID := service.LookupAgentToken(st, token)
|
||||
if agentID == "" {
|
||||
return nil, fmt.Errorf("invalid AX_TOKEN: agent not found")
|
||||
}
|
||||
return service.NewLocalNodeService(st, agentID), nil
|
||||
}
|
||||
user := cfg.User
|
||||
if user == "" {
|
||||
return nil, fmt.Errorf("no user configured: run 'ax user set <username>' first")
|
||||
|
||||
Reference in New Issue
Block a user