azcontainerregistry

package module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 24 Imported by: 0

README

Azure Container Registry client module for Go

Azure Container Registry allows you to store and manage container images and artifacts in a private registry for all types of container deployments.

Use the client library for Azure Container Registry to:

  • List images or artifacts in a registry
  • Obtain metadata for images and artifacts, repositories and tags
  • Set read/write/delete properties on registry items
  • Delete images and artifacts, repositories and tags
  • Upload and download images

Source code | Package (pkg.go.dev) | REST API documentation | Product documentation

Getting started

Install packages

Install azcontainerregistry and azidentity with go get:

go get github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry
go get github.com/Azure/azure-sdk-for-go/sdk/azidentity

azidentity is used for Azure Active Directory authentication as demonstrated below.

Prerequisites

To create a new Container Registry, you can use the Azure Portal, Azure PowerShell, or the Azure CLI. Here's an example using the Azure CLI:

az acr create --name MyContainerRegistry --resource-group MyResourceGroup --location westus --sku Basic
Authentication

This document demonstrates using azidentity.NewDefaultAzureCredential to authenticate. This credential type works in both local development and production environments. We recommend using a managed identity in production.

Client and BlobClient accepts any [azidentity][https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity] credential. See the azidentity documentation for more information about other credential types.

Create a client

Constructing the client requires your Container Registry's endpoint URL, which you can get from the Azure CLI (loginServer value returned by az acr list) or the Azure Portal (Login server value on registry overview page).

import (
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}

	client, err := azcontainerregistry.NewClient("<your Container Registry's endpoint URL>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
}

Key concepts

A registry stores Docker images and OCI Artifacts. An image or artifact consists of a manifest and layers. An image's manifest describes the layers that make up the image, and is uniquely identified by its digest. An image can also be "tagged" to give it a human-readable alias. An image or artifact can have zero or more tags associated with it, and each tag uniquely identifies the image. A collection of images that share the same name but have different tags, is referred to as a repository.

For more information please see Container Registry Concepts.

Examples

Get started with our examples.

Troubleshooting

For information about troubleshooting, refer to the troubleshooting guide.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the [Microsoft Open Source Code of Conduct][https://opensource.microsoft.com/codeofconduct/]. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Documentation

Overview

Example (DeleteImages)
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	client, err := azcontainerregistry.NewClient("<your Container Registry's endpoint URL>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	ctx := context.Background()
	repositoryPager := client.NewListRepositoriesPager(nil)
	for repositoryPager.More() {
		repositoryPage, err := repositoryPager.NextPage(ctx)
		if err != nil {
			log.Fatalf("failed to advance repository page: %v", err)
		}
		for _, r := range repositoryPage.Repositories.Names {
			manifestPager := client.NewListManifestsPager(*r, &azcontainerregistry.ClientListManifestsOptions{
				OrderBy: to.Ptr(azcontainerregistry.ArtifactManifestOrderByLastUpdatedOnDescending),
			})
			for manifestPager.More() {
				manifestPage, err := manifestPager.NextPage(ctx)
				if err != nil {
					log.Fatalf("failed to advance manifest page: %v", err)
				}
				imagesToKeep := 3
				for i, m := range manifestPage.Manifests.Attributes {
					if i >= imagesToKeep {
						for _, t := range m.Tags {
							fmt.Printf("delete tag from image: %s", *t)
							_, err := client.DeleteTag(ctx, *r, *t, nil)
							if err != nil {
								log.Fatalf("failed to delete tag: %v", err)
							}
						}
						_, err := client.DeleteManifest(ctx, *r, *m.Digest, nil)
						if err != nil {
							log.Fatalf("failed to delete manifest: %v", err)
						}
						fmt.Printf("delete image with digest: %s", *m.Digest)
					}
				}
			}
		}
	}
}
Output:

Example (DownloadImage)
package main

import (
	"context"
	"encoding/json"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"io"
	"log"
	"os"
	"strings"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	client, err := azcontainerregistry.NewClient("<your Container Registry's endpoint URL>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	blobClient, err := azcontainerregistry.NewBlobClient("<your Container Registry's endpoint URL>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create blob client: %v", err)
	}
	ctx := context.Background()

	// Get manifest
	manifestRes, err := client.GetManifest(ctx, "library/hello-world", "1.0.0", &azcontainerregistry.ClientGetManifestOptions{Accept: to.Ptr(string(azcontainerregistry.ContentTypeApplicationVndDockerDistributionManifestV2JSON))})
	if err != nil {
		log.Fatalf("failed to get manifest: %v", err)
	}
	reader, err := azcontainerregistry.NewDigestValidationReader(*manifestRes.DockerContentDigest, manifestRes.ManifestData)
	if err != nil {
		log.Fatalf("failed to create validation reader: %v", err)
	}
	manifest, err := io.ReadAll(reader)
	if err != nil {
		log.Fatalf("failed to read manifest data: %v", err)
	}
	fmt.Printf("manifest: %s\n", manifest)

	// Get config
	var manifestJSON map[string]any
	err = json.Unmarshal(manifest, &manifestJSON)
	if err != nil {
		log.Fatalf("failed to unmarshal manifest: %v", err)
	}
	configDigest := manifestJSON["config"].(map[string]any)["digest"].(string)
	configRes, err := blobClient.GetBlob(ctx, "library/hello-world", configDigest, nil)
	if err != nil {
		log.Fatalf("failed to get config: %v", err)
	}
	reader, err = azcontainerregistry.NewDigestValidationReader(configDigest, configRes.BlobData)
	if err != nil {
		log.Fatalf("failed to create validation reader: %v", err)
	}
	config, err := io.ReadAll(reader)
	if err != nil {
		log.Fatalf("failed to read config data: %v", err)
	}
	fmt.Printf("config: %s\n", config)

	// Get layers
	layers := manifestJSON["layers"].([]any)
	for _, layer := range layers {
		layerDigest := layer.(map[string]any)["digest"].(string)
		layerRes, err := blobClient.GetBlob(ctx, "library/hello-world", layerDigest, nil)
		if err != nil {
			log.Fatalf("failed to get layer: %v", err)
		}
		reader, err = azcontainerregistry.NewDigestValidationReader(layerDigest, layerRes.BlobData)
		if err != nil {
			log.Fatalf("failed to create validation reader: %v", err)
		}
		f, err := os.Create(strings.Split(layerDigest, ":")[1])
		if err != nil {
			log.Fatalf("failed to create blob file: %v", err)
		}
		_, err = io.Copy(f, reader)
		if err != nil {
			log.Fatalf("failed to write to the file: %v", err)
		}
		err = f.Close()
		if err != nil {
			log.Fatalf("failed to close the file: %v", err)
		}
	}
}
Output:

Example (ListRepositories)
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	client, err := azcontainerregistry.NewClient("<your Container Registry's endpoint URL>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	ctx := context.Background()
	pager := client.NewListRepositoriesPager(nil)
	for pager.More() {
		page, err := pager.NextPage(ctx)
		if err != nil {
			log.Fatalf("failed to advance page: %v", err)
		}
		for _, v := range page.Repositories.Names {
			fmt.Printf("repository: %s\n", *v)
		}
	}
}
Output:

Example (ListTagsWithAnonymousAccess)
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"
)

func main() {
	client, err := azcontainerregistry.NewClient("<your Container Registry's endpoint URL>", nil, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	ctx := context.Background()
	pager := client.NewListTagsPager("library/hello-world", nil)
	for pager.More() {
		page, err := pager.NextPage(ctx)
		if err != nil {
			log.Fatalf("failed to advance page: %v", err)
		}
		for _, v := range page.Tags {
			fmt.Printf("tag: %s\n", *v.Name)
		}
	}
}
Output:

Example (SetArtifactProperties)
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	client, err := azcontainerregistry.NewClient("<your Container Registry's endpoint URL>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	ctx := context.Background()
	res, err := client.UpdateTagProperties(ctx, "library/hello-world", "latest", &azcontainerregistry.ClientUpdateTagPropertiesOptions{
		Value: &azcontainerregistry.TagWriteableProperties{
			CanWrite:  to.Ptr(false),
			CanDelete: to.Ptr(false),
		}})
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	fmt.Printf("repository library/hello-world - tag latest: 'CanWrite' property: %t, 'CanDelete' property: %t\n", *res.Tag.ChangeableAttributes.CanWrite, *res.Tag.ChangeableAttributes.CanDelete)
}
Output:

Example (UploadImage)
package main

import (
	"bytes"
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	client, err := azcontainerregistry.NewClient("<your Container Registry's endpoint URL>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	blobClient, err := azcontainerregistry.NewBlobClient("<your Container Registry's endpoint URL>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create blob client: %v", err)
	}
	ctx := context.Background()
	layer := []byte("hello world")
	startRes, err := blobClient.StartUpload(ctx, "library/hello-world", nil)
	if err != nil {
		log.Fatalf("failed to start upload layer: %v", err)
	}
	calculator := azcontainerregistry.NewBlobDigestCalculator()
	uploadResp, err := blobClient.UploadChunk(ctx, *startRes.Location, bytes.NewReader(layer), calculator, nil)
	if err != nil {
		log.Fatalf("failed to upload layer: %v", err)
	}
	completeResp, err := blobClient.CompleteUpload(ctx, *uploadResp.Location, calculator, nil)
	if err != nil {
		log.Fatalf("failed to complete layer upload: %v", err)
	}
	layerDigest := *completeResp.DockerContentDigest
	config := []byte(fmt.Sprintf(`{
  architecture: "amd64",
  os: "windows",
  rootfs: {
	type: "layers",
	diff_ids: [%s],
  },
}`, layerDigest))
	startRes, err = blobClient.StartUpload(ctx, "library/hello-world", nil)
	if err != nil {
		log.Fatalf("failed to start upload config: %v", err)
	}
	calculator = azcontainerregistry.NewBlobDigestCalculator()
	uploadResp, err = blobClient.UploadChunk(ctx, *startRes.Location, bytes.NewReader(config), calculator, nil)
	if err != nil {
		log.Fatalf("failed to upload config: %v", err)
	}
	completeResp, err = blobClient.CompleteUpload(ctx, *uploadResp.Location, calculator, nil)
	if err != nil {
		log.Fatalf("failed to complete config upload: %v", err)
	}
	manifest := fmt.Sprintf(`{
  "schemaVersion": 2,
  "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
  "config": {
	"mediaType": "application/vnd.oci.image.config.v1+json",
	"digest": "%s",
	"size": %d
  },
  "layers": [
	{
	  "mediaType": "application/vnd.oci.image.layer.v1.tar",
	  "digest": "%s",
	  "size": %d,
	  "annotations": {
		"title": "artifact.txt"
	  }
    }
  ]
}`, layerDigest, len(config), *completeResp.DockerContentDigest, len(layer))
	uploadManifestRes, err := client.UploadManifest(ctx, "library/hello-world", "1.0.0", azcontainerregistry.ContentTypeApplicationVndDockerDistributionManifestV2JSON, streaming.NopCloser(bytes.NewReader([]byte(manifest))), nil)
	if err != nil {
		log.Fatalf("failed to upload manifest: %v", err)
	}
	fmt.Printf("digest of uploaded manifest: %s", *uploadManifestRes.DockerContentDigest)
}
Output:

Index

Examples

Constants

View Source
const (
	// ServiceName is the cloud service name for Azure Container Registry
	ServiceName cloud.ServiceName = "azcontainerregistry"
)

Variables

View Source
var (
	ErrMismatchedHash        = errors.New("mismatched hash")
	ErrDigestAlgNotSupported = errors.New("digest algorithm not supported")
)

Functions

This section is empty.

Types

type ArtifactArchitecture

type ArtifactArchitecture string

ArtifactArchitecture - The artifact platform's architecture.

const (
	// ArtifactArchitectureAmd64 - AMD64
	ArtifactArchitectureAmd64 ArtifactArchitecture = "amd64"
	// ArtifactArchitectureArm - ARM
	ArtifactArchitectureArm ArtifactArchitecture = "arm"
	// ArtifactArchitectureArm64 - ARM64
	ArtifactArchitectureArm64 ArtifactArchitecture = "arm64"
	// ArtifactArchitectureI386 - i386
	ArtifactArchitectureI386 ArtifactArchitecture = "386"
	// ArtifactArchitectureMips - MIPS
	ArtifactArchitectureMips ArtifactArchitecture = "mips"
	// ArtifactArchitectureMips64 - MIPS64
	ArtifactArchitectureMips64 ArtifactArchitecture = "mips64"
	// ArtifactArchitectureMips64Le - MIPS64LE
	ArtifactArchitectureMips64Le ArtifactArchitecture = "mips64le"
	// ArtifactArchitectureMipsLe - MIPSLE
	ArtifactArchitectureMipsLe ArtifactArchitecture = "mipsle"
	// ArtifactArchitecturePpc64 - PPC64
	ArtifactArchitecturePpc64 ArtifactArchitecture = "ppc64"
	// ArtifactArchitecturePpc64Le - PPC64LE
	ArtifactArchitecturePpc64Le ArtifactArchitecture = "ppc64le"
	// ArtifactArchitectureRiscV64 - RISCv64
	ArtifactArchitectureRiscV64 ArtifactArchitecture = "riscv64"
	// ArtifactArchitectureS390X - s390x
	ArtifactArchitectureS390X ArtifactArchitecture = "s390x"
	// ArtifactArchitectureWasm - Wasm
	ArtifactArchitectureWasm ArtifactArchitecture = "wasm"
)

func PossibleArtifactArchitectureValues

func PossibleArtifactArchitectureValues() []ArtifactArchitecture

PossibleArtifactArchitectureValues returns the possible values for the ArtifactArchitecture const type.

type ArtifactManifestOrderBy

type ArtifactManifestOrderBy string

ArtifactManifestOrderBy - Sort options for ordering manifests in a collection.

const (
	// ArtifactManifestOrderByLastUpdatedOnAscending - Order manifest by LastUpdatedOn field, from least recently updated to most
	// recently updated.
	ArtifactManifestOrderByLastUpdatedOnAscending ArtifactManifestOrderBy = "timeasc"
	// ArtifactManifestOrderByLastUpdatedOnDescending - Order manifests by LastUpdatedOn field, from most recently updated to
	// least recently updated.
	ArtifactManifestOrderByLastUpdatedOnDescending ArtifactManifestOrderBy = "timedesc"
	// ArtifactManifestOrderByNone - Do not provide an orderby value in the request.
	ArtifactManifestOrderByNone ArtifactManifestOrderBy = "none"
)

func PossibleArtifactManifestOrderByValues

func PossibleArtifactManifestOrderByValues() []ArtifactManifestOrderBy

PossibleArtifactManifestOrderByValues returns the possible values for the ArtifactManifestOrderBy const type.

type ArtifactManifestPlatform

type ArtifactManifestPlatform struct {
	// READ-ONLY; Manifest digest
	Digest *string

	// READ-ONLY; CPU architecture
	Architecture *ArtifactArchitecture

	// READ-ONLY; Operating system
	OperatingSystem *ArtifactOperatingSystem
}

ArtifactManifestPlatform - The artifact's platform, consisting of operating system and architecture.

func (*ArtifactManifestPlatform) UnmarshalJSON

func (a *ArtifactManifestPlatform) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type ArtifactManifestPlatform.

type ArtifactManifestProperties

type ArtifactManifestProperties struct {
	// READ-ONLY; Manifest attributes
	Manifest *ManifestAttributes

	// READ-ONLY; Registry login server name. This is likely to be similar to {registry-name}.azurecr.io.
	RegistryLoginServer *string

	// READ-ONLY; Repository name
	RepositoryName *string
}

ArtifactManifestProperties - Manifest attributes details

func (*ArtifactManifestProperties) UnmarshalJSON

func (a *ArtifactManifestProperties) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type ArtifactManifestProperties.

type ArtifactOperatingSystem

type ArtifactOperatingSystem string

ArtifactOperatingSystem - The artifact platform's operating system.

const (
	ArtifactOperatingSystemAix       ArtifactOperatingSystem = "aix"
	ArtifactOperatingSystemAndroid   ArtifactOperatingSystem = "android"
	ArtifactOperatingSystemDarwin    ArtifactOperatingSystem = "darwin"
	ArtifactOperatingSystemDragonfly ArtifactOperatingSystem = "dragonfly"
	ArtifactOperatingSystemFreeBsd   ArtifactOperatingSystem = "freebsd"
	ArtifactOperatingSystemIOS       ArtifactOperatingSystem = "ios"
	ArtifactOperatingSystemIllumos   ArtifactOperatingSystem = "illumos"
	ArtifactOperatingSystemJS        ArtifactOperatingSystem = "js"
	ArtifactOperatingSystemLinux     ArtifactOperatingSystem = "linux"
	ArtifactOperatingSystemNetBsd    ArtifactOperatingSystem = "netbsd"
	ArtifactOperatingSystemOpenBsd   ArtifactOperatingSystem = "openbsd"
	ArtifactOperatingSystemPlan9     ArtifactOperatingSystem = "plan9"
	ArtifactOperatingSystemSolaris   ArtifactOperatingSystem = "solaris"
	ArtifactOperatingSystemWindows   ArtifactOperatingSystem = "windows"
)

func PossibleArtifactOperatingSystemValues

func PossibleArtifactOperatingSystemValues() []ArtifactOperatingSystem

PossibleArtifactOperatingSystemValues returns the possible values for the ArtifactOperatingSystem const type.

type ArtifactTagOrderBy

type ArtifactTagOrderBy string

ArtifactTagOrderBy - Sort options for ordering tags in a collection.

const (
	// ArtifactTagOrderByLastUpdatedOnAscending - Order tags by LastUpdatedOn field, from least recently updated to most recently
	// updated.
	ArtifactTagOrderByLastUpdatedOnAscending ArtifactTagOrderBy = "timeasc"
	// ArtifactTagOrderByLastUpdatedOnDescending - Order tags by LastUpdatedOn field, from most recently updated to least recently
	// updated.
	ArtifactTagOrderByLastUpdatedOnDescending ArtifactTagOrderBy = "timedesc"
	// ArtifactTagOrderByNone - Do not provide an orderby value in the request.
	ArtifactTagOrderByNone ArtifactTagOrderBy = "none"
)

func PossibleArtifactTagOrderByValues

func PossibleArtifactTagOrderByValues() []ArtifactTagOrderBy

PossibleArtifactTagOrderByValues returns the possible values for the ArtifactTagOrderBy const type.

type ArtifactTagProperties

type ArtifactTagProperties struct {
	// READ-ONLY; Registry login server name. This is likely to be similar to {registry-name}.azurecr.io.
	RegistryLoginServer *string

	// READ-ONLY; Image name
	RepositoryName *string

	// READ-ONLY; List of tag attribute details
	Tag *TagAttributes
}

ArtifactTagProperties - Tag attributes

func (*ArtifactTagProperties) UnmarshalJSON

func (a *ArtifactTagProperties) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type ArtifactTagProperties.

type BlobClient

type BlobClient struct {
	// contains filtered or unexported fields
}

BlobClient contains the methods for the ContainerRegistryBlob group. Don't use this type directly, use a constructor function instead.

func NewBlobClient

func NewBlobClient(endpoint string, credential azcore.TokenCredential, options *BlobClientOptions) (*BlobClient, error)

NewBlobClient creates a new instance of BlobClient with the specified values.

  • endpoint - registry login URL
  • credential - used to authorize requests. Usually a credential from azidentity.
  • options - client options, pass nil to accept the default values.
Example
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
	log.Fatalf("failed to obtain a credential: %v", err)
}
blobClient, err = azcontainerregistry.NewBlobClient("https://example.azurecr.io", cred, nil)
if err != nil {
	log.Fatalf("failed to create blob client: %v", err)
}
_ = blobClient
Output:

func (*BlobClient) CancelUpload

func (client *BlobClient) CancelUpload(ctx context.Context, location string, options *BlobClientCancelUploadOptions) (BlobClientCancelUploadResponse, error)

CancelUpload - Cancel outstanding upload processes, releasing associated resources. If this is not called, the unfinished uploads will eventually timeout. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2021-07-01

  • location - Link acquired from upload start or previous chunk. Note, do not include initial / (must do substring(1) )
  • options - BlobClientCancelUploadOptions contains the optional parameters for the BlobClient.CancelUpload method.
Example
package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"
)

var blobClient *azcontainerregistry.BlobClient

func main() {
	_, err := blobClient.CancelUpload(context.TODO(), "v2/blobland/blobs/uploads/2b28c60d-d296-44b7-b2b4-1f01c63195c6?_nouploadcache=false&_state=VYABvUSCNW2yY5e5VabLHppXqwU0K7cvT0YUdq57KBt7Ik5hbWUiOiJibG9ibGFuZCIsIlVVSUQiOiIyYjI4YzYwZC1kMjk2LTQ0YjctYjJiNC0xZjAxYzYzMTk1YzYiLCJPZmZzZXQiOjAsIlN0YXJ0ZWRBdCI6IjIwMTktMDgtMjdUMjM6NTI6NDcuMDUzNjU2Mjg1WiJ9", nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
}
Output:

func (*BlobClient) CheckBlobExists

func (client *BlobClient) CheckBlobExists(ctx context.Context, name string, digest string, options *BlobClientCheckBlobExistsOptions) (BlobClientCheckBlobExistsResponse, error)

CheckBlobExists - Same as GET, except only the headers are returned. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2021-07-01

  • name - Name of the image (including the namespace)
  • digest - Digest of a BLOB
  • options - BlobClientCheckBlobExistsOptions contains the optional parameters for the BlobClient.CheckBlobExists method.
Example
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"
)

var blobClient *azcontainerregistry.BlobClient

func main() {
	res, err := blobClient.CheckBlobExists(context.TODO(), "prod/bash", "sha256:16463e0c481e161aabb735437d30b3c9c7391c2747cc564bb927e843b73dcb39", nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	fmt.Printf("blob digest: %s", *res.DockerContentDigest)
}
Output:

func (*BlobClient) CheckChunkExists

func (client *BlobClient) CheckChunkExists(ctx context.Context, name string, digest string, rangeParam string, options *BlobClientCheckChunkExistsOptions) (BlobClientCheckChunkExistsResponse, error)

CheckChunkExists - Same as GET, except only the headers are returned. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2021-07-01

  • name - Name of the image (including the namespace)
  • digest - Digest of a BLOB
  • rangeParam - Format : bytes=-, HTTP Range header specifying blob chunk.
  • options - BlobClientCheckChunkExistsOptions contains the optional parameters for the BlobClient.CheckChunkExists method.
Example
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"
)

var blobClient *azcontainerregistry.BlobClient

func main() {
	res, err := blobClient.CheckChunkExists(context.TODO(), "prod/bash", "sha256:16463e0c481e161aabb735437d30b3c9c7391c2747cc564bb927e843b73dcb39", "bytes=0-299", nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	fmt.Printf("chunk size: %d", *res.ContentLength)
	fmt.Printf("chunk range: %s", *res.ContentRange)
}
Output:

func (*BlobClient) CompleteUpload

func (client *BlobClient) CompleteUpload(ctx context.Context, location string, blobDigestCalculator *BlobDigestCalculator, options *BlobClientCompleteUploadOptions) (BlobClientCompleteUploadResponse, error)

CompleteUpload - Complete the upload with previously uploaded content.

  • digest - Digest of a BLOB
  • location - Link acquired from upload start or previous chunk
  • blobDigestCalculator - Calculator that help to calculate blob digest
  • options - BlobClientCompleteUploadOptions contains the optional parameters for the BlobClient.CompleteUpload method.
Example
// calculator should be created when starting upload blob and passing to UploadChunk and CompleteUpload method
calculator := azcontainerregistry.NewBlobDigestCalculator()
res, err := blobClient.CompleteUpload(context.TODO(), "v2/blobland/blobs/uploads/2b28c60d-d296-44b7-b2b4-1f01c63195c6?_nouploadcache=false&_state=VYABvUSCNW2yY5e5VabLHppXqwU0K7cvT0YUdq57KBt7Ik5hbWUiOiJibG9ibGFuZCIsIlVVSUQiOiIyYjI4YzYwZC1kMjk2LTQ0YjctYjJiNC0xZjAxYzYzMTk1YzYiLCJPZmZzZXQiOjAsIlN0YXJ0ZWRBdCI6IjIwMTktMDgtMjdUMjM6NTI6NDcuMDUzNjU2Mjg1WiJ9", calculator, nil)
if err != nil {
	log.Fatalf("failed to finish the request: %v", err)
}
fmt.Printf("content digest: %s", *res.DockerContentDigest)
Output:

func (*BlobClient) DeleteBlob

func (client *BlobClient) DeleteBlob(ctx context.Context, name string, digest string, options *BlobClientDeleteBlobOptions) (BlobClientDeleteBlobResponse, error)

DeleteBlob - Removes an already uploaded blob. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2021-07-01

  • name - Name of the image (including the namespace)
  • digest - Digest of a BLOB
  • options - BlobClientDeleteBlobOptions contains the optional parameters for the BlobClient.DeleteBlob method.
Example
package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"
)

var blobClient *azcontainerregistry.BlobClient

func main() {
	_, err := blobClient.DeleteBlob(context.TODO(), "prod/bash", "sha256:16463e0c481e161aabb735437d30b3c9c7391c2747cc564bb927e843b73dcb39", nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
}
Output:

func (*BlobClient) GetBlob

func (client *BlobClient) GetBlob(ctx context.Context, name string, digest string, options *BlobClientGetBlobOptions) (BlobClientGetBlobResponse, error)

GetBlob - Retrieve the blob from the registry identified by digest. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2021-07-01

  • name - Name of the image (including the namespace)
  • digest - Digest of a BLOB
  • options - BlobClientGetBlobOptions contains the optional parameters for the BlobClient.GetBlob method.
Example
package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"io"
	"log"
	"os"
)

var blobClient *azcontainerregistry.BlobClient

func main() {
	const digest = "sha256:16463e0c481e161aabb735437d30b3c9c7391c2747cc564bb927e843b73dcb39"
	res, err := blobClient.GetBlob(context.TODO(), "prod/bash", digest, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	reader, err := azcontainerregistry.NewDigestValidationReader(digest, res.BlobData)
	if err != nil {
		log.Fatalf("failed to create validation reader: %v", err)
	}
	f, err := os.Create("blob_file")
	if err != nil {
		log.Fatalf("failed to create blob file: %v", err)
	}
	defer f.Close()
	_, err = io.Copy(f, reader)
	if err != nil {
		log.Fatalf("failed to write to the file: %v", err)
	}
}
Output:

func (*BlobClient) GetChunk

func (client *BlobClient) GetChunk(ctx context.Context, name string, digest string, rangeParam string, options *BlobClientGetChunkOptions) (BlobClientGetChunkResponse, error)

GetChunk - Retrieve the blob from the registry identified by digest. This endpoint may also support RFC7233 compliant range requests. Support can be detected by issuing a HEAD request. If the header Accept-Range: bytes is returned, range requests can be used to fetch partial content. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2021-07-01

  • name - Name of the image (including the namespace)
  • digest - Digest of a BLOB
  • rangeParam - Format : bytes=-, HTTP Range header specifying blob chunk.
  • options - BlobClientGetChunkOptions contains the optional parameters for the BlobClient.GetChunk method.
Example
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"io"
	"log"
	"os"
	"strconv"
	"strings"
)

var blobClient *azcontainerregistry.BlobClient

func main() {
	chunkSize := 1024 * 1024
	const digest = "sha256:16463e0c481e161aabb735437d30b3c9c7391c2747cc564bb927e843b73dcb39"
	current := 0
	f, err := os.Create("blob_file")
	if err != nil {
		log.Fatalf("failed to create blob file: %v", err)
	}
	defer f.Close()
	for {
		res, err := blobClient.GetChunk(context.TODO(), "prod/bash", digest, fmt.Sprintf("bytes=%d-%d", current, current+chunkSize-1), nil)
		if err != nil {
			log.Fatalf("failed to finish the request: %v", err)
		}
		chunk, err := io.ReadAll(res.ChunkData)
		if err != nil {
			log.Fatalf("failed to read the chunk: %v", err)
		}
		_, err = f.Write(chunk)
		if err != nil {
			log.Fatalf("failed to write to the file: %v", err)
		}

		totalSize, _ := strconv.Atoi(strings.Split(*res.ContentRange, "/")[1])
		currentRangeEnd, _ := strconv.Atoi(strings.Split(strings.Split(*res.ContentRange, "/")[0], "-")[1])
		if totalSize == currentRangeEnd+1 {
			break
		}
		current += chunkSize
	}
	_, err = f.Seek(0, io.SeekStart)
	if err != nil {
		log.Fatalf("failed to set to the start of the file: %v", err)
	}
	reader, err := azcontainerregistry.NewDigestValidationReader(digest, f)
	if err != nil {
		log.Fatalf("failed to create digest validation reader: %v", err)
	}
	_, err = io.ReadAll(reader)
	if err != nil {
		log.Fatalf("failed to validate digest: %v", err)
	}
}
Output:

func (*BlobClient) GetUploadStatus

func (client *BlobClient) GetUploadStatus(ctx context.Context, location string, options *BlobClientGetUploadStatusOptions) (BlobClientGetUploadStatusResponse, error)

GetUploadStatus - Retrieve status of upload identified by uuid. The primary purpose of this endpoint is to resolve the current status of a resumable upload. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2021-07-01

  • location - Link acquired from upload start or previous chunk. Note, do not include initial / (must do substring(1) )
  • options - BlobClientGetUploadStatusOptions contains the optional parameters for the BlobClient.GetUploadStatus method.
Example
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"
)

var blobClient *azcontainerregistry.BlobClient

func main() {
	res, err := blobClient.GetUploadStatus(context.TODO(), "v2/blobland/blobs/uploads/2b28c60d-d296-44b7-b2b4-1f01c63195c6?_nouploadcache=false&_state=VYABvUSCNW2yY5e5VabLHppXqwU0K7cvT0YUdq57KBt7Ik5hbWUiOiJibG9ibGFuZCIsIlVVSUQiOiIyYjI4YzYwZC1kMjk2LTQ0YjctYjJiNC0xZjAxYzYzMTk1YzYiLCJPZmZzZXQiOjAsIlN0YXJ0ZWRBdCI6IjIwMTktMDgtMjdUMjM6NTI6NDcuMDUzNjU2Mjg1WiJ9", nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	fmt.Printf("upload UUID: %s", *res.DockerUploadUUID)
}
Output:

func (*BlobClient) MountBlob

func (client *BlobClient) MountBlob(ctx context.Context, name string, from string, mount string, options *BlobClientMountBlobOptions) (BlobClientMountBlobResponse, error)

MountBlob - Mount a blob identified by the mount parameter from another repository. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2021-07-01

  • name - Name of the image (including the namespace)
  • from - Name of the source repository.
  • mount - Digest of blob to mount from the source repository.
  • options - BlobClientMountBlobOptions contains the optional parameters for the BlobClient.MountBlob method.
Example
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"
)

var blobClient *azcontainerregistry.BlobClient

func main() {
	res, err := blobClient.MountBlob(context.TODO(), "newimage", "prod/bash", "sha256:16463e0c481e161aabb735437d30b3c9c7391c2747cc564bb927e843b73dcb39", nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	fmt.Printf("upload location: %s", *res.Location)
}
Output:

func (*BlobClient) StartUpload

StartUpload - Initiate a resumable blob upload with an empty request body. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2021-07-01

  • name - Name of the image (including the namespace)
  • options - BlobClientStartUploadOptions contains the optional parameters for the BlobClient.StartUpload method.
Example
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"
)

var blobClient *azcontainerregistry.BlobClient

func main() {
	res, err := blobClient.StartUpload(context.TODO(), "newimg", nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	fmt.Printf("upload location: %s", *res.Location)
}
Output:

func (*BlobClient) UploadChunk

func (client *BlobClient) UploadChunk(ctx context.Context, location string, chunkData io.ReadSeeker, blobDigestCalculator *BlobDigestCalculator, options *BlobClientUploadChunkOptions) (BlobClientUploadChunkResponse, error)

UploadChunk - Upload a stream of data without completing the upload.

  • location - Link acquired from upload start or previous chunk
  • chunkData - Raw data of blob
  • blobDigestCalculator - Calculator that help to calculate blob digest
  • options - BlobClientUploadChunkOptions contains the optional parameters for the BlobClient.UploadChunk method.
Example
// calculator should be created when starting upload blob and passing to UploadChunk and CompleteUpload method
calculator := azcontainerregistry.NewBlobDigestCalculator()
location := "v2/blobland/blobs/uploads/2b28c60d-d296-44b7-b2b4-1f01c63195c6?_nouploadcache=false&_state=VYABvUSCNW2yY5e5VabLHppXqwU0K7cvT0YUdq57KBt7Ik5hbWUiOiJibG9ibGFuZCIsIlVVSUQiOiIyYjI4YzYwZC1kMjk2LTQ0YjctYjJiNC0xZjAxYzYzMTk1YzYiLCJPZmZzZXQiOjAsIlN0YXJ0ZWRBdCI6IjIwMTktMDgtMjdUMjM6NTI6NDcuMDUzNjU2Mjg1WiJ9"
f, err := os.Open("blob-file")
if err != nil {
	log.Fatalf("failed to read blob file: %v", err)
}
size, err := f.Seek(0, io.SeekEnd)
if err != nil {
	log.Fatalf("failed to calculate blob size: %v", err)
}
chunkSize := int64(5)
current := int64(0)
for {
	end := current + chunkSize
	if end > size {
		end = size
	}
	chunkReader := io.NewSectionReader(f, current, end-current)
	uploadResp, err := blobClient.UploadChunk(context.TODO(), location, chunkReader, calculator, &azcontainerregistry.BlobClientUploadChunkOptions{RangeStart: to.Ptr(int32(current)), RangeEnd: to.Ptr(int32(end - 1))})
	if err != nil {
		log.Fatalf("failed to upload chunk: %v", err)
	}
	location = *uploadResp.Location
	current = end
	if current >= size {
		break
	}
}
fmt.Printf("upload location: %s", location)
Output:

type BlobClientCancelUploadOptions

type BlobClientCancelUploadOptions struct {
}

BlobClientCancelUploadOptions contains the optional parameters for the BlobClient.CancelUpload method.

type BlobClientCancelUploadResponse

type BlobClientCancelUploadResponse struct {
}

BlobClientCancelUploadResponse contains the response from method BlobClient.CancelUpload.

type BlobClientCheckBlobExistsOptions

type BlobClientCheckBlobExistsOptions struct {
}

BlobClientCheckBlobExistsOptions contains the optional parameters for the BlobClient.CheckBlobExists method.

type BlobClientCheckBlobExistsResponse

type BlobClientCheckBlobExistsResponse struct {
	// ContentLength contains the information returned from the Content-Length header response.
	ContentLength *int64

	// DockerContentDigest contains the information returned from the Docker-Content-Digest header response.
	DockerContentDigest *string
}

BlobClientCheckBlobExistsResponse contains the response from method BlobClient.CheckBlobExists.

type BlobClientCheckChunkExistsOptions

type BlobClientCheckChunkExistsOptions struct {
}

BlobClientCheckChunkExistsOptions contains the optional parameters for the BlobClient.CheckChunkExists method.

type BlobClientCheckChunkExistsResponse

type BlobClientCheckChunkExistsResponse struct {
	// ContentLength contains the information returned from the Content-Length header response.
	ContentLength *int64

	// ContentRange contains the information returned from the Content-Range header response.
	ContentRange *string
}

BlobClientCheckChunkExistsResponse contains the response from method BlobClient.CheckChunkExists.

type BlobClientCompleteUploadOptions

type BlobClientCompleteUploadOptions struct {
}

BlobClientCompleteUploadOptions contains the optional parameters for the BlobClient.CompleteUpload method.

type BlobClientCompleteUploadResponse

type BlobClientCompleteUploadResponse struct {
	// DockerContentDigest contains the information returned from the Docker-Content-Digest header response.
	DockerContentDigest *string

	// Location contains the information returned from the Location header response.
	Location *string

	// Range contains the information returned from the Range header response.
	Range *string
}

BlobClientCompleteUploadResponse contains the response from method BlobClient.CompleteUpload.

type BlobClientDeleteBlobOptions

type BlobClientDeleteBlobOptions struct {
}

BlobClientDeleteBlobOptions contains the optional parameters for the BlobClient.DeleteBlob method.

type BlobClientDeleteBlobResponse

type BlobClientDeleteBlobResponse struct {
	// DockerContentDigest contains the information returned from the Docker-Content-Digest header response.
	DockerContentDigest *string
}

BlobClientDeleteBlobResponse contains the response from method BlobClient.DeleteBlob.

type BlobClientGetBlobOptions

type BlobClientGetBlobOptions struct {
}

BlobClientGetBlobOptions contains the optional parameters for the BlobClient.GetBlob method.

type BlobClientGetBlobResponse

type BlobClientGetBlobResponse struct {
	// Body contains the streaming response.
	BlobData io.ReadCloser

	// ContentLength contains the information returned from the Content-Length header response.
	ContentLength *int64

	// DockerContentDigest contains the information returned from the Docker-Content-Digest header response.
	DockerContentDigest *string
}

BlobClientGetBlobResponse contains the response from method BlobClient.GetBlob.

type BlobClientGetChunkOptions

type BlobClientGetChunkOptions struct {
}

BlobClientGetChunkOptions contains the optional parameters for the BlobClient.GetChunk method.

type BlobClientGetChunkResponse

type BlobClientGetChunkResponse struct {
	// Body contains the streaming response.
	ChunkData io.ReadCloser

	// ContentLength contains the information returned from the Content-Length header response.
	ContentLength *int64

	// ContentRange contains the information returned from the Content-Range header response.
	ContentRange *string
}

BlobClientGetChunkResponse contains the response from method BlobClient.GetChunk.

type BlobClientGetUploadStatusOptions

type BlobClientGetUploadStatusOptions struct {
}

BlobClientGetUploadStatusOptions contains the optional parameters for the BlobClient.GetUploadStatus method.

type BlobClientGetUploadStatusResponse

type BlobClientGetUploadStatusResponse struct {
	// DockerUploadUUID contains the information returned from the Docker-Upload-UUID header response.
	DockerUploadUUID *string

	// Range contains the information returned from the Range header response.
	Range *string
}

BlobClientGetUploadStatusResponse contains the response from method BlobClient.GetUploadStatus.

type BlobClientMountBlobOptions

type BlobClientMountBlobOptions struct {
}

BlobClientMountBlobOptions contains the optional parameters for the BlobClient.MountBlob method.

type BlobClientMountBlobResponse

type BlobClientMountBlobResponse struct {
	// DockerContentDigest contains the information returned from the Docker-Content-Digest header response.
	DockerContentDigest *string

	// DockerUploadUUID contains the information returned from the Docker-Upload-UUID header response.
	DockerUploadUUID *string

	// Location contains the information returned from the Location header response.
	Location *string
}

BlobClientMountBlobResponse contains the response from method BlobClient.MountBlob.

type BlobClientOptions

type BlobClientOptions struct {
	azcore.ClientOptions
}

BlobClientOptions contains the optional parameters for the NewBlobClient method.

type BlobClientStartUploadOptions

type BlobClientStartUploadOptions struct {
}

BlobClientStartUploadOptions contains the optional parameters for the BlobClient.StartUpload method.

type BlobClientStartUploadResponse

type BlobClientStartUploadResponse struct {
	// DockerUploadUUID contains the information returned from the Docker-Upload-UUID header response.
	DockerUploadUUID *string

	// Location contains the information returned from the Location header response.
	Location *string

	// Range contains the information returned from the Range header response.
	Range *string
}

BlobClientStartUploadResponse contains the response from method BlobClient.StartUpload.

type BlobClientUploadChunkOptions

type BlobClientUploadChunkOptions struct {
	// Start of range for the blob to be uploaded.
	RangeStart *int32
	// End of range for the blob to be uploaded, inclusive.
	RangeEnd *int32
}

BlobClientUploadChunkOptions contains the optional parameters for the BlobClient.UploadChunk method.

type BlobClientUploadChunkResponse

type BlobClientUploadChunkResponse struct {
	// DockerUploadUUID contains the information returned from the Docker-Upload-UUID header response.
	DockerUploadUUID *string

	// Location contains the information returned from the Location header response.
	Location *string

	// Range contains the information returned from the Range header response.
	Range *string
}

BlobClientUploadChunkResponse contains the response from method BlobClient.UploadChunk.

type BlobDigestCalculator

type BlobDigestCalculator struct {
	// contains filtered or unexported fields
}

BlobDigestCalculator help to calculate blob digest when uploading blob. Don't use this type directly, use NewBlobDigestCalculator() instead.

func NewBlobDigestCalculator

func NewBlobDigestCalculator() *BlobDigestCalculator

NewBlobDigestCalculator creates a new calculator to help to calculate blob digest when uploading blob. You should use a new BlobDigestCalculator each time you upload a blob.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client contains the methods for the ContainerRegistry group. Don't use this type directly, use a constructor function instead.

func NewClient

func NewClient(endpoint string, credential azcore.TokenCredential, options *ClientOptions) (*Client, error)

NewClient creates a new instance of Client with the specified values.

  • endpoint - registry login URL
  • credential - used to authorize requests. Usually a credential from azidentity.
  • options - client options, pass nil to accept the default values.
Example
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
	log.Fatalf("failed to obtain a credential: %v", err)
}
client, err = azcontainerregistry.NewClient("https://example.azurecr.io", cred, nil)
if err != nil {
	log.Fatalf("failed to create client: %v", err)
}
_ = client
Output:

func (*Client) DeleteManifest

func (client *Client) DeleteManifest(ctx context.Context, name string, digest string, options *ClientDeleteManifestOptions) (ClientDeleteManifestResponse, error)

DeleteManifest - Delete the manifest identified by name and reference. Note that a manifest can only be deleted by digest. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2021-07-01

  • name - Name of the image (including the namespace)
  • digest - Digest of a BLOB
  • options - ClientDeleteManifestOptions contains the optional parameters for the Client.DeleteManifest method.
Example
package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"
)

var client *azcontainerregistry.Client

func main() {
	resp, err := client.GetTagProperties(context.TODO(), "alpine", "3.7", nil)
	if err != nil {
		log.Fatalf("failed to get tag properties: %v", err)
	}
	_, err = client.DeleteManifest(context.TODO(), "alpine", *resp.Tag.Digest, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
}
Output:

func (*Client) DeleteRepository

func (client *Client) DeleteRepository(ctx context.Context, name string, options *ClientDeleteRepositoryOptions) (ClientDeleteRepositoryResponse, error)

DeleteRepository - Delete the repository identified by name If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2021-07-01

  • name - Name of the image (including the namespace)
  • options - ClientDeleteRepositoryOptions contains the optional parameters for the Client.DeleteRepository method.
Example
package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"
)

var client *azcontainerregistry.Client

func main() {
	_, err := client.DeleteRepository(context.TODO(), "nanoserver", nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
}
Output:

func (*Client) DeleteTag

func (client *Client) DeleteTag(ctx context.Context, name string, tag string, options *ClientDeleteTagOptions) (ClientDeleteTagResponse, error)

DeleteTag - Delete tag If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2021-07-01

  • name - Name of the image (including the namespace)
  • tag - Tag name
  • options - ClientDeleteTagOptions contains the optional parameters for the Client.DeleteTag method.
Example
package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"
)

var client *azcontainerregistry.Client

func main() {
	_, err := client.DeleteTag(context.TODO(), "nanoserver", "4.7.2-20180905-nanoserver-1803", nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
}
Output:

func (*Client) GetManifest

func (client *Client) GetManifest(ctx context.Context, name string, reference string, options *ClientGetManifestOptions) (ClientGetManifestResponse, error)

GetManifest - Get the manifest identified by name and reference where reference can be a tag or digest. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2021-07-01

  • name - Name of the image (including the namespace)
  • reference - A tag or a digest, pointing to a specific image
  • options - ClientGetManifestOptions contains the optional parameters for the Client.GetManifest method.
Example (Reference)
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"io"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
)

var client *azcontainerregistry.Client

func main() {
	const reference = "sha256:110d2b6c84592561338aa040b1b14b7ab81c2f9edbd564c2285dd7d70d777086"
	res, err := client.GetManifest(context.TODO(), "nanoserver", reference, &azcontainerregistry.ClientGetManifestOptions{Accept: to.Ptr("application/vnd.docker.distribution.manifest.v2+json")})
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	if reference != *res.DockerContentDigest {
		log.Fatalf("failed to fetch manifest correctly: %v", err)
	}
	reader, err := azcontainerregistry.NewDigestValidationReader(reference, res.ManifestData)
	if err != nil {
		log.Fatalf("failed to create validation reader: %v", err)
	}
	manifest, err := io.ReadAll(reader)
	if err != nil {
		log.Fatalf("failed to read manifest data: %v", err)
	}
	fmt.Printf("manifest content: %s\n", manifest)
}
Output:

Example (Tag)
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"io"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
)

var client *azcontainerregistry.Client

func main() {
	res, err := client.GetManifest(context.TODO(), "hello-world-dangling", "20190628-033033z", &azcontainerregistry.ClientGetManifestOptions{Accept: to.Ptr("application/vnd.docker.distribution.manifest.v2+json")})
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	reader, err := azcontainerregistry.NewDigestValidationReader(*res.DockerContentDigest, res.ManifestData)
	if err != nil {
		log.Fatalf("failed to create validation reader: %v", err)
	}
	manifest, err := io.ReadAll(reader)
	if err != nil {
		log.Fatalf("failed to read manifest data: %v", err)
	}
	fmt.Printf("manifest content: %s\n", manifest)
}
Output:

func (*Client) GetManifestProperties

func (client *Client) GetManifestProperties(ctx context.Context, name string, digest string, options *ClientGetManifestPropertiesOptions) (ClientGetManifestPropertiesResponse, error)

GetManifestProperties - Get manifest attributes If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2021-07-01

  • name - Name of the image (including the namespace)
  • digest - Digest of a BLOB
  • options - ClientGetManifestPropertiesOptions contains the optional parameters for the Client.GetManifestProperties method.
Example
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"
)

var client *azcontainerregistry.Client

func main() {
	res, err := client.GetManifestProperties(context.TODO(), "nanoserver", "sha256:110d2b6c84592561338aa040b1b14b7ab81c2f9edbd564c2285dd7d70d777086", nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	fmt.Printf("manifest digest: %s\n", *res.Manifest.Digest)
	fmt.Printf("manifest size: %d\n", *res.Manifest.Size)
}
Output:

func (*Client) GetRepositoryProperties

func (client *Client) GetRepositoryProperties(ctx context.Context, name string, options *ClientGetRepositoryPropertiesOptions) (ClientGetRepositoryPropertiesResponse, error)

GetRepositoryProperties - Get repository attributes If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2021-07-01

  • name - Name of the image (including the namespace)
  • options - ClientGetRepositoryPropertiesOptions contains the optional parameters for the Client.GetRepositoryProperties method.
Example
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"
)

var client *azcontainerregistry.Client

func main() {
	res, err := client.GetRepositoryProperties(context.TODO(), "nanoserver", nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	fmt.Printf("repository name: %s\n", *res.Name)
	fmt.Printf("registry login server of the repository: %s\n", *res.RegistryLoginServer)
	fmt.Printf("repository manifest count: %d\n", *res.ManifestCount)
}
Output:

func (*Client) GetTagProperties

func (client *Client) GetTagProperties(ctx context.Context, name string, tag string, options *ClientGetTagPropertiesOptions) (ClientGetTagPropertiesResponse, error)

GetTagProperties - Get tag attributes by tag If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2021-07-01

  • name - Name of the image (including the namespace)
  • tag - Tag name
  • options - ClientGetTagPropertiesOptions contains the optional parameters for the Client.GetTagProperties method.
Example
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"
)

var client *azcontainerregistry.Client

func main() {
	res, err := client.GetTagProperties(context.TODO(), "test/bash", "latest", nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	fmt.Printf("tag name: %s\n", *res.Tag.Name)
	fmt.Printf("tag digest: %s\n", *res.Tag.Digest)
}
Output:

func (*Client) NewListManifestsPager

func (client *Client) NewListManifestsPager(name string, options *ClientListManifestsOptions) *runtime.Pager[ClientListManifestsResponse]

NewListManifestsPager - List manifests of a repository

Generated from API version 2021-07-01

  • name - Name of the image (including the namespace)
  • options - ClientListManifestsOptions contains the optional parameters for the Client.NewListManifestsPager method.
Example
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"
)

var client *azcontainerregistry.Client

func main() {
	pager := client.NewListManifestsPager("nanoserver", nil)
	for pager.More() {
		page, err := pager.NextPage(context.TODO())
		if err != nil {
			log.Fatalf("failed to advance page: %v", err)
		}
		for i, v := range page.Manifests.Attributes {
			fmt.Printf("manifest %d: %s\n", i+1, *v.Digest)
		}
	}
}
Output:

func (*Client) NewListRepositoriesPager

func (client *Client) NewListRepositoriesPager(options *ClientListRepositoriesOptions) *runtime.Pager[ClientListRepositoriesResponse]

NewListRepositoriesPager - List repositories

Generated from API version 2021-07-01

  • options - ClientListRepositoriesOptions contains the optional parameters for the Client.NewListRepositoriesPager method.
Example
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"
)

var client *azcontainerregistry.Client

func main() {
	pager := client.NewListRepositoriesPager(nil)
	for pager.More() {
		page, err := pager.NextPage(context.TODO())
		if err != nil {
			log.Fatalf("failed to advance page: %v", err)
		}
		for i, v := range page.Repositories.Names {
			fmt.Printf("repository %d: %s\n", i+1, *v)
		}
	}
}
Output:

func (*Client) NewListTagsPager

func (client *Client) NewListTagsPager(name string, options *ClientListTagsOptions) *runtime.Pager[ClientListTagsResponse]

NewListTagsPager - List tags of a repository

Generated from API version 2021-07-01

  • name - Name of the image (including the namespace)
  • options - ClientListTagsOptions contains the optional parameters for the Client.NewListTagsPager method.
Example
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"
)

var client *azcontainerregistry.Client

func main() {
	pager := client.NewListTagsPager("nanoserver", nil)
	for pager.More() {
		page, err := pager.NextPage(context.TODO())
		if err != nil {
			log.Fatalf("failed to advance page: %v", err)
		}
		for i, v := range page.Tags {
			fmt.Printf("tag %d: %s\n", i+1, *v.Name)
		}
	}
}
Output:

func (*Client) UpdateManifestProperties

func (client *Client) UpdateManifestProperties(ctx context.Context, name string, digest string, options *ClientUpdateManifestPropertiesOptions) (ClientUpdateManifestPropertiesResponse, error)

UpdateManifestProperties - Update properties of a manifest If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2021-07-01

  • name - Name of the image (including the namespace)
  • digest - Digest of a BLOB
  • options - ClientUpdateManifestPropertiesOptions contains the optional parameters for the Client.UpdateManifestProperties method.
Example
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
)

var client *azcontainerregistry.Client

func main() {
	res, err := client.UpdateManifestProperties(context.TODO(), "nanoserver", "sha256:110d2b6c84592561338aa040b1b14b7ab81c2f9edbd564c2285dd7d70d777086", &azcontainerregistry.ClientUpdateManifestPropertiesOptions{Value: &azcontainerregistry.ManifestWriteableProperties{
		CanWrite: to.Ptr(false),
	},
	})
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	fmt.Printf("repository nanoserver - manifest sha256:110d2b6c84592561338aa040b1b14b7ab81c2f9edbd564c2285dd7d70d777086 - 'CanWrite' property: %t", *res.Manifest.ChangeableAttributes.CanWrite)
}
Output:

func (*Client) UpdateRepositoryProperties

func (client *Client) UpdateRepositoryProperties(ctx context.Context, name string, options *ClientUpdateRepositoryPropertiesOptions) (ClientUpdateRepositoryPropertiesResponse, error)

UpdateRepositoryProperties - Update the attribute identified by name where reference is the name of the repository. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2021-07-01

  • name - Name of the image (including the namespace)
  • options - ClientUpdateRepositoryPropertiesOptions contains the optional parameters for the Client.UpdateRepositoryProperties method.
Example
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
)

var client *azcontainerregistry.Client

