Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Luke Kysow <[email protected]>
  • Loading branch information
2 people authored and thisisnotashwin committed Aug 13, 2020
1 parent b8ceaf5 commit 53aca86
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion subcommand/acl-init/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (c *Command) Run(args []string) int {
}

func (c *Command) getSecret(secretName string) (string, error) {
secret, err := c.k8sClient.CoreV1().Secrets(c.flagNamespace).Get(context.Background(), secretName, metav1.GetOptions{})
secret, err := c.k8sClient.CoreV1().Secrets(c.flagNamespace).Get(context.TODO(), secretName, metav1.GetOptions{})
if err != nil {
return "", err
}
Expand Down
6 changes: 3 additions & 3 deletions subcommand/create-federation-secret/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ func (c *Command) Run(args []string) int {

// Now create the Kubernetes secret.
logger.Info("Creating/updating Kubernetes secret", "name", federationSecret.ObjectMeta.Name, "ns", c.flagK8sNamespace)
_, err = c.k8sClient.CoreV1().Secrets(c.flagK8sNamespace).Create(context.Background(), federationSecret, metav1.CreateOptions{})
_, err = c.k8sClient.CoreV1().Secrets(c.flagK8sNamespace).Create(context.TODO(), federationSecret, metav1.CreateOptions{})
if k8serrors.IsAlreadyExists(err) {
logger.Info("Secret already exists, updating instead")
_, err = c.k8sClient.CoreV1().Secrets(c.flagK8sNamespace).Update(context.Background(), federationSecret, metav1.UpdateOptions{})
_, err = c.k8sClient.CoreV1().Secrets(c.flagK8sNamespace).Update(context.TODO(), federationSecret, metav1.UpdateOptions{})
}

if err != nil {
Expand Down Expand Up @@ -298,7 +298,7 @@ func (c *Command) replicationToken(logger hclog.Logger) ([]byte, error) {
// This will run forever but it's running as a Helm hook so Helm will timeout
// after a configurable time period.
backoff.Retry(func() error {
secret, err := c.k8sClient.CoreV1().Secrets(c.flagK8sNamespace).Get(context.Background(), secretName, metav1.GetOptions{})
secret, err := c.k8sClient.CoreV1().Secrets(c.flagK8sNamespace).Get(context.TODO(), secretName, metav1.GetOptions{})
if k8serrors.IsNotFound(err) {
logger.Warn("secret not yet created, retrying", "secret", secretName, "ns", c.flagK8sNamespace)
return errors.New("")
Expand Down
4 changes: 2 additions & 2 deletions subcommand/delete-completed-job/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (c *Command) Run(args []string) int {
// Wait for job to complete.
logger.Info(fmt.Sprintf("waiting for job %q to complete successfully", jobName))
for {
job, err := c.k8sClient.BatchV1().Jobs(c.flagNamespace).Get(context.Background(), jobName, metav1.GetOptions{})
job, err := c.k8sClient.BatchV1().Jobs(c.flagNamespace).Get(context.TODO(), jobName, metav1.GetOptions{})
if k8serrors.IsNotFound(err) {
logger.Info(fmt.Sprintf("job %q does not exist, no need to delete", jobName))
return 0
Expand Down Expand Up @@ -142,7 +142,7 @@ func (c *Command) Run(args []string) int {
// ourselves.
logger.Info(fmt.Sprintf("job %q has succeeded, deleting", jobName))
propagationPolicy := metav1.DeletePropagationForeground
err = c.k8sClient.BatchV1().Jobs(c.flagNamespace).Delete(context.Background(), jobName, metav1.DeleteOptions{
err = c.k8sClient.BatchV1().Jobs(c.flagNamespace).Delete(context.TODO(), jobName, metav1.DeleteOptions{
// Needed so that the underlying pods are also deleted.
PropagationPolicy: &propagationPolicy,
})
Expand Down
2 changes: 1 addition & 1 deletion subcommand/inject-connect/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ func (c *Command) certWatcher(ctx context.Context, ch <-chan cert.Bundle, client

_, err := clientset.AdmissionregistrationV1beta1().
MutatingWebhookConfigurations().
Patch(context.Background(), c.flagAutoName, types.JSONPatchType, []byte(fmt.Sprintf(
Patch(context.TODO(), c.flagAutoName, types.JSONPatchType, []byte(fmt.Sprintf(
`[{
"op": "add",
"path": "/webhooks/0/clientConfig/caBundle",
Expand Down
2 changes: 1 addition & 1 deletion subcommand/server-acl-init/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ func (c *Command) Run(args []string) int {
// reading the Kubernetes Secret with name secretName.
// If there is no bootstrap token yet, then it returns an empty string (not an error).
func (c *Command) getBootstrapToken(secretName string) (string, error) {
secret, err := c.clientset.CoreV1().Secrets(c.flagK8sNamespace).Get(context.Background(), secretName, metav1.GetOptions{})
secret, err := c.clientset.CoreV1().Secrets(c.flagK8sNamespace).Get(context.TODO(), secretName, metav1.GetOptions{})
if err != nil {
if k8serrors.IsNotFound(err) {
return "", nil
Expand Down
2 changes: 1 addition & 1 deletion subcommand/service-address/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (c *Command) Run(args []string) int {
var address string
var unretryableErr error
backoff.Retry(withErrLogger(log, func() error {
svc, err := c.k8sClient.CoreV1().Services(c.flagNamespace).Get(context.Background(), c.flagServiceName, metav1.GetOptions{})
svc, err := c.k8sClient.CoreV1().Services(c.flagNamespace).Get(context.TODO(), c.flagServiceName, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("getting service %s: %s", c.flagServiceName, err)
}
Expand Down

0 comments on commit 53aca86

Please sign in to comment.