ec2

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package ec2 contains the EC2 search functions.

It implements the common.Results interface

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSortFields

func GetSortFields(f string) (map[string]string, error)

GetSortFields returns a map of the sort fields and their corresponding struct field.

The sort fields are defined in the struct tag `sort`. The function returns an error if the given field is not a valid sort field.

func SearchInstanceName

func SearchInstanceName(profile, region, instanceID string) (string, error)

SearchInstanceName returns the name of an instance.

It returns the value of the tag:Name or empty string in case that the instance has no name.

Types

type Results

type Results struct {
	// Profile is the profile used to search.
	Profile string `json:"profile"`

	// Region is the region used to search.
	Region string `json:"region"`

	// Errors contains the erros found during the search.
	Errors []string `json:"errors,omitempty"`

	// Data contains the instances found.
	Data []dataRow `json:"data"`

	// Filters is a map of strings used to search.
	Filters map[string][]string `json:"-"`

	// SortField is the field used to sort the results.
	SortField string `json:"-"`
}

Results describes results of the EC2 instances search.

func New

func New(profile, region string, filters map[string][]string, sortField string) *Results

New initiates and returns a new instance of EC2 results.

func (*Results) GetErrors

func (r *Results) GetErrors() []string

GetErrors returns the errors found during the search.

func (*Results) GetHeaders

func (r *Results) GetHeaders() []interface{}

GetHeaders returns the the tag `header` of the struct fields.

func (*Results) GetProfile

func (r *Results) GetProfile() string

GetProfile returns the profile used to search.

func (*Results) GetRegion

func (r *Results) GetRegion() string

GetRegion returns the region used to search.

func (*Results) GetRows

func (r *Results) GetRows() []interface{}

GetRows iterates results.Data and returns the results as a slice of interface{}.

func (*Results) GetSortField

func (r *Results) GetSortField() string

GetSortField returns the field used to sort the results.

func (*Results) Len

func (r *Results) Len() int

Len returns the length of the results.

func (*Results) Search

func (r *Results) Search()

Search performs the EC2s search.

results are stored in the Data field.

Jump to

Keyboard shortcuts

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