Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherHX committed Oct 20, 2024
1 parent e0329d9 commit 1e679d3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion actionsdotnetactcompat/act_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type ActRunner struct {

func (arunner *ActRunner) ExecWorker(run *actionsrunner.RunRunner, wc actionsrunner.WorkerContext, jobreq *protocol.AgentJobRequestMessage, src []byte) error {
if len(arunner.WorkerArgs) <= 0 {
ExecWorker(jobreq, wc)
execWorker(arunner, jobreq, wc)
return nil
}
return arunner.WorkerRunnerEnvironment.ExecWorker(run, wc, jobreq, src)
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ func (run *RunRunner) RunWithContext(listenerctx context.Context, ctx context.Co
},
ApplyConfig: func(config *nrunner.Config, jobreq *protocol.AgentJobRequestMessage) error {
println(jobreq.ContextData["github"].GetString("server_url"))
println(jobreq.ContextData["github"].GetString("api_url"))

return nil
},
}, listenerctx, ctx)
Expand Down
34 changes: 17 additions & 17 deletions protocol/pipeline_context_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import (
)

type DictionaryContextDataPair struct {
Key string `json:"k"`
Value PipelineContextData `json:"v"`
Key string `json:"k"`
Value *PipelineContextData `json:"v"`
}

type PipelineContextData struct {
Type *int32 `json:"t,omitempty"`
BoolValue *bool `json:"b,omitempty"`
NumberValue *float64 `json:"n,omitempty"`
StringValue *string `json:"s,omitempty"`
ArrayValue *[]PipelineContextData `json:"a,omitempty"`
ArrayValue *[]*PipelineContextData `json:"a,omitempty"`
DictionaryValue *[]DictionaryContextDataPair `json:"d,omitempty"`
}

Expand Down Expand Up @@ -50,8 +50,8 @@ func (ctx *PipelineContextData) UnmarshalJSON(data []byte) error {
}
}

func (ctx PipelineContextData) ToRawObject() interface{} {
if ctx.Type == nil {
func (ctx *PipelineContextData) ToRawObject() interface{} {
if ctx == nil || ctx.Type == nil {
return nil
}
switch *ctx.Type {
Expand Down Expand Up @@ -81,36 +81,36 @@ func (ctx PipelineContextData) ToRawObject() interface{} {
return nil
}

func ToPipelineContextDataWithError(data interface{}) (PipelineContextData, error) {
func ToPipelineContextDataWithError(data interface{}) (*PipelineContextData, error) {
if b, ok := data.(bool); ok {
var typ int32 = 3
return PipelineContextData{
return &PipelineContextData{
Type: &typ,
BoolValue: &b,
}, nil
} else if n, ok := data.(float64); ok {
var typ int32 = 4
return PipelineContextData{
return &PipelineContextData{
Type: &typ,
NumberValue: &n,
}, nil
} else if s, ok := data.(string); ok {
var typ int32
return PipelineContextData{
return &PipelineContextData{
Type: &typ,
StringValue: &s,
}, nil
} else if a, ok := data.([]interface{}); ok {
arr := []PipelineContextData{}
arr := []*PipelineContextData{}
for _, v := range a {
e, err := ToPipelineContextDataWithError(v)
if err != nil {
return PipelineContextData{}, err
return nil, err
}
arr = append(arr, e)
}
var typ int32 = 1
return PipelineContextData{
return &PipelineContextData{
Type: &typ,
ArrayValue: &arr,
}, nil
Expand All @@ -119,23 +119,23 @@ func ToPipelineContextDataWithError(data interface{}) (PipelineContextData, erro
for k, v := range o {
e, err := ToPipelineContextDataWithError(v)
if err != nil {
return PipelineContextData{}, err
return nil, err
}
obj = append(obj, DictionaryContextDataPair{Key: k, Value: e})
}
var typ int32 = 2
return PipelineContextData{
return &PipelineContextData{
Type: &typ,
DictionaryValue: &obj,
}, nil
}
if data == nil {
return PipelineContextData{}, nil
return nil, nil
}
return PipelineContextData{}, fmt.Errorf("unknown type")
return nil, fmt.Errorf("unknown type")
}

func ToPipelineContextData(data interface{}) PipelineContextData {
func ToPipelineContextData(data interface{}) *PipelineContextData {
ret, err := ToPipelineContextDataWithError(data)
if err != nil {
panic(err)
Expand Down

0 comments on commit 1e679d3

Please sign in to comment.