-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For FIPS support we need to be able to tell when an OCP cluster has been deployed in FIPS mode (it's a day one operation). This patch adds the `IsFipsCluster` function that checks if FIPS is enabled or not. The way to do that is checking the install-config YAML that is stored in the cluster-config-v1 Config Map. If we find the fips key, and it has the true value, then it's deployed in FIPS mode, otherwise it isn't.
- Loading branch information
Showing
3 changed files
with
51 additions
and
0 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,49 @@ | ||
/* | ||
Copyright 2024 Red Hat | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package ocp | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/openstack-k8s-operators/lib-common/modules/common/helper" | ||
|
||
"github.com/ghodss/yaml" | ||
corev1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/types" | ||
) | ||
|
||
// IsFipsCluster - Check if OCP has fips enabled which is a day 1 operation | ||
func IsFipsCluster(ctx context.Context, h *helper.Helper) (bool, error) { | ||
configMap := &corev1.ConfigMap{} | ||
err := h.GetClient().Get(ctx, types.NamespacedName{Name: "cluster-config-v1", Namespace: "kube-system"}, configMap) | ||
if err != nil { | ||
return false, err | ||
} | ||
|
||
var installConfig map[string]interface{} | ||
installConfigYAML := configMap.Data["install-config"] | ||
err = yaml.Unmarshal([]byte(installConfigYAML), &installConfig) | ||
if err != nil { | ||
return false, err | ||
} | ||
|
||
fipsEnabled, ok := installConfig["fips"].(bool) | ||
if !ok { | ||
return false, nil | ||
} | ||
return fipsEnabled, nil | ||
} |