Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d59677e
Update package versions (#22201)
RickWinter Jan 4, 2024
4228971
Increment package version after release of messaging/azeventgrid (#22…
azure-sdk Jan 4, 2024
8c72917
Increment package version after release of ai/azopenai (#22126)
azure-sdk Jan 4, 2024
5798b0d
azblob: STG91 upgrade (#22194)
souravgupta-msft Jan 5, 2024
7f7c19b
azfile: STG91 upgrade (#22193)
souravgupta-msft Jan 5, 2024
3ba6817
update source link to new azopenai location (#22208)
fkarg Jan 5, 2024
4162eea
More azappconfig cleanup (#22209)
jhendrixMSFT Jan 5, 2024
2d017b7
Fix spelling (preceeding=> preceding) (#22202)
azure-sdk Jan 5, 2024
06a9327
Storage: Reject HTTP endpoints (#22183)
souravgupta-msft Jan 8, 2024
e63fa24
[azeventhubs] Fixing an issue where a processor wouldn't grab partiti…
richardpark-msft Jan 8, 2024
9f9219c
Clean up ETags in azappconfig (#22212)
jhendrixMSFT Jan 9, 2024
ecdb3a6
[azopenai] Fixing issue where you can't use whisper with m4a files. (…
richardpark-msft Jan 9, 2024
ed7cbbe
Updating changelog for STG91 preview (#22216)
souravgupta-msft Jan 9, 2024
a672b5d
azfile: STG 91 Preview (#22217)
souravgupta-msft Jan 9, 2024
a5c4497
Increment package version after release of storage/azblob (#22219)
azure-sdk Jan 9, 2024
c7abe2d
[azopenai] Update changelog for release. (#22215)
richardpark-msft Jan 9, 2024
f386581
Replace string with azcore.ETag (#22218)
jhendrixMSFT Jan 9, 2024
dbf4d0d
Add script to go mod tidy modules (#22214)
jhendrixMSFT Jan 9, 2024
8b19787
Increment package version after release of storage/azfile (#22220)
azure-sdk Jan 9, 2024
bdf62de
Added Simon and Kushagra as code owners on GO Cosmos SDK (#22221)
kushagraThapar Jan 9, 2024
46b3614
[azservicebus] Updating batching to allow for a configurable wait tim…
richardpark-msft Jan 9, 2024
0fbeb23
Sync eng/common directory with azure-sdk-tools for PR 7459 (#22222)
azure-sdk Jan 9, 2024
58413e0
Fix image tag for multiimage deployments (#22224)
azure-sdk Jan 9, 2024
e274f37
Refresh azcontainerregistry module (#22161)
tadelesh Jan 10, 2024
fbe326d
fix generator tool (#22205)
Alancere Jan 10, 2024
3264125
azdatalake preview stg82
tanyasethi-msft Jan 10, 2024
467afcf
azdatalake preview stg82 (#22227)
tanyasethi-msft Jan 10, 2024
4b274bc
Rename azidentity/cache pipeline (#22231)
chlowell Jan 10, 2024
c99ab58
Handle errors in mod tidy script (#22234)
benbp Jan 11, 2024
498b32e
Merge branch 'Azure:main' into main
tanyasethi-msft Jan 11, 2024
1ae9698
Sync eng/common directory with azure-sdk-tools for PR 7445 (#22233)
azure-sdk Jan 11, 2024
0677fb4
Use package filter to prevent recursive package publish (#22232)
benbp Jan 11, 2024
c10d3f8
Merge branch 'Azure:main' into main
tanyasethi-msft Jan 12, 2024
cef53c7
append with flush
tanyasethi-msft Jan 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refresh azcontainerregistry module (#22161)
* upgrade to latest codegen

* merge resolver

* enable span and add changelog

* update module name
  • Loading branch information
tadelesh authored Jan 10, 2024
commit e274f377098fbd866460ae998f6446c0f9214b25
2 changes: 2 additions & 0 deletions sdk/containers/azcontainerregistry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

### Features Added
* Add `ConfigMediaType` and `MediaType` properties to `ManifestAttributes`
* Enabled spans for distributed tracing

### Other Changes
* Refine some logics and comments
* Updated to latest version of azcore

## 0.2.0 (2023-06-06)

Expand Down
44 changes: 30 additions & 14 deletions sdk/containers/azcontainerregistry/authentication_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 16 additions & 10 deletions sdk/containers/azcontainerregistry/authentication_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import (
func Test_authenticationClient_ExchangeAADAccessTokenForACRRefreshToken(t *testing.T) {
startRecording(t)
endpoint, cred, options := getEndpointCredAndClientOptions(t)
client := newAuthenticationClient(endpoint, &authenticationClientOptions{ClientOptions: options})
client, err := newAuthenticationClient(endpoint, &authenticationClientOptions{ClientOptions: options})
require.NoError(t, err)
ctx := context.Background()
if reflect.ValueOf(options.Cloud).IsZero() {
options.Cloud = cloud.AzurePublic
Expand All @@ -44,9 +45,10 @@ func Test_authenticationClient_ExchangeAADAccessTokenForACRRefreshToken(t *testi
func Test_authenticationClient_ExchangeAADAccessTokenForACRRefreshToken_fail(t *testing.T) {
startRecording(t)
endpoint, _, options := getEndpointCredAndClientOptions(t)
client := newAuthenticationClient(endpoint, &authenticationClientOptions{ClientOptions: options})
client, err := newAuthenticationClient(endpoint, &authenticationClientOptions{ClientOptions: options})
require.NoError(t, err)
ctx := context.Background()
_, err := client.ExchangeAADAccessTokenForACRRefreshToken(ctx, postContentSchemaGrantTypeAccessToken, strings.TrimPrefix(endpoint, "https://"), &authenticationClientExchangeAADAccessTokenForACRRefreshTokenOptions{
_, err = client.ExchangeAADAccessTokenForACRRefreshToken(ctx, postContentSchemaGrantTypeAccessToken, strings.TrimPrefix(endpoint, "https://"), &authenticationClientExchangeAADAccessTokenForACRRefreshTokenOptions{
Tenant: to.Ptr("wrong tenant"),
RefreshToken: to.Ptr("wrong token"),
AccessToken: to.Ptr("wrong token"),
Expand All @@ -58,16 +60,18 @@ func Test_authenticationClient_ExchangeAADAccessTokenForACRRefreshToken_error(t
srv, closeServer := mock.NewServer()
defer closeServer()
srv.AppendResponse(mock.WithStatusCode(http.StatusOK), mock.WithBody([]byte("wrong response")))
client := newAuthenticationClient(srv.URL(), &authenticationClientOptions{ClientOptions: azcore.ClientOptions{Transport: srv}})
client, err := newAuthenticationClient(srv.URL(), &authenticationClientOptions{ClientOptions: azcore.ClientOptions{Transport: srv}})
require.NoError(t, err)
ctx := context.Background()
_, err := client.ExchangeAADAccessTokenForACRRefreshToken(ctx, "grantType", "service", nil)
_, err = client.ExchangeAADAccessTokenForACRRefreshToken(ctx, "grantType", "service", nil)
require.Error(t, err)
}

func Test_authenticationClient_ExchangeACRRefreshTokenForACRAccessToken(t *testing.T) {
startRecording(t)
endpoint, cred, options := getEndpointCredAndClientOptions(t)
client := newAuthenticationClient(endpoint, &authenticationClientOptions{ClientOptions: options})
client, err := newAuthenticationClient(endpoint, &authenticationClientOptions{ClientOptions: options})
require.NoError(t, err)
ctx := context.Background()
if reflect.ValueOf(options.Cloud).IsZero() {
options.Cloud = cloud.AzurePublic
Expand All @@ -91,18 +95,20 @@ func Test_authenticationClient_ExchangeACRRefreshTokenForACRAccessToken(t *testi
func Test_authenticationClient_ExchangeACRRefreshTokenForACRAccessToken_fail(t *testing.T) {
startRecording(t)
endpoint, _, options := getEndpointCredAndClientOptions(t)
client := newAuthenticationClient(endpoint, &authenticationClientOptions{ClientOptions: options})
client, err := newAuthenticationClient(endpoint, &authenticationClientOptions{ClientOptions: options})
require.NoError(t, err)
ctx := context.Background()
_, err := client.ExchangeACRRefreshTokenForACRAccessToken(ctx, strings.TrimPrefix(endpoint, "https://"), "registry:catalog:*", "wrong token", &authenticationClientExchangeACRRefreshTokenForACRAccessTokenOptions{GrantType: to.Ptr(tokenGrantTypeRefreshToken)})
_, err = client.ExchangeACRRefreshTokenForACRAccessToken(ctx, strings.TrimPrefix(endpoint, "https://"), "registry:catalog:*", "wrong token", &authenticationClientExchangeACRRefreshTokenForACRAccessTokenOptions{GrantType: to.Ptr(tokenGrantTypeRefreshToken)})
require.Error(t, err)
}

func Test_authenticationClient_ExchangeACRRefreshTokenForACRAccessToken_error(t *testing.T) {
srv, closeServer := mock.NewServer()
defer closeServer()
srv.AppendResponse(mock.WithStatusCode(http.StatusOK), mock.WithBody([]byte("wrong response")))
client := newAuthenticationClient(srv.URL(), &authenticationClientOptions{ClientOptions: azcore.ClientOptions{Transport: srv}})
client, err := newAuthenticationClient(srv.URL(), &authenticationClientOptions{ClientOptions: azcore.ClientOptions{Transport: srv}})
require.NoError(t, err)
ctx := context.Background()
_, err := client.ExchangeACRRefreshTokenForACRAccessToken(ctx, "service", "scope", "refresh token", nil)
_, err = client.ExchangeACRRefreshTokenForACRAccessToken(ctx, "service", "scope", "refresh token", nil)
require.Error(t, err)
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@ type authenticationClientOptions struct {
// newAuthenticationClient creates a new instance of AuthenticationClient with the specified values.
// - endpoint - Registry login URL
// - options - Client options, pass nil to accept the default values.
func newAuthenticationClient(endpoint string, options *authenticationClientOptions) *authenticationClient {
func newAuthenticationClient(endpoint string, options *authenticationClientOptions) (*authenticationClient, error) {
if options == nil {
options = &authenticationClientOptions{}
}

pipeline := runtime.NewPipeline(moduleName, moduleVersion, runtime.PipelineOptions{}, &options.ClientOptions)
azcoreClient, err := azcore.NewClient(moduleName, moduleVersion, runtime.PipelineOptions{}, &options.ClientOptions)
if err != nil {
return nil, err
}

client := &authenticationClient{
internal: azcoreClient,
endpoint: endpoint,
pl: pipeline,
}
return client
return client, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
)

func Test_newAuthenticationClient(t *testing.T) {
client := newAuthenticationClient("test", nil)
client, err := newAuthenticationClient("test", nil)
require.NoError(t, err)
require.NotNil(t, client)
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ func Test_authenticationPolicy_getAccessToken_live(t *testing.T) {
if reflect.ValueOf(options.Cloud).IsZero() {
options.Cloud = cloud.AzurePublic
}
authClient := newAuthenticationClient(endpoint, &authenticationClientOptions{options})
authClient, err := newAuthenticationClient(endpoint, &authenticationClientOptions{options})
require.NoError(t, err)
p := &authenticationPolicy{
temporal.NewResource(acquireRefreshToken),
atomic.Value{},
Expand All @@ -154,7 +155,8 @@ func Test_authenticationPolicy_getAccessToken_error(t *testing.T) {
srv.AppendResponse(mock.WithStatusCode(http.StatusOK), mock.WithBody([]byte("{\"refresh_token\": \".eyJqdGkiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDAiLCJzdWIiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDAiLCJuYmYiOjQ2NzA0MTEyMTIsImV4cCI6NDY3MDQyMjkxMiwiaWF0Ijo0NjcwNDExMjEyLCJpc3MiOiJBenVyZSBDb250YWluZXIgUmVnaXN0cnkiLCJhdWQiOiJhemFjcmxpdmV0ZXN0LmF6dXJlY3IuaW8iLCJ2ZXJzaW9uIjoiMS4wIiwicmlkIjoiMDAwMCIsImdyYW50X3R5cGUiOiJyZWZyZXNoX3Rva2VuIiwiYXBwaWQiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDAiLCJwZXJtaXNzaW9ucyI6eyJBY3Rpb25zIjpbInJlYWQiLCJ3cml0ZSIsImRlbGV0ZSIsImRlbGV0ZWQvcmVhZCIsImRlbGV0ZWQvcmVzdG9yZS9hY3Rpb24iXSwiTm90QWN0aW9ucyI6bnVsbH0sInJvbGVzIjpbXX0.\"}")))
srv.AppendResponse(mock.WithStatusCode(http.StatusOK), mock.WithBody([]byte("wrong response")))
srv.AppendResponse(mock.WithStatusCode(http.StatusOK), mock.WithBody([]byte("wrong response")))
authClient := newAuthenticationClient(srv.URL(), &authenticationClientOptions{ClientOptions: azcore.ClientOptions{Transport: srv}})
authClient, err := newAuthenticationClient(srv.URL(), &authenticationClientOptions{ClientOptions: azcore.ClientOptions{Transport: srv}})
require.NoError(t, err)

p := &authenticationPolicy{
temporal.NewResource(acquireRefreshToken),
Expand All @@ -179,7 +181,8 @@ func Test_authenticationPolicy_getAccessToken_error(t *testing.T) {
func Test_authenticationPolicy_getAccessToken_live_anonymous(t *testing.T) {
startRecording(t)
endpoint, _, options := getEndpointCredAndClientOptions(t)
authClient := newAuthenticationClient(endpoint, &authenticationClientOptions{options})
authClient, err := newAuthenticationClient(endpoint, &authenticationClientOptions{options})
require.NoError(t, err)
p := &authenticationPolicy{
refreshTokenCache: temporal.NewResource(acquireRefreshToken),
authClient: authClient,
Expand Down Expand Up @@ -237,7 +240,8 @@ func Test_authenticationPolicy(t *testing.T) {
srv.AppendResponse(mock.WithStatusCode(http.StatusOK), mock.WithBody([]byte("{\"access_token\": \"test\"}")))
srv.AppendResponse(mock.WithStatusCode(http.StatusOK))

authClient := newAuthenticationClient(srv.URL(), &authenticationClientOptions{ClientOptions: azcore.ClientOptions{Transport: srv}})
authClient, err := newAuthenticationClient(srv.URL(), &authenticationClientOptions{ClientOptions: azcore.ClientOptions{Transport: srv}})
require.NoError(t, err)
authPolicy := &authenticationPolicy{
temporal.NewResource(acquireRefreshToken),
atomic.Value{},
Expand Down
10 changes: 7 additions & 3 deletions sdk/containers/azcontainerregistry/autorest.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ clear-output-folder: false
export-clients: true
openapi-type: "data-plane"
output-folder: ../azcontainerregistry
use: "@autorest/[email protected].45"
use: "@autorest/[email protected].60"
honor-body-placement: true
remove-unreferenced-types: true
module-name: sdk/containers/azcontainerregistry
module: github.com/Azure/azure-sdk-for-go/$(module-name)
inject-spans: true
```

## Customizations
Expand Down Expand Up @@ -328,10 +331,11 @@ directive:
transform: return $.replaceAll(/AuthenticationClient/g, "authenticationClient").replace(/AcrRefreshToken\n/, "acrRefreshToken\n").replace(/AcrAccessToken\n/, "acrAccessToken\n");
- from:
- models.go
- options.go
where: $
transform: return $.replaceAll(/AuthenticationClient/g, "authenticationClient").replace(/AcrRefreshToken struct/, "acrRefreshToken struct").replace(/AcrAccessToken struct/, "acrAccessToken struct");
- from:
- models.go
- options.go
where: $
transform: return $.replace(/TokenGrantType/, "tokenGrantType");
- from:
Expand Down Expand Up @@ -444,7 +448,7 @@ directive:
});
- from:
- blob_client.go
- models.go
- options.go
where: $
transform: return $.replaceAll(/BlobClientUploadChunkOptions/g, "blobClientUploadChunkOptions").replace(/BlobClient\.UploadChunk/, "BlobClient.uploadChunk");
```
Expand Down
Loading