-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inject certificates if proxy is enabled
- Loading branch information
Showing
12 changed files
with
257 additions
and
71 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,71 @@ | ||
package actions | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
rhtasv1alpha1 "github.com/securesign/operator/api/v1alpha1" | ||
"github.com/securesign/operator/internal/controller/common/action" | ||
"github.com/securesign/operator/internal/controller/constants" | ||
futils "github.com/securesign/operator/internal/controller/fulcio/utils" | ||
"k8s.io/apimachinery/pkg/api/meta" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" | ||
) | ||
|
||
func NewConfigMapAction() action.Action[rhtasv1alpha1.Fulcio] { | ||
return &configMapAction{} | ||
} | ||
|
||
type configMapAction struct { | ||
action.BaseAction | ||
} | ||
|
||
func (i configMapAction) Name() string { | ||
return "configmap" | ||
} | ||
|
||
func (i configMapAction) CanHandle(_ context.Context, instance *rhtasv1alpha1.Fulcio) bool { | ||
c := meta.FindStatusCondition(instance.Status.Conditions, constants.Ready) | ||
return (c.Reason == constants.Creating || c.Reason == constants.Ready) && instance.Spec.Config.Proxy.Enabled | ||
} | ||
|
||
func (i configMapAction) Handle(ctx context.Context, instance *rhtasv1alpha1.Fulcio) *action.Result { | ||
var ( | ||
updated bool | ||
err error | ||
) | ||
|
||
cm, err := futils.CreateConfigMap(instance, "ca-inject") | ||
if err != nil { | ||
meta.SetStatusCondition(&instance.Status.Conditions, metav1.Condition{ | ||
Type: constants.Ready, | ||
Status: metav1.ConditionFalse, | ||
Reason: constants.Failure, | ||
Message: err.Error(), | ||
}) | ||
return i.FailedWithStatusUpdate(ctx, fmt.Errorf("could create ConfigMap: %w", err), instance) | ||
} | ||
|
||
if err = controllerutil.SetControllerReference(instance, cm, i.Client.Scheme()); err != nil { | ||
return i.Failed(fmt.Errorf("could not set controller reference for ConfigMap: %w", err)) | ||
} | ||
|
||
if updated, err = i.Ensure(ctx, cm); err != nil { | ||
meta.SetStatusCondition(&instance.Status.Conditions, metav1.Condition{ | ||
Type: constants.Ready, | ||
Status: metav1.ConditionFalse, | ||
Reason: constants.Failure, | ||
Message: err.Error(), | ||
}) | ||
return i.FailedWithStatusUpdate(ctx, fmt.Errorf("could not create Fulcio ConfigMap: %w", err), instance) | ||
} | ||
|
||
if updated { | ||
meta.SetStatusCondition(&instance.Status.Conditions, metav1.Condition{Type: constants.Ready, | ||
Status: metav1.ConditionFalse, Reason: constants.Creating, Message: "ConfigMap created"}) | ||
return i.StatusUpdate(ctx, instance) | ||
} else { | ||
return i.Continue() | ||
} | ||
} |
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,18 @@ | ||
package utils | ||
|
||
import ( | ||
"github.com/securesign/operator/api/v1alpha1" | ||
corev1 "k8s.io/api/core/v1" | ||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func CreateConfigMap(instance *v1alpha1.Fulcio, configMapName string) (*corev1.ConfigMap, error) { | ||
|
||
return &corev1.ConfigMap{ | ||
ObjectMeta: v1.ObjectMeta{ | ||
Name: configMapName, | ||
Namespace: instance.Namespace, | ||
Labels: map[string]string{"config.openshift.io/inject-trusted-cabundle": "true"}, | ||
}, | ||
}, nil | ||
} |
Oops, something went wrong.