mirror of
https://github.com/hanzoai/runtime.git
synced 2026-10-30 18:23:13 +00:00
- Add main Dockerfile for production builds - Add Dockerfile.runtime for secure code execution - Add Dockerfile.runtime.fixed with improved configuration - Include .dockerignore for build optimization - Add integration documentation and publishing guides - Update API and CLI components for better runtime support - Enhance sandbox and container management features
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
// Copyright 2025 Hanzo Industries Inc.
|
|
// SPDX-License-Identifier: AGPL-3.0
|
|
|
|
package common
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/hanzoai/apiclient"
|
|
apiclient_cli "github.com/hanzoai/runtime/cli/apiclient"
|
|
"github.com/hanzoai/runtime/cli/config"
|
|
)
|
|
|
|
func GetPersonalOrganizationId(profile config.Profile) (string, error) {
|
|
apiClient, err := apiclient_cli.GetApiClient(&profile, nil)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
organizationList, res, err := apiClient.OrganizationsAPI.ListOrganizations(context.Background()).Execute()
|
|
if err != nil {
|
|
return "", apiclient_cli.HandleErrorResponse(res, err)
|
|
}
|
|
|
|
for _, organization := range organizationList {
|
|
if organization.Personal {
|
|
return organization.Id, nil
|
|
}
|
|
}
|
|
|
|
return "", nil
|
|
}
|
|
|
|
func GetActiveOrganizationName(apiClient *apiclient.APIClient, ctx context.Context) (string, error) {
|
|
activeOrganizationId, err := config.GetActiveOrganizationId()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
if activeOrganizationId == "" {
|
|
return "", config.ErrNoActiveOrganization
|
|
}
|
|
|
|
activeOrganization, res, err := apiClient.OrganizationsAPI.GetOrganization(ctx, activeOrganizationId).Execute()
|
|
if err != nil {
|
|
return "", apiclient_cli.HandleErrorResponse(res, err)
|
|
}
|
|
|
|
return activeOrganization.Name, nil
|
|
}
|