初始提交:OCI 面板后端(含 GenAI 网关一期)
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"oci-portal/internal/oci"
|
||||
)
|
||||
|
||||
// Compartments 递归列出租户下全部 ACTIVE compartment(不含租户根)。
|
||||
func (s *OciConfigService) Compartments(ctx context.Context, id uint) ([]oci.Compartment, error) {
|
||||
cred, err := s.credentialsByID(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.client.ListCompartments(ctx, cred)
|
||||
}
|
||||
|
||||
// credentialsInCompartment 取配置凭据并限定资源操作的目标 compartment(空为租户根)。
|
||||
func (s *OciConfigService) credentialsInCompartment(ctx context.Context, id uint, compartmentID string) (oci.Credentials, error) {
|
||||
cred, err := s.credentialsByID(ctx, id)
|
||||
if err != nil {
|
||||
return oci.Credentials{}, err
|
||||
}
|
||||
cred.CompartmentID = compartmentID
|
||||
return cred, nil
|
||||
}
|
||||
Reference in New Issue
Block a user