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

goto / guardian / 12304289958

12 Dec 2024 08:30PM UTC coverage: 73.933% (-0.5%) from 74.39%
12304289958

push

github

Ayushi Sharma
fix: update oss client caching logic

10823 of 14639 relevant lines covered (73.93%)

4.8 hits per line

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

0.0
/domain/provider.go
1
package domain
2

3
import (
4
        "fmt"
5
        "sort"
6
        "time"
7
)
8

9
const (
10
        ProviderTypeBigQuery   = "bigquery"
11
        ProviderTypeMetabase   = "metabase"
12
        ProviderTypeGrafana    = "grafana"
13
        ProviderTypeTableau    = "tableau"
14
        ProviderTypeGCloudIAM  = "gcloud_iam"
15
        ProviderTypeNoOp       = "noop"
16
        ProviderTypeGCS        = "gcs"
17
        ProviderTypePolicyTag  = "dataplex"
18
        ProviderTypeShield     = "shield"
19
        ProviderTypeGitlab     = "gitlab"
20
        ProviderTypeGate       = "gate"
21
        ProviderTypeMaxCompute = "maxcompute"
22
        ProviderTypeOss        = "oss"
23
)
24

25
// Role is the configuration to define a role and mapping the permissions in the provider
26
type Role struct {
27
        ID          string        `json:"id" yaml:"id" validate:"required"`
28
        Name        string        `json:"name" yaml:"name" validate:"required"`
29
        Description string        `json:"description,omitempty" yaml:"description"`
30
        Permissions []interface{} `json:"permissions" yaml:"permissions" validate:"required"`
31
}
32

33
// GetOrderedPermissions returns the permissions as a string slice
34
func (r Role) GetOrderedPermissions() []string {
×
35
        permissions := []string{}
×
36
        for _, p := range r.Permissions {
×
37
                permissions = append(permissions, fmt.Sprintf("%s", p))
×
38
        }
×
39
        sort.Strings(permissions)
×
40
        return permissions
×
41
}
42

43
// PolicyConfig is the configuration that defines which policy is being used in the provider
44
type PolicyConfig struct {
45
        ID      string `json:"id" yaml:"id" validate:"required"`
46
        Version int    `json:"version" yaml:"version" validate:"required"`
47
}
48

49
// ResourceConfig is the configuration for a resource type within a provider
50
type ResourceConfig struct {
51
        Type   string        `json:"type" yaml:"type" validate:"required"`
52
        Filter string        `json:"filter" yaml:"filter"`
53
        Policy *PolicyConfig `json:"policy" yaml:"policy"`
54
        Roles  []*Role       `json:"roles" yaml:"roles" validate:"required"`
55
}
56

57
// AppealConfig is the policy configuration of the appeal
58
type AppealConfig struct {
59
        AllowPermanentAccess         bool   `json:"allow_permanent_access" yaml:"allow_permanent_access"`
60
        AllowActiveAccessExtensionIn string `json:"allow_active_access_extension_in" yaml:"allow_active_access_extension_in" validate:"required"`
61
}
62
type ProviderConfig struct {
63
        Type                string               `json:"type" yaml:"type" validate:"required,oneof=google_bigquery metabase grafana tableau gcloud_iam noop gcs shield"`
64
        URN                 string               `json:"urn" yaml:"urn" validate:"required"`
65
        AllowedAccountTypes []string             `json:"allowed_account_types" yaml:"allowed_account_types" validate:"omitempty,min=1"`
66
        Labels              map[string]string    `json:"labels,omitempty" yaml:"labels,omitempty"`
67
        Credentials         interface{}          `json:"credentials,omitempty" yaml:"credentials" validate:"required"`
68
        Appeal              *AppealConfig        `json:"appeal,omitempty" yaml:"appeal,omitempty" validate:"required"`
69
        Resources           []*ResourceConfig    `json:"resources" yaml:"resources" validate:"required"`
70
        Parameters          []*ProviderParameter `json:"parameters,omitempty" yaml:"parameters,omitempty"`
71
        Activity            *ActivityConfig      `json:"activity,omitempty" yaml:"activity,omitempty"`
72
}
73

74
type ProviderParameter struct {
75
        Key         string `json:"key" yaml:"key" validate:"required"`
76
        Label       string `json:"label" yaml:"label" validate:"required"`
77
        Required    bool   `json:"required" yaml:"required" validate:"required"`
78
        Description string `json:"description" yaml:"description"`
79
}
80

81
func (pc ProviderConfig) GetResourceTypes() (resourceTypes []string) {
×
82
        for _, rc := range pc.Resources {
×
83
                resourceTypes = append(resourceTypes, rc.Type)
×
84
        }
×
85
        return
×
86
}
87

88
func (pc ProviderConfig) GetParameterKeys() (keys []string) {
×
89
        for _, param := range pc.Parameters {
×
90
                keys = append(keys, param.Key)
×
91
        }
×
92
        return
×
93
}
94

95
func (pc ProviderConfig) GetFilterForResourceType(resourceType string) string {
×
96
        for _, resource := range pc.Resources {
×
97
                if resource.Type == resourceType {
×
98
                        return resource.Filter
×
99
                }
×
100
        }
101
        return ""
×
102
}
103

104
type Provider struct {
105
        ID        string          `json:"id" yaml:"id"`
106
        Type      string          `json:"type" yaml:"type"`
107
        URN       string          `json:"urn" yaml:"urn"`
108
        Config    *ProviderConfig `json:"config" yaml:"config"`
109
        CreatedAt time.Time       `json:"created_at,omitempty" yaml:"created_at,omitempty"`
110
        UpdatedAt time.Time       `json:"updated_at,omitempty" yaml:"updated_at,omitempty"`
111
}
112

113
type ProviderType struct {
114
        Name          string   `json:"name" yaml:"name"`
115
        ResourceTypes []string `json:"resource_types" yaml:"resource_types"`
116
}
117

118
type ActivityConfig struct {
119
        Source  string
120
        Options map[string]interface{}
121
}
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