2017-08-01 05:06:47 -04:00
|
|
|
package builders
|
|
|
|
|
|
|
|
import (
|
2024-06-05 10:28:24 -04:00
|
|
|
"github.com/docker/docker/api/types/network"
|
2017-08-01 05:06:47 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// NetworkResource creates a network resource with default values.
|
|
|
|
// Any number of networkResource function builder can be pass to modify the existing value.
|
|
|
|
// feel free to add another builder func if you need to override another value
|
2024-06-05 10:28:24 -04:00
|
|
|
func NetworkResource(builders ...func(resource *network.Summary)) *network.Summary {
|
|
|
|
resource := &network.Summary{}
|
2017-08-01 05:06:47 -04:00
|
|
|
|
|
|
|
for _, builder := range builders {
|
|
|
|
builder(resource)
|
|
|
|
}
|
|
|
|
return resource
|
|
|
|
}
|
|
|
|
|
|
|
|
// NetworkResourceName sets the name of the resource network
|
2024-06-05 10:28:24 -04:00
|
|
|
func NetworkResourceName(name string) func(networkResource *network.Summary) {
|
|
|
|
return func(networkResource *network.Summary) {
|
2017-08-01 05:06:47 -04:00
|
|
|
networkResource.Name = name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NetworkResourceID sets the ID of the resource network
|
2024-06-05 10:28:24 -04:00
|
|
|
func NetworkResourceID(id string) func(networkResource *network.Summary) {
|
|
|
|
return func(networkResource *network.Summary) {
|
2017-08-01 05:06:47 -04:00
|
|
|
networkResource.ID = id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NetworkResourceDriver sets the driver of the resource network
|
2024-06-05 10:28:24 -04:00
|
|
|
func NetworkResourceDriver(name string) func(networkResource *network.Summary) {
|
|
|
|
return func(networkResource *network.Summary) {
|
2017-08-01 05:06:47 -04:00
|
|
|
networkResource.Driver = name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NetworkResourceScope sets the Scope of the resource network
|
2024-06-05 10:28:24 -04:00
|
|
|
func NetworkResourceScope(scope string) func(networkResource *network.Summary) {
|
|
|
|
return func(networkResource *network.Summary) {
|
2017-08-01 05:06:47 -04:00
|
|
|
networkResource.Scope = scope
|
|
|
|
}
|
|
|
|
}
|