Skip to content

Commit

Permalink
feat: storage codegen
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian committed Aug 24, 2021
1 parent 978ecb5 commit d450ba3
Show file tree
Hide file tree
Showing 149 changed files with 9,063 additions and 3,398 deletions.
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

672 changes: 369 additions & 303 deletions client/docs/swagger-ui/swagger.yaml

Large diffs are not rendered by default.

195 changes: 139 additions & 56 deletions go.sum

Large diffs are not rendered by default.

35 changes: 22 additions & 13 deletions pkg/apis/akash.network/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package v1

import (
"fmt"
ctypes "github.com/ovrclk/akash/provider/cluster/types"
"math"
"strconv"

ctypes "github.com/ovrclk/akash/provider/cluster/types"

"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

Expand Down Expand Up @@ -92,7 +93,7 @@ func (d deployment) ManifestGroup() manifest.Group {
return d.group
}

// NewManifest creates new manifest with provided details. Returns error incase of failure.
// NewManifest creates new manifest with provided details. Returns error in case of failure.
func NewManifest(name string, lid mtypes.LeaseID, mgroup *manifest.Group) (*Manifest, error) {
group, err := manifestGroupFromAkash(mgroup)
if err != nil {
Expand Down Expand Up @@ -351,19 +352,28 @@ func manifestServiceExposeFromAkash(amse manifest.ServiceExpose) ManifestService

// ResourceUnits stores cpu, memory and storage details
type ResourceUnits struct {
CPU uint32 `json:"cpu,omitempty"`
Memory string `json:"memory,omitempty"`
Storage string `json:"storage,omitempty"`
CPU uint32 `json:"cpu,omitempty"`
Memory string `json:"memory,omitempty"`
Storage []string `json:"storage,omitempty"`
}

func (ru ResourceUnits) toAkash() (types.ResourceUnits, error) {
memory, err := strconv.ParseUint(ru.Memory, 10, 64)
if err != nil {
return types.ResourceUnits{}, err
}
storage, err := strconv.ParseUint(ru.Storage, 10, 64)
if err != nil {
return types.ResourceUnits{}, err

storage := make([]types.Storage, 0, len(ru.Storage))

for _, st := range ru.Storage {
size, err := strconv.ParseUint(st, 10, 64)
if err != nil {
return types.ResourceUnits{}, err
}

storage = append(storage, types.Storage{
Quantity: types.NewResourceValue(size),
})
}

return types.ResourceUnits{
Expand All @@ -373,9 +383,7 @@ func (ru ResourceUnits) toAkash() (types.ResourceUnits, error) {
Memory: &types.Memory{
Quantity: types.NewResourceValue(memory),
},
Storage: &types.Storage{
Quantity: types.NewResourceValue(storage),
},
Storage: storage,
}, nil
}

Expand All @@ -391,8 +399,9 @@ func resourceUnitsFromAkash(aru types.ResourceUnits) (ResourceUnits, error) {
res.Memory = strconv.FormatUint(aru.Memory.Quantity.Value(), 10)
}

if aru.Storage != nil {
res.Storage = strconv.FormatUint(aru.Storage.Quantity.Value(), 10)
res.Storage = make([]string, 0, len(aru.Storage))
for _, size := range aru.Storage {
res.Storage = append(res.Storage, strconv.FormatUint(size.Quantity.Value(), 10))
}

return res, nil
Expand Down
127 changes: 126 additions & 1 deletion pkg/apis/akash.network/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d450ba3

Please sign in to comment.