77 "fmt"
88 "math/big"
99 "strconv"
10+ "strings"
1011
1112 "github.com/ChristopherHX/github-act-runner/common"
1213 "github.com/ChristopherHX/github-act-runner/protocol"
@@ -24,19 +25,30 @@ type DotnetRsaParameters struct {
2425 Q []byte `json:"q"`
2526}
2627
28+ type DotnetBoolean bool
29+
30+ func (b * DotnetBoolean ) UnmarshalJSON (data []byte ) error {
31+ var v bool
32+ if err := json .Unmarshal ([]byte (strings .Trim (strings .ToLower (string (data )), "\" " )), & v ); err != nil {
33+ return err
34+ }
35+ * b = DotnetBoolean (v )
36+ return nil
37+ }
38+
2739type DotnetAgent struct {
28- AgentID string `json:"AgentId"`
29- AgentName string `json:"AgentName"`
30- DisableUpdate string `json:"DisableUpdate"`
31- Ephemeral string `json:"Ephemeral"`
32- PoolID string `json:"PoolId"`
33- PoolName string `json:"PoolName,omitempty"`
34- ServerURL string `json:"ServerUrl"`
35- WorkFolder string `json:"WorkFolder"`
36- GitHubURL string `json:"GitHubUrl"`
37- UseV2Flow bool `json:"UseV2Flow"`
38- ServerURLV2 string `json:"ServerUrlV2"`
39- UseRunnerAdminFlow bool `json:"UseRunnerAdminFlow,omitempty"`
40+ AgentID string `json:"AgentId"`
41+ AgentName string `json:"AgentName"`
42+ DisableUpdate string `json:"DisableUpdate"`
43+ Ephemeral string `json:"Ephemeral"`
44+ PoolID string `json:"PoolId"`
45+ PoolName string `json:"PoolName,omitempty"`
46+ ServerURL string `json:"ServerUrl"`
47+ WorkFolder string `json:"WorkFolder"`
48+ GitHubURL string `json:"GitHubUrl"`
49+ UseV2Flow DotnetBoolean `json:"UseV2Flow"`
50+ ServerURLV2 string `json:"ServerUrlV2"`
51+ UseRunnerAdminFlow DotnetBoolean `json:"UseRunnerAdminFlow,omitempty"`
4052}
4153
4254type DotnetCredentials struct {
@@ -45,9 +57,9 @@ type DotnetCredentials struct {
4557}
4658
4759type DotnetCredentialsData struct {
48- ClientID string `json:"ClientId"`
49- AuthorizationURL string `json:"AuthorizationUrl"`
50- RequireFipsCryptography bool `json:"RequireFipsCryptography"`
60+ ClientID string `json:"ClientId"`
61+ AuthorizationURL string `json:"AuthorizationUrl"`
62+ RequireFipsCryptography DotnetBoolean `json:"RequireFipsCryptography"`
5163}
5264
5365func BytesToBigInt (bytes []byte ) * big.Int {
@@ -171,7 +183,7 @@ func ToRunnerInstance(fileAccess ConfigFileAccess) (*runnerconfiguration.RunnerI
171183 PoolID : poolID ,
172184 Auth : & protocol.GitHubAuthResult {
173185 TenantURL : agent .ServerURL ,
174- UseV2FLow : agent .UseRunnerAdminFlow ,
186+ UseV2FLow : bool ( agent .UseRunnerAdminFlow ) ,
175187 },
176188 PKey : FromRsaParameters (rsaParameters ),
177189 Agent : & protocol.TaskAgent {
@@ -208,9 +220,9 @@ func FromRunnerInstance(instance *runnerconfiguration.RunnerInstance, fileAccess
208220 ServerURL : serverURL ,
209221 WorkFolder : instance .WorkFolder ,
210222 GitHubURL : instance .RegistrationURL ,
211- UseV2Flow : useV2Flow ,
223+ UseV2Flow : DotnetBoolean ( useV2Flow ) ,
212224 ServerURLV2 : serverV2URL ,
213- UseRunnerAdminFlow : instance .Auth .UseV2FLow ,
225+ UseRunnerAdminFlow : DotnetBoolean ( instance .Auth .UseV2FLow ) ,
214226 }
215227 if agent .WorkFolder == "" {
216228 agent .WorkFolder = "_work"
@@ -223,7 +235,7 @@ func FromRunnerInstance(instance *runnerconfiguration.RunnerInstance, fileAccess
223235 AuthorizationURL : instance .Agent .Authorization .AuthorizationURL ,
224236 // serverV2URL != "" means recent GitHub Server that requires recent actions/runner
225237 // that has received this bugfix https://github.com/actions/runner/pull/3789
226- RequireFipsCryptography : requireFipsCryptography && hasRequireFipsCryptography || serverV2URL != "" ,
238+ RequireFipsCryptography : DotnetBoolean ( requireFipsCryptography && hasRequireFipsCryptography || serverV2URL != "" ) ,
227239 },
228240 }
229241 if err := fileAccess .Write (".runner" , agent ); err != nil {
0 commit comments