mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-03-24 15:55:03 +01:00
feat: contextdata overlay api and more gh/gt instance flags (#105)
* add TestGetGitHubContextOverlay
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
"runtime"
|
||||
|
||||
"github.com/actions-oss/act-cli/pkg/common"
|
||||
@@ -48,6 +49,9 @@ type Config struct {
|
||||
ContainerOptions string // Options for the job container
|
||||
UseGitIgnore bool // controls if paths in .gitignore should not be copied into container, default true
|
||||
GitHubInstance string // GitHub instance to use, default "github.com"
|
||||
GitHubServerURL string // GitHub server url to use
|
||||
GitHubAPIServerURL string // GitHub api server url to use
|
||||
GitHubGraphQlAPIServerURL string // GitHub graphql server url to use
|
||||
ContainerCapAdd []string // list of kernel capabilities to add to the containers
|
||||
ContainerCapDrop []string // list of kernel capabilities to remove from the containers
|
||||
AutoRemove bool // controls if the container is automatically removed upon workflow completion
|
||||
@@ -64,6 +68,38 @@ type Config struct {
|
||||
HostEnvironmentDir string // Custom folder for host environment, parallel jobs must be 1
|
||||
}
|
||||
|
||||
func (runnerConfig *Config) GetGitHubServerURL() string {
|
||||
if len(runnerConfig.GitHubServerURL) > 0 {
|
||||
return runnerConfig.GitHubServerURL
|
||||
}
|
||||
return fmt.Sprintf("https://%s", runnerConfig.GitHubInstance)
|
||||
}
|
||||
func (runnerConfig *Config) GetGitHubAPIServerURL() string {
|
||||
if len(runnerConfig.GitHubAPIServerURL) > 0 {
|
||||
return runnerConfig.GitHubAPIServerURL
|
||||
}
|
||||
if runnerConfig.GitHubInstance == "github.com" {
|
||||
return "https://api.github.com"
|
||||
}
|
||||
return fmt.Sprintf("https://%s/api/v3", runnerConfig.GitHubInstance)
|
||||
}
|
||||
func (runnerConfig *Config) GetGitHubGraphQlAPIServerURL() string {
|
||||
if len(runnerConfig.GitHubGraphQlAPIServerURL) > 0 {
|
||||
return runnerConfig.GitHubGraphQlAPIServerURL
|
||||
}
|
||||
if runnerConfig.GitHubInstance == "github.com" {
|
||||
return "https://api.github.com/graphql"
|
||||
}
|
||||
return fmt.Sprintf("https://%s/api/graphql", runnerConfig.GitHubInstance)
|
||||
}
|
||||
func (runnerConfig *Config) GetGitHubInstance() string {
|
||||
if len(runnerConfig.GitHubServerURL) > 0 {
|
||||
regex := regexp.MustCompile("^https?://(.*)$")
|
||||
return regex.ReplaceAllString(runnerConfig.GitHubServerURL, "$1")
|
||||
}
|
||||
return runnerConfig.GitHubInstance
|
||||
}
|
||||
|
||||
type caller struct {
|
||||
runContext *RunContext
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user