[#25] Add computing container version
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
parent
665bcfb52d
commit
8f4c94f134
2 changed files with 16 additions and 0 deletions
|
@ -693,6 +693,7 @@ func restContainerGet(ctx context.Context, t *testing.T, owner user.ID, cnrID ci
|
|||
require.Equal(t, cnrID.EncodeToString(), *cnrInfo.ContainerID)
|
||||
require.Equal(t, owner.EncodeToString(), *cnrInfo.OwnerID)
|
||||
require.Equal(t, containerName, *cnrInfo.ContainerName)
|
||||
require.NotEmpty(t, *cnrInfo.Version)
|
||||
}
|
||||
|
||||
func restContainerDelete(ctx context.Context, t *testing.T, clientPool *pool.Pool, owner user.ID) {
|
||||
|
|
|
@ -24,6 +24,7 @@ import (
|
|||
"github.com/nspcc-dev/neofs-sdk-go/pool"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/session"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/version"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
@ -240,9 +241,23 @@ func getContainerInfo(ctx context.Context, p *pool.Pool, cnrID cid.ID) (*models.
|
|||
BasicACL: util.NewString(cnr.BasicACL().EncodeToString()),
|
||||
PlacementPolicy: util.NewString(sb.String()),
|
||||
Attributes: attrs,
|
||||
Version: util.NewString(getContainerVersion(cnr).String()),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func getContainerVersion(cnr *container.Container) version.Version {
|
||||
var v2cnr containerv2.Container
|
||||
cnr.WriteToV2(&v2cnr)
|
||||
|
||||
var cnrVersion version.Version
|
||||
v2version := v2cnr.GetVersion()
|
||||
if v2version != nil {
|
||||
cnrVersion = version.Version(*v2version)
|
||||
}
|
||||
|
||||
return cnrVersion
|
||||
}
|
||||
|
||||
func parseContainerID(containerID string) (cid.ID, error) {
|
||||
var cnrID cid.ID
|
||||
if err := cnrID.DecodeString(containerID); err != nil {
|
||||
|
|
Reference in a new issue