Error cleaning up secrets: resource name may not be empty

Description

The Kubernetes executor's setupCredentials function creates a new secret with docker repository credentials:

	s.credentials, err = s.kubeClient.CoreV1().Secrets(s.configurationOverwrites.namespace).Create(&secret)
	if err != nil {
		return err
	}

Unfortunetly, when creating a secret, if an error is encountered, an empty resource object is still returned.

Later, in cleanupResources, we check that the credential exists and try to delete it:

	if s.credentials != nil {
		// s.kubeClient.CoreV1().Delete etc...
	}

This causes an additional error, because we're trying to delete a resource that technically doesn't exist:

image

Proposal

Only set s.credentials when Create() on the secret succeeds.

Edited by Arran Walker