Skip to content

Commit

Permalink
handler: Setup HomomorphicHashing for container
Browse files Browse the repository at this point in the history
Signed-off-by: Evgenii Baidakov <[email protected]>
  • Loading branch information
smallhive committed Oct 22, 2024
1 parent 0fb9b43 commit 2b5cecd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions handlers/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (a *RestAPI) PutContainer(ctx echo.Context, params apiserver.PutContainerPa
return ctx.JSON(http.StatusBadRequest, resp)
}

cnrID, err := createContainer(ctx.Request().Context(), a.pool, stoken, body, params, a.signer)
cnrID, err := createContainer(ctx.Request().Context(), a.pool, stoken, body, params, a.signer, a.networkInfoGetter)

Check warning on line 67 in handlers/containers.go

View check run for this annotation

Codecov / codecov/patch

handlers/containers.go#L67

Added line #L67 was not covered by tests
if err != nil {
resp := a.logAndGetErrorResponse("create container", err)
return ctx.JSON(http.StatusBadRequest, resp)
Expand Down Expand Up @@ -381,7 +381,7 @@ func getContainerEACL(ctx context.Context, p *pool.Pool, cnrID cid.ID) (*apiserv
return tableResp, nil
}

func createContainer(ctx context.Context, p *pool.Pool, stoken session.Container, request apiserver.ContainerPutInfo, params apiserver.PutContainerParams, signer user.Signer) (cid.ID, error) {
func createContainer(ctx context.Context, p *pool.Pool, stoken session.Container, request apiserver.ContainerPutInfo, params apiserver.PutContainerParams, signer user.Signer, networkInfoGetter networkInfoGetter) (cid.ID, error) {

Check warning on line 384 in handlers/containers.go

View check run for this annotation

Codecov / codecov/patch

handlers/containers.go#L384

Added line #L384 was not covered by tests
if request.PlacementPolicy == "" {
request.PlacementPolicy = defaultPlacementPolicy
}
Expand All @@ -406,6 +406,15 @@ func createContainer(ctx context.Context, p *pool.Pool, stoken session.Container
cnr.SetBasicACL(basicACL)
cnr.SetOwner(stoken.Issuer())

ni, err := networkInfoGetter.NetworkInfo(ctx)
if err != nil {
return cid.ID{}, fmt.Errorf("couldn't get network info: %w", err)
}

Check warning on line 412 in handlers/containers.go

View check run for this annotation

Codecov / codecov/patch

handlers/containers.go#L409-L412

Added lines #L409 - L412 were not covered by tests

if ni.HomomorphicHashingDisabled() {
cnr.DisableHomomorphicHashing()
}

Check warning on line 416 in handlers/containers.go

View check run for this annotation

Codecov / codecov/patch

handlers/containers.go#L414-L416

Added lines #L414 - L416 were not covered by tests

cnr.SetCreationTime(time.Now())

if request.ContainerName != "" {
Expand Down

0 comments on commit 2b5cecd

Please sign in to comment.