GetOperatorNamespace returns the namespace the operator should be running in. This function was ported over from Operator SDK 0.17.0 and modified.
()
| 29 | // |
| 30 | // This function was ported over from Operator SDK 0.17.0 and modified. |
| 31 | func GetOperatorNamespace() (string, error) { |
| 32 | nsBytes, err := os.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace") |
| 33 | if err != nil { |
| 34 | if os.IsNotExist(err) { |
| 35 | return "", fmt.Errorf("could not read namespace from mounted serviceaccount info") |
| 36 | } |
| 37 | return "", err |
| 38 | } |
| 39 | ns := strings.TrimSpace(string(nsBytes)) |
| 40 | return ns, nil |
| 41 | } |
| 42 | |
| 43 | // GetWatchNamespace returns the namespace the operator should be watching for changes |
| 44 | // |
no outgoing calls
no test coverage detected