This commit is contained in:
Eoin McAfee
2023-09-20 11:28:53 +01:00
parent d8b4088b75
commit 9b81ce8da8
2 changed files with 37 additions and 9 deletions
+23
View File
@@ -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
View File
@@ -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,