forked from gravitational/teleport
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dronegen: drone config generator (gravitational#6071)
- Loading branch information
Showing
13 changed files
with
3,396 additions
and
2,244 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,100 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
var ( | ||
triggerPullRequest = trigger{ | ||
Event: triggerRef{Include: []string{"pull_request"}}, | ||
Repo: triggerRef{Include: []string{"gravitational/*"}}, | ||
} | ||
triggerPush = trigger{ | ||
Event: triggerRef{Include: []string{"push"}, Exclude: []string{"pull_request"}}, | ||
Branch: triggerRef{Include: []string{"master", "branch/*"}}, | ||
Repo: triggerRef{Include: []string{"gravitational/*"}}, | ||
} | ||
triggerTag = trigger{ | ||
Event: triggerRef{Include: []string{"tag"}}, | ||
Ref: triggerRef{Include: []string{"refs/tags/v*"}}, | ||
Repo: triggerRef{Include: []string{"gravitational/*"}}, | ||
} | ||
|
||
volumeDocker = volume{ | ||
Name: "dockersock", | ||
Temp: &volumeTemp{}, | ||
} | ||
volumeTmpfs = volume{ | ||
Name: "tmpfs", | ||
Temp: &volumeTemp{Medium: "memory"}, | ||
} | ||
volumeTmpDind = volume{ | ||
Name: "tmp-dind", | ||
Temp: &volumeTemp{}, | ||
} | ||
volumeTmpIntegration = volume{ | ||
Name: "tmp-integration", | ||
Temp: &volumeTemp{}, | ||
} | ||
|
||
volumeRefTmpfs = volumeRef{ | ||
Name: "tmpfs", | ||
Path: "/tmpfs", | ||
} | ||
volumeRefDocker = volumeRef{ | ||
Name: "dockersock", | ||
Path: "/var/run", | ||
} | ||
volumeRefTmpDind = volumeRef{ | ||
Name: "tmp-dind", | ||
Path: "/tmp", | ||
} | ||
volumeRefTmpIntegration = volumeRef{ | ||
Name: "tmp-integration", | ||
Path: "/tmp", | ||
} | ||
|
||
// TODO(gus): Set this from `make -C build.assets print-runtime-version` or similar rather | ||
// than hardcoding it. Also remove the usage of RUNTIME as a pipeline-level environment variable | ||
// (as support for these varies among Drone runners) and only set it for steps that need it. | ||
goRuntime = value{raw: "go1.15.5"} | ||
) | ||
|
||
type buildType struct { | ||
os string | ||
arch string | ||
fips bool | ||
centos6 bool | ||
} | ||
|
||
// dockerService generates a docker:dind service | ||
// It includes the Docker socket volume by default, plus any extra volumes passed in | ||
func dockerService(v ...volumeRef) service { | ||
return service{ | ||
Name: "Start Docker", | ||
Image: "docker:dind", | ||
Volumes: append(v, volumeRefDocker), | ||
} | ||
} | ||
|
||
// dockerVolumes returns a slice of volumes | ||
// It includes the Docker socket volume by default, plus any extra volumes passed in | ||
func dockerVolumes(v ...volume) []volume { | ||
return append(v, volumeDocker) | ||
} | ||
|
||
// dockerVolumeRefs returns a slice of volumeRefs | ||
// It includes the Docker socket volumeRef as a default, plus any extra volumeRefs passed in | ||
func dockerVolumeRefs(v ...volumeRef) []volumeRef { | ||
return append(v, volumeRefDocker) | ||
} | ||
|
||
// releaseMakefileTarget gets the correct Makefile target for a given arch/fips/centos6 combo | ||
func releaseMakefileTarget(b buildType) string { | ||
makefileTarget := fmt.Sprintf("release-%s", b.arch) | ||
if b.centos6 { | ||
makefileTarget += "-centos6" | ||
} | ||
if b.fips { | ||
makefileTarget += "-fips" | ||
} | ||
return makefileTarget | ||
} |
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,6 @@ | ||
package main | ||
|
||
func cronPipelines() []pipeline { | ||
// TODO: migrate | ||
return 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
) | ||
|
||
func checkDroneCLI() error { | ||
if _, err := exec.LookPath("drone"); err != nil { | ||
return fmt.Errorf("can't find drone CLI in $PATH: %w; get it from https://docs.drone.io/cli/install/", err) | ||
} | ||
if os.Getenv("DRONE_SERVER") == "" || os.Getenv("DRONE_TOKEN") == "" { | ||
return fmt.Errorf("$DRONE_SERVER and/or $DRONE_TOKEN env vars not set; get them at https://drone.gravitational.io/account") | ||
} | ||
return nil | ||
} | ||
|
||
func signDroneConfig() error { | ||
out, err := exec.Command("drone", "sign", "gravitational/teleport", "--save").CombinedOutput() | ||
if err != nil { | ||
if len(out) > 0 { | ||
err = fmt.Errorf("drone signing failed: %v\noutput:\n%s", err, out) | ||
} | ||
return err | ||
} | ||
return nil | ||
} |
Oops, something went wrong.