@@ -11,10 +11,10 @@ import (
11
11
"github.com/boson-project/faas/mock"
12
12
)
13
13
14
- // TestRepository for calculating destination image during tests.
14
+ // TestRegistry for calculating destination image during tests.
15
15
// Will be optional once we support in-cluster container registries
16
- // by default. See TestRepositoryRequired for details.
17
- const TestRepository = "quay.io/alice"
16
+ // by default. See TestRegistryRequired for details.
17
+ const TestRegistry = "quay.io/alice"
18
18
19
19
// TestCreate completes without error using all defaults and zero values. The base case.
20
20
func TestCreate (t * testing.T ) {
@@ -25,7 +25,7 @@ func TestCreate(t *testing.T) {
25
25
}
26
26
defer os .RemoveAll (root )
27
27
28
- client := faas .New (faas .WithRepository ( TestRepository ))
28
+ client := faas .New (faas .WithRegistry ( TestRegistry ))
29
29
30
30
if err := client .Create (faas.Function {Root : root }); err != nil {
31
31
t .Fatal (err )
@@ -42,7 +42,7 @@ func TestCreateWritesTemplate(t *testing.T) {
42
42
defer os .RemoveAll (root )
43
43
44
44
// Create the function at root
45
- client := faas .New (faas .WithRepository ( TestRepository ))
45
+ client := faas .New (faas .WithRegistry ( TestRegistry ))
46
46
if err := client .Create (faas.Function {Root : root }); err != nil {
47
47
t .Fatal (err )
48
48
}
@@ -125,7 +125,7 @@ func TestCreateDefaultRuntime(t *testing.T) {
125
125
defer os .RemoveAll (root )
126
126
127
127
// Create a new function at root with all defaults.
128
- client := faas .New (faas .WithRepository ( TestRepository ))
128
+ client := faas .New (faas .WithRegistry ( TestRegistry ))
129
129
if err := client .Create (faas.Function {Root : root }); err != nil {
130
130
t .Fatal (err )
131
131
}
@@ -154,8 +154,7 @@ func TestCreateDefaultTrigger(t *testing.T) {
154
154
// location is not defined herein but expected to be provided because, for
155
155
// example, a CLI may want to use XDG_CONFIG_HOME. Assuming a repository path
156
156
// $FAAS_TEMPLATES, a Go template named 'json' which is provided in the
157
- // repository repository 'boson-experimental', would be expected to be in the
158
- // location:
157
+ // repository 'boson-experimental', would be expected to be in the location:
159
158
// $FAAS_TEMPLATES/boson-experimental/go/json
160
159
// See the CLI for full details, but a standard default location is
161
160
// $HOME/.config/templates/boson-experimental/go/json
@@ -170,7 +169,7 @@ func TestExtensibleTemplates(t *testing.T) {
170
169
// Create a new client with a path to the extensible templates
171
170
client := faas .New (
172
171
faas .WithTemplates ("testdata/templates" ),
173
- faas .WithRepository ( TestRepository ))
172
+ faas .WithRegistry ( TestRegistry ))
174
173
175
174
// Create a Function specifying a template, 'json' that only exists in the extensible set
176
175
if err := client .Create (faas.Function {Root : root , Trigger : "boson-experimental/json" }); err != nil {
@@ -243,7 +242,7 @@ func TestNamed(t *testing.T) {
243
242
}
244
243
defer os .RemoveAll (root )
245
244
246
- client := faas .New (faas .WithRepository ( TestRepository ))
245
+ client := faas .New (faas .WithRegistry ( TestRegistry ))
247
246
248
247
if err := client .Create (faas.Function {Root : root , Name : name }); err != nil {
249
248
t .Fatal (err )
@@ -259,19 +258,19 @@ func TestNamed(t *testing.T) {
259
258
}
260
259
}
261
260
262
- // TestRepository ensures that a repository is required, and is
261
+ // TestRegistry ensures that a registry is required, and is
263
262
// prepended with the DefaultRegistry if a single token.
264
- // Repository is the namespace at the container image registry.
263
+ // Registry is the namespace at the container image registry.
265
264
// If not prepended with the registry, it will be defaulted:
266
265
// Examples: "docker.io/alice"
267
266
// "quay.io/bob"
268
267
// "charlie" (becomes [DefaultRegistry]/charlie
269
- // At this time a repository namespace is required as we rely on a third-party
268
+ // At this time a registry namespace is required as we rely on a third-party
270
269
// registry in all cases. When we support in-cluster container registries,
271
270
// this configuration parameter will become optional.
272
- func TestRepositoryRequired (t * testing.T ) {
271
+ func TestRegistryRequired (t * testing.T ) {
273
272
// Create a root for the Function
274
- root := "testdata/example.com/testRepository "
273
+ root := "testdata/example.com/testRegistry "
275
274
if err := os .MkdirAll (root , 0700 ); err != nil {
276
275
t .Fatal (err )
277
276
}
@@ -285,7 +284,7 @@ func TestRepositoryRequired(t *testing.T) {
285
284
}
286
285
287
286
// TestDeriveImage ensures that the full image (tag) of the resultant OCI
288
- // container is populated based of a derivation using configured repository
287
+ // container is populated based of a derivation using configured registry
289
288
// plus the service name.
290
289
func TestDeriveImage (t * testing.T ) {
291
290
// Create the root Function directory
@@ -296,7 +295,7 @@ func TestDeriveImage(t *testing.T) {
296
295
defer os .RemoveAll (root )
297
296
298
297
// Create the function which calculates fields such as name and image.
299
- client := faas .New (faas .WithRepository ( TestRepository ))
298
+ client := faas .New (faas .WithRegistry ( TestRegistry ))
300
299
if err := client .Create (faas.Function {Root : root }); err != nil {
301
300
t .Fatal (err )
302
301
}
@@ -307,14 +306,14 @@ func TestDeriveImage(t *testing.T) {
307
306
t .Fatal (err )
308
307
}
309
308
310
- // In form: [Default Registry]/[Repository Namespace]/[Service Name]:latest
311
- expected := TestRepository + "/" + f .Name + ":latest"
309
+ // In form: [Default Registry]/[Registry Namespace]/[Service Name]:latest
310
+ expected := TestRegistry + "/" + f .Name + ":latest"
312
311
if f .Image != expected {
313
312
t .Fatalf ("expected image '%v' got '%v'" , expected , f .Image )
314
313
}
315
314
}
316
315
317
- // TestDeriveImageDefaultRegistry ensures that a Repository which does not have
316
+ // TestDeriveImageDefaultRegistry ensures that a Registry which does not have
318
317
// a registry prefix has the DefaultRegistry prepended.
319
318
// For example "alice" becomes "docker.io/alice"
320
319
func TestDeriveImageDefaultRegistry (t * testing.T ) {
@@ -326,9 +325,9 @@ func TestDeriveImageDefaultRegistry(t *testing.T) {
326
325
defer os .RemoveAll (root )
327
326
328
327
// Create the function which calculates fields such as name and image.
329
- // Rather than use TestRepository , use a single-token name and expect
328
+ // Rather than use TestRegistry , use a single-token name and expect
330
329
// the DefaultRegistry to be prepended.
331
- client := faas .New (faas .WithRepository ("alice" ))
330
+ client := faas .New (faas .WithRegistry ("alice" ))
332
331
if err := client .Create (faas.Function {Root : root }); err != nil {
333
332
t .Fatal (err )
334
333
}
@@ -351,7 +350,7 @@ func TestDeriveImageDefaultRegistry(t *testing.T) {
351
350
func TestCreateDelegates (t * testing.T ) {
352
351
var (
353
352
root = "testdata/example.com/testCreateDelegates" // .. in which to initialize
354
- expectedName = "testCreateDelegates" // expected to be derived
353
+ expectedName = "testCreateDelegates" // expected to be derived
355
354
expectedImage = "quay.io/alice/testCreateDelegates:latest"
356
355
builder = mock .NewBuilder ()
357
356
pusher = mock .NewPusher ()
@@ -366,7 +365,7 @@ func TestCreateDelegates(t *testing.T) {
366
365
367
366
// Create a client with mocks for each of the subcomponents.
368
367
client := faas .New (
369
- faas .WithRepository ( TestRepository ),
368
+ faas .WithRegistry ( TestRegistry ),
370
369
faas .WithBuilder (builder ), // builds an image
371
370
faas .WithPusher (pusher ), // pushes images to a registry
372
371
faas .WithDeployer (deployer ), // deploys images as a running service
@@ -437,7 +436,7 @@ func TestRun(t *testing.T) {
437
436
438
437
// Create a client with the mock runner and the new test Function
439
438
runner := mock .NewRunner ()
440
- client := faas .New (faas .WithRepository ( TestRepository ), faas .WithRunner (runner ))
439
+ client := faas .New (faas .WithRegistry ( TestRegistry ), faas .WithRunner (runner ))
441
440
if err := client .Create (faas.Function {Root : root }); err != nil {
442
441
t .Fatal (err )
443
442
}
@@ -480,7 +479,7 @@ func TestUpdate(t *testing.T) {
480
479
481
480
// A client with mocks whose implementaton will validate input.
482
481
client := faas .New (
483
- faas .WithRepository ( TestRepository ),
482
+ faas .WithRegistry ( TestRegistry ),
484
483
faas .WithBuilder (builder ),
485
484
faas .WithPusher (pusher ),
486
485
faas .WithDeployer (deployer ))
@@ -554,7 +553,7 @@ func TestRemoveByPath(t *testing.T) {
554
553
defer os .RemoveAll (root )
555
554
556
555
client := faas .New (
557
- faas .WithRepository ( TestRepository ),
556
+ faas .WithRegistry ( TestRegistry ),
558
557
faas .WithRemover (remover ))
559
558
560
559
if err := client .Create (faas.Function {Root : root }); err != nil {
@@ -593,7 +592,7 @@ func TestRemoveByName(t *testing.T) {
593
592
defer os .RemoveAll (root )
594
593
595
594
client := faas .New (
596
- faas .WithRepository ( TestRepository ),
595
+ faas .WithRegistry ( TestRegistry ),
597
596
faas .WithRemover (remover ))
598
597
599
598
if err := client .Create (faas.Function {Root : root }); err != nil {
@@ -644,7 +643,7 @@ func TestRemoveUninitializedFails(t *testing.T) {
644
643
645
644
// Instantiate the client with the failing remover.
646
645
client := faas .New (
647
- faas .WithRepository ( TestRepository ),
646
+ faas .WithRegistry ( TestRegistry ),
648
647
faas .WithRemover (remover ))
649
648
650
649
// Attempt to remove by path (uninitialized), expecting an error.
0 commit comments