cloud

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDetectorNotInitialized is the error returned when the Detector is not initialized yet.
	ErrDetectorNotInitialized = errors.New("cloud detector not initialized yet")
	// ErrCouldNotDetect is the error returned when the Detector could not be initialized.
	ErrCouldNotDetect = errors.New("detector is unable to detect the cloud type")
	// ErrMethodNotImplemented is the error returned when a method is still not implemented by an implementation.
	ErrMethodNotImplemented = errors.New("cloud harvester does not implement the method")
)

Functions

func GetAzureMetadata

func GetAzureMetadata(disableKeepAlive bool) (result *azureMetadata, err error)

GetAzureMetadata is used to request metadata from Azure API.

func GetGCPMetadata

func GetGCPMetadata(disableKeepAlive bool) (result *gcpMetadata, err error)

GetGCPMetadata is used to request metadata from GCP API.

Types

type AWSHarvester

type AWSHarvester struct {
	// contains filtered or unexported fields
}

AWSHarvester is used to fetch data from AWS api.

func NewAWSHarvester

func NewAWSHarvester(disableKeepAlive bool) *AWSHarvester

NewAWSHarvester returns a new instance of AWSHarvester.

func (*AWSHarvester) GetAWSMetadataValue

func (a *AWSHarvester) GetAWSMetadataValue(fieldName string, disableKeepAlive bool) (data string, err error)

GetAWSMetadataValue is used to request metadata from aws API.

func (*AWSHarvester) GetAccountID

func (a *AWSHarvester) GetAccountID() (string, error)

GetAccount will return the cloud account.

func (*AWSHarvester) GetCloudSource

func (a *AWSHarvester) GetCloudSource() string

GetCloudSource returns a string key which will be used as a HostSource (see host_aliases plugin).

func (*AWSHarvester) GetCloudType

func (a *AWSHarvester) GetCloudType() Type

GetCloudType returns the type of the cloud.

func (*AWSHarvester) GetHarvester

func (a *AWSHarvester) GetHarvester() (Harvester, error)

GetHarvester returns instance of the Harvester detected (or instance of themselves)

func (*AWSHarvester) GetHostType

func (a *AWSHarvester) GetHostType() (string, error)

GetHostType will return the cloud instance type.

func (*AWSHarvester) GetInstanceID

func (a *AWSHarvester) GetInstanceID() (string, error)

GetInstanceID returns the AWS instance ID.

func (*AWSHarvester) GetInstanceImageID

func (a *AWSHarvester) GetInstanceImageID() (string, error)

GetImageID will return the cloud image ID.

func (*AWSHarvester) GetRegion

func (a *AWSHarvester) GetRegion() (string, error)

GetRegion will return the cloud region.

func (*AWSHarvester) GetZone

func (a *AWSHarvester) GetZone() (string, error)

GetAvailability will return the cloud availability zone.

type AlibabaHarvester

type AlibabaHarvester struct {
	// contains filtered or unexported fields
}

AlibabaHarvester is used to fetch data from Alibaba api.

func NewAlibabaHarvester

func NewAlibabaHarvester(disableKeepAlive bool) *AlibabaHarvester

AlibabaHarvester returns a new instance of AlibabaHarvester.

func (*AlibabaHarvester) GetAccountID

func (a *AlibabaHarvester) GetAccountID() (string, error)

GetAccount will return the cloud account.

func (*AlibabaHarvester) GetCloudSource

func (a *AlibabaHarvester) GetCloudSource() string

GetCloudSource returns a string key which will be used as a HostSource (see host_aliases plugin).

func (*AlibabaHarvester) GetCloudType

func (a *AlibabaHarvester) GetCloudType() Type

GetCloudType returns the type of the cloud.

func (*AlibabaHarvester) GetHarvester

func (a *AlibabaHarvester) GetHarvester() (Harvester, error)

GetHarvester returns instance of the Harvester detected (or instance of themselves)

func (*AlibabaHarvester) GetHostType

func (a *AlibabaHarvester) GetHostType() (string, error)

GetHostType will return the cloud instance type.

func (*AlibabaHarvester) GetInstanceID

