Skip to content

Commit 81708be

Browse files
List System Containers (#21243)
* Listing system containers * Updating CHANGELOG.md * Record test
1 parent 31f07c2 commit 81708be

File tree

5 files changed

+36
-2
lines changed

5 files changed

+36
-2
lines changed

sdk/storage/azblob/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

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

910
### Breaking Changes
1011

sdk/storage/azblob/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "go",
44
"TagPrefix": "go/storage/azblob",
5-
"Tag": "go/storage/azblob_5f550f0ded"
5+
"Tag": "go/storage/azblob_816342f61e"
66
}

sdk/storage/azblob/service/client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ func (s *Client) NewListContainersPager(o *ListContainersOptions) *runtime.Pager
194194
if o.Include.Metadata {
195195
listOptions.Include = append(listOptions.Include, generated.ListContainersIncludeTypeMetadata)
196196
}
197+
if o.Include.System {
198+
listOptions.Include = append(listOptions.Include, generated.ListContainersIncludeTypeSystem)
199+
}
197200
listOptions.Marker = o.Marker
198201
listOptions.Maxresults = o.MaxResults
199202
listOptions.Prefix = o.Prefix

sdk/storage/azblob/service/client_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,33 @@ func (s *ServiceUnrecordedTestsSuite) TestListContainersBasic() {
160160
_require.GreaterOrEqual(count, 0)
161161
}
162162

163+
func (s *ServiceRecordedTestsSuite) TestListContainersSystem() {
164+
_require := require.New(s.T())
165+
svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil)
166+
_require.Nil(err)
167+
168+
listOptions := service.ListContainersOptions{Include: service.ListContainersInclude{System: true}}
169+
pager := svcClient.NewListContainersPager(&listOptions)
170+
171+
count := 0
172+
for pager.More() {
173+
resp, err := pager.NextPage(context.Background())
174+
_require.Nil(err)
175+
for _, c := range resp.ContainerItems {
176+
_require.NotNil(c.Name)
177+
if strings.Contains(*c.Name, "$") {
178+
count += 1
179+
}
180+
}
181+
if err != nil {
182+
break
183+
}
184+
}
185+
186+
_require.Nil(err)
187+
_require.GreaterOrEqual(count, 1) // every account will always have one system container, i.e. '$logs'
188+
}
189+
163190
func (s *ServiceRecordedTestsSuite) TestSetPropertiesLogging() {
164191
_require := require.New(s.T())
165192
svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil)

sdk/storage/azblob/service/models.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ type ListContainersInclude struct {
156156

157157
// Tells the service whether to return soft-deleted containers.
158158
Deleted bool
159+
160+
// Tells the service whether to return system containers.
161+
System bool
159162
}
160163

161164
// ---------------------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)