Skip to content

Commit

Permalink
feat: clean v1beta3
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian committed May 20, 2024
1 parent d05c262 commit a60e149
Show file tree
Hide file tree
Showing 231 changed files with 69,870 additions and 1,920 deletions.
5,675 changes: 3,918 additions & 1,757 deletions docs/proto/node.md

Large diffs are not rendered by default.

212 changes: 212 additions & 0 deletions docs/proto/provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@
- [ServiceParams](#akash.manifest.v2beta2.ServiceParams)
- [StorageParams](#akash.manifest.v2beta2.StorageParams)

- [akash/manifest/v2beta3/group.proto](#akash/manifest/v2beta3/group.proto)
- [Group](#akash.manifest.v2beta3.Group)

- [akash/manifest/v2beta3/httpoptions.proto](#akash/manifest/v2beta3/httpoptions.proto)
- [ServiceExposeHTTPOptions](#akash.manifest.v2beta3.ServiceExposeHTTPOptions)

- [akash/manifest/v2beta3/serviceexpose.proto](#akash/manifest/v2beta3/serviceexpose.proto)
- [ServiceExpose](#akash.manifest.v2beta3.ServiceExpose)

- [akash/manifest/v2beta3/service.proto](#akash/manifest/v2beta3/service.proto)
- [ImageCredentials](#akash.manifest.v2beta3.ImageCredentials)
- [Service](#akash.manifest.v2beta3.Service)
- [ServiceParams](#akash.manifest.v2beta3.ServiceParams)
- [StorageParams](#akash.manifest.v2beta3.StorageParams)

- [akash/provider/v1/status.proto](#akash/provider/v1/status.proto)
- [BidEngineStatus](#akash.provider.v1.BidEngineStatus)
- [ClusterStatus](#akash.provider.v1.ClusterStatus)
Expand Down Expand Up @@ -450,6 +465,203 @@



<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



<a name="akash/manifest/v2beta3/group.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## akash/manifest/v2beta3/group.proto



<a name="akash.manifest.v2beta3.Group"></a>

### Group
Group store name and list of services


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `name` | [string](#string) | | |
| `services` | [Service](#akash.manifest.v2beta3.Service) | repeated | |





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



<a name="akash/manifest/v2beta3/httpoptions.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## akash/manifest/v2beta3/httpoptions.proto



<a name="akash.manifest.v2beta3.ServiceExposeHTTPOptions"></a>

### ServiceExposeHTTPOptions
ServiceExposeHTTPOptions


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `max_body_size` | [uint32](#uint32) | | |
| `read_timeout` | [uint32](#uint32) | | |
| `send_timeout` | [uint32](#uint32) | | |
| `next_tries` | [uint32](#uint32) | | |
| `next_timeout` | [uint32](#uint32) | | |
| `next_cases` | [string](#string) | repeated | |





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



<a name="akash/manifest/v2beta3/serviceexpose.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## akash/manifest/v2beta3/serviceexpose.proto



<a name="akash.manifest.v2beta3.ServiceExpose"></a>

### ServiceExpose
ServiceExpose stores exposed ports and hosts details


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `port` | [uint32](#uint32) | | port on the container |
| `external_port` | [uint32](#uint32) | | port on the service definition |
| `proto` | [string](#string) | | |
| `service` | [string](#string) | | |
| `global` | [bool](#bool) | | |
| `hosts` | [string](#string) | repeated | |
| `http_options` | [ServiceExposeHTTPOptions](#akash.manifest.v2beta3.ServiceExposeHTTPOptions) | | |
| `ip` | [string](#string) | | The name of the IP address associated with this, if any |
| `endpoint_sequence_number` | [uint32](#uint32) | | The sequence number of the associated endpoint in the on-chain data |





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



<a name="akash/manifest/v2beta3/service.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## akash/manifest/v2beta3/service.proto



<a name="akash.manifest.v2beta3.ImageCredentials"></a>

### ImageCredentials
Credentials to fetch image from registry


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `host` | [string](#string) | | |
| `email` | [string](#string) | | |
| `username` | [string](#string) | | |
| `password` | [string](#string) | | |






<a name="akash.manifest.v2beta3.Service"></a>

### Service
Service stores name, image, args, env, unit, count and expose list of service


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `name` | [string](#string) | | |
| `image` | [string](#string) | | |
| `command` | [string](#string) | repeated | |
| `args` | [string](#string) | repeated | |
| `env` | [string](#string) | repeated | |
| `resources` | [akash.base.resources.v1.Resources](#akash.base.resources.v1.Resources) | | |
| `count` | [uint32](#uint32) | | |
| `expose` | [ServiceExpose](#akash.manifest.v2beta3.ServiceExpose) | repeated | |
| `params` | [ServiceParams](#akash.manifest.v2beta3.ServiceParams) | | |






<a name="akash.manifest.v2beta3.ServiceParams"></a>

### ServiceParams
ServiceParams


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `storage` | [StorageParams](#akash.manifest.v2beta3.StorageParams) | repeated | |
| `credentials` | [ImageCredentials](#akash.manifest.v2beta3.ImageCredentials) | | |






<a name="akash.manifest.v2beta3.StorageParams"></a>

### StorageParams
StorageParams


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `name` | [string](#string) | | |
| `mount` | [string](#string) | | |
| `read_only` | [bool](#bool) | | |





<!-- end messages -->

<!-- end enums -->
Expand Down
10 changes: 10 additions & 0 deletions go/manifest/v2beta3/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package v2beta3

import (
"errors"
)

var (
ErrInvalidManifest = errors.New("invalid manifest")
ErrManifestCrossValidation = errors.New("manifest cross-validation error")
)
79 changes: 79 additions & 0 deletions go/manifest/v2beta3/group.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package v2beta3

import (
"fmt"
"sort"

dtypes "github.com/akash-network/akash-api/go/node/deployment/v1beta4"
)

var _ dtypes.ResourceGroup = (*Group)(nil)

// GetName returns the name of group
func (g Group) GetName() string {
return g.Name
}

func (g Group) GetResourceUnits() dtypes.ResourceUnits {
groups := make(map[uint32]*dtypes.ResourceUnit)

for _, svc := range g.Services {
if _, exists := groups[svc.Resources.ID]; !exists {
groups[svc.Resources.ID] = &dtypes.ResourceUnit{
Resources: svc.Resources,
Count: svc.Count,
}
} else {
groups[svc.Resources.ID].Count += svc.Count
}
}

units := make(dtypes.ResourceUnits, 0, len(groups))

for i := range groups {
units = append(units, *groups[i])
}

return units
}

func (g Group) AllHostnames() []string {
allHostnames := make([]string, 0)
for _, service := range g.Services {
for _, expose := range service.Expose {
allHostnames = append(allHostnames, expose.Hosts...)
}
}

return allHostnames
}

func (g *Group) Validate(helper *validateManifestGroupsHelper) error {
if 0 == len(g.Services) {
return fmt.Errorf("%w: group %q contains no services", ErrInvalidManifest, g.GetName())
}

if !sort.IsSorted(g.Services) {
return fmt.Errorf("%w: group %q services is not sorted", ErrInvalidManifest, g.GetName())
}

for _, s := range g.Services {
if err := s.validate(helper); err != nil {
return err
}
}

return nil
}

// checkAgainstGSpec check if manifest group is within GroupSpec resources
// NOTE: it modifies caller's gspec
func (g *Group) checkAgainstGSpec(gspec *groupSpec) error {
for _, svc := range g.Services {
if err := svc.checkAgainstGSpec(gspec); err != nil {
return fmt.Errorf("%w: group %q: %w", ErrManifestCrossValidation, g.Name, err)
}
}

return nil
}
Loading

0 comments on commit a60e149

Please sign in to comment.