Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkg/operator/targetconfigcontroller: wait for kcm-o to generate certs…
… before rollout Signed-off-by: Sam Batschelet <sbatsche@redhat.com>
- Loading branch information
Showing
2 changed files
with
84 additions
and
1 deletion.
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
52 changes: 52 additions & 0 deletions
52
pkg/operator/targetconfigcontroller/targetconfigcontroller_test.go
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,52 @@ | ||
package targetconfigcontroller | ||
|
||
import ( | ||
"testing" | ||
|
||
v1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func Test_checkCSRControllerCAConfigMap(t *testing.T) { | ||
scenarios := []struct { | ||
name string | ||
configMap *v1.ConfigMap | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "happy path: cluster-kube-controller-manager-operator has generated cert", | ||
configMap: csrControllerCAConfigMap("cluster-kube-controller-manager-operator"), | ||
}, | ||
{ | ||
name: "cert missing managed fields", | ||
configMap: &v1.ConfigMap{}, | ||
wantErr: true, | ||
}, | ||
{ | ||
name: "unexpected manager", | ||
configMap: csrControllerCAConfigMap("foobar"), | ||
wantErr: true, | ||
}, | ||
} | ||
for _, scenario := range scenarios { | ||
t.Run(scenario.name, func(t *testing.T) { | ||
gotErr := checkCSRControllerCAConfigMap(scenario.configMap) | ||
if gotErr != nil && !scenario.wantErr { | ||
t.Errorf("unexpected expected error %v", gotErr) | ||
} | ||
if gotErr == nil && scenario.wantErr { | ||
t.Errorf("expected error got nil") | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func csrControllerCAConfigMap(manager string) *v1.ConfigMap { | ||
return &v1.ConfigMap{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "csr-controller-ca", | ||
Namespace: "openshift-config-managed", | ||
ManagedFields: []metav1.ManagedFieldsEntry{{Manager: manager}}, | ||
}, | ||
} | ||
} |