github.com/ali-iotechsys/cli@v20.10.0+incompatible/internal/test/builders/network.go (about) 1 package builders 2 3 import ( 4 "github.com/docker/docker/api/types" 5 ) 6 7 // NetworkResource creates a network resource with default values. 8 // Any number of networkResource function builder can be pass to modify the existing value. 9 // feel free to add another builder func if you need to override another value 10 func NetworkResource(builders ...func(resource *types.NetworkResource)) *types.NetworkResource { 11 resource := &types.NetworkResource{} 12 13 for _, builder := range builders { 14 builder(resource) 15 } 16 return resource 17 } 18 19 // NetworkResourceName sets the name of the resource network 20 func NetworkResourceName(name string) func(networkResource *types.NetworkResource) { 21 return func(networkResource *types.NetworkResource) { 22 networkResource.Name = name 23 } 24 } 25 26 // NetworkResourceID sets the ID of the resource network 27 func NetworkResourceID(id string) func(networkResource *types.NetworkResource) { 28 return func(networkResource *types.NetworkResource) { 29 networkResource.ID = id 30 } 31 } 32 33 // NetworkResourceDriver sets the driver of the resource network 34 func NetworkResourceDriver(name string) func(networkResource *types.NetworkResource) { 35 return func(networkResource *types.NetworkResource) { 36 networkResource.Driver = name 37 } 38 } 39 40 // NetworkResourceScope sets the Scope of the resource network 41 func NetworkResourceScope(scope string) func(networkResource *types.NetworkResource) { 42 return func(networkResource *types.NetworkResource) { 43 networkResource.Scope = scope 44 } 45 }