MCPcopy Index your code
hub / github.com/coder/coder / readAWSInstanceMetadata

Function readAWSInstanceMetadata

coderd/workspaceresourceauth_test.go:483–504  ·  view source on GitHub ↗
(
	ctx context.Context,
	t testing.TB,
	metadataClient *http.Client,
	path string,
)

Source from the content-addressed store, hash-verified

481}
482
483func readAWSInstanceMetadata(
484 ctx context.Context,
485 t testing.TB,
486 metadataClient *http.Client,
487 path string,
488) string {
489 t.Helper()
490
491 req, err := http.NewRequestWithContext(
492 ctx,
493 http.MethodGet,
494 awsInstanceIdentityMetadataURL+"/"+path,
495 nil,
496 )
497 require.NoError(t, err)
498 res, err := metadataClient.Do(req)
499 require.NoError(t, err)
500 defer res.Body.Close()
501 body, err := io.ReadAll(res.Body)
502 require.NoError(t, err)
503 return string(body)
504}
505
506func newTestInstanceID(t testing.TB) string {
507 t.Helper()

Callers 1

postAWSInstanceIdentityFunction · 0.85

Calls 4

HelperMethod · 0.65
DoMethod · 0.65
CloseMethod · 0.65
ReadAllMethod · 0.45

Tested by

no test coverage detected