MCPcopy Create free account
hub / github.com/danderson/netboot / GetBootURL

Method GetBootURL

pixiecore/boot_configuration.go:85–102  ·  view source on GitHub ↗

GetBootURL returns Boot File URL, see RFC 5970

(id []byte, clientArchType uint16)

Source from the content-addressed store, hash-verified

83
84// GetBootURL returns Boot File URL, see RFC 5970
85func (bc *APIBootConfiguration) GetBootURL(id []byte, clientArchType uint16) ([]byte, error) {
86 reqURL := fmt.Sprintf("%s/boot/%x/%d", bc.URLPrefix, id, clientArchType)
87 resp, err := bc.Client.Get(reqURL)
88 if err != nil {
89 return nil, err
90 }
91 if resp.StatusCode != http.StatusOK {
92 resp.Body.Close()
93 return nil, fmt.Errorf("%s: %s", reqURL, http.StatusText(resp.StatusCode))
94 }
95 defer resp.Body.Close()
96
97 buf := new(bytes.Buffer)
98 buf.ReadFrom(resp.Body)
99 url, _ := bc.makeURLAbsolute(buf.String())
100
101 return []byte(url), nil
102}
103
104func (bc *APIBootConfiguration) makeURLAbsolute(urlStr string) (string, error) {
105 u, err := url.Parse(urlStr)

Callers

nothing calls this directly

Calls 3

makeURLAbsoluteMethod · 0.95
CloseMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected