Files
my-rook-config/pkg/operator/k8sutil/test/deployment.go
T
Travis Nielsen e74c7eaef8 ceph: refactor context and clusterInfo passed to the ceph commands
To provide more context for executing commands in a ceph cluster,
the full clusterInfo is now passed to the ceph execution commands.
All information about the cluster will now be available throughout
all the areas of the operator. The namespace, ceph credentials,
mon endpoints, and other info is a core part of that cluster info.

Arguments passed through the controllers are also simplified for
mons, mgr, osds, and other daemons where the parameters had
become too complex.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2020-07-16 15:54:54 -06:00

42 lines
1.9 KiB
Go

package test
import (
"github.com/rook/rook/pkg/clusterd"
"github.com/rook/rook/pkg/daemon/ceph/client"
apps "k8s.io/api/apps/v1"
)
// UpdateDeploymentAndWaitStub returns a stub replacement for the UpdateDeploymentAndWait function
// for unit tests which always returns success (nil). The generated simple clientset doesn't seem to
// handle the Deployment.Update method as expected. The deployment is instead zero-ed out when the
// deployment is updated with an unchanged version, which breaks unit tests.
// In order to still test the UpdateDeploymentAndWait function, the stub function returned will
// append a copy of the deployment used as input to the list of deployments updated. The function
// returns a pointer to this slice which the calling func may use to verify the expected contents of
// deploymentsUpdated based on expected behavior.
func UpdateDeploymentAndWaitStub() (
stubFunc func(context *clusterd.Context, clusterInfo *client.ClusterInfo, deployment *apps.Deployment, daemonType, daemonName string, skipUpgradeChecks, continueUpgradeAfterChecksEvenIfNotHealthy bool) error,
deploymentsUpdated *[]*apps.Deployment,
) {
deploymentsUpdated = &[]*apps.Deployment{}
stubFunc = func(context *clusterd.Context, clusterInfo *client.ClusterInfo, deployment *apps.Deployment, daemonType, daemonName string, skipUpgradeChecks, continueUpgradeAfterChecksEvenIfNotHealthy bool) error {
*deploymentsUpdated = append(*deploymentsUpdated, deployment)
return nil
}
return stubFunc, deploymentsUpdated
}
// DeploymentNamesUpdated converts a deploymentsUpdated slice into a string slice of deployment names
func DeploymentNamesUpdated(deploymentsUpdated *[]*apps.Deployment) []string {
ns := []string{}
for _, d := range *deploymentsUpdated {
ns = append(ns, d.GetName())
}
return ns
}
// ClearDeploymentsUpdated clears the deploymentsUpdated list
func ClearDeploymentsUpdated(deploymentsUpdated *[]*apps.Deployment) {
*deploymentsUpdated = []*apps.Deployment{}
}