@@ -36,56 +36,112 @@ type RepositoryResponse struct {
36
36
LastSnapshotTask * TaskInfoResponse `json:"last_snapshot_task,omitempty"` // Last snapshot task response (contains last snapshot status)
37
37
}
38
38
39
- // RepositoryRequest holds data received from request to create/update repository
39
+ // RepositoryRequest holds data received from request to create repository
40
40
type RepositoryRequest struct {
41
- UUID * string `json:"uuid" readonly:"true" swaggerignore:"true"`
42
- Name * string `json:"name"` // Name of the remote yum repository
43
- URL * string `json:"url"` // URL of the remote yum repository
44
- DistributionVersions * []string `json:"distribution_versions" example:"7,8"` // Versions to restrict client usage to
45
- DistributionArch * string `json:"distribution_arch" example:"x86_64"` // Architecture to restrict client usage to
46
- GpgKey * string `json:"gpg_key"` // GPG key for repository
47
- MetadataVerification * bool `json:"metadata_verification"` // Verify packages
48
- ModuleHotfixes * bool `json:"module_hotfixes"` // Disable modularity filtering on this repository
49
- Snapshot * bool `json:"snapshot"` // Enable snapshotting and hosting of this repository
50
- AccountID * string `json:"account_id" readonly:"true" swaggerignore:"true"` // Account ID of the owner
51
- OrgID * string `json:"org_id" readonly:"true" swaggerignore:"true"` // Organization ID of the owner
52
- Origin * string `json:"origin" readonly:"true" swaggerignore:"true"` // Origin of the repository
53
- ContentType * string `json:"content_type" readonly:"true" swaggerignore:"true"` // Content Type (rpm) of the repository
41
+ UUID * string `json:"uuid" readonly:"true" swaggerignore:"true"`
42
+ AccountID * string `json:"account_id" readonly:"true" swaggerignore:"true"` // Account ID of the owner
43
+ OrgID * string `json:"org_id" readonly:"true" swaggerignore:"true"` // Organization ID of the owner
44
+ Origin * string `json:"origin" readonly:"true"` // Origin of the repository
45
+ ContentType * string `json:"content_type" readonly:"true" swaggerignore:"true"` // Content Type (rpm) of the repository
46
+
47
+ Name * string `json:"name"` // Name of the remote yum repository
48
+ URL * string `json:"url"` // URL of the remote yum repository
49
+ DistributionVersions * []string `json:"distribution_versions" example:"7,8"` // Versions to restrict client usage to
50
+ DistributionArch * string `json:"distribution_arch" example:"x86_64"` // Architecture to restrict client usage to
51
+ GpgKey * string `json:"gpg_key"` // GPG key for repository
52
+ MetadataVerification * bool `json:"metadata_verification"` // Verify packages
53
+ ModuleHotfixes * bool `json:"module_hotfixes"` // Disable modularity filtering on this repository
54
+ Snapshot * bool `json:"snapshot"` // Enable snapshotting and hosting of this repository
55
+ }
56
+
57
+ type RepositoryUpdateRequest struct {
58
+ Name * string `json:"name"` // Name of the remote yum repository
59
+ URL * string `json:"url"` // URL of the remote yum repository
60
+ DistributionVersions * []string `json:"distribution_versions" example:"7,8"` // Versions to restrict client usage to
61
+ DistributionArch * string `json:"distribution_arch" example:"x86_64"` // Architecture to restrict client usage to
62
+ GpgKey * string `json:"gpg_key"` // GPG key for repository
63
+ MetadataVerification * bool `json:"metadata_verification"` // Verify packages
64
+ ModuleHotfixes * bool `json:"module_hotfixes"` // Disable modularity filtering on this repository
65
+ Snapshot * bool `json:"snapshot"` // Enable snapshotting and hosting of this repository
66
+ }
67
+
68
+ func (r * RepositoryRequest ) ToRepositoryUpdateRequest () RepositoryUpdateRequest {
69
+ return RepositoryUpdateRequest {
70
+ Name : r .Name ,
71
+ URL : r .URL ,
72
+ DistributionVersions : r .DistributionVersions ,
73
+ DistributionArch : r .DistributionArch ,
74
+ GpgKey : r .GpgKey ,
75
+ MetadataVerification : r .MetadataVerification ,
76
+ ModuleHotfixes : r .ModuleHotfixes ,
77
+ Snapshot : r .Snapshot ,
78
+ }
79
+ }
80
+
81
+ var defaultRepoValues = RepositoryUpdateRequest {
82
+ Name : pointy .Pointer ("" ),
83
+ URL : pointy .Pointer ("" ),
84
+ DistributionVersions : pointy .Pointer ([]string {"any" }),
85
+ DistributionArch : pointy .Pointer ("any" ),
86
+ GpgKey : pointy .Pointer ("" ),
87
+ MetadataVerification : pointy .Pointer (false ),
88
+ ModuleHotfixes : pointy .Pointer (false ),
89
+ Snapshot : pointy .Pointer (false ),
90
+ }
91
+
92
+ func (r * RepositoryUpdateRequest ) FillDefaults () {
93
+ if r .Name == nil {
94
+ r .Name = defaultRepoValues .Name
95
+ }
96
+ if r .URL == nil {
97
+ r .URL = defaultRepoValues .URL
98
+ }
99
+ if r .DistributionVersions == nil {
100
+ r .DistributionVersions = defaultRepoValues .DistributionVersions
101
+ }
102
+ if r .DistributionArch == nil {
103
+ r .DistributionArch = defaultRepoValues .DistributionArch
104
+ }
105
+ if r .GpgKey == nil {
106
+ r .GpgKey = defaultRepoValues .GpgKey
107
+ }
108
+ if r .MetadataVerification == nil {
109
+ r .MetadataVerification = defaultRepoValues .MetadataVerification
110
+ }
111
+ if r .ModuleHotfixes == nil {
112
+ r .ModuleHotfixes = defaultRepoValues .ModuleHotfixes
113
+ }
54
114
}
55
115
56
116
func (r * RepositoryRequest ) FillDefaults () {
57
- // Currently the user cannot change these
58
- r .Origin = pointy .Pointer (config .OriginExternal )
117
+ // Currently the user cannot change these, only set at creation
59
118
r .ContentType = pointy .Pointer (config .ContentTypeRpm )
60
- // Fill in default values in case of PUT request, doesn't have to be valid, let the db validate that
61
- defaultName := ""
62
- defaultUrl := ""
63
- defaultVersions := []string {"any" }
64
- defaultArch := "any"
65
- defaultGpgKey := ""
66
- defaultMetadataVerification := false
67
- defaultModuleHotfixes := false
68
119
120
+ if r .Origin == nil {
121
+ r .Origin = pointy .Pointer (config .OriginExternal )
122
+ }
123
+
124
+ // copied from RepositoryUpdateRequest FillDefaults
69
125
if r .Name == nil {
70
- r .Name = & defaultName
126
+ r .Name = defaultRepoValues . Name
71
127
}
72
128
if r .URL == nil {
73
- r .URL = & defaultUrl
129
+ r .URL = defaultRepoValues . URL
74
130
}
75
131
if r .DistributionVersions == nil {
76
- r .DistributionVersions = & defaultVersions
132
+ r .DistributionVersions = defaultRepoValues . DistributionVersions
77
133
}
78
134
if r .DistributionArch == nil {
79
- r .DistributionArch = & defaultArch
135
+ r .DistributionArch = defaultRepoValues . DistributionArch
80
136
}
81
137
if r .GpgKey == nil {
82
- r .GpgKey = & defaultGpgKey
138
+ r .GpgKey = defaultRepoValues . GpgKey
83
139
}
84
140
if r .MetadataVerification == nil {
85
- r .MetadataVerification = & defaultMetadataVerification
141
+ r .MetadataVerification = defaultRepoValues . MetadataVerification
86
142
}
87
143
if r .ModuleHotfixes == nil {
88
- r .ModuleHotfixes = & defaultModuleHotfixes
144
+ r .ModuleHotfixes = defaultRepoValues . ModuleHotfixes
89
145
}
90
146
}
91
147
@@ -103,3 +159,11 @@ func (r *RepositoryCollectionResponse) SetMetadata(meta ResponseMetadata, links
103
159
r .Meta = meta
104
160
r .Links = links
105
161
}
162
+
163
+ func (r * RepositoryResponse ) Snapshottable () bool {
164
+ return r .Origin != config .OriginUpload && r .Snapshot
165
+ }
166
+
167
+ func (r * RepositoryResponse ) Introspectable () bool {
168
+ return r .Origin != config .OriginUpload
169
+ }
0 commit comments