forked from cilium/cilium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bgp: move config mode struct to separate package
Moving ConfigMode of bgp controller into its own package. It is done so ConfigMode can be used in various other sub-packages without causing circular dependency. Signed-off-by: harsimran pabla <hpabla@isovalent.com>
- Loading branch information
1 parent
7a930fa
commit 373f32e
Showing
4 changed files
with
79 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Authors of Cilium | ||
|
||
package mode | ||
|
||
import ( | ||
"github.com/cilium/cilium/pkg/lock" | ||
) | ||
|
||
// Mode defines the modes in which BGP agent can be configured. | ||
type Mode int | ||
|
||
const ( | ||
// Disabled mode, BGP control plane is not enabled | ||
Disabled Mode = iota | ||
// BGPv1 mode is enabled, BGP configuration of the agent will rely on matching CiliumBGPPeeringPolicy for the node. | ||
BGPv1 | ||
// BGPv2 mode is enabled, BGP configuration of the agent will rely on CiliumBGPNodeConfig, CiliumBGPAdvertisement and CiliumBGPPeerConfig. | ||
BGPv2 | ||
) | ||
|
||
func NewConfigMode() *ConfigMode { | ||
return &ConfigMode{} | ||
} | ||
|
||
type ConfigMode struct { | ||
lock.RWMutex | ||
configMode Mode | ||
} | ||
|
||
func (m *ConfigMode) Get() Mode { | ||
m.RLock() | ||
defer m.RUnlock() | ||
return m.configMode | ||
} | ||
|
||
func (m *ConfigMode) Set(mode Mode) { | ||
m.Lock() | ||
defer m.Unlock() | ||
m.configMode = mode | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters