Skip to content

Commit baad7fb

Browse files
committed
refactor(github): pass arch to GithubRunnerArgs, internalize runner image repo, clean up ppc64le snippet
1 parent a1d6416 commit baad7fb

13 files changed

Lines changed: 34 additions & 137 deletions

File tree

cmd/mapt/cmd/aws/hosts/fedora.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func getFedoraCreate() *cobra.Command {
5656
Debug: viper.IsSet(params.Debug),
5757
DebugLevel: viper.GetUint(params.DebugLevel),
5858
CirrusPWArgs: params.CirrusPersistentWorkerArgs(),
59-
GHRunnerArgs: params.GithubRunnerArgs(),
59+
GHRunnerArgs: params.GithubRunnerArgs(nil),
6060
GLRunnerArgs: params.GitLabRunnerArgs(params.LinuxGitLabArch()),
6161
Tags: viper.GetStringMapString(params.Tags),
6262
},

cmd/mapt/cmd/aws/hosts/mac.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func getMacRequest() *cobra.Command {
4747
ResultsOutput: viper.GetString(params.ConnectionDetailsOutput),
4848
Debug: viper.IsSet(params.Debug),
4949
DebugLevel: viper.GetUint(params.DebugLevel),
50-
GHRunnerArgs: params.GithubRunnerArgs(),
50+
GHRunnerArgs: params.GithubRunnerArgs(nil),
5151
GLRunnerArgs: params.GitLabRunnerArgs(params.LinuxGitLabArch()),
5252
Tags: viper.GetStringMapString(params.Tags),
5353
},

cmd/mapt/cmd/aws/hosts/rhel.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func getRHELCreate() *cobra.Command {
5252
Debug: viper.IsSet(params.Debug),
5353
DebugLevel: viper.GetUint(params.DebugLevel),
5454
CirrusPWArgs: params.CirrusPersistentWorkerArgs(),
55-
GHRunnerArgs: params.GithubRunnerArgs(),
55+
GHRunnerArgs: params.GithubRunnerArgs(nil),
5656
GLRunnerArgs: params.GitLabRunnerArgs(params.LinuxGitLabArch()),
5757
Tags: viper.GetStringMapString(params.Tags),
5858
},

cmd/mapt/cmd/aws/hosts/windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func getWindowsCreate() *cobra.Command {
6565
Debug: viper.IsSet(params.Debug),
6666
DebugLevel: viper.GetUint(params.DebugLevel),
6767
CirrusPWArgs: params.CirrusPersistentWorkerArgs(),
68-
GHRunnerArgs: params.GithubRunnerArgs(),
68+
GHRunnerArgs: params.GithubRunnerArgs(nil),
6969
GLRunnerArgs: params.GitLabRunnerArgs(params.LinuxGitLabArch()),
7070
Tags: viper.GetStringMapString(params.Tags),
7171
},

cmd/mapt/cmd/aws/services/mac-pool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func request() *cobra.Command {
173173
Debug: viper.IsSet(params.Debug),
174174
DebugLevel: viper.GetUint(params.DebugLevel),
175175
CirrusPWArgs: params.CirrusPersistentWorkerArgs(),
176-
GHRunnerArgs: params.GithubRunnerArgs(),
176+
GHRunnerArgs: params.GithubRunnerArgs(nil),
177177
GLRunnerArgs: params.GitLabRunnerArgs(params.LinuxGitLabArch()),
178178
Tags: viper.GetStringMapString(params.Tags),
179179
},

cmd/mapt/cmd/azure/hosts/rhel.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func getCreateRHEL() *cobra.Command {
4848
Debug: viper.IsSet(params.Debug),
4949
DebugLevel: viper.GetUint(params.DebugLevel),
5050
CirrusPWArgs: params.CirrusPersistentWorkerArgs(),
51-
GHRunnerArgs: params.GithubRunnerArgs(),
51+
GHRunnerArgs: params.GithubRunnerArgs(nil),
5252
GLRunnerArgs: params.GitLabRunnerArgs(params.LinuxGitLabArch()),
5353
Tags: viper.GetStringMapString(params.Tags),
5454
},

cmd/mapt/cmd/azure/hosts/windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func getCreateWindowsDesktop() *cobra.Command {
6161
Debug: viper.IsSet(params.Debug),
6262
DebugLevel: viper.GetUint(params.DebugLevel),
6363
CirrusPWArgs: params.CirrusPersistentWorkerArgs(),
64-
GHRunnerArgs: params.GithubRunnerArgs(),
64+
GHRunnerArgs: params.GithubRunnerArgs(nil),
6565
GLRunnerArgs: params.GitLabRunnerArgs(params.LinuxGitLabArch()),
6666
Tags: viper.GetStringMapString(params.Tags),
6767
},

cmd/mapt/cmd/ibmcloud/hosts/ibm-power.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ func ibmPowerCreate() *cobra.Command {
4444
if err := viper.BindPFlags(cmd.Flags()); err != nil {
4545
return err
4646
}
47-
ghRunnerArgs := params.GithubRunnerArgs()
48-
if ghRunnerArgs != nil {
49-
ghRunnerArgs.Arch = &github.Ppc64le
50-
}
5147
return ibmpower.New(
5248
&maptContext.ContextArgs{
5349
Context: cmd.Context(),
@@ -57,7 +53,7 @@ func ibmPowerCreate() *cobra.Command {
5753
Debug: viper.IsSet(params.Debug),
5854
DebugLevel: viper.GetUint(params.DebugLevel),
5955
CirrusPWArgs: params.CirrusPersistentWorkerArgs(),
60-
GHRunnerArgs: ghRunnerArgs,
56+
GHRunnerArgs: params.GithubRunnerArgs(&github.Ppc64le),
6157
GLRunnerArgs: params.GitLabRunnerArgs(&gitlab.Ppc64le),
6258
Tags: viper.GetStringMapString(params.Tags),
6359
},

cmd/mapt/cmd/ibmcloud/hosts/ibm-z.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ func ibmZCreate() *cobra.Command {
4444
if err := viper.BindPFlags(cmd.Flags()); err != nil {
4545
return err
4646
}
47-
ghRunnerArgs := params.GithubRunnerArgs()
48-
if ghRunnerArgs != nil {
49-
ghRunnerArgs.Arch = &github.S390x
50-
}
5147
return ibmz.New(
5248
&maptContext.ContextArgs{
5349
Context: cmd.Context(),
@@ -57,7 +53,7 @@ func ibmZCreate() *cobra.Command {
5753
Debug: viper.IsSet(params.Debug),
5854
DebugLevel: viper.GetUint(params.DebugLevel),
5955
CirrusPWArgs: params.CirrusPersistentWorkerArgs(),
60-
GHRunnerArgs: ghRunnerArgs,
56+
GHRunnerArgs: params.GithubRunnerArgs(&github.S390x),
6157
GLRunnerArgs: params.GitLabRunnerArgs(&gitlab.S390x),
6258
Tags: viper.GetStringMapString(params.Tags),
6359
},

cmd/mapt/cmd/params/params.go

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package params
22

33
import (
4-
"fmt"
54
"os"
6-
"strings"
75

86
"github.com/redhat-developer/mapt/pkg/integrations/cirrus"
97
"github.com/redhat-developer/mapt/pkg/integrations/github"
@@ -77,14 +75,9 @@ const (
7775
CreateCmdName string = "create"
7876
DestroyCmdName string = "destroy"
7977

80-
ghActionsRunnerToken string = "ghactions-runner-token"
81-
ghActionsRunnerRepo string = "ghactions-runner-repo"
82-
ghActionsRunnerLabels string = "ghactions-runner-labels"
83-
ghActionsRunnerImageRepo string = "ghactions-runner-image-repo"
84-
// TODO: once the RHEL script is merged to https://github.com/IBM/action-runner-image-pz,
85-
// switch default from deekay2310 fork to IBM upstream.
86-
ghActionsRunnerImageRepoDefault string = "https://github.com/deekay2310/action-runner-image-pz.git"
87-
GHActionsRunnerImageRepoDesc string = "Git clone URL for the action-runner-image-pz repository, used to build the GitHub Actions runner from source on ppc64le/s390x (no official binaries exist for these architectures)"
78+
ghActionsRunnerToken string = "ghactions-runner-token"
79+
ghActionsRunnerRepo string = "ghactions-runner-repo"
80+
ghActionsRunnerLabels string = "ghactions-runner-labels"
8881

8982
cirrusPWToken string = "it-cirrus-pw-token"
9083
cirrusPWTokenDesc string = "Add mapt target as a cirrus persistent worker. The value will hold a valid token to be used by cirrus cli to join the project."
@@ -289,10 +282,9 @@ func AddGHActionsFlags(fs *pflag.FlagSet) {
289282
fs.StringP(ghActionsRunnerToken, "", "", GHActionsRunnerTokenDesc)
290283
fs.StringP(ghActionsRunnerRepo, "", "", GHActionsRunnerRepoDesc)
291284
fs.StringSlice(ghActionsRunnerLabels, nil, GHActionsRunnerLabelsDesc)
292-
fs.StringP(ghActionsRunnerImageRepo, "", ghActionsRunnerImageRepoDefault, GHActionsRunnerImageRepoDesc)
293285
}
294286

295-
func GithubRunnerArgs() *github.GithubRunnerArgs {
287+
func GithubRunnerArgs(arch *github.Arch) *github.GithubRunnerArgs {
296288
token := viper.GetString(ghActionsRunnerToken)
297289
repoURL := viper.GetString(ghActionsRunnerRepo)
298290
pat := os.Getenv("GITHUB_TOKEN")
@@ -317,35 +309,18 @@ func GithubRunnerArgs() *github.GithubRunnerArgs {
317309
logging.Info("runner registration token generated successfully")
318310
}
319311

320-
imageRepo := viper.GetString(ghActionsRunnerImageRepo)
321-
if imageRepo != "" {
322-
if err := validateRunnerImageRepo(imageRepo); err != nil {
323-
logging.Errorf("invalid --ghactions-runner-image-repo: %v", err)
324-
return nil
325-
}
326-
if imageRepo != ghActionsRunnerImageRepoDefault {
327-
logging.Infof("using custom runner image repo: %s", imageRepo)
328-
} else {
329-
logging.Debugf("using temporary fork %s; will switch to IBM upstream once RHEL script is merged", imageRepo)
330-
}
312+
if arch == nil {
313+
arch = linuxArchAsGithubActionsArch(viper.GetString(LinuxArch))
331314
}
332315
return &github.GithubRunnerArgs{
333-
Token: token,
334-
RepoURL: repoURL,
335-
Labels: viper.GetStringSlice(ghActionsRunnerLabels),
336-
Platform: &github.Linux,
337-
Arch: linuxArchAsGithubActionsArch(viper.GetString(LinuxArch)),
338-
RunnerImageRepo: imageRepo,
316+
Token: token,
317+
RepoURL: repoURL,
318+
Labels: viper.GetStringSlice(ghActionsRunnerLabels),
319+
Platform: &github.Linux,
320+
Arch: arch,
339321
}
340322
}
341323

342-
func validateRunnerImageRepo(repo string) error {
343-
if !strings.HasPrefix(repo, "https://") {
344-
return fmt.Errorf("only HTTPS URLs are allowed, got: %s", repo)
345-
}
346-
return nil
347-
}
348-
349324
func AddCirrusFlags(fs *pflag.FlagSet) {
350325
fs.StringP(cirrusPWToken, "", "", cirrusPWTokenDesc)
351326
fs.StringToStringP(cirrusPWLabels, "", nil, cirrusPWLabelsDesc)

0 commit comments

Comments
 (0)