• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

goto / guardian / 17695507522

13 Sep 2025 10:47AM UTC coverage: 70.095% (-0.3%) from 70.379%
17695507522

Pull #222

github

rahmatrhd
chore: update proto
Pull Request #222: feat: introduce create resource API

0 of 65 new or added lines in 5 files covered. (0.0%)

19 existing lines in 3 files now uncovered.

11319 of 16148 relevant lines covered (70.1%)

4.63 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/domain/resource.go
1
package domain
2

3
import (
4
        "errors"
5
        "time"
6
)
7

8
// Resource struct
9
type Resource struct {
10
        ID           string                 `json:"id" yaml:"id"`
11
        ProviderType string                 `json:"provider_type" yaml:"provider_type"`
12
        ProviderURN  string                 `json:"provider_urn" yaml:"provider_urn"`
13
        Type         string                 `json:"type" yaml:"type"`
14
        URN          string                 `json:"urn" yaml:"urn"`
15
        Name         string                 `json:"name" yaml:"name"`
16
        Details      map[string]interface{} `json:"details" yaml:"details"`
17
        Labels       map[string]string      `json:"labels,omitempty" yaml:"labels,omitempty"`
18
        CreatedAt    time.Time              `json:"created_at,omitempty" yaml:"created_at,omitempty"`
19
        UpdatedAt    time.Time              `json:"updated_at,omitempty" yaml:"updated_at,omitempty"`
20
        IsDeleted    bool                   `json:"is_deleted,omitempty" yaml:"is_deleted,omitempty"`
21
        ParentID     *string                `json:"parent_id,omitempty" yaml:"parent_id,omitempty"`
22
        Children     []*Resource            `json:"children,omitempty" yaml:"children,omitempty"`
23
        GlobalURN    string                 `json:"global_urn" yaml:"global_urn"`
24
}
25

26
func (r *Resource) GetFlattened() []*Resource {
×
27
        resources := []*Resource{r}
×
28
        for _, child := range r.Children {
×
29
                resources = append(resources, child.GetFlattened()...)
×
30
        }
×
31
        return resources
×
32
}
33

NEW
34
func (r *Resource) Validate() error {
×
NEW
35
        if r.Type == "" {
×
NEW
36
                return errors.New("type is required")
×
NEW
37
        }
×
NEW
38
        if r.URN == "" {
×
NEW
39
                return errors.New("urn is required")
×
NEW
40
        }
×
NEW
41
        if r.Name == "" {
×
NEW
42
                return errors.New("name is required")
×
NEW
43
        }
×
NEW
44
        return nil
×
45
}
46

47
type ListResourcesFilter struct {
48
        IDs           []string          `mapstructure:"ids" validate:"omitempty,min=1"`
49
        IsDeleted     bool              `mapstructure:"is_deleted" validate:"omitempty"`
50
        ProviderType  string            `mapstructure:"provider_type" validate:"omitempty"`
51
        ProviderURN   string            `mapstructure:"provider_urn" validate:"omitempty"`
52
        Name          string            `mapstructure:"name" validate:"omitempty"`
53
        ResourceURN   string            `mapstructure:"urn" validate:"omitempty"`
54
        ResourceType  string            `mapstructure:"type" validate:"omitempty"`
55
        ResourceURNs  []string          `mapstructure:"urns" validate:"omitempty"`
56
        ResourceTypes []string          `mapstructure:"types" validate:"omitempty"`
57
        Details       map[string]string `mapstructure:"details"`
58
        Size          uint32            `mapstructure:"size" validate:"omitempty"`
59
        Offset        uint32            `mapstructure:"offset" validate:"omitempty"`
60
        OrderBy       []string          `mapstructure:"order_by" validate:"omitempty"`
61
        Q             string            `mapstructure:"q" validate:"omitempty"`
62
}
63

64
type Resources []*Resource
65

UNCOV
66
func (r Resources) ToMap() map[string]*Resource {
×
UNCOV
67
        resources := make(map[string]*Resource, len(r))
×
UNCOV
68
        for _, resource := range r {
×
UNCOV
69
                resources[resource.ID] = resource
×
UNCOV
70
        }
×
UNCOV
71
        return resources
×
72
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc