@azure/container-registry 1.0.0-beta.3 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +70 -37
  3. package/dist/index.js +1255 -1123
  4. package/dist/index.js.map +1 -1
  5. package/dist-esm/src/containerRegistryChallengeHandler.js +35 -38
  6. package/dist-esm/src/containerRegistryChallengeHandler.js.map +1 -1
  7. package/dist-esm/src/containerRegistryClient.js +69 -50
  8. package/dist-esm/src/containerRegistryClient.js.map +1 -1
  9. package/dist-esm/src/containerRegistryTokenCredential.js +39 -126
  10. package/dist-esm/src/containerRegistryTokenCredential.js.map +1 -1
  11. package/dist-esm/src/containerRepository.js +100 -63
  12. package/dist-esm/src/containerRepository.js.map +1 -1
  13. package/dist-esm/src/generated/generatedClient.js +7 -6
  14. package/dist-esm/src/generated/generatedClient.js.map +1 -1
  15. package/dist-esm/src/generated/generatedClientContext.js +13 -2
  16. package/dist-esm/src/generated/generatedClientContext.js.map +1 -1
  17. package/dist-esm/src/generated/index.js +1 -0
  18. package/dist-esm/src/generated/index.js.map +1 -1
  19. package/dist-esm/src/generated/models/index.js +61 -1
  20. package/dist-esm/src/generated/models/index.js.map +1 -1
  21. package/dist-esm/src/generated/models/mappers.js +514 -557
  22. package/dist-esm/src/generated/models/mappers.js.map +1 -1
  23. package/dist-esm/src/generated/models/parameters.js +87 -7
  24. package/dist-esm/src/generated/models/parameters.js.map +1 -1
  25. package/dist-esm/src/generated/operations/authentication.js +28 -8
  26. package/dist-esm/src/generated/operations/authentication.js.map +1 -1
  27. package/dist-esm/src/generated/operations/containerRegistry.js +27 -7
  28. package/dist-esm/src/generated/operations/containerRegistry.js.map +1 -1
  29. package/dist-esm/src/generated/operations/containerRegistryBlob.js +2 -2
  30. package/dist-esm/src/generated/operations/containerRegistryBlob.js.map +1 -1
  31. package/dist-esm/src/generated/operationsInterfaces/authentication.js +9 -0
  32. package/dist-esm/src/generated/operationsInterfaces/authentication.js.map +1 -0
  33. package/dist-esm/src/generated/operationsInterfaces/containerRegistry.js +9 -0
  34. package/dist-esm/src/generated/operationsInterfaces/containerRegistry.js.map +1 -0
  35. package/dist-esm/src/generated/operationsInterfaces/containerRegistryBlob.js +9 -0
  36. package/dist-esm/src/generated/operationsInterfaces/containerRegistryBlob.js.map +1 -0
  37. package/dist-esm/src/generated/operationsInterfaces/index.js +11 -0
  38. package/dist-esm/src/generated/operationsInterfaces/index.js.map +1 -0
  39. package/dist-esm/src/index.js.map +1 -1
  40. package/dist-esm/src/models.js +43 -2
  41. package/dist-esm/src/models.js.map +1 -1
  42. package/dist-esm/src/registryArtifact.js +176 -135
  43. package/dist-esm/src/registryArtifact.js.map +1 -1
  44. package/dist-esm/src/tracing.js +1 -1
  45. package/dist-esm/src/tracing.js.map +1 -1
  46. package/dist-esm/src/transformations.js +2 -2
  47. package/dist-esm/src/transformations.js.map +1 -1
  48. package/dist-esm/src/{base64.browser.js → utils/base64.browser.js} +0 -0
  49. package/dist-esm/src/utils/base64.browser.js.map +1 -0
  50. package/dist-esm/src/{base64.js → utils/base64.js} +0 -0
  51. package/dist-esm/src/utils/base64.js.map +1 -0
  52. package/dist-esm/src/{utils.js → utils/helpers.js} +1 -1
  53. package/dist-esm/src/utils/helpers.js.map +1 -0
  54. package/dist-esm/src/{tokenCycler.js → utils/tokenCycler.js} +29 -34
  55. package/dist-esm/src/utils/tokenCycler.js.map +1 -0
  56. package/dist-esm/src/{url.browser.js → utils/url.browser.js} +0 -0
  57. package/dist-esm/src/utils/url.browser.js.map +1 -0
  58. package/dist-esm/src/{url.js → utils/url.js} +0 -0
  59. package/dist-esm/src/utils/url.js.map +1 -0
  60. package/dist-esm/src/{wwwAuthenticateParser.js → utils/wwwAuthenticateParser.js} +0 -0
  61. package/dist-esm/src/utils/wwwAuthenticateParser.js.map +1 -0
  62. package/package.json +22 -25
  63. package/types/container-registry.d.ts +258 -83
  64. package/dist-esm/src/base64.browser.js.map +0 -1
  65. package/dist-esm/src/base64.js.map +0 -1
  66. package/dist-esm/src/constants.js +0 -4
  67. package/dist-esm/src/constants.js.map +0 -1
  68. package/dist-esm/src/tokenCycler.js.map +0 -1
  69. package/dist-esm/src/url.browser.js.map +0 -1
  70. package/dist-esm/src/url.js.map +0 -1
  71. package/dist-esm/src/utils.js.map +0 -1
  72. package/dist-esm/src/wwwAuthenticateParser.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # Release History
2
2
 
3
+ ## 1.0.0 (2022-01-11)
4
+
5
+ This release marks the general availability release of Azure Container Registry client SDK library.
6
+
7
+ ### Breaking Changes
8
+
9
+ - `TagOrderBy` is renamed to `ArtifactTagOrder`.
10
+ - `ManifestOrderBy` is renamed to `ArtifactManifestOrder`.
11
+ - `size` property in `ArtifactManifestProperties` is renamed to `sizeInBytes`.
12
+
13
+ ## 1.0.0-beta.6 (2021-11-09)
14
+
15
+ ### Features Added
16
+
17
+ - Support passing service version via client options [PR #18067](https://github.com/Azure/azure-sdk-for-js/pull/18067).
18
+
19
+ ## 1.0.0-beta.5 (2021-09-08)
20
+
21
+ ### Breaking Changes
22
+
23
+ - Replace `authenticationScope` with `audience` in `ContainerRegistryClientOptions`. An extensible enum `KnownContainerRegistryAudience` is introduced which has known audience values.
24
+
25
+ ## 1.0.0-beta.4 (2021-08-17)
26
+
27
+ ### Breaking Changes
28
+
29
+ - `UpdateManifestPropertiesOptions` is no longer optional.
30
+
31
+ ### Bug Fixes
32
+
33
+ - Fixed issue of thrown `TypeError: _a.spanContext is not a function` [Issue 16842](https://github.com/Azure/azure-sdk-for-js/issues/16842).
34
+
3
35
  ## 1.0.0-beta.3 (2021-06-08)
4
36
 
5
37
  ### Breaking Changes
package/README.md CHANGED
@@ -9,22 +9,29 @@ Use the client library for Azure Container Registry to:
9
9
  - Set read/write/delete properties on registry items
10
10
  - Delete images and artifacts, repositories and tags
11
11
 
12
- [Source code][source] |
13
- [Package (NPM)][package] |
14
- [API reference documentation][api_docs] |
15
- [REST API documentation][rest_docs] |
16
- [Product documentation][product_docs] |
17
- [Samples][samples]
12
+ Key links:
13
+
14
+ - [Source code][source]
15
+ - [Package (NPM)][package]
16
+ - [API reference documentation][api_docs]
17
+ - [REST API documentation][rest_docs]
18
+ - [Product documentation][product_docs]
19
+ - [Samples][samples]
18
20
 
19
21
  ## Getting started
20
22
 
21
23
  ### Currently supported environments
22
24
 
23
- - Node.js version 8.x or higher
25
+ - [LTS versions of Node.js](https://nodejs.org/about/releases/)
26
+
27
+ See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details.
28
+
29
+ > Note: This package cannot be used in the browser due to service limitations, please refer to [this document][cors] for guidance.
24
30
 
25
31
  ### Prerequisites
26
32
 
27
- You need an [Azure subscription][azure_sub] and a [Container Registry account][container_registry_docs] to use this package.
33
+ - An [Azure Subscription](https://azure.microsoft.com)
34
+ - A [Container Registry account][container_registry_docs]
28
35
 
29
36
  To create a new Container Registry, you can use the [Azure Portal][container_registry_create_portal],
30
37
  [Azure PowerShell][container_registry_create_ps], or the [Azure CLI][container_registry_create_cli].
@@ -42,23 +49,22 @@ Install the Container Registry client library for JavaScript with `npm`:
42
49
  npm install @azure/container-registry
43
50
  ```
44
51
 
45
- ### Browser support
46
-
47
- #### JavaScript Bundle
48
-
49
- To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling).
50
-
51
52
  ### Authenticate the client
52
53
 
53
54
  The [Azure Identity library][identity] provides easy Azure Active Directory support for authentication.
54
55
 
55
56
  ```javascript
56
- const { ContainerRegistryClient } = require("@azure/container-registry");
57
+ const {
58
+ ContainerRegistryClient,
59
+ KnownContainerRegistryAudience
60
+ } = require("@azure/container-registry");
57
61
  const { DefaultAzureCredential } = require("@azure/identity");
58
62
 
59
63
  const endpoint = process.env.CONTAINER_REGISTRY_ENDPOINT;
60
64
  // Create a ContainerRegistryClient that will authenticate through Active Directory
61
- const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());
65
+ const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential(), {
66
+ audience: KnownContainerRegistryAudience.AzureResourceManagerPublicCloud
67
+ });
62
68
  ```
63
69
 
64
70
  Note that these samples assume you have a `CONTAINER_REGISTRY_ENDPOINT` environment variable set, which is the URL including the name of the login server and the `https://` prefix.
@@ -68,10 +74,13 @@ Note that these samples assume you have a `CONTAINER_REGISTRY_ENDPOINT` environm
68
74
  To authenticate with a registry in a [National Cloud](https://docs.microsoft.com/azure/active-directory/develop/authentication-national-cloud), you will need to make the following additions to your configuration:
69
75
 
70
76
  - Set the `authorityHost` in the credential options or via the `AZURE_AUTHORITY_HOST` environment variable
71
- - Set the `authenticationScope` in `ContainerRegistryClientOptions`
77
+ - Set the `audience` in `ContainerRegistryClientOptions`
72
78
 
73
79
  ```javascript
74
- const { ContainerRegistryClient } = require("@azure/container-registry");
80
+ const {
81
+ ContainerRegistryClient,
82
+ KnownContainerRegistryAudience
83
+ } = require("@azure/container-registry");
75
84
  const { DefaultAzureCredential, AzureAuthorityHosts } = require("@azure/identity");
76
85
 
77
86
  const endpoint = process.env.CONTAINER_REGISTRY_ENDPOINT;
@@ -80,7 +89,7 @@ const client = new ContainerRegistryClient(
80
89
  endpoint,
81
90
  new DefaultAzureCredential({ authorityHost: AzureAuthorityHosts.AzureChina }),
82
91
  {
83
- authenticationScope: "https://management.chinacloudapi.cn/.default"
92
+ audience: KnownContainerRegistryAudience.AzureResourceManagerChina
84
93
  }
85
94
  );
86
95
  ```
@@ -100,14 +109,19 @@ For more information please see [Container Registry Concepts](https://docs.micro
100
109
  Iterate through the collection of repositories in the registry.
101
110
 
102
111
  ```javascript
103
- const { ContainerRegistryClient } = require("@azure/container-registry");
112
+ const {
113
+ ContainerRegistryClient,
114
+ KnownContainerRegistryAudience
115
+ } = require("@azure/container-registry");
104
116
  const { DefaultAzureCredential } = require("@azure/identity");
105
117
 
106
118
  async function main() {
107
119
  // endpoint should be in the form of "https://myregistryname.azurecr.io"
108
120
  // where "myregistryname" is the actual name of your registry
109
121
  const endpoint = process.env.CONTAINER_REGISTRY_ENDPOINT || "<endpoint>";
110
- const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());
122
+ const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential(), {
123
+ audience: KnownContainerRegistryAudience.AzureResourceManagerPublicCloud
124
+ });
111
125
 
112
126
  console.log("Listing repositories");
113
127
  const iterator = client.listRepositoryNames();
@@ -124,14 +138,19 @@ main().catch((err) => {
124
138
  ### List tags with anonymous access
125
139
 
126
140
  ```javascript
127
- const { ContainerRegistryClient } = require("@azure/container-registry");
141
+ const {
142
+ ContainerRegistryClient,
143
+ KnownContainerRegistryAudience
144
+ } = require("@azure/container-registry");
128
145
 
129
146
  async function main() {
130
147
  // Get the service endpoint from the environment
131
148
  const endpoint = process.env.CONTAINER_REGISTRY_ENDPOINT || "<endpoint>";
132
149
 
133
150
  // Create a new ContainerRegistryClient for anonymous access
134
- const client = new ContainerRegistryClient(endpoint);
151
+ const client = new ContainerRegistryClient(endpoint, {
152
+ audience: KnownContainerRegistryAudience.AzureResourceManagerPublicCloud
153
+ });
135
154
 
136
155
  // Obtain a RegistryArtifact object to get access to image operations
137
156
  const image = client.getArtifact("library/hello-world", "latest");
@@ -154,7 +173,10 @@ main().catch((err) => {
154
173
  ### Set artifact properties
155
174
 
156
175
  ```javascript
157
- const { ContainerRegistryClient } = require("@azure/container-registry");
176
+ const {
177
+ ContainerRegistryClient,
178
+ KnownContainerRegistryAudience
179
+ } = require("@azure/container-registry");
158
180
  const { DefaultAzureCredential } = require("@azure/identity");
159
181
 
160
182
  async function main() {
@@ -162,11 +184,13 @@ async function main() {
162
184
  const endpoint = process.env.CONTAINER_REGISTRY_ENDPOINT || "<endpoint>";
163
185
 
164
186
  // Create a new ContainerRegistryClient and RegistryArtifact to access image operations
165
- const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());
187
+ const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential(), {
188
+ audience: KnownContainerRegistryAudience.AzureResourceManagerPublicCloud
189
+ });
166
190
  const image = client.getArtifact("library/hello-world", "v1");
167
191
 
168
192
  // Set permissions on the image's "latest" tag
169
- await image.setTagProperties("latest", { canWrite: false, canDelete: false });
193
+ await image.updateTagProperties("latest", { canWrite: false, canDelete: false });
170
194
  }
171
195
 
172
196
  main().catch((err) => {
@@ -177,34 +201,42 @@ main().catch((err) => {
177
201
  ### Delete images
178
202
 
179
203
  ```javascript
180
- const { ContainerRegistryClient } = require("@azure/container-registry");
204
+ const {
205
+ ContainerRegistryClient,
206
+ KnownContainerRegistryAudience
207
+ } = require("@azure/container-registry");
181
208
  const { DefaultAzureCredential } = require("@azure/identity");
182
209
 
183
210
  async function main() {
184
211
  // Get the service endpoint from the environment
185
212
  const endpoint = process.env.CONTAINER_REGISTRY_ENDPOINT || "<endpoint>";
186
213
  // Create a new ContainerRegistryClient
187
- const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());
214
+ const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential(), {
215
+ audience: KnownContainerRegistryAudience.AzureResourceManagerPublicCloud
216
+ });
188
217
 
189
218
  // Iterate through repositories
190
219
  const repositoryNames = client.listRepositoryNames();
191
220
  for await (const repositoryName of repositoryNames) {
192
221
  const repository = client.getRepository(repositoryName);
193
- // Obtain the images ordered from newest to oldest
222
+ // Obtain the images ordered from newest to oldest by passing the `order` option
194
223
  const imageManifests = repository.listManifestProperties({
195
- orderBy: "LastUpdatedOnDescending"
224
+ order: "LastUpdatedOnDescending"
196
225
  });
197
226
  const imagesToKeep = 3;
198
227
  let imageCount = 0;
199
228
  // Delete images older than the first three.
200
229
  for await (const manifest of imageManifests) {
201
- if (imageCount++ > imagesToKeep) {
230
+ imageCount++;
231
+ if (imageCount > imagesToKeep) {
232
+ const image = repository.getArtifact(manifest.digest);
202
233
  console.log(`Deleting image with digest ${manifest.digest}`);
203
- console.log(` This image has the following tags:`);
234
+ console.log(` Deleting the following tags from the image:`);
204
235
  for (const tagName of manifest.tags) {
205
236
  console.log(` ${manifest.repositoryName}:${tagName}`);
237
+ image.deleteTag(tagName);
206
238
  }
207
- await repository.getArtifact(manifest.digest).delete();
239
+ await image.delete();
208
240
  }
209
241
  }
210
242
  }
@@ -233,7 +265,7 @@ Please take a look at the [samples][samples] directory for detailed examples tha
233
265
 
234
266
  ## Contributing
235
267
 
236
- If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/master/CONTRIBUTING.md) to learn more about how to build and test the code.
268
+ If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.
237
269
 
238
270
  ## Related projects
239
271
 
@@ -243,12 +275,13 @@ If you'd like to contribute to this library, please read the [contributing guide
243
275
 
244
276
  [azure_sub]: https://azure.microsoft.com/free/
245
277
  [acr_resource]: https://ms.portal.azure.com/#create/Microsoft.ContainerRegistry
246
- [source]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/containerregistry/container-registry/
278
+ [source]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/containerregistry/container-registry/
247
279
  [package]: https://www.npmjs.com/package/@azure/container-registry
248
280
  [api_docs]: https://docs.microsoft.com/javascript/api/@azure/container-registry
249
281
  [rest_docs]: https://docs.microsoft.com/rest/api/containerregistry/
250
282
  [product_docs]: https://docs.microsoft.com/azure/container-registry/
251
- [samples]: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/containerregistry/container-registry/samples
283
+ [cors]: https://github.com/Azure/azure-sdk-for-js/blob/main/samples/cors/ts/README.md
284
+ [samples]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/containerregistry/container-registry/samples
252
285
  [container_registry_docs]: https://docs.microsoft.com/azure/container-registry/container-registry-intro
253
286
  [container_registry_create_ps]: https://docs.microsoft.com/azure/container-registry/container-registry-get-started-powershell
254
287
  [container_registry_create_cli]: https://docs.microsoft.com/azure/container-registry/container-registry-get-started-azure-cli
@@ -256,5 +289,5 @@ If you'd like to contribute to this library, please read the [contributing guide
256
289
  [container_registry_concepts]: https://docs.microsoft.com/azure/container-registry/container-registry-concepts
257
290
  [azure_cli]: https://docs.microsoft.com/cli/azure
258
291
  [azure_sub]: https://azure.microsoft.com/free/
259
- [identity]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/README.md
292
+ [identity]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/README.md
260
293
  [az_sdk_js]: https://github.com/Azure/azure-sdk-for-js