Skip to content

Commit

Permalink
fix: check service account token first
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Oct 3, 2023
1 parent 781e2e3 commit 03057e2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions cmd/tasks_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
"io/ioutil"
"os"
"strings"

Expand Down Expand Up @@ -169,7 +168,7 @@ func iterateTaskGenerator(allowDeployMissingErrors bool, taskRunner runTaskInEnv
if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
retErr = fmt.Errorf("A target namespace is required to run pre/post-rollout tasks")
}
nsb, err := ioutil.ReadFile(filename)
nsb, err := os.ReadFile(filename)
if err != nil {
retErr = err
}
Expand Down
5 changes: 2 additions & 3 deletions internal/lagoon/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
"io/ioutil"
"os"
"strconv"
"time"
Expand Down Expand Up @@ -85,9 +84,9 @@ func getConfig() (*rest.Config, error) {
if *kubeconfig == "" {
//Fall back on out of cluster
// read the deployer token.
token, err := ioutil.ReadFile("/var/run/secrets/lagoon/deployer/token")
token, err := os.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/token")
if err != nil {
token, err = ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/token")
token, err = os.ReadFile("/var/run/secrets/lagoon/deployer/token")
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 03057e2

Please sign in to comment.