Skip to content

Commit

Permalink
Added more DEBUG messages
Browse files Browse the repository at this point in the history
  • Loading branch information
JayBeale committed May 8, 2024
1 parent 52fe61d commit 9cfaff2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
13 changes: 9 additions & 4 deletions aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ func PullIamCredentialsFromAWSWithIMDSv2() (AWSCredentials, error) {
return credentials, err
}

// println("DEBUG: Got IMDSv2 token: " + string(token))
if Verbose {
println("DEBUG: Got IMDSv2 token: " + string(token))
}

// REQUEST 2: Get the account/role name
accountURL := "http://169.254.169.254/latest/meta-data/iam/security-credentials/"
Expand All @@ -208,7 +210,9 @@ func PullIamCredentialsFromAWSWithIMDSv2() (AWSCredentials, error) {
fmt.Println("Error reading security credentials:", err)
return credentials, err
}
// fmt.Println("DEBUG: Role Name:", string(accountName))
if Verbose {
fmt.Println("DEBUG: Role Name:", string(accountName))
}

// REQUEST 3: Get the security credentials
credURL := accountURL + string(accountName)
Expand All @@ -233,8 +237,9 @@ func PullIamCredentialsFromAWSWithIMDSv2() (AWSCredentials, error) {
fmt.Println("Error reading security credentials:", err)
return credentials, err
}
// fmt.Println("DEBUG Credentials:", string(temporaryCredentials))

if Verbose {
fmt.Println("DEBUG Credentials:", string(temporaryCredentials))
}
// Parse result as an account, then construct a request asking for that account's credentials

err = json.Unmarshal(temporaryCredentials, &credentials)
Expand Down
3 changes: 3 additions & 0 deletions kubectl_wrappers.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ func runKubectlWithConfig(cfg ServerInfo, stdin io.Reader, stdout, stderr io.Wri
connArgs = append(connArgs, "--client-key="+keyTmpFile.Name())
}

if Verbose {
println("DEBUG: Running kubectl with the following arguments: ", connArgs)
}
return runKubectl(stdin, stdout, stderr, append(connArgs, cmdArgs...)...)
}

Expand Down
2 changes: 1 addition & 1 deletion peirates.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var UseAuthCanI bool = true
// Main starts Peirates[]
func Main() {
// Peirates version string
var version = "1.1.20"
var version = "1.1.21a"

var err error

Expand Down
3 changes: 3 additions & 0 deletions service_account_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ func assignAuthenticationCertificateAndKeyToConnection(keypair ClientCertificate
info.ClientKeyData = keypair.ClientKeyData
info.ClientCertName = keypair.Name
info.APIServer = keypair.APIServer
if Verbose {
println("DEBUG: Switching API server to: " + info.APIServer)
}
info.Namespace = "default"

// Zero out any service account token, so it's clear what to authenticate with.
Expand Down

0 comments on commit 9cfaff2

Please sign in to comment.