Skip to content

Commit

Permalink
Fixing formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Curran committed Aug 16, 2023
1 parent 2ae34b8 commit e2bcba9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
3 changes: 3 additions & 0 deletions internal/tool/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func NewKubectl(kubeConfig clientcmd.ClientConfig) (*Kubectl, error) {

return kubectl, nil
}

func (k Kubectl) WaitForWorkloadResources(context context.Context, namespace string, selector string) error {
deadline, _ := context.Deadline()
unavailableWorkloadResources := []workloadNotReady{{Name: "none", Unavailable: 1}}
Expand Down Expand Up @@ -214,13 +215,15 @@ func getDeploymentsList(k Kubectl, context context.Context, namespace string, se
}
return list.Items, err
}

func getStatefulSetsList(k Kubectl, context context.Context, namespace string, selector string) ([]v1.StatefulSet, error) {
list, err := k.clientset.AppsV1().StatefulSets(namespace).List(context, metav1.ListOptions{LabelSelector: selector})
if err != nil {
return nil, err
}
return list.Items, err
}

func getDaemonSetsList(k Kubectl, context context.Context, namespace string, selector string) ([]v1.DaemonSet, error) {
list, err := k.clientset.AppsV1().DaemonSets(namespace).List(context, metav1.ListOptions{LabelSelector: selector})
if err != nil {
Expand Down
21 changes: 11 additions & 10 deletions internal/tool/kubectl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,11 @@ var testStatefulSets = []v1.StatefulSet{
},
}

var DeploymentList1 []v1.Deployment
var DaemonSetList1 []v1.DaemonSet
var StatefulSetList1 []v1.StatefulSet
var (
DeploymentList1 []v1.Deployment
DaemonSetList1 []v1.DaemonSet
StatefulSetList1 []v1.StatefulSet
)

func TestGetDeploymentList(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
Expand All @@ -171,7 +173,6 @@ func TestGetDeploymentList(t *testing.T) {
require.NoError(t, err)
require.Equal(t, 1, len(deps))
require.Equal(t, testDeployments[0], deps[0])

}

func TestGetDaemonSetList(t *testing.T) {
Expand All @@ -187,7 +188,6 @@ func TestGetDaemonSetList(t *testing.T) {
require.NoError(t, err)
require.Equal(t, 1, len(daemons))
require.Equal(t, testDaemonSets[0], daemons[0])

}

func TestGetStatefulSetList(t *testing.T) {
Expand All @@ -203,7 +203,6 @@ func TestGetStatefulSetList(t *testing.T) {
require.NoError(t, err)
require.Equal(t, 1, len(sts))
require.Equal(t, testStatefulSets[0], sts[0])

}

func TestWaitForWorkloadResources(t *testing.T) {
Expand Down Expand Up @@ -288,7 +287,6 @@ func TestBadToGoodWaitForStatefulSets(t *testing.T) {
k := new(Kubectl)
err := k.WaitForWorkloadResources(ctx, "testNameSpace", "selector")
require.NoError(t, err)

}

func TestTimeExpirationWaitingForWorkloadResources(t *testing.T) {
Expand Down Expand Up @@ -345,6 +343,7 @@ func daemonSetTestListGood(k Kubectl, context context.Context, namespace string,
}
return DaemonSetList1, nil
}

func statefulSetTestListGood(k Kubectl, context context.Context, namespace string, selector string) ([]v1.StatefulSet, error) {
fmt.Println("statefulSetSetTestListGood called")
for index := 0; index < len(testDaemonSets); index++ {
Expand All @@ -364,9 +363,11 @@ func deploymentTestListBad(k Kubectl, context context.Context, namespace string,
return nil, errors.New("pretend error getting deployment list")
}

var deploymentErrorSent = false
var daemonSetErrorSent = false
var statefulSetErrorSent = false
var (
deploymentErrorSent = false
daemonSetErrorSent = false
statefulSetErrorSent = false
)

func deploymentTestListBadToGood(k Kubectl, context context.Context, namespace string, selector string) ([]v1.Deployment, error) {
if !deploymentErrorSent {
Expand Down

0 comments on commit e2bcba9

Please sign in to comment.