Files
coder/codersdk/initscript.go
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
506 B
Go
Raw Normal View History

package codersdk
import (
"context"
"fmt"
"io"
"net/http"
)
func (c *Client) InitScript(ctx context.Context, os, arch string) (string, error) {
url := fmt.Sprintf("/api/v2/init-script/%s/%s", os, arch)
res, err := c.Request(ctx, http.MethodGet, url, nil)
if err != nil {
return "", err
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
return "", ReadBodyAsError(res)
}
script, err := io.ReadAll(res.Body)
if err != nil {
return "", err
}
return string(script), nil
}