Remove client pkg from kubectl pkg (#638)

The nested client pkg was necessary to implement a generator pattern.
The generator was necessary as the Kubewrapper type
expects a k8sapi.Client object during instantiation.
However, the required kubeconfig is not ready during Kubewrapper creation.
This patch relies on an Initialize function to set the Kubeconfig
and hands over an empty struct during Kubewrapper creation.
This allows us to remove the extra Client abstraction.
This commit is contained in:
Otto Bittner 2022-11-25 11:19:22 +01:00 committed by GitHub
parent 1968dfe70c
commit 6af54142f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 93 additions and 1197 deletions

View file

@ -502,7 +502,6 @@ func (s *stubConfigProvider) JoinConfiguration(_ bool) k8sapi.KubeadmJoinYAML {
}
type stubKubectl struct {
applyErr error
createConfigMapErr error
addTolerationsToDeploymentErr error
addTNodeSelectorsToDeploymentErr error
@ -510,17 +509,10 @@ type stubKubectl struct {
listAllNamespacesErr error
listAllNamespacesResp *corev1.NamespaceList
resources []kubernetes.Marshaler
kubeconfigs [][]byte
}
func (s *stubKubectl) Apply(resources kubernetes.Marshaler, forceConflicts bool) error {
s.resources = append(s.resources, resources)
return s.applyErr
}
func (s *stubKubectl) SetKubeconfig(kubeconfig []byte) {
s.kubeconfigs = append(s.kubeconfigs, kubeconfig)
func (s *stubKubectl) Initialize(kubeconfig []byte) error {
return nil
}
func (s *stubKubectl) CreateConfigMap(ctx context.Context, configMap corev1.ConfigMap) error {