Skip to content

Commit 3ee6a55

Browse files
authored
Merge pull request #1063 from adamantike/fix/use-defaults-in-file-provider
fix: Use global defaults in File provider
2 parents ae1e3e0 + 29200f1 commit 3ee6a55

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed

internal/provider/file/file_test.go

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ var (
1313
defaults = model.Defaults{
1414
NotifyOn: model.NotifyOnDefaults,
1515
SortTags: registry.SortTagReverse,
16+
MaxTags: 25,
17+
IncludeTags: []string{
18+
`^(0|[1-9]\d*)\..*`,
19+
},
20+
ExcludeTags: []string{
21+
`^0\.0\..*`,
22+
},
1623
}
1724
bintrayFile = []model.Job{
1825
{
@@ -22,6 +29,13 @@ var (
2229
RegOpt: "bintrayoptions",
2330
NotifyOn: model.NotifyOnDefaults,
2431
SortTags: registry.SortTagReverse,
32+
MaxTags: 25,
33+
IncludeTags: []string{
34+
`^(0|[1-9]\d*)\..*`,
35+
},
36+
ExcludeTags: []string{
37+
`^0\.0\..*`,
38+
},
2539
},
2640
},
2741
{
@@ -34,6 +48,12 @@ var (
3448
},
3549
SortTags: registry.SortTagLexicographical,
3650
MaxTags: 50,
51+
IncludeTags: []string{
52+
`^(0|[1-9]\d*)\..*`,
53+
},
54+
ExcludeTags: []string{
55+
`^0\.0\..*`,
56+
},
3757
},
3858
},
3959
}
@@ -45,6 +65,13 @@ var (
4565
RegOpt: "myregistry",
4666
NotifyOn: model.NotifyOnDefaults,
4767
SortTags: registry.SortTagReverse,
68+
MaxTags: 25,
69+
IncludeTags: []string{
70+
`^(0|[1-9]\d*)\..*`,
71+
},
72+
ExcludeTags: []string{
73+
`^0\.0\..*`,
74+
},
4875
},
4976
},
5077
{
@@ -54,9 +81,13 @@ var (
5481
WatchRepo: utl.NewTrue(),
5582
NotifyOn: model.NotifyOnDefaults,
5683
SortTags: registry.SortTagSemver,
84+
MaxTags: 25,
5785
IncludeTags: []string{
5886
`^1\.2\..*`,
5987
},
88+
ExcludeTags: []string{
89+
`^0\.0\..*`,
90+
},
6091
},
6192
},
6293
{
@@ -70,6 +101,9 @@ var (
70101
IncludeTags: []string{
71102
`^(0|[1-9]\d*)\..*`,
72103
},
104+
ExcludeTags: []string{
105+
`^0\.0\..*`,
106+
},
73107
},
74108
},
75109
{
@@ -79,6 +113,13 @@ var (
79113
WatchRepo: utl.NewTrue(),
80114
NotifyOn: model.NotifyOnDefaults,
81115
SortTags: registry.SortTagDefault,
116+
MaxTags: 25,
117+
IncludeTags: []string{
118+
`^(0|[1-9]\d*)\..*`,
119+
},
120+
ExcludeTags: []string{
121+
`latest`,
122+
},
82123
},
83124
},
84125
{
@@ -92,6 +133,13 @@ var (
92133
Arch: "arm64",
93134
Variant: "v8",
94135
},
136+
MaxTags: 25,
137+
IncludeTags: []string{
138+
`^(0|[1-9]\d*)\..*`,
139+
},
140+
ExcludeTags: []string{
141+
`^0\.0\..*`,
142+
},
95143
},
96144
},
97145
{
@@ -100,6 +148,13 @@ var (
100148
Name: "docker.io/graylog/graylog:3.2.0",
101149
NotifyOn: model.NotifyOnDefaults,
102150
SortTags: registry.SortTagReverse,
151+
MaxTags: 25,
152+
IncludeTags: []string{
153+
`^(0|[1-9]\d*)\..*`,
154+
},
155+
ExcludeTags: []string{
156+
`^0\.0\..*`,
157+
},
103158
},
104159
},
105160
{
@@ -108,6 +163,13 @@ var (
108163
Name: "jacobalberty/unifi:5.9",
109164
NotifyOn: model.NotifyOnDefaults,
110165
SortTags: registry.SortTagReverse,
166+
MaxTags: 25,
167+
IncludeTags: []string{
168+
`^(0|[1-9]\d*)\..*`,
169+
},
170+
ExcludeTags: []string{
171+
`^0\.0\..*`,
172+
},
111173
},
112174
},
113175
{
@@ -117,9 +179,13 @@ var (
117179
WatchRepo: utl.NewTrue(),
118180
NotifyOn: model.NotifyOnDefaults,
119181
SortTags: registry.SortTagReverse,
182+
MaxTags: 25,
120183
IncludeTags: []string{
121184
`^1\..*`,
122185
},
186+
ExcludeTags: []string{
187+
`^0\.0\..*`,
188+
},
123189
},
124190
},
125191
}
@@ -130,6 +196,13 @@ var (
130196
Name: "quay.io/coreos/hyperkube",
131197
NotifyOn: model.NotifyOnDefaults,
132198
SortTags: registry.SortTagReverse,
199+
MaxTags: 25,
200+
IncludeTags: []string{
201+
`^(0|[1-9]\d*)\..*`,
202+
},
203+
ExcludeTags: []string{
204+
`^0\.0\..*`,
205+
},
133206
},
134207
},
135208
{
@@ -138,6 +211,13 @@ var (
138211
Name: "quay.io/coreos/hyperkube:v1.1.7-coreos.1",
139212
NotifyOn: model.NotifyOnDefaults,
140213
SortTags: registry.SortTagReverse,
214+
MaxTags: 25,
215+
IncludeTags: []string{
216+
`^(0|[1-9]\d*)\..*`,
217+
},
218+
ExcludeTags: []string{
219+
`^0\.0\..*`,
220+
},
141221
},
142222
},
143223
}
@@ -149,6 +229,13 @@ var (
149229
NotifyOn: model.NotifyOnDefaults,
150230
SortTags: registry.SortTagReverse,
151231
HubLink: "https://fleet.linuxserver.io/image?name=linuxserver/heimdall",
232+
MaxTags: 25,
233+
IncludeTags: []string{
234+
`^(0|[1-9]\d*)\..*`,
235+
},
236+
ExcludeTags: []string{
237+
`^0\.0\..*`,
238+
},
152239
},
153240
},
154241
}

internal/provider/file/fixtures/dockerhub.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
- name: traefik
1515
watch_repo: true
1616
sort_tags: default
17+
exclude_tags:
18+
- latest
1719
- name: alpine
1820
platform:
1921
os: linux

internal/provider/file/image.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,21 @@ func (c *Client) listFileImage() []model.Image {
8080
}
8181
}
8282

83+
// Set default MaxTags
84+
if item.MaxTags == 0 {
85+
item.MaxTags = c.defaults.MaxTags
86+
}
87+
88+
// Set default IncludeTags
89+
if len(item.IncludeTags) == 0 {
90+
item.IncludeTags = c.defaults.IncludeTags
91+
}
92+
93+
// Set default ExcludeTags
94+
if len(item.ExcludeTags) == 0 {
95+
item.ExcludeTags = c.defaults.ExcludeTags
96+
}
97+
8398
images = append(images, item)
8499
}
85100
}

0 commit comments

Comments
 (0)