func (a *AlibabaHarvester) GetInstanceID() (string, error)

GetInstanceID returns the Alibaba instance ID.

func (*AlibabaHarvester) GetInstanceImageID

func (a *AlibabaHarvester) GetInstanceImageID() (string, error)

GetImageID will return the cloud image ID.

func (*AlibabaHarvester) GetRegion

func (a *AlibabaHarvester) GetRegion() (string, error)

GetRegion will return the cloud instance region.

func (*AlibabaHarvester) GetZone

func (a *AlibabaHarvester) GetZone() (string, error)

GetAvailability will return the cloud availability zone.

type AlibabaMetadata

type AlibabaMetadata struct {
	RegionID        string `json:"region-id"`
	InstanceID      string `json:"instance-id"`
	InstanceType    string `json:"instance-type"`
	InstanceImageID string `json:"image-id"`
	AccountID       string `json:"owner-account-id"`
	Zone            string `json:"zone-id"`
}

Captures the fields we care about from the Alibaba metadata API

func GetAlibabaMetadata

func GetAlibabaMetadata(disableKeepAlive bool) (result *AlibabaMetadata, err error)

GetAlibabaMetadata is used to request metadata from Alibaba API.

type AzureHarvester

type AzureHarvester struct {
	// contains filtered or unexported fields
}

AzureHarvester is used to fetch data from Azure api.

func NewAzureHarvester

func NewAzureHarvester(disableKeepAlive bool) *AzureHarvester

AzureHarvester returns a new instance of AzureHarvester.

func (*AzureHarvester) GetAccountID

func (a *AzureHarvester) GetAccountID() (string, error)

GetAccountID returns the cloud account

func (*AzureHarvester) GetCloudSource

func (a *AzureHarvester) GetCloudSource() string

GetCloudSource returns a string key which will be used as a HostSource (see host_aliases plugin).

func (*AzureHarvester) GetCloudType

func (a *AzureHarvester) GetCloudType() Type

GetCloudType returns the type of the cloud.

func (*AzureHarvester) GetHarvester

func (a *AzureHarvester) GetHarvester() (Harvester, error)

func (*AzureHarvester) GetHostType

func (a *AzureHarvester) GetHostType() (string, error)

GetHostType will return the cloud instance type.

func (*AzureHarvester) GetInstanceID

func (a *AzureHarvester) GetInstanceID() (string, error)

GetInstanceID returns the Azure instance ID.

func (*AzureHarvester) GetInstanceImageID

func (a *AzureHarvester) GetInstanceImageID() (string, error)

GetInstanceImageID returns the cloud instance image ID

func (*AzureHarvester) GetRegion

func (a *AzureHarvester) GetRegion() (string, error)

GetRegion will return the cloud instance region.

func (*AzureHarvester) GetZone

func (a *AzureHarvester) GetZone() (string, error)

GetZone returns the cloud instance zone

type Detector

type Detector struct {
	// contains filtered or unexported fields
}

Detector is used to detect the cloud type on which the instance is running and can be queried in order to get the information needed.

func NewDetector

func NewDetector(disableCloudMetadata bool, maxRetriesNumber, retryBackOffSec, expiryInSec int, disableKeepAlive bool) *Detector

NewDetector returns a new Detector instance.

func (*Detector) GetAccountID

func (d *Detector) GetAccountID() (string, error)

GetHostType will return the cloud instance type.

func (*Detector) GetCloudSource

func (d *Detector) GetCloudSource() string

GetCloudSource Returns a string key which will be used as a HostSource (see host_aliases plugin).

func (*Detector) GetCloudType

func (d *Detector) GetCloudType() Type

GetCloudType will return the cloud type on which the instance is running.

func (*Detector) GetHarvester

func (d *Detector) GetHarvester() (Harvester, error)

func (*Detector) GetHostType

func (d *Detector) GetHostType() (string, error)

GetHostType will return the cloud instance type.

func (*Detector) GetInstanceID

func (d *Detector) GetInstanceID() (string, error)

GetInstanceID will return the id of the cloud instance.

func (*Detector) GetInstanceImageID

func (d *Detector) GetInstanceImageID() (string, error)

GetRegion will return the region of cloud instance.

func (*Detector) GetRegion

func (d *Detector) GetRegion() (string, error)

GetRegion will return the region of cloud instance.

func (*Detector) GetZone

func (d *Detector) GetZone() (string, error)

GetCloudType will return the cloud type on which the instance is running.

func (*Detector) Initialize

func (d *Detector) Initialize()

Initialize should be called in order to Detect the cloud harvester.

type GCPHarvester

type GCPHarvester struct {
	// contains filtered or unexported fields
}

GCPHarvester is used to fetch data from GCP API.

func NewGCPHarvester

func NewGCPHarvester(disableKeepAlive bool) *GCPHarvester

NewGCPHarvester return a new GCPHarvester instance.

func (*GCPHarvester) GetAccountID

func (gcp *GCPHarvester) GetAccountID() (string, error)

GetAccountID returns the cloud account

func (*GCPHarvester) GetCloudSource

func (gcp *GCPHarvester) GetCloudSource() string

GetCloudSource returns a string key which will be used as a HostSource (see host_aliases plugin).

func (*GCPHarvester) GetCloudType

func (gcp *GCPHarvester) GetCloudType() Type

GetCloudType returns the type of the cloud.

func (*GCPHarvester) GetHarvester

func (gcp *GCPHarvester) GetHarvester() (Harvester, error)

func (*GCPHarvester) GetHostType

func (gcp *GCPHarvester) GetHostType() (string, error)

GetHostType will return the cloud instance type.

func (*GCPHarvester) GetInstanceID

func (gcp *GCPHarvester) GetInstanceID() (string, error)

GetInstanceID returns the gcp instance ID.

func (*GCPHarvester) GetInstanceImageID

func (gcp *GCPHarvester) GetInstanceImageID() (string, error)

GetInstanceImageID returns the cloud instance image ID

func (*GCPHarvester) GetRegion

func (gcp *GCPHarvester) GetRegion() (string, error)

GetRegion will return the cloud instance region.

func (*GCPHarvester) GetZone

func (gcp *GCPHarvester) GetZone() (string, error)

GetZone returns the cloud instance zone

type Harvester

type Harvester interface {
	// GetInstanceID will return the id of the cloud instance.
	GetInstanceID() (string, error)
	// GetHostType will return the cloud instance type.
	GetHostType() (string, error)
	// GetCloudType will return the cloud type on which the instance is running.
	GetCloudType() Type
	// Returns a string key which will be used as a HostSource (see host_aliases plugin).
	GetCloudSource() string
	// GetRegion returns the cloud region
	GetRegion() (string, error)
	// GetAccountID returns the cloud account
	GetAccountID() (string, error)
	// GetZone returns the cloud instance zone
	GetZone() (string, error)
	// GetInstanceImageID returns the cloud instance image ID
	GetInstanceImageID() (string, error)
	// GetHarvester returns instance of the Harvester detected (or instance of themselves)
	GetHarvester() (Harvester, error)
}

Harvester is the interfaces that should be implemented by any cloud harvester.

type Timeout

type Timeout struct {
	// contains filtered or unexported fields
}

Timeout is used to check if a period of time has passed.

func NewTimeout

func NewTimeout(seconds int) *Timeout

NewTimeout will create a new Timeout instance.

func (*Timeout) HasExpired

func (t *Timeout) HasExpired() bool

HasExpired will check if the timeout has expired.

type Type

type Type string

The type of the cloud on which the instance is running.

const (
	TypeNoCloud    Type = "no_cloud"    // No cloud type has been detected.
	TypeInProgress Type = "in_progress" // Cloud detection is in progress.
	TypeAWS        Type = "aws"         // This instance is running in aws.
	TypeAzure      Type = "azure"       // This instance is running in Azure.
	TypeGCP        Type = "gcp"         // This instance is running in gcp.
	TypeAlibaba    Type = "alibaba"     // This instance is running in alibaba.
)

func (Type) IsValidCloud

func (t Type) IsValidCloud() bool

func (Type) ShouldCollect

func (t Type) ShouldCollect() bool

ShouldCollect returns true if we should collect data for this cloud type.

Jump to

Keyboard shortcuts

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