You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* fixed issue with OD pricing for european regions
* made string replacement more readable in getRegionForPricingAPI
* implemented sorting of instance types
* fixed typo in filtering error message
* moved sort to selector.go and refactored FilterVerbose tests
* brought back FilterWithOutput() in selector.go
* working implementation of refactoring solution
* added method comments
* converted Filter and FilterVerbose tests to TestGetFilteredOutput tests
* added filtering and output tests
* split filter functions into fetching filtered types and outputing types
* removed OutputInstanceTypes. Output functions only in Outputs.go
* fixed typos and updated function comments
* fixed invalid maxResults check in main
* added error to TruncateResults for negative values
* updated error message for formatting instance types
* reduced the amount of times pricing caches are refreshed
* fixed cache refresh related comments
Co-authored-by: Rodrigo Okamoto <rodocp@amazon.com>
@@ -138,9 +143,8 @@ Full docs can be found at github.com/aws/amazon-` + binName
138
143
cliOutputTypes:= []string{
139
144
tableOutput,
140
145
tableWideOutput,
141
-
oneLine,
146
+
oneLineOutput,
142
147
}
143
-
resultsOutputFn:=outputs.SimpleInstanceTypeOutput
144
148
145
149
// Registers flags with specific input types from the cli pkg
146
150
// Filter Flags - These will be grouped at the top of the help flags
@@ -200,7 +204,7 @@ Full docs can be found at github.com/aws/amazon-` + binName
200
204
cli.ConfigIntFlag(maxResults, nil, env.WithDefaultInt("EC2_INSTANCE_SELECTOR_MAX_RESULTS", 20), "The maximum number of instance types that match your criteria to return")
201
205
cli.ConfigStringFlag(profile, nil, nil, "AWS CLI profile to use for credentials and config", nil)
202
206
cli.ConfigStringFlag(region, cli.StringMe("r"), nil, "AWS Region to use for API requests (NOTE: if not passed in, uses AWS SDK default precedence)", nil)
203
-
cli.ConfigStringFlag(output, cli.StringMe("o"), nil, fmt.Sprintf("Specify the output format (%s)", strings.Join(cliOutputTypes, ", ")), nil)
207
+
cli.ConfigStringFlag(output, cli.StringMe("o"), cli.StringMe(simpleOutput), fmt.Sprintf("Specify the output format (%s)", strings.Join(cliOutputTypes, ", ")), nil)
204
208
cli.ConfigIntFlag(cacheTTL, nil, env.WithDefaultInt("EC2_INSTANCE_SELECTOR_CACHE_TTL", 168), "Cache TTLs in hours for pricing and instance type caches. Setting the cache to 0 will turn off caching and cleanup any on-disk caches.")
205
209
cli.ConfigPathFlag(cacheDir, nil, env.WithDefaultString("EC2_INSTANCE_SELECTOR_CACHE_DIR", "~/.ec2-instance-selector/"), "Directory to save the pricing and instance type caches")
206
210
cli.ConfigBoolFlag(verbose, cli.StringMe("v"), nil, "Verbose - will print out full instance specs")
@@ -237,30 +241,6 @@ Full docs can be found at github.com/aws/amazon-` + binName
237
241
}
238
242
}
239
243
registerShutdown(shutdown)
240
-
outputFlag:=cli.StringMe(flags[output])
241
-
ifoutputFlag!=nil&&*outputFlag==tableWideOutput {
242
-
// If output type is `table-wide`, simply print both prices for better comparison,
243
-
// even if the actual filter is applied on any one of those based on usage class
log.Println("The criteria was too narrow and returned no valid instance types. Consider broadening your criteria so that more instance types are returned.")
350
346
os.Exit(1)
351
347
}
352
348
349
+
// print output
353
350
for_, instanceType:=rangeinstanceTypes {
354
351
fmt.Println(instanceType)
355
352
}
@@ -360,60 +357,6 @@ Full docs can be found at github.com/aws/amazon-` + binName
0 commit comments