func main() {
	res, err := client.UpdateRepositoryProperties(context.TODO(), "nanoserver", &azcontainerregistry.ClientUpdateRepositoryPropertiesOptions{Value: &azcontainerregistry.RepositoryWriteableProperties{
		CanWrite: to.Ptr(false),
	},
	})
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	fmt.Printf("repository namoserver - 'CanWrite' property: %t\n", *res.ContainerRepositoryProperties.ChangeableAttributes.CanWrite)
}
Output:

func (*Client) UpdateTagProperties

func (client *Client) UpdateTagProperties(ctx context.Context, name string, tag string, options *ClientUpdateTagPropertiesOptions) (ClientUpdateTagPropertiesResponse, error)

UpdateTagProperties - Update tag attributes If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2021-07-01

  • name - Name of the image (including the namespace)
  • tag - Tag name
  • options - ClientUpdateTagPropertiesOptions contains the optional parameters for the Client.UpdateTagProperties method.
Example
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
)

var client *azcontainerregistry.Client

func main() {
	res, err := client.UpdateTagProperties(context.TODO(), "nanoserver", "4.7.2-20180905-nanoserver-1803", &azcontainerregistry.ClientUpdateTagPropertiesOptions{
		Value: &azcontainerregistry.TagWriteableProperties{
			CanWrite: to.Ptr(false),
		}})
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	fmt.Printf("repository namoserver - tag 4.7.2-20180905-nanoserver-1803 - 'CanWrite' property: %t\n", *res.Tag.ChangeableAttributes.CanWrite)
}
Output:

func (*Client) UploadManifest

func (client *Client) UploadManifest(ctx context.Context, name string, reference string, contentType ContentType, manifestData io.ReadSeekCloser, options *ClientUploadManifestOptions) (ClientUploadManifestResponse, error)

UploadManifest - Put the manifest identified by name and reference where reference can be a tag or digest. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2021-07-01

  • name - Name of the image (including the namespace)
  • reference - A tag or a digest, pointing to a specific image
  • contentType - Upload file type
  • manifestData - Manifest body, can take v1 or v2 values depending on accept header
  • options - ClientUploadManifestOptions contains the optional parameters for the Client.UploadManifest method.
Example (Reference)
package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"
	"os"
)

var client *azcontainerregistry.Client

func main() {
	f, err := os.Open("example-manifest.json")
	if err != nil {
		log.Fatalf("failed to read manifest file: %v", err)
	}
	const reference = "sha256:110d2b6c84592561338aa040b1b14b7ab81c2f9edbd564c2285dd7d70d777086"
	resp, err := client.UploadManifest(context.TODO(), "nanoserver", reference, "application/vnd.docker.distribution.manifest.v2+json", f, nil)
	if err != nil {
		log.Fatalf("failed to upload manifest: %v", err)
	}
	if *resp.DockerContentDigest != reference {
		log.Fatalf("failed to validate manifest digest: %v", err)
	}
}
Output:

Example (Tag)
package main

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"io"
	"log"
	"os"
)

var client *azcontainerregistry.Client

func main() {
	f, err := os.Open("example-manifest.json")
	if err != nil {
		log.Fatalf("failed to read manifest file: %v", err)
	}
	resp, err := client.UploadManifest(context.TODO(), "nanoserver", "test", "application/vnd.docker.distribution.manifest.v2+json", f, nil)
	if err != nil {
		log.Fatalf("failed to upload manifest: %v", err)
	}
	_, err = f.Seek(0, io.SeekStart)
	if err != nil {
		log.Fatalf("failed to validate manifest digest: %v", err)
	}
	reader, err := azcontainerregistry.NewDigestValidationReader(*resp.DockerContentDigest, f)
	if err != nil {
		log.Fatalf("failed to validate manifest digest: %v", err)
	}
	_, err = io.ReadAll(reader)
	if err != nil {
		log.Fatalf("failed to validate manifest digest: %v", err)
	}
}
Output:

type ClientDeleteManifestOptions

type ClientDeleteManifestOptions struct {
}

ClientDeleteManifestOptions contains the optional parameters for the Client.DeleteManifest method.

type ClientDeleteManifestResponse

type ClientDeleteManifestResponse struct {
}

ClientDeleteManifestResponse contains the response from method Client.DeleteManifest.

type ClientDeleteRepositoryOptions

type ClientDeleteRepositoryOptions struct {
}

ClientDeleteRepositoryOptions contains the optional parameters for the Client.DeleteRepository method.

type ClientDeleteRepositoryResponse

type ClientDeleteRepositoryResponse struct {
}

ClientDeleteRepositoryResponse contains the response from method Client.DeleteRepository.

type ClientDeleteTagOptions

type ClientDeleteTagOptions struct {
}

ClientDeleteTagOptions contains the optional parameters for the Client.DeleteTag method.

type ClientDeleteTagResponse

type ClientDeleteTagResponse struct {
}

ClientDeleteTagResponse contains the response from method Client.DeleteTag.

type ClientGetManifestOptions

type ClientGetManifestOptions struct {
	// Accept header string delimited by comma. For example, application/vnd.docker.distribution.manifest.v2+json
	Accept *string
}

ClientGetManifestOptions contains the optional parameters for the Client.GetManifest method.

type ClientGetManifestPropertiesOptions

type ClientGetManifestPropertiesOptions struct {
}

ClientGetManifestPropertiesOptions contains the optional parameters for the Client.GetManifestProperties method.

type ClientGetManifestPropertiesResponse

type ClientGetManifestPropertiesResponse struct {
	// Manifest attributes details
	ArtifactManifestProperties
}

ClientGetManifestPropertiesResponse contains the response from method Client.GetManifestProperties.

type ClientGetManifestResponse

type ClientGetManifestResponse struct {
	// Body contains the streaming response.
	ManifestData io.ReadCloser

	// DockerContentDigest contains the information returned from the Docker-Content-Digest header response.
	DockerContentDigest *string
}

ClientGetManifestResponse contains the response from method Client.GetManifest.

type ClientGetRepositoryPropertiesOptions

type ClientGetRepositoryPropertiesOptions struct {
}

ClientGetRepositoryPropertiesOptions contains the optional parameters for the Client.GetRepositoryProperties method.

type ClientGetRepositoryPropertiesResponse

type ClientGetRepositoryPropertiesResponse struct {
	// Properties of this repository.
	ContainerRepositoryProperties
}

ClientGetRepositoryPropertiesResponse contains the response from method Client.GetRepositoryProperties.

type ClientGetTagPropertiesOptions

type ClientGetTagPropertiesOptions struct {
}

ClientGetTagPropertiesOptions contains the optional parameters for the Client.GetTagProperties method.

type ClientGetTagPropertiesResponse

type ClientGetTagPropertiesResponse struct {
	// Tag attributes
	ArtifactTagProperties
}

ClientGetTagPropertiesResponse contains the response from method Client.GetTagProperties.

type ClientListManifestsOptions

type ClientListManifestsOptions struct {
	// Query parameter for the last item in previous query. Result set will include values lexically after last.
	Last *string

	// query parameter for max number of items
	MaxNum *int32

	// Sort options for ordering manifests in a collection.
	OrderBy *ArtifactManifestOrderBy
}

ClientListManifestsOptions contains the optional parameters for the Client.NewListManifestsPager method.

type ClientListManifestsResponse

type ClientListManifestsResponse struct {
	// Manifest attributes
	Manifests

	// Link contains the information returned from the Link header response.
	Link *string
}

ClientListManifestsResponse contains the response from method Client.NewListManifestsPager.

type ClientListRepositoriesOptions

type ClientListRepositoriesOptions struct {
	// Query parameter for the last item in previous query. Result set will include values lexically after last.
	Last *string

	// query parameter for max number of items
	MaxNum *int32
}

ClientListRepositoriesOptions contains the optional parameters for the Client.NewListRepositoriesPager method.

type ClientListRepositoriesResponse

type ClientListRepositoriesResponse struct {
	// List of repositories
	Repositories

	// Link contains the information returned from the Link header response.
	Link *string
}

ClientListRepositoriesResponse contains the response from method Client.NewListRepositoriesPager.

type ClientListTagsOptions

type ClientListTagsOptions struct {
	// filter by digest
	Digest *string

	// Query parameter for the last item in previous query. Result set will include values lexically after last.
	Last *string

	// query parameter for max number of items
	MaxNum *int32

	// Sort options for ordering tags in a collection.
	OrderBy *ArtifactTagOrderBy
}

ClientListTagsOptions contains the optional parameters for the Client.NewListTagsPager method.

type ClientListTagsResponse

type ClientListTagsResponse struct {
	// List of tag details
	TagList

	// Link contains the information returned from the Link header response.
	Link *string
}

ClientListTagsResponse contains the response from method Client.NewListTagsPager.

type ClientOptions

type ClientOptions struct {
	azcore.ClientOptions
}

ClientOptions contains the optional parameters for the NewClient method.

type ClientUpdateManifestPropertiesOptions

type ClientUpdateManifestPropertiesOptions struct {
	// Manifest attribute value
	Value *ManifestWriteableProperties
}

ClientUpdateManifestPropertiesOptions contains the optional parameters for the Client.UpdateManifestProperties method.

type ClientUpdateManifestPropertiesResponse

type ClientUpdateManifestPropertiesResponse struct {
	// Manifest attributes details
	ArtifactManifestProperties
}

ClientUpdateManifestPropertiesResponse contains the response from method Client.UpdateManifestProperties.

type ClientUpdateRepositoryPropertiesOptions

type ClientUpdateRepositoryPropertiesOptions struct {
	// Repository attribute value
	Value *RepositoryWriteableProperties
}

ClientUpdateRepositoryPropertiesOptions contains the optional parameters for the Client.UpdateRepositoryProperties method.

type ClientUpdateRepositoryPropertiesResponse

type ClientUpdateRepositoryPropertiesResponse struct {
	// Properties of this repository.
	ContainerRepositoryProperties
}

ClientUpdateRepositoryPropertiesResponse contains the response from method Client.UpdateRepositoryProperties.

type ClientUpdateTagPropertiesOptions

type ClientUpdateTagPropertiesOptions struct {
	// Tag attribute value
	Value *TagWriteableProperties
}

ClientUpdateTagPropertiesOptions contains the optional parameters for the Client.UpdateTagProperties method.

type ClientUpdateTagPropertiesResponse

type ClientUpdateTagPropertiesResponse struct {
	// Tag attributes
	ArtifactTagProperties
}

ClientUpdateTagPropertiesResponse contains the response from method Client.UpdateTagProperties.

type ClientUploadManifestOptions

type ClientUploadManifestOptions struct {
}

ClientUploadManifestOptions contains the optional parameters for the Client.UploadManifest method.

type ClientUploadManifestResponse

type ClientUploadManifestResponse struct {
	// ContentLength contains the information returned from the Content-Length header response.
	ContentLength *int64

	// DockerContentDigest contains the information returned from the Docker-Content-Digest header response.
	DockerContentDigest *string

	// Location contains the information returned from the Location header response.
	Location *string
}

ClientUploadManifestResponse contains the response from method Client.UploadManifest.

type ContainerRepositoryProperties

type ContainerRepositoryProperties struct {
	// REQUIRED; Writeable properties of the resource
	ChangeableAttributes *RepositoryWriteableProperties

	// READ-ONLY; Image created time
	CreatedOn *time.Time

	// READ-ONLY; Image last update time
	LastUpdatedOn *time.Time

	// READ-ONLY; Number of the manifests
	ManifestCount *int32

	// READ-ONLY; Image name
	Name *string

	// READ-ONLY; Registry login server name. This is likely to be similar to {registry-name}.azurecr.io.
	RegistryLoginServer *string

	// READ-ONLY; Number of the tags
	TagCount *int32
}

ContainerRepositoryProperties - Properties of this repository.

func (*ContainerRepositoryProperties) UnmarshalJSON

func (c *ContainerRepositoryProperties) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type ContainerRepositoryProperties.

type ContentType

type ContentType string

ContentType - Content type for upload

const (
	// ContentTypeApplicationVndDockerDistributionManifestV2JSON - Content Type 'application/vnd.docker.distribution.manifest.v2+json'
	ContentTypeApplicationVndDockerDistributionManifestV2JSON ContentType = "application/vnd.docker.distribution.manifest.v2+json"
	// ContentTypeApplicationVndOciImageManifestV1JSON - Content Type 'application/vnd.oci.image.manifest.v1+json'
	ContentTypeApplicationVndOciImageManifestV1JSON ContentType = "application/vnd.oci.image.manifest.v1+json"
)

func PossibleContentTypeValues

func PossibleContentTypeValues() []ContentType

PossibleContentTypeValues returns the possible values for the ContentType const type.

type DigestValidationReader added in v0.2.0

type DigestValidationReader struct {
	// contains filtered or unexported fields
}

DigestValidationReader help to validate digest when fetching manifest or blob. Don't use this type directly, use NewDigestValidationReader() instead.

func NewDigestValidationReader added in v0.2.0

func NewDigestValidationReader(digest string, reader io.Reader) (*DigestValidationReader, error)

NewDigestValidationReader creates a new reader that help you to validate digest when you read manifest or blob data.

func (*DigestValidationReader) Read added in v0.2.0

func (d *DigestValidationReader) Read(p []byte) (int, error)

Read write to digest validator while read and validate digest when reach EOF.

type ManifestAttributes

type ManifestAttributes struct {
	// READ-ONLY; Created time
	CreatedOn *time.Time

	// READ-ONLY; Manifest
	Digest *string

	// READ-ONLY; Last update time
	LastUpdatedOn *time.Time

	// Writeable properties of the resource
	ChangeableAttributes *ManifestWriteableProperties

	// Config blob media type
	ConfigMediaType *string

	// Media type for this Manifest
	MediaType *string

	// READ-ONLY; CPU architecture
	Architecture *ArtifactArchitecture

	// READ-ONLY; Operating system
	OperatingSystem *ArtifactOperatingSystem

	// READ-ONLY; List of artifacts that are referenced by this manifest list, with information about the platform each supports.
	// This list will be empty if this is a leaf manifest and not a manifest list.
	RelatedArtifacts []*ArtifactManifestPlatform

	// READ-ONLY; Image size
	Size *int64

	// READ-ONLY; List of tags
	Tags []*string
}

ManifestAttributes - Manifest details

func (*ManifestAttributes) UnmarshalJSON

func (m *ManifestAttributes) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type ManifestAttributes.

type ManifestWriteableProperties

type ManifestWriteableProperties struct {
	// Delete enabled
	CanDelete *bool

	// List enabled
	CanList *bool

	// Read enabled
	CanRead *bool

	// Write enabled
	CanWrite *bool
}

ManifestWriteableProperties - Changeable attributes

func (ManifestWriteableProperties) MarshalJSON

func (m ManifestWriteableProperties) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type ManifestWriteableProperties.

func (*ManifestWriteableProperties) UnmarshalJSON

func (m *ManifestWriteableProperties) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type ManifestWriteableProperties.

type Manifests

type Manifests struct {
	// List of manifests
	Attributes []*ManifestAttributes
	Link       *string

	// Registry login server name. This is likely to be similar to {registry-name}.azurecr.io.
	RegistryLoginServer *string

	// Image name
	Repository *string
}

Manifests - Manifest attributes

func (*Manifests) UnmarshalJSON

func (m *Manifests) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type Manifests.

type Repositories

type Repositories struct {
	Link *string

	// Repository names
	Names []*string
}

Repositories - List of repositories

func (*Repositories) UnmarshalJSON

func (r *Repositories) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type Repositories.

type RepositoryWriteableProperties

type RepositoryWriteableProperties struct {
	// Delete enabled
	CanDelete *bool

	// List enabled
	CanList *bool

	// Read enabled
	CanRead *bool

	// Write enabled
	CanWrite *bool
}

RepositoryWriteableProperties - Changeable attributes for Repository

func (RepositoryWriteableProperties) MarshalJSON

func (r RepositoryWriteableProperties) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type RepositoryWriteableProperties.

func (*RepositoryWriteableProperties) UnmarshalJSON

func (r *RepositoryWriteableProperties) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type RepositoryWriteableProperties.

type TagAttributes

type TagAttributes struct {
	// REQUIRED; Writeable properties of the resource
	ChangeableAttributes *TagWriteableProperties

	// READ-ONLY; Tag created time
	CreatedOn *time.Time

	// READ-ONLY; Tag digest
	Digest *string

	// READ-ONLY; Tag last update time
	LastUpdatedOn *time.Time

	// READ-ONLY; Tag name
	Name *string
}

TagAttributes - Tag attribute details

func (*TagAttributes) UnmarshalJSON

func (t *TagAttributes) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type TagAttributes.

type TagList

type TagList struct {
	// REQUIRED; Registry login server name. This is likely to be similar to {registry-name}.azurecr.io.
	RegistryLoginServer *string

	// REQUIRED; Image name
	Repository *string

	// REQUIRED; List of tag attribute details
	Tags []*TagAttributes
	Link *string
}

TagList - List of tag details

func (*TagList) UnmarshalJSON

func (t *TagList) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type TagList.

type TagWriteableProperties

type TagWriteableProperties struct {
	// Delete enabled
	CanDelete *bool

	// List enabled
	CanList *bool

	// Read enabled
	CanRead *bool

	// Write enabled
	CanWrite *bool
}

TagWriteableProperties - Changeable attributes

func (TagWriteableProperties) MarshalJSON

func (t TagWriteableProperties) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type TagWriteableProperties.

func (*TagWriteableProperties) UnmarshalJSON

func (t *TagWriteableProperties) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type TagWriteableProperties.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL