All checks were successful
/ DCO (pull_request) Successful in 26s
/ Vulncheck (pull_request) Successful in 57s
/ Builds (pull_request) Successful in 1m22s
/ OCI image (pull_request) Successful in 1m34s
/ Lint (pull_request) Successful in 2m18s
/ Tests (pull_request) Successful in 59s
/ Integration tests (pull_request) Successful in 5m53s
/ Builds (push) Successful in 1m4s
/ Vulncheck (push) Successful in 1m2s
/ Lint (push) Successful in 2m22s
/ Tests (push) Successful in 1m11s
/ Integration tests (push) Successful in 6m2s
/ OCI image (push) Successful in 1m11s
Signed-off-by: Nikita Zinkevich <n.zinkevich@yadro.com>
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package handler
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-http-gw/internal/data"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-http-gw/internal/logs"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
|
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func (h *Handler) containerInfo(ctx context.Context, cnrID cid.ID) (*data.BucketInfo, error) {
|
|
info := &data.BucketInfo{
|
|
CID: cnrID,
|
|
Name: cnrID.EncodeToString(),
|
|
}
|
|
res, err := h.cnrContract.GetContainerByID(cnrID)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("get frostfs container: %w", err)
|
|
}
|
|
|
|
cnr := *res
|
|
|
|
if domain := container.ReadDomain(cnr); domain.Name() != "" {
|
|
info.Name = domain.Name()
|
|
info.Zone = domain.Zone()
|
|
}
|
|
info.HomomorphicHashDisabled = container.IsHomomorphicHashingDisabled(cnr)
|
|
info.PlacementPolicy = cnr.PlacementPolicy()
|
|
|
|
if err = h.cache.Put(info); err != nil {
|
|
h.reqLogger(ctx).Warn(logs.CouldntPutBucketIntoCache,
|
|
zap.String("bucket name", info.Name),
|
|
zap.Stringer("cid", info.CID),
|
|
zap.Error(err),
|
|
logs.TagField(logs.TagDatapath))
|
|
}
|
|
|
|
return info, nil
|
|
}
|