github.com/imran-kn/cilium-fork@v1.6.9/pkg/policy/config.go (about) 1 // Copyright 2016-2017 Authors of Cilium 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 policy 16 17 import ( 18 "github.com/cilium/cilium/pkg/lock" 19 "github.com/cilium/cilium/pkg/logging" 20 "github.com/cilium/cilium/pkg/logging/logfields" 21 ) 22 23 var ( 24 log = logging.DefaultLogger.WithField(logfields.LogSubsys, "policy") 25 mutex lock.RWMutex // Protects enablePolicy 26 enablePolicy string // Whether policy enforcement is enabled. 27 ) 28 29 // SetPolicyEnabled sets the policy enablement configuration. Valid values are: 30 // - endpoint.AlwaysEnforce 31 // - endpoint.NeverEnforce 32 // - endpoint.DefaultEnforcement 33 func SetPolicyEnabled(val string) { 34 mutex.Lock() 35 enablePolicy = val 36 mutex.Unlock() 37 } 38 39 // GetPolicyEnabled returns the policy enablement configuration 40 func GetPolicyEnabled() string { 41 mutex.RLock() 42 val := enablePolicy 43 mutex.RUnlock() 44 return val 45 }