good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
fa011174
Unverified
Commit
fa011174
authored
4 years ago
by
Martin Holst Swende
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
build/ci: handle split up listing (#21293)
parent
490b380a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
build/ci.go
+3
-0
3 additions, 0 deletions
build/ci.go
internal/build/azure.go
+20
-10
20 additions, 10 deletions
internal/build/azure.go
with
23 additions
and
10 deletions
build/ci.go
+
3
−
0
View file @
fa011174
...
...
@@ -1098,6 +1098,8 @@ func doPurge(cmdline []string) {
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
fmt
.
Printf
(
"Found %d blobs
\n
"
,
len
(
blobs
))
// Iterate over the blobs, collect and sort all unstable builds
for
i
:=
0
;
i
<
len
(
blobs
);
i
++
{
if
!
strings
.
Contains
(
blobs
[
i
]
.
Name
,
"unstable"
)
{
...
...
@@ -1119,6 +1121,7 @@ func doPurge(cmdline []string) {
break
}
}
fmt
.
Printf
(
"Deleting %d blobs
\n
"
,
len
(
blobs
))
// Delete all marked as such and return
if
err
:=
build
.
AzureBlobstoreDelete
(
auth
,
blobs
);
err
!=
nil
{
log
.
Fatal
(
err
)
...
...
This diff is collapsed.
Click to expand it.
internal/build/azure.go
+
20
−
10
View file @
fa011174
...
...
@@ -71,26 +71,35 @@ func AzureBlobstoreUpload(path string, name string, config AzureBlobstoreConfig)
// AzureBlobstoreList lists all the files contained within an azure blobstore.
func
AzureBlobstoreList
(
config
AzureBlobstoreConfig
)
([]
azblob
.
BlobItem
,
error
)
{
credential
,
err
:=
azblob
.
NewSharedKeyCredential
(
config
.
Account
,
config
.
Token
)
if
err
!=
nil
{
return
nil
,
err
credential
:=
azblob
.
NewAnonymousCredential
()
if
len
(
config
.
Token
)
>
0
{
c
,
err
:=
azblob
.
NewSharedKeyCredential
(
config
.
Account
,
config
.
Token
)
if
err
!=
nil
{
return
nil
,
err
}
credential
=
c
}
pipeline
:=
azblob
.
NewPipeline
(
credential
,
azblob
.
PipelineOptions
{})
u
,
_
:=
url
.
Parse
(
fmt
.
Sprintf
(
"https://%s.blob.core.windows.net"
,
config
.
Account
))
service
:=
azblob
.
NewServiceURL
(
*
u
,
pipeline
)
var
allBlobs
[]
azblob
.
BlobItem
// List all the blobs from the container and return them
container
:=
service
.
NewContainerURL
(
config
.
Container
)
nextMarker
:=
azblob
.
Marker
{}
for
nextMarker
.
NotDone
()
{
res
,
err
:=
container
.
ListBlobsFlatSegment
(
context
.
Background
(),
nextMarker
,
azblob
.
ListBlobsSegmentOptions
{
MaxResults
:
5000
,
// The server only gives max 5K items
})
if
err
!=
nil
{
return
nil
,
err
}
allBlobs
=
append
(
allBlobs
,
res
.
Segment
.
BlobItems
...
)
nextMarker
=
res
.
NextMarker
res
,
err
:=
container
.
ListBlobsFlatSegment
(
context
.
Background
(),
azblob
.
Marker
{},
azblob
.
ListBlobsSegmentOptions
{
MaxResults
:
1024
*
1024
*
1024
,
// Yes, fetch all of them
})
if
err
!=
nil
{
return
nil
,
err
}
return
res
.
Segment
.
BlobItem
s
,
nil
return
allBlob
s
,
nil
}
// AzureBlobstoreDelete iterates over a list of files to delete and removes them
...
...
@@ -121,6 +130,7 @@ func AzureBlobstoreDelete(config AzureBlobstoreConfig, blobs []azblob.BlobItem)
if
_
,
err
:=
blockblob
.
Delete
(
context
.
Background
(),
azblob
.
DeleteSnapshotsOptionInclude
,
azblob
.
BlobAccessConditions
{});
err
!=
nil
{
return
err
}
fmt
.
Printf
(
"deleted %s (%s)
\n
"
,
blob
.
Name
,
blob
.
Properties
.
LastModified
)
}
return
nil
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment