Documentation ¶
Overview ¶
Package common contains common functions and types.
It has AWS related functions and types. It also has functions to print the results in different formats.
Package common contains common functions and types.
common defines an important interface that all results must implement. It has AWS related functions and types. It also has functions to print the results in different formats.
Package common contains common functions and types.
It has AWS related functions and types. It also has functions to print the results in different formats.
Package common contains common functions and types.
It has AWS related functions and types. It also has functions to print the results in different formats.
Index ¶
- Constants
- Variables
- func AwsConfig(profile, region string) (aws.Config, error)
- func FilterAvailabilityZones(availabilityZones []string, region string) []types.Filter
- func FilterDefault(key string, values []string) []types.Filter
- func FilterNames(names []string) []types.Filter
- func FilterTags(tags []string) []types.Filter
- func GetAwsProfiles() ([]string, error)
- func IPtoString(i []net.IP) []string
- func ParseTags(tags []string) (map[string][]string, error)
- func PrintResults(w io.Writer, resultsChan <-chan Results, done chan<- bool, output string, ...)
- func String(s string) *string
- func StringInSlice(s string, slice []string) bool
- func StringSliceToString(s []string, sep string) string
- func StringValue(s *string) string
- func StructToFilters(s interface{}) (map[string][]string, error)
- func TagName(tags []types.Tag) string
- func TagsToMap(tags []types.Tag) map[string]string
- func TerminalSize() terminalSize
- func ValidOutputs(o string) (string, bool)
- func WhoAmI(profile, region string) (string, error)
- type Results
Constants ¶
const ( // JSON is the JSON output format. JSON = "json" // JSONPretty is the pretty JSON output format. JSONPretty = "json-pretty" // Table is the table output format. Table = "table" )
Variables ¶
var Bold = toBold
Bold is the function used to bold text.
We use this var to allow tests to mock the function.
Functions ¶
func FilterAvailabilityZones ¶
FilterAvailabilityZones returns a list of types.Filter by availability-zone.
The availabilityZones must be a list of letters that represent the availability zone. For example: "a", "b", "c". The region is used to get the full availability zone name.
func FilterDefault ¶
FilterDefault returns a list of types.Filter. The key is used as filter Name and the values as Values.
func FilterNames ¶
FilterNames returns a list of types.Filter where the filter Name is tag:Name and the names are the Values.
func FilterTags ¶
FilterTags returns a list of types.Filter by tag:Key=Value1,Value2,Value3...
func GetAwsProfiles ¶
GetAwsProfiles returns a list of profiles from the AWS config file.
It is used to get the list of profiles from the AWS config file. The default location is ~/.aws/config.
func IPtoString ¶
IPtoString returns a slice of strings from a slice of IPs.
func ParseTags ¶
ParseTags receives a slice of strings and returns a map of tags and values.
It expects a string in the format of "key1=value1:value2,key2=value3" and returns a map[string][]string{"key1":{"value1","value2"},"key2":{"value3"}}.
func PrintResults ¶
func PrintResults(w io.Writer, resultsChan <-chan Results, done chan<- bool, output string, showEmpty, showTags bool)
PrintResults prints the results in the given format.
The results are read from the resultsChan channel. The done channel is used to signal that the results were printed. The output is the format of the output. The showEmpty flag indicates if empty results should be shown. The showTags flag indicates if the tags should be shown.
func StringInSlice ¶
StringInSlice returns true if the string is in the slice.
func StringSliceToString ¶
StringSliceToString returns a string from a slice of strings.
The separator is the string that will be used to join the strings.
func StringValue ¶
StringValue returns an empty string if the pointer is nil.
func StructToFilters ¶
StructToFilters returns a map of filters from a struct.
The struct must have the tag "filter" in the fields that should be used as filters.
func TerminalSize ¶ added in v0.7.3
func TerminalSize() terminalSize
func ValidOutputs ¶ added in v0.7.3
ValidOutputs returns the valid output formats and if the given output is valid.