1 // Copyright 2021 Palantir Technologies, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package appconfig 16 17 type Option func(*Loader) 18 19 // WithRemoteRefParser sets the parser for encoded RemoteRefs. The default 20 // parser uses YAML. Set a nil parser to disable remote references. 21 func WithRemoteRefParser(parser RemoteRefParser) Option { 22 return func(ld *Loader) { 23 ld.parser = parser 24 } 25 } 26 27 // WithOwnerDefault sets the owner repository and paths to check when a 28 // repository does not define its own configuration. By default, the repository 29 // name is ".github" and the paths are those passed to the loader with the 30 // ".github/" prefix removed. Set an empty repository name to disable 31 // owner defaults. 32 func WithOwnerDefault(name string, paths []string) Option { 33 return func(ld *Loader) { 34 ld.defaultRepo = name 35 ld.defaultPaths = paths 36 } 37 } 38 39 /* 40 41 Not sure this is valuable yet, but leaving this option function as a starting 42 point for a future implementation. See https://github.com/palantir/policy-bot/issues/111 43 for some explanation of why this is desired. 44 45 In the Loader implementation, if a ClientCreator and InstallationsService are 46 set, the loadRemoteConfig method would use them to create a new client if the 47 remote owner does not equal the starting owner. 48 49 // WithPrivateRemotes enables loading remote configuration from private 50 // repositories in different organizations. By default, only public 51 // repositories can be remote targets. 52 func WithPrivateRemotes(cc githubapp.ClientCreator, installs githubapp.InstallationsService) Option { 53 return func(ld *Loader) {} 54 } 55 */ 56