0
0
mirror of https://github.com/thegeeklab/wp-plugin-go.git synced 2024-11-22 00:20:38 +00:00

Add Repo struct

This commit is contained in:
Don 2019-09-09 14:02:00 -07:00
parent df0859e244
commit 25dcc45148
2 changed files with 57 additions and 0 deletions

View File

@ -20,6 +20,35 @@ import (
// Drone prior to the 1.0 release.
const (
// The following environment variables are being ignored currently
//
// * DRONE_GIT_HTTP_URL
// * DRONE_GIT_SSH_URL
// * DRONE_REPO_NAMESPACE - Redundant to DRONE_REPO_OWNER
//---------------------------------------------------------------------
// Repo Enviornment Variables
//---------------------------------------------------------------------
// RepoDefaultBranchEnvVar corresponds to Repo.DefaultBranch.
RepoDefaultBranchEnvVar = "DRONE_REPO_BRANCH"
// RepoFullNameEnvVar corresponds to Repo.FullName.
RepoFullNameEnvVar = "DRONE_REPO"
// RepoLinkEnvVar corresponds to Repo.Link.
RepoLinkEnvVar = "DRONE_REPO_LINK"
// RepoNameEnvVar corresponds to Repo.Name
RepoNameEnvVar = "DRONE_REPO_NAME"
// RepoOwnerEnvVar corresponds to Repo.Owner.
RepoOwnerEnvVar = "DRONE_REPO_OWNER"
// RepoPrivateEnvVar corresponds to Repo.Private.
RepoPrivateEnvVar = "DRONE_REPO_PRIVATE"
// RepoRemoteURLEnvVar corresponds to Repo.RemoteURL.
RepoRemoteURLEnvVar = "DRONE_REMOTE_URL"
// RepoSCMEnvVar corresponds to Repo.SCM.
RepoSCMEnvVar = "DRONE_REPO_SCM"
// RepoVisibilityEnvVar corresponds to Repo.Visbility.
RepoVisibilityEnvVar = "DRONE_REPO_VISIBILITY"
//---------------------------------------------------------------------
// Stage Enviornment Variables
//---------------------------------------------------------------------

View File

@ -27,6 +27,19 @@ type (
Step Step
}
// Repo represents the repository for the build.
Repo struct {
DefaultBranch string
FullName string
Link string
Name string
Owner string
Private bool
RemoteURL string
SCM string
Visibility string
}
// Stage represents a build stage.
Stage struct {
// Arch is the platform architecture of the current build stage.
@ -88,6 +101,21 @@ type (
}
)
// RepoFromEnv creates a Repo from the environment variables used by Drone.
func RepoFromEnv() Repo {
return Repo{
DefaultBranch: StringEnvVar(RepoDefaultBranchEnvVar),
FullName: StringEnvVar(RepoFullNameEnvVar),
Link: StringEnvVar(RepoLinkEnvVar),
Name: StringEnvVar(RepoNameEnvVar),
Owner: StringEnvVar(RepoOwnerEnvVar),
Private: BoolEnvVar(RepoPrivateEnvVar),
RemoteURL: StringEnvVar(RepoRemoteURLEnvVar),
SCM: StringEnvVar(RepoSCMEnvVar),
Visibility: StringEnvVar(RepoVisibilityEnvVar),
}
}
// StageFromEnv creates a Stage from the environment variables used by Drone.
func StageFromEnv() Stage {
return Stage{