-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathfeed_resource.go
More file actions
115 lines (98 loc) · 5.1 KB
/
Copy pathfeed_resource.go
File metadata and controls
115 lines (98 loc) · 5.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package feeds
import (
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources"
"github.com/go-playground/validator/v10"
"github.com/go-playground/validator/v10/non-standard/validators"
)
type FeedResource struct {
AccessKey string `json:"AccessKey,omitempty"`
OidcAuthentication *OidcAuthentication `json:"OidcAuthentication,omitempty"`
APIVersion string `json:"ApiVersion,omitempty"`
DeletePackagesAssociatedWithReleases bool `json:"DeletePackagesAssociatedWithReleases"`
DeleteUnreleasedPackagesAfterDays int `json:"DeleteUnreleasedPackagesAfterDays"`
DownloadAttempts int `json:"DownloadAttempts"`
DownloadRetryBackoffSeconds int `json:"DownloadRetryBackoffSeconds"`
EnhancedMode bool `json:"EnhancedMode"`
FeedType FeedType `json:"FeedType" validate:"required,notblank"`
FeedURI string `json:"FeedUri,omitempty"`
IsBuiltInRepoSyncEnabled bool `json:"IsBuiltInRepoSyncEnabled"`
Name string `json:"Name" validate:"required,notblank"`
Password *core.SensitiveValue `json:"Password,omitempty"`
PackageAcquisitionLocationOptions []string `json:"PackageAcquisitionLocationOptions,omitempty"`
Region string `json:"Region,omitempty"`
RegistryPath string `json:"RegistryPath,omitempty"`
SecretKey *core.SensitiveValue `json:"SecretKey,omitempty"`
SpaceID string `json:"SpaceId,omitempty"`
Username string `json:"Username,omitempty"`
LayoutRegex string `json:"LayoutRegex,omitempty"`
Repository string `json:"Repository,omitempty"`
UseMachineCredentials bool `json:"UseMachineCredentials,omitempty"`
resources.Resource
}
func NewFeedResource(name string, feedType FeedType) *FeedResource {
return &FeedResource{
FeedType: feedType,
Name: name,
Resource: *resources.NewResource(),
}
}
// GetFeedType returns the type of this feed.
func (f *FeedResource) GetFeedType() FeedType {
return f.FeedType
}
// GetName returns the name of the feed.
func (f *FeedResource) GetName() string {
return f.Name
}
// GetSpaceID returns the space ID of the feed.
func (f *FeedResource) GetSpaceID() string {
return f.SpaceID
}
// GetPackageAcquisitionLocationOptions returns the package acquisition location options of the feed.
func (f *FeedResource) GetPackageAcquisitionLocationOptions() []string {
return f.PackageAcquisitionLocationOptions
}
// GetPassword returns the password of the feed.
func (f *FeedResource) GetPassword() *core.SensitiveValue {
return f.Password
}
// GetUsername returns the username of the feed.
func (f *FeedResource) GetUsername() string {
return f.Username
}
// SetFeedType returns the type of this feed.
func (f *FeedResource) SetFeedType(feedType FeedType) {
f.FeedType = feedType
}
// SetName sets the name of the feed.
func (f *FeedResource) SetName(name string) {
f.Name = name
}
// SetPackageAcquisitionLocationOptions sets the package acquisition location options of the feed.
func (f *FeedResource) SetPackageAcquisitionLocationOptions(packageAcquisitionLocationOptions []string) {
f.PackageAcquisitionLocationOptions = packageAcquisitionLocationOptions
}
// SetPassword sets the password of the feed.
func (f *FeedResource) SetPassword(password *core.SensitiveValue) {
f.Password = password
}
// SetSpaceID sets the space ID of the feed.
func (f *FeedResource) SetSpaceID(spaceID string) {
f.SpaceID = spaceID
}
// SetUsername sets the username of the feed.
func (f *FeedResource) SetUsername(username string) {
f.Username = username
}
// Validate checks the state of the feed resource and returns an error if
// invalid.
func (f FeedResource) Validate() error {
v := validator.New()
err := v.RegisterValidation("notblank", validators.NotBlank)
if err != nil {
return err
}
return v.Struct(f)
}
var _ IFeed = &FeedResource{}