github.com/choria-io/go-choria@v0.28.1-0.20240416190746-b3bf9c7d5a45/providers/discovery/inventory/options.go (about) 1 // Copyright (c) 2021-2022, R.I. Pienaar and the Choria Project contributors 2 // 3 // SPDX-License-Identifier: Apache-2.0 4 5 package inventory 6 7 import ( 8 "github.com/choria-io/go-choria/protocol" 9 ) 10 11 type dOpts struct { 12 filter *protocol.Filter 13 collective string 14 do map[string]string 15 source string 16 noValidate bool 17 } 18 19 // DiscoverOption configures the broadcast discovery method 20 type DiscoverOption func(o *dOpts) 21 22 // Filter sets the filter to use for the discovery, else a blank one is used 23 func Filter(f *protocol.Filter) DiscoverOption { 24 return func(o *dOpts) { 25 o.filter = f 26 } 27 } 28 29 // Collective sets the collective to discover in, else main collective is used 30 func Collective(c string) DiscoverOption { 31 return func(o *dOpts) { 32 o.collective = c 33 } 34 } 35 36 // DiscoveryOptions sets the key value pairs that make user supplied discovery options. 37 // 38 // Supported options: 39 // 40 // file - set the file to read 41 func DiscoveryOptions(opt map[string]string) DiscoverOption { 42 return func(o *dOpts) { 43 o.do = opt 44 } 45 } 46 47 // File sets the file to read nodes from 48 func File(f string) DiscoverOption { 49 return func(o *dOpts) { 50 o.source = f 51 } 52 }