-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: check pushed Dockerfile (#1257)
* feat: check pushed Dockerfile STONEBLD-2522 Signed-off-by: Chenxiong Qi <[email protected]> * fix: only check pushed Dockerfile in build_templates.go Signed-off-by: Chenxiong Qi <[email protected]> * fix: update test order Signed-off-by: Chenxiong Qi <[email protected]> --------- Signed-off-by: Chenxiong Qi <[email protected]>
- Loading branch information
Showing
4 changed files
with
102 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package oras | ||
|
||
import ( | ||
"context" | ||
"os" | ||
|
||
"github.com/openshift/library-go/pkg/image/reference" | ||
oras "oras.land/oras-go/v2" | ||
"oras.land/oras-go/v2/content/file" | ||
"oras.land/oras-go/v2/registry/remote" | ||
"oras.land/oras-go/v2/registry/remote/auth" | ||
"oras.land/oras-go/v2/registry/remote/retry" | ||
) | ||
|
||
// PullArtifacts pulls artifacts from the given imagePullSpec. | ||
// Pulled artifacts will be stored in a local directory, whose path is returned. | ||
func PullArtifacts(imagePullSpec string) (string, error) { | ||
storePath, err := os.MkdirTemp("", "pulled-artifacts") | ||
if err != nil { | ||
return "", err | ||
} | ||
fs, err := file.New(storePath) | ||
if err != nil { | ||
return "", err | ||
} | ||
defer fs.Close() | ||
|
||
imageRef, err := reference.Parse(imagePullSpec) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
repo, err := remote.NewRepository(imagePullSpec) | ||
if err != nil { | ||
return "", err | ||
} | ||
repo.Client = &auth.Client{ | ||
Client: retry.DefaultClient, | ||
Cache: auth.NewCache(), | ||
Credential: auth.StaticCredential(imageRef.Registry, auth.Credential{ | ||
AccessToken: os.Getenv("QUAY_TOKEN"), | ||
}), | ||
} | ||
|
||
ctx := context.Background() | ||
tag := imageRef.Tag | ||
if _, err := oras.Copy(ctx, repo, tag, fs, tag, oras.DefaultCopyOptions); err != nil { | ||
return "", err | ||
} | ||
|
||
return storePath, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters