Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.1.0
current_version = 0.2.0
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion cmd/boltdb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func Log(handler http.Handler) http.Handler {
func main() {
flag.Parse()
if *version {
fmt.Println(`v0.1.0`)
fmt.Println(`v0.2.0`)
os.Exit(0)
}
port := os.Getenv("PORT")
Expand Down
19 changes: 12 additions & 7 deletions pkg/storage/dynamodb/machinetype_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ func (s *machineTypeService) GetByUsername(username string) (mt *storage.Machine
if err != nil {
return
}
log.Println("Found item:")
log.Println("Login: ", user.Login)
log.Println("Password: ", user.Password)
mt = &storage.MachineType{
Login: user.Login,
Password: user.Password,
Expand All @@ -50,9 +47,6 @@ func (s *machineTypeService) GetByUsername(username string) (mt *storage.Machine
if err != nil {
return
}
log.Println("Found item:")
log.Println("Type: ", typ.Type)
log.Println("Featuresd: ", typ.Features)
mt.Features = strings.Split(typ.Features, ",")
mt.DisplayName = typ.Type
log.Printf("Return MT: %v", mt)
Expand All @@ -67,8 +61,19 @@ func (s *machineTypeService) Delete(accountName string, id int64) error {
return nil
}

func (s *machineTypeService) List(accountName string) (mt []storage.MachineType, err error) {
func (s *machineTypeService) List(accountName string) (mts []storage.MachineType, err error) {
log.Printf("mt.List(accountName=%s)", accountName)
typeItems, err := mhTableTypeList(svc, fmt.Sprintf("%s_types", mhDbTablePrefix))
if err != nil {
return
}
for _, tItem := range typeItems {
mt := storage.MachineType{
DisplayName: tItem.Type,
Features: strings.Split(tItem.Features, ","),
}
mts = append(mts, mt)
}
return
}

Expand Down
14 changes: 14 additions & 0 deletions pkg/storage/dynamodb/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,20 @@ func mhTableUserScan(db *dynamodb.DynamoDB, tableName, usern string) (user Users
return
}

func mhTableTypeList(db *dynamodb.DynamoDB, tableName string) (typeItems []TypeItem, err error) {
log.Printf("List machine types in '%s'", tableName)
params := &dynamodb.ScanInput{
TableName: aws.String(tableName),
}
result, err := svc.Scan(params)
if err != nil {
fmt.Println(err.Error())
return
}
err = dynamodbattribute.UnmarshalListOfMaps(result.Items, &typeItems)
return
}

func mhTableTypeScan(db *dynamodb.DynamoDB, tableName, typen string) (typeItem TypeItem, err error) {
log.Printf("Search for type '%s' in '%s'", typen, tableName)
var queryInput = &dynamodb.QueryInput{
Expand Down