mirror of
https://github.com/drone-plugins/drone-docker.git
synced 2026-06-04 18:24:24 +08:00
test
This commit is contained in:
@@ -113,6 +113,28 @@ docker run --rm \
|
||||
plugins/docker --dry-run
|
||||
```
|
||||
|
||||
### GAR (Google Artifact Registry)
|
||||
|
||||
```yaml
|
||||
kind: pipeline
|
||||
name: default
|
||||
type: docker
|
||||
|
||||
steps:
|
||||
- name: push-to-gar
|
||||
image: plugins/gcr
|
||||
pull: never
|
||||
settings:
|
||||
tag: latest
|
||||
repo: harness/drone
|
||||
registry_type: GAR
|
||||
location: us
|
||||
project_id: projectID
|
||||
image_name: drone
|
||||
json_key:
|
||||
from_secret: gcr_json_key
|
||||
```
|
||||
|
||||
## Developer Notes
|
||||
|
||||
- When updating the base image, you will need to update for each architecture and OS.
|
||||
@@ -137,3 +159,4 @@ docker run -it --rm -v "$(pwd)":/usr/local/src/your-app githubchangeloggenerator
|
||||
```
|
||||
|
||||
Create your pull request for the release. Get it merged then tag the release.
|
||||
|
||||
|
||||
+14
-9
@@ -38,6 +38,11 @@ func loadConfig() Config {
|
||||
}
|
||||
}
|
||||
|
||||
location := getenv("PLUGIN_LOCATION")
|
||||
projectID := getenv("PLUGIN_PROJECT_ID")
|
||||
imageName := getenv("PLUGIN_IMAGE_NAME")
|
||||
repo := getenv("PLUGIN_REPO")
|
||||
|
||||
password := getenv(
|
||||
"PLUGIN_JSON_KEY",
|
||||
"GCR_JSON_KEY",
|
||||
@@ -47,7 +52,7 @@ func loadConfig() Config {
|
||||
workloadIdentity := parseBoolOrDefault(false, getenv("PLUGIN_WORKLOAD_IDENTITY"))
|
||||
username, password = setUsernameAndPassword(username, password, workloadIdentity)
|
||||
|
||||
registryType := os.Getenv("PLUGIN_REGISTRY_TYPE")
|
||||
registryType := getenv("PLUGIN_REGISTRY_TYPE")
|
||||
if registryType == "" {
|
||||
registryType = "GCR"
|
||||
}
|
||||
@@ -57,22 +62,22 @@ func loadConfig() Config {
|
||||
switch registryType {
|
||||
case "GCR":
|
||||
registry = "gcr.io"
|
||||
if !strings.HasPrefix(repo, registry) {
|
||||
repo = path.Join(registry, repo)
|
||||
}
|
||||
case "GAR":
|
||||
location := getenv("PLUGIN_GAR_LOCATION")
|
||||
if location == "" {
|
||||
logrus.Fatalf("Error: For GAR, PLUGIN_GAR_LOCATION must be set")
|
||||
if location == "" || projectID == "" || imageName == "" {
|
||||
logrus.Fatalf("Error: For GAR, LOCATION, PROJECT_ID and IMAGE must be set")
|
||||
}
|
||||
registry = fmt.Sprintf("%s-docker.pkg.dev", location)
|
||||
if !strings.HasPrefix(repo, registry) {
|
||||
repo = path.Join(registry, projectID, repo, imageName)
|
||||
}
|
||||
default:
|
||||
logrus.Fatalf("Unsupported registry type: %s", registryType)
|
||||
}
|
||||
}
|
||||
|
||||
repo := getenv("PLUGIN_REPO")
|
||||
if !strings.HasPrefix(repo, registry) {
|
||||
repo = path.Join(registry, repo)
|
||||
}
|
||||
|
||||
return Config{
|
||||
Repo: repo,
|
||||
Registry: registry,
|
||||
|
||||
Reference in New Issue
Block a user