metadatafs

package
v0.0.0-...-98f36a1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IMDSv1Client

type IMDSv1Client struct {
	Client   *http.Client
	Endpoint string
	Logger   logger.LeveledLogger
}

IMDSv1Client wraps an HTTP client to access v1 of the Instance Metadata Service API

func NewIMDSv1Client

func NewIMDSv1Client(endpoint string, l logger.LeveledLogger) *IMDSv1Client

NewIMDSv1Client returns a new IMDSv1Client

func (*IMDSv1Client) Get

func (c *IMDSv1Client) Get(path string) (*http.Response, error)

Get issues a GET request to the given path

func (*IMDSv1Client) Head

func (c *IMDSv1Client) Head(path string) (*http.Response, error)

Head issues a HEAD request to the given path

type IMDSv2Client

type IMDSv2Client struct {
	Client   *http.Client
	Endpoint string
	TokenTTL time.Duration
	Logger   logger.LeveledLogger
	// contains filtered or unexported fields
}

IMDSv2Client wraps an HTTP client to access v2 of the Instance Metadata Service API

func NewIMDSv2Client

func NewIMDSv2Client(endpoint string, tokenTTL time.Duration, l logger.LeveledLogger) *IMDSv2Client

NewIMDSv2Client returns a new IMDSv2Client

func (*IMDSv2Client) Get

func (c *IMDSv2Client) Get(path string) (*http.Response, error)

Get issues a GET request to the given path, refreshing the access token if needed

func (*IMDSv2Client) Head

func (c *IMDSv2Client) Head(path string) (*http.Response, error)

Head issues a HEAD request to the given path, refreshing the access token if needed

type Logger

type Logger interface {
	Fatalf(m string, args ...interface{})
	Debugf(m string, args ...interface{})
	Errorf(m string, args ...interface{})
	Infof(m string, args ...interface{})
	Warningf(m string, args ...interface{})
}

Logger is an interface that specifies methods that are needed for leveled logging

type MetadataClient

type MetadataClient interface {
	Head(path string) (resp *http.Response, err error)
	Get(path string) (resp *http.Response, err error)
}

MetadataClient is a client for accessing the AWS Instance Metadata Service

type MetadataFs

type MetadataFs struct {
	pathfs.FileSystem

	Client MetadataClient

	Logger logger.LeveledLogger
}

MetadataFs represents a filesystem that exposes metadata about EC2 instances Satisfies pathfs.FileSystem

func New

New initializes a new MetadataFs that uses the given endpoint as the target of metadata requests

func (*MetadataFs) GetAttr

func (fs *MetadataFs) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status)

GetAttr returns an fuse.Attr representing a read-only file or directory

func (*MetadataFs) Open

func (fs *MetadataFs) Open(name string, flags uint32, context *fuse.Context) (file nodefs.File, code fuse.Status)

Open returns a datafile representing the HTTP response body

func (*MetadataFs) OpenDir

func (fs *MetadataFs) OpenDir(name string, context *fuse.Context) (c []fuse.DirEntry, code fuse.Status)

OpenDir returns the list of paths under the given path

func (*MetadataFs) StatFs

func (fs *MetadataFs) StatFs(name string) *fuse.StatfsOut

StatFs returns the statistics of the filesystem

Currently stubbed to return the empty struct to satisfy programs like `df` until we are able to implement accurate filesystem statistics

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL