Skip to content

List System Containers #21243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion sdk/storage/azblob/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

### Features Added
* Added support for [Cold tier](https://learn.microsoft.com/azure/storage/blobs/access-tiers-overview?tabs=azure-portal).
* Added CopySourceTag option for UploadBlobFromURLOptions
* Added `CopySourceTag` option for `UploadBlobFromURLOptions`
* Added `System` option to `ListContainersInclude` to allow listing of system containers.

### Breaking Changes

Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/azblob/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "go",
"TagPrefix": "go/storage/azblob",
"Tag": "go/storage/azblob_5f550f0ded"
"Tag": "go/storage/azblob_816342f61e"
}
3 changes: 3 additions & 0 deletions sdk/storage/azblob/service/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ func (s *Client) NewListContainersPager(o *ListContainersOptions) *runtime.Pager
if o.Include.Metadata {
listOptions.Include = append(listOptions.Include, generated.ListContainersIncludeTypeMetadata)
}
if o.Include.System {
listOptions.Include = append(listOptions.Include, generated.ListContainersIncludeTypeSystem)
}
listOptions.Marker = o.Marker
listOptions.Maxresults = o.MaxResults
listOptions.Prefix = o.Prefix
Expand Down
27 changes: 27 additions & 0 deletions sdk/storage/azblob/service/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,33 @@ func (s *ServiceUnrecordedTestsSuite) TestListContainersBasic() {
_require.GreaterOrEqual(count, 0)
}

func (s *ServiceRecordedTestsSuite) TestListContainersSystem() {
_require := require.New(s.T())
svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil)
_require.Nil(err)

listOptions := service.ListContainersOptions{Include: service.ListContainersInclude{System: true}}
pager := svcClient.NewListContainersPager(&listOptions)

count := 0
for pager.More() {
resp, err := pager.NextPage(context.Background())
_require.Nil(err)
for _, c := range resp.ContainerItems {
_require.NotNil(c.Name)
if strings.Contains(*c.Name, "$") {
count += 1
}
}
if err != nil {
break
}
}

_require.Nil(err)
_require.GreaterOrEqual(count, 1) // every account will always have one system container, i.e. '$logs'
}

func (s *ServiceRecordedTestsSuite) TestSetPropertiesLogging() {
_require := require.New(s.T())
svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil)
Expand Down
3 changes: 3 additions & 0 deletions sdk/storage/azblob/service/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ type ListContainersInclude struct {

// Tells the service whether to return soft-deleted containers.
Deleted bool

// Tells the service whether to return system containers.
System bool
}

// ---------------------------------------------------------------------------------------------------------------------
Expand Down