@@ -44,20 +44,23 @@ Usage:
44
44
falcoctl artifact config [ref] [flags]
45
45
46
46
Flags:
47
- -h, --help help for config
48
- --plain-http allows interacting with remote registry via plain http requests
47
+ -h, --help help for config
48
+ --plain-http allows interacting with remote registry via plain http requests
49
+ --platform string os and architecture of the artifact in OS/ARCH format (default "linux/amd64")
49
50
50
51
Global Flags:
51
52
--config string config file to be used for falcoctl (default "/etc/falcoctl/falcoctl.yaml")
52
53
--log-format string Set formatting for logs (color, text, json) (default "color")
53
- --log-level string Set level for logs (info, warn, debug, trace) (default "info")`
54
+ --log-level string Set level for logs (info, warn, debug, trace) (default "info")
55
+ `
54
56
55
57
var _ = Describe ("Config" , func () {
56
58
const (
57
- artifactCmd = "artifact"
58
- configCmd = "config"
59
- plaingHTTP = "--plain-http"
60
- configFlag = "--config"
59
+ artifactCmd = "artifact"
60
+ configCmd = "config"
61
+ plaingHTTP = "--plain-http"
62
+ configFlag = "--config"
63
+ platformFlag = "--platform"
61
64
)
62
65
63
66
var (
@@ -93,7 +96,7 @@ var _ = Describe("Config", func() {
93
96
94
97
It ("should match the saved one" , func () {
95
98
Expect (err ).ShouldNot (HaveOccurred ())
96
- Expect (string (output .Contents ())).ShouldNot (Equal (help ))
99
+ Expect (string (output .Contents ())).Should (Equal (help ))
97
100
})
98
101
})
99
102
@@ -139,6 +142,13 @@ var _ = Describe("Config", func() {
139
142
140
143
assertFailedBehavior (usage , "ERROR cannot find among the configured indexes, skipping " )
141
144
})
145
+
146
+ When ("no manifest for given platform" , func () {
147
+ BeforeEach (func () {
148
+ args = []string {artifactCmd , configCmd , pluginMultiPlatformRef , plaingHTTP , configFlag , configDir , platformFlag , "linux/wrong" }
149
+ })
150
+ assertFailedBehavior (usage , "ERROR unable to get manifest: unable to find a manifest matching the given platform: linux/wrong" )
151
+ })
142
152
})
143
153
144
154
Context ("success" , func () {
@@ -163,6 +173,39 @@ var _ = Describe("Config", func() {
163
173
Expect (output ).Should (gbytes .Say (regexp .QuoteMeta (`{"dependencies":[{"name":"dep1","version":"1.2.3"},{"name":"dep2","version":"2.3.1"}]}` )))
164
174
})
165
175
})
166
- })
167
176
177
+ When ("no platform flag" , func () {
178
+ BeforeEach (func () {
179
+ args = []string {artifactCmd , configCmd , pluginMultiPlatformRef , plaingHTTP , configFlag , configDir }
180
+ })
181
+
182
+ It ("should success getting the platform where tests are running" , func () {
183
+ Expect (err ).ShouldNot (HaveOccurred ())
184
+ Expect (output ).Should (gbytes .Say (regexp .QuoteMeta (`{"dependencies":[{"name":"my-dep","version":"1.2.3","alternatives":[{"name":"my-alt-dep","version":"` )))
185
+ })
186
+ })
187
+
188
+ When ("with valid platform" , func () {
189
+ BeforeEach (func () {
190
+ args = []string {artifactCmd , configCmd , pluginMultiPlatformRef , plaingHTTP , configFlag , configDir , platformFlag , testPluginPlatform3 }
191
+ })
192
+
193
+ It ("should success" , func () {
194
+ Expect (err ).ShouldNot (HaveOccurred ())
195
+ Expect (output ).Should (gbytes .Say (regexp .QuoteMeta (`{"dependencies":[{"name":"my-dep","version":"1.2.3","alternatives":[{"name":"my-alt-dep","version":"` )))
196
+ })
197
+ })
198
+
199
+ When ("with non existing platform for artifacts without platforms" , func () {
200
+ BeforeEach (func () {
201
+ args = []string {artifactCmd , configCmd , rulesRef , plaingHTTP , configFlag , configDir , platformFlag , testPluginPlatform3 }
202
+ })
203
+
204
+ It ("should success" , func () {
205
+ Expect (err ).ShouldNot (HaveOccurred ())
206
+ Expect (output ).Should (gbytes .Say (regexp .QuoteMeta (`{"dependencies":[{"name":"dep1","version":"1.2.3"},{"name":"dep2","version":"2.3.1"}]}` )))
207
+ })
208
+ })
209
+
210
+ })
168
211
})
0 commit comments