Skip to content

Commit

Permalink
gce g1-small, f1-micro instance type price fixed (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
prekoa authored and martonsereg committed Jul 30, 2018
1 parent 8ff0336 commit df5af19
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ ineffassign: install-ineffassign
ineffassign ${GOFILES_NOVENDOR}

gocyclo: install-gocyclo
gocyclo -over 18 ${GOFILES_NOVENDOR}
gocyclo -over 19 ${GOFILES_NOVENDOR}

install-go-junit-report:
GOLINT_CMD=$(shell command -v go-junit-report 2> /dev/null)
Expand Down
9 changes: 7 additions & 2 deletions pkg/productinfo/gce/productinfo_gce.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,19 @@ func (g *GceInfoer) Initialize() (map[string]map[string]productinfo.Price, error
if sku.Category.ResourceFamily != "Compute" {
continue
} else {
// TODO: f1-micro?
if strings.Contains(sku.Description, "VCPU") {
if strings.Contains(sku.Description, "CPU") {

vcpus := strings.Split(g.cpuRegex.FindString(sku.Description), " ")[0]
resourceGroup := strings.ToLower(sku.Category.ResourceGroup)
prefix := g.resourceGroupRegex.FindString(resourceGroup)
instanceType := fmt.Sprintf("%s-%s", strings.Join(strings.SplitAfter(resourceGroup, prefix), "-"), vcpus)

switch instanceType {
case "f1-micro-":
instanceType = "f1-micro"
case "g1-small-1":
instanceType = "g1-small"
}
if len(sku.PricingInfo) != 1 {
return fmt.Errorf("pricing info not parsable, %d pricing info entries are returned", len(sku.PricingInfo))
}
Expand Down

0 comments on commit df5af19

Please sign in to comment.