MCPcopy
hub / github.com/argoproj/argo-workflows / do

Method do

pkg/apiclient/http1/facade.go:93–143  ·  view source on GitHub ↗
(ctx context.Context, in interface{}, out interface{}, method string, path string)

Source from the content-addressed store, hash-verified

91}
92
93func (h Facade) do(ctx context.Context, in interface{}, out interface{}, method string, path string) error {
94 log := logging.RequireLoggerFromContext(ctx)
95 var data []byte
96 if method != "GET" && method != "DELETE" {
97 var err error
98 data, err = json.Marshal(in)
99 if err != nil {
100 return err
101 }
102 }
103 u, err := h.url(method, path, in)
104 if err != nil {
105 return err
106 }
107 req, err := http.NewRequestWithContext(ctx, method, u.String(), bytes.NewReader(data))
108 if err != nil {
109 return err
110 }
111 headers, err := parseHeaders(h.headers)
112 if err != nil {
113 return err
114 }
115 req.Header = headers
116 req.Header.Set("Authorization", h.authorization)
117 log.WithFields(logging.Fields{"url": u, "method": method, "data": string(data)}).Debug(ctx, "curl -X")
118 client := h.httpClient
119 if h.httpClient == nil {
120 client = &http.Client{
121 Transport: &http.Transport{
122 TLSClientConfig: &tls.Config{
123 InsecureSkipVerify: h.insecureSkipVerify,
124 },
125 DisableKeepAlives: true,
126 },
127 }
128 }
129 resp, err := client.Do(req)
130 if err != nil {
131 return err
132 }
133 defer resp.Body.Close()
134 err = errFromResponse(resp)
135 if err != nil {
136 return err
137 }
138 if out != nil {
139 return json.NewDecoder(resp.Body).Decode(out)
140 } else {
141 return nil
142 }
143}
144
145func (h Facade) url(method, path string, in interface{}) (*url.URL, error) {
146 query := url.Values{}

Callers 4

GetMethod · 0.95
PutMethod · 0.95
PostMethod · 0.95
DeleteMethod · 0.95

Calls 12

urlMethod · 0.95
RequireLoggerFromContextFunction · 0.92
parseHeadersFunction · 0.85
errFromResponseFunction · 0.85
NewDecoderMethod · 0.80
DebugMethod · 0.65
WithFieldsMethod · 0.65
DoMethod · 0.65
CloseMethod · 0.65
MarshalMethod · 0.45
StringMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected