Skip to content

Commit

Permalink
changed activations exports to match account format
Browse files Browse the repository at this point in the history
  • Loading branch information
aricart committed Oct 19, 2018
1 parent 9e34f00 commit af7d2f8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
18 changes: 18 additions & 0 deletions exports.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ func (es *ExportedStreams) Valid() error {
return nil
}

func (es *ExportedStreams) Add(s ExportedStream) {
*es = append(*es, s)
}

type ExportedService struct {
Export
}
Expand All @@ -48,6 +52,10 @@ func (es *ExportedService) Valid() error {
return nil
}

func (es *ExportedServices) Add(s ExportedService) {
*es = append(*es, s)
}

type ExportedServices []ExportedService

func (es *ExportedServices) Valid() error {
Expand All @@ -63,3 +71,13 @@ type Exports struct {
Streams ExportedStreams `json:"streams,omitempty"`
Services ExportedServices `json:"services,omitempty"`
}

func (e *Exports) Valid() error {
if err := e.Services.Valid(); err != nil {
return err
}
if err := e.Streams.Valid(); err != nil {
return err
}
return nil
}
9 changes: 2 additions & 7 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,13 @@ func (u *Permissions) Valid() error {
}

type Activation struct {
Exports []Export `json:"exports,omitempty"`
Exports Exports `json:"exports,omitempty"`
Limits
OperatorLimits
}

func (a *Activation) Valid() error {
for i, t := range a.Exports {
if err := t.Valid(); err != nil {
return fmt.Errorf("error validating activation (index %d):%v", i, err)
}
}
return nil
return a.Exports.Valid()
}

type Identity struct {
Expand Down

0 comments on commit af7d2f8

Please sign in to comment.