11package params
22
33import (
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-
349324func AddCirrusFlags (fs * pflag.FlagSet ) {
350325 fs .StringP (cirrusPWToken , "" , "" , cirrusPWTokenDesc )
351326 fs .StringToStringP (cirrusPWLabels , "" , nil , cirrusPWLabelsDesc )
0 commit comments