Attach a referrer manifest to an existing manifest
// This example demonstrates how to attach a referrer to an existing manifest.
// Create a HttpClient instance to be used for making HTTP requests.
var httpClient = new HttpClient();
// Create a repository instance with the target registry.
var mockCredentialProvider = new Mock<ICredentialProvider>();
var repo = new Repository(new RepositoryOptions()
{
Reference = Reference.Parse("localhost:5000/test"),
Client = new Client(httpClient, mockCredentialProvider.Object),
});
var targetReference = "target";
// Resolve the target reference to get its descriptor.
var targetDescriptor = await repo.ResolveAsync(targetReference);
// Add annotations to the manifest.
var artifactType = "doc/example";
var annotations = new Dictionary<string, string>
{
{ "org.opencontainers.image.created", "2000-01-01T00:00:00Z" },
{ "eol", "2025-07-01" }
};
var options = new PackManifestOptions
{
ManifestAnnotations = annotations,
Subject = targetDescriptor,
};
// Pack the manifest with the specified artifact type and annotations and push it to the repository.
await Packer.PackManifestAsync(repo, Packer.ManifestVersion.Version1_1, artifactType, options);