chore: Wrap long lines in plugins/common (#12182)
This commit is contained in:
parent
979eec8fb8
commit
8203b503b7
|
|
@ -2,6 +2,7 @@ package aws
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
awsV2 "github.com/aws/aws-sdk-go-v2/aws"
|
awsV2 "github.com/aws/aws-sdk-go-v2/aws"
|
||||||
configV2 "github.com/aws/aws-sdk-go-v2/config"
|
configV2 "github.com/aws/aws-sdk-go-v2/config"
|
||||||
credentialsV2 "github.com/aws/aws-sdk-go-v2/credentials"
|
credentialsV2 "github.com/aws/aws-sdk-go-v2/credentials"
|
||||||
|
|
@ -60,11 +61,16 @@ func (c *CredentialConfig) configWithAssumeCredentials() (awsV2.Config, error) {
|
||||||
var provider awsV2.CredentialsProvider
|
var provider awsV2.CredentialsProvider
|
||||||
stsService := sts.NewFromConfig(defaultConfig)
|
stsService := sts.NewFromConfig(defaultConfig)
|
||||||
if c.WebIdentityTokenFile != "" {
|
if c.WebIdentityTokenFile != "" {
|
||||||
provider = stscredsV2.NewWebIdentityRoleProvider(stsService, c.RoleARN, stscredsV2.IdentityTokenFile(c.WebIdentityTokenFile), func(opts *stscredsV2.WebIdentityRoleOptions) {
|
provider = stscredsV2.NewWebIdentityRoleProvider(
|
||||||
|
stsService,
|
||||||
|
c.RoleARN,
|
||||||
|
stscredsV2.IdentityTokenFile(c.WebIdentityTokenFile),
|
||||||
|
func(opts *stscredsV2.WebIdentityRoleOptions) {
|
||||||
if c.RoleSessionName != "" {
|
if c.RoleSessionName != "" {
|
||||||
opts.RoleSessionName = c.RoleSessionName
|
opts.RoleSessionName = c.RoleSessionName
|
||||||
}
|
}
|
||||||
})
|
},
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
provider = stscredsV2.NewAssumeRoleProvider(stsService, c.RoleARN, func(opts *stscredsV2.AssumeRoleOptions) {
|
provider = stscredsV2.NewAssumeRoleProvider(stsService, c.RoleARN, func(opts *stscredsV2.AssumeRoleOptions) {
|
||||||
if c.RoleSessionName != "" {
|
if c.RoleSessionName != "" {
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,8 @@ func generateCert(host string, rsaBits int, certFile, keyFile string, dur time.D
|
||||||
NotBefore: notBefore,
|
NotBefore: notBefore,
|
||||||
NotAfter: notAfter,
|
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},
|
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth, x509.ExtKeyUsageClientAuth},
|
||||||
BasicConstraintsValid: true,
|
BasicConstraintsValid: true,
|
||||||
}
|
}
|
||||||
|
|
@ -191,7 +192,8 @@ func (o *OpcUAClient) generateClientOpts(endpoints []*ua.EndpointDescription) ([
|
||||||
case strings.HasPrefix(policy, ua.SecurityPolicyURIPrefix):
|
case strings.HasPrefix(policy, ua.SecurityPolicyURIPrefix):
|
||||||
secPolicy = policy
|
secPolicy = policy
|
||||||
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
|
secPolicy = ua.SecurityPolicyURIPrefix + policy
|
||||||
policy = ""
|
policy = ""
|
||||||
default:
|
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)
|
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) {
|
if e.SecurityPolicyURI == secPolicy && e.SecurityMode == secMode && (serverEndpoint == nil || e.SecurityLevel >= serverEndpoint.SecurityLevel) {
|
||||||
serverEndpoint = e
|
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,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var pollInterval = flag.Duration("poll_interval", 1*time.Second, "how often to send metrics")
|
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 configFile = flag.String("config", "", "path to the config file for this plugin")
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue