chore: Wrap long lines in plugins/common (#12182)

This commit is contained in:
Paweł Żak 2022-11-08 18:35:08 +01:00 committed by GitHub
parent 979eec8fb8
commit 8203b503b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 9 deletions

View File

@ -2,6 +2,7 @@ package aws
import (
"context"
awsV2 "github.com/aws/aws-sdk-go-v2/aws"
configV2 "github.com/aws/aws-sdk-go-v2/config"
credentialsV2 "github.com/aws/aws-sdk-go-v2/credentials"
@ -60,11 +61,16 @@ func (c *CredentialConfig) configWithAssumeCredentials() (awsV2.Config, error) {
var provider awsV2.CredentialsProvider
stsService := sts.NewFromConfig(defaultConfig)
if c.WebIdentityTokenFile != "" {
provider = stscredsV2.NewWebIdentityRoleProvider(stsService, c.RoleARN, stscredsV2.IdentityTokenFile(c.WebIdentityTokenFile), func(opts *stscredsV2.WebIdentityRoleOptions) {
if c.RoleSessionName != "" {
opts.RoleSessionName = c.RoleSessionName
}
})
provider = stscredsV2.NewWebIdentityRoleProvider(
stsService,
c.RoleARN,
stscredsV2.IdentityTokenFile(c.WebIdentityTokenFile),
func(opts *stscredsV2.WebIdentityRoleOptions) {
if c.RoleSessionName != "" {
opts.RoleSessionName = c.RoleSessionName
}
},
)
} else {
provider = stscredsV2.NewAssumeRoleProvider(stsService, c.RoleARN, func(opts *stscredsV2.AssumeRoleOptions) {
if c.RoleSessionName != "" {

View File

@ -67,7 +67,8 @@ func generateCert(host string, rsaBits int, certFile, keyFile string, dur time.D
NotBefore: notBefore,
NotAfter: notAfter,
KeyUsage: x509.KeyUsageContentCommitment | x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageDataEncipherment | x509.KeyUsageCertSign,
KeyUsage: x509.KeyUsageContentCommitment | x509.KeyUsageKeyEncipherment |
x509.KeyUsageDigitalSignature | x509.KeyUsageDataEncipherment | x509.KeyUsageCertSign,
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth, x509.ExtKeyUsageClientAuth},
BasicConstraintsValid: true,
}
@ -191,7 +192,8 @@ func (o *OpcUAClient) generateClientOpts(endpoints []*ua.EndpointDescription) ([
case strings.HasPrefix(policy, ua.SecurityPolicyURIPrefix):
secPolicy = policy
policy = ""
case policy == "None" || policy == "Basic128Rsa15" || policy == "Basic256" || policy == "Basic256Sha256" || policy == "Aes128_Sha256_RsaOaep" || policy == "Aes256_Sha256_RsaPss":
case policy == "None" || policy == "Basic128Rsa15" || policy == "Basic256" || policy == "Basic256Sha256" ||
policy == "Aes128_Sha256_RsaOaep" || policy == "Aes256_Sha256_RsaPss":
secPolicy = ua.SecurityPolicyURIPrefix + policy
policy = ""
default:
@ -261,7 +263,11 @@ func (o *OpcUAClient) generateClientOpts(endpoints []*ua.EndpointDescription) ([
o.Log.Debugf("Evaluating endpoint %s, policy %s, mode %s, level %d", e.EndpointURL, e.SecurityPolicyURI, e.SecurityMode, e.SecurityLevel)
if e.SecurityPolicyURI == secPolicy && e.SecurityMode == secMode && (serverEndpoint == nil || e.SecurityLevel >= serverEndpoint.SecurityLevel) {
serverEndpoint = e
o.Log.Debugf("Security policy and mode found. Using server endpoint %s for security. Policy %s", serverEndpoint.EndpointURL, serverEndpoint.SecurityPolicyURI)
o.Log.Debugf(
"Security policy and mode found. Using server endpoint %s for security. Policy %s",
serverEndpoint.EndpointURL,
serverEndpoint.SecurityPolicyURI,
)
}
}
}

View File

@ -13,7 +13,12 @@ import (
)
var pollInterval = flag.Duration("poll_interval", 1*time.Second, "how often to send metrics")
var pollIntervalDisabled = flag.Bool("poll_interval_disabled", false, "set to true to disable polling. You want to use this when you are sending metrics on your own schedule")
var pollIntervalDisabled = flag.Bool(
"poll_interval_disabled",
false,
"set to true to disable polling. You want to use this when you are sending metrics on your own schedule",
)
var configFile = flag.String("config", "", "path to the config file for this plugin")
var err error