support OCI-Subject header (#18885)

fixes #18865
the response header OCI-Subject to indicate to the client that the registry processed the request's subject.

Signed-off-by: wang yan <wangyan@vmware.com>
Co-authored-by: System Administrator <root@wangyanCQFQY.vmware.com>
This commit is contained in:
Wang Yan 2023-07-05 11:25:19 +08:00 committed by GitHub
parent 1d2624eefc
commit dbaae9e64e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 0 deletions

View File

@ -129,6 +129,7 @@ func Middleware() func(http.Handler) http.Handler {
return err
}
}
w.Header().Set("OCI-Subject", subjectArt.Digest)
}
return nil

View File

@ -159,6 +159,7 @@ func (suite *MiddlewareTestSuite) TestSubject() {
suite.Equal(name, accs[0].GetData().SubArtifactRepo)
suite.True(accs[0].IsHard())
suite.Equal(accessorymodel.TypeSubject, accs[0].GetData().Type)
suite.Equal(subArtDigest, res.Header().Values("OCI-Subject")[0])
})
}