mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-06 10:21:05 +02:00
fix lint
This commit is contained in:
parent
bee64a21b8
commit
f9def98eb1
17 changed files with 56 additions and 53 deletions
|
@ -4,6 +4,6 @@ package opa
|
||||||
|
|
||||||
import _ "embed" // to embed files
|
import _ "embed" // to embed files
|
||||||
|
|
||||||
// HeadersRego is the headers.rego script.
|
|
||||||
//go:embed policy/headers.rego
|
//go:embed policy/headers.rego
|
||||||
|
// HeadersRego is the headers.rego script.
|
||||||
var HeadersRego string
|
var HeadersRego string
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// Package main contains pomerium.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// Package main contains the pomerium-integration-tests command.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -78,12 +79,12 @@ func runGenerateConfiguration(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
asYAML, _ := yaml.JSONToYAML([]byte(contents))
|
asYAML, _ := yaml.JSONToYAML([]byte(contents))
|
||||||
|
|
||||||
err = os.MkdirAll(filepath.Dir(dstPath), 0755)
|
err = os.MkdirAll(filepath.Dir(dstPath), 0o755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error creating directory (path=%s): %w", dstPath, err)
|
return fmt.Errorf("error creating directory (path=%s): %w", dstPath, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.WriteFile(dstPath, asYAML, 0600)
|
err = os.WriteFile(dstPath, asYAML, 0o600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error writing file (path=%s): %w", dstPath, err)
|
return fmt.Errorf("error writing file (path=%s): %w", dstPath, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// Package main contains integration tests.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -66,7 +66,6 @@ func (claims Claims) Claims(v interface{}) error {
|
||||||
// Flatten flattens the claims to a FlattenedClaims map. For example:
|
// Flatten flattens the claims to a FlattenedClaims map. For example:
|
||||||
//
|
//
|
||||||
// { "a": { "b": { "c": 12345 } } } => { "a.b.c": [12345] }
|
// { "a": { "b": { "c": 12345 } } } => { "a.b.c": [12345] }
|
||||||
//
|
|
||||||
func (claims Claims) Flatten() FlattenedClaims {
|
func (claims Claims) Flatten() FlattenedClaims {
|
||||||
flattened := make(FlattenedClaims)
|
flattened := make(FlattenedClaims)
|
||||||
for k, v := range claims {
|
for k, v := range claims {
|
||||||
|
|
|
@ -120,7 +120,6 @@ func NewClientFromURL(rawURL string, tlsConfig *tls.Config) (redis.UniversalClie
|
||||||
// pool_timeout: duration
|
// pool_timeout: duration
|
||||||
// idle_timeout: duration
|
// idle_timeout: duration
|
||||||
// idle_check_frequency: duration
|
// idle_check_frequency: duration
|
||||||
//
|
|
||||||
func ParseClusterURL(rawurl string) (*redis.ClusterOptions, error) {
|
func ParseClusterURL(rawurl string) (*redis.ClusterOptions, error) {
|
||||||
u, err := url.Parse(rawurl)
|
u, err := url.Parse(rawurl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// Package main contains main.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -189,7 +190,8 @@ func saveConfig(ctx context.Context, client databroker.DataBrokerServiceClient,
|
||||||
Type: any.GetTypeUrl(),
|
Type: any.GetTypeUrl(),
|
||||||
Id: "test_config",
|
Id: "test_config",
|
||||||
Data: any,
|
Data: any,
|
||||||
}}})
|
}},
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,7 @@ type SignedURL struct {
|
||||||
|
|
||||||
// NewSignedURL creates a new copy of a URL that can be signed with a shared key.
|
// NewSignedURL creates a new copy of a URL that can be signed with a shared key.
|
||||||
//
|
//
|
||||||
// N.B. It is the user's responsibility to make sure the key is 256 bits and
|
// N.B. It is the user's responsibility to make sure the key is 256 bits and the url is not nil.
|
||||||
// the url is not nil.
|
|
||||||
func NewSignedURL(key []byte, uri *url.URL) *SignedURL {
|
func NewSignedURL(key []byte, uri *url.URL) *SignedURL {
|
||||||
return &SignedURL{uri: *uri, key: key, timeNow: time.Now} // uri is copied
|
return &SignedURL{uri: *uri, key: key, timeNow: time.Now} // uri is copied
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// Package pomerium houses the main pomerium CLI command.
|
// Package pomerium houses the main pomerium CLI command.
|
||||||
//
|
|
||||||
package pomerium
|
package pomerium
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -9,12 +9,15 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMerge(t *testing.T) {
|
func TestMerge(t *testing.T) {
|
||||||
|
type key1 struct{}
|
||||||
|
type key2 struct{}
|
||||||
|
|
||||||
t.Run("value", func(t *testing.T) {
|
t.Run("value", func(t *testing.T) {
|
||||||
ctx1 := context.WithValue(context.Background(), "key1", "value1")
|
ctx1 := context.WithValue(context.Background(), key1{}, "value1")
|
||||||
ctx2 := context.WithValue(context.Background(), "key2", "value2")
|
ctx2 := context.WithValue(context.Background(), key2{}, "value2")
|
||||||
ctx3, _ := Merge(ctx1, ctx2)
|
ctx3, _ := Merge(ctx1, ctx2)
|
||||||
assert.Equal(t, "value1", ctx3.Value("key1"))
|
assert.Equal(t, "value1", ctx3.Value(key1{}))
|
||||||
assert.Equal(t, "value2", ctx3.Value("key2"))
|
assert.Equal(t, "value2", ctx3.Value(key2{}))
|
||||||
})
|
})
|
||||||
t.Run("cancel", func(t *testing.T) {
|
t.Run("cancel", func(t *testing.T) {
|
||||||
ctx1, cancel1 := context.WithCancel(context.Background())
|
ctx1, cancel1 := context.WithCancel(context.Background())
|
||||||
|
|
|
@ -10,7 +10,8 @@ import (
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
// A keypair for NIST P-256 / secp256r1
|
// A keypair for NIST P-256 / secp256r1.
|
||||||
|
//
|
||||||
// Generated using:
|
// Generated using:
|
||||||
// openssl ecparam -genkey -name prime256v1 -outform PEM
|
// openssl ecparam -genkey -name prime256v1 -outform PEM
|
||||||
var pemECPrivateKeyP256 = `-----BEGIN EC PARAMETERS-----
|
var pemECPrivateKeyP256 = `-----BEGIN EC PARAMETERS-----
|
||||||
|
|
|
@ -24,7 +24,6 @@ import (
|
||||||
// - Our KEKs are asymmetric Curve25519 keys. We use the *public* key to encrypt the DEK so only the *private* key can
|
// - Our KEKs are asymmetric Curve25519 keys. We use the *public* key to encrypt the DEK so only the *private* key can
|
||||||
// decrypt it.
|
// decrypt it.
|
||||||
// - Our DEKs are symmetric XChaCha20Poly1305 keys.
|
// - Our DEKs are symmetric XChaCha20Poly1305 keys.
|
||||||
//
|
|
||||||
type KeyEncryptionKey interface {
|
type KeyEncryptionKey interface {
|
||||||
ID() string
|
ID() string
|
||||||
KeyBytes() []byte
|
KeyBytes() []byte
|
||||||
|
|
|
@ -59,7 +59,6 @@ func NewLeasers(leaseName string, ttl time.Duration, client DataBrokerServiceCli
|
||||||
//
|
//
|
||||||
// 1. ctx is canceled
|
// 1. ctx is canceled
|
||||||
// 2. a non-cancel error is returned from handler
|
// 2. a non-cancel error is returned from handler
|
||||||
//
|
|
||||||
func (locker *Leaser) Run(ctx context.Context) error {
|
func (locker *Leaser) Run(ctx context.Context) error {
|
||||||
retryTicker := time.NewTicker(locker.ttl / 2)
|
retryTicker := time.NewTicker(locker.ttl / 2)
|
||||||
defer retryTicker.Stop()
|
defer retryTicker.Stop()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue