-
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathmisc.go
More file actions
142 lines (124 loc) · 3.51 KB
/
misc.go
File metadata and controls
142 lines (124 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package protocol
import (
"fmt"
"strings"
)
type RunnerAddRemove struct {
URL string `json:"url"`
RunnerEvent string `json:"runner_event"`
}
type GitHubRunnerRegisterToken struct {
Token string `json:"token"`
ExpiresAt string `json:"expires_at"`
}
type GitHubAuthResult struct {
TenantURL string `json:"url"`
TokenSchema string `json:"token_schema"`
Token string `json:"token"`
UseV2FLow bool `json:"use_v2_flow"`
}
type TaskOrchestrationPlanReference struct {
ScopeIdentifier string
PlanID string
PlanType string
Version int32
}
type JobAuthorization struct {
Parameters map[string]string
Scheme string
}
type JobEndpoint struct {
Data map[string]string
Name string
URL string
Authorization JobAuthorization
IsShared bool
IsReady bool
}
type JobResources struct {
Endpoints []JobEndpoint
}
type WorkspaceOptions struct {
Clean *string `json:",omitempty"`
}
type MaskHint struct {
Type string
Value string
}
type ActionsEnvironmentReference struct {
Name *string `json:",omitempty"`
URL *string `json:",omitempty"`
}
type ActionStepDefinitionReference struct {
Type string
Image string
Name string
Ref string
RepositoryType string
Path string
}
type ActionStep struct {
ID string
Type string
Reference ActionStepDefinitionReference
DisplayNameToken *TemplateToken
ContextName string
Environment *TemplateToken
Inputs *TemplateToken
Condition string
ContinueOnError *TemplateToken
TimeoutInMinutes *TemplateToken
}
type AgentJobRequestMessage struct {
MessageType string
Plan *TaskOrchestrationPlanReference
Timeline *TimeLineReference
JobID string
JobDisplayName string
JobName string
JobContainer *TemplateToken
JobServiceContainers *TemplateToken
JobOutputs *TemplateToken
RequestID int64
LockedUntil string
Resources *JobResources
ContextData map[string]PipelineContextData
Workspace *WorkspaceOptions
MaskHints []MaskHint `json:"mask"`
EnvironmentVariables []TemplateToken
Defaults []TemplateToken
ActionsEnvironment *ActionsEnvironmentReference
Variables map[string]VariableValue
Steps []ActionStep
FileTable []string
}
func (jobreq *AgentJobRequestMessage) GetConnection(name string) (*VssConnection, map[string]string, error) {
if jobreq.Resources == nil {
return nil, nil, fmt.Errorf("missing resources")
}
if jobreq.Resources.Endpoints == nil {
return nil, nil, fmt.Errorf("missing resources.endpoints")
}
for _, endpoint := range jobreq.Resources.Endpoints {
if strings.EqualFold(endpoint.Name, name) {
con := &VssConnection{
TenantURL: endpoint.URL,
}
if endpoint.Authorization.Parameters != nil {
con.Token = endpoint.Authorization.Parameters["AccessToken"]
}
return con, endpoint.Data, nil
}
}
return nil, nil, fmt.Errorf("no connection with name '%v' found", name)
}
type RenewAgent struct {
RequestID int64
}
type VssOAuthTokenResponse struct {
AccessToken string `json:"access_token"`
ExpiresIn int `json:"expires_in"`
TokenType string `json:"token_type"`
}
var TimestampInputFormat = "2006-01-02T15:04:05.9999999Z07:00" // allow to omit fractional seconds
var TimestampOutputFormat = "2006-01-02T15:04:05.0000000Z07:00" // dotnet "O"