AB#2234: Introduce AddTolerationsToDeployment

Add the above function to the different client interfaces.
Update adjacent functions to provided needed ctx and client
objects.
This commit is contained in:
Otto Bittner 2022-07-14 21:15:31 +02:00
parent ad02249b9a
commit 6b6a3ee976
8 changed files with 133 additions and 27 deletions

View file

@ -20,6 +20,7 @@ type Client interface {
// GetObjects converts resources into prepared info fields for use in ApplyOneObject.
GetObjects(resources resources.Marshaler) ([]*resource.Info, error)
CreateConfigMap(ctx context.Context, configMap corev1.ConfigMap) error
AddTolerationsToDeployment(ctx context.Context, tolerations []corev1.Toleration, name string) error
}
// clientGenerator can generate new clients from a kubeconfig.
@ -83,3 +84,17 @@ func (k *Kubectl) CreateConfigMap(ctx context.Context, configMap corev1.ConfigMa
return nil
}
func (k *Kubectl) AddTolerationsToDeployment(ctx context.Context, tolerations []corev1.Toleration, name string) error {
client, err := k.clientGenerator.NewClient(k.kubeconfig)
if err != nil {
return err
}
if err = client.AddTolerationsToDeployment(ctx, tolerations, name); err != nil {
return err
}
return nil
}