mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-25 14:08:09 +02:00
inegration: fix linting issues
This commit is contained in:
parent
cb3e78cd01
commit
b11a336a33
8 changed files with 21 additions and 12 deletions
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TLSCerts holds the certificate authority, certificate and certificate key for a TLS connection.
|
||||||
type TLSCerts struct {
|
type TLSCerts struct {
|
||||||
CA string
|
CA string
|
||||||
Cert string
|
Cert string
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// Package cluster is used to configure a kubernetes cluster for testing.
|
||||||
package cluster
|
package cluster
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -8,6 +9,7 @@ import (
|
||||||
"golang.org/x/net/publicsuffix"
|
"golang.org/x/net/publicsuffix"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// A Cluster is used to configure a kubernetes cluster.
|
||||||
type Cluster struct {
|
type Cluster struct {
|
||||||
workingDir string
|
workingDir string
|
||||||
|
|
||||||
|
@ -15,12 +17,15 @@ type Cluster struct {
|
||||||
certs *TLSCerts
|
certs *TLSCerts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// New creates a new Cluster.
|
||||||
func New(workingDir string) *Cluster {
|
func New(workingDir string) *Cluster {
|
||||||
return &Cluster{
|
return &Cluster{
|
||||||
workingDir: workingDir,
|
workingDir: workingDir,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewHTTPClient creates a new *http.Client, with a cookie jar, and a LocalRoundTripper
|
||||||
|
// which routes traffic to the nginx ingress controller.
|
||||||
func (cluster *Cluster) NewHTTPClient() *http.Client {
|
func (cluster *Cluster) NewHTTPClient() *http.Client {
|
||||||
jar, err := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
|
jar, err := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
package cluster
|
|
||||||
|
|
||||||
type Config struct {
|
|
||||||
WorkingDirectory string
|
|
||||||
HTTPSPort int
|
|
||||||
}
|
|
|
@ -40,7 +40,7 @@ func (cluster *Cluster) Setup(ctx context.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonsrc, err := cluster.generateManifests(ctx)
|
jsonsrc, err := cluster.generateManifests()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ func (cluster *Cluster) getNodeHTTPSAddr(ctx context.Context) (hostport string,
|
||||||
return net.JoinHostPort(hostIP, port), nil
|
return net.JoinHostPort(hostIP, port), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cluster *Cluster) generateManifests(ctx context.Context) (string, error) {
|
func (cluster *Cluster) generateManifests() (string, error) {
|
||||||
src, err := ioutil.ReadFile(filepath.Join(cluster.workingDir, "manifests", "manifests.jsonnet"))
|
src, err := ioutil.ReadFile(filepath.Join(cluster.workingDir, "manifests", "manifests.jsonnet"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("error reading manifest jsonnet src: %w", err)
|
return "", fmt.Errorf("error reading manifest jsonnet src: %w", err)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// Package flows has helper functions for working with pomerium end-user use-case flows.
|
||||||
package flows
|
package flows
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// Package forms has helper functions for working with HTML forms.
|
||||||
package forms
|
package forms
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -69,6 +70,7 @@ func Parse(r io.Reader) []Form {
|
||||||
return forms
|
return forms
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewRequestWithContext creates a new request from the form details.
|
||||||
func (f *Form) NewRequestWithContext(ctx context.Context, baseURL *url.URL) (*http.Request, error) {
|
func (f *Form) NewRequestWithContext(ctx context.Context, baseURL *url.URL) (*http.Request, error) {
|
||||||
actionURL, err := url.Parse(f.Action)
|
actionURL, err := url.Parse(f.Action)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// Package httputil has helper functions for working with HTTP.
|
||||||
package httputil
|
package httputil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -11,6 +12,8 @@ type localRoundTripper struct {
|
||||||
portToAddr map[string]string
|
portToAddr map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewLocalRoundTripper creates a new http.RoundTripper which routes localhost traffic to the remote destinations
|
||||||
|
// defined by `portToAddr`.
|
||||||
func NewLocalRoundTripper(underlying http.RoundTripper, portToAddr map[string]string) http.RoundTripper {
|
func NewLocalRoundTripper(underlying http.RoundTripper, portToAddr map[string]string) http.RoundTripper {
|
||||||
lrt := &localRoundTripper{underlying: underlying, portToAddr: portToAddr}
|
lrt := &localRoundTripper{underlying: underlying, portToAddr: portToAddr}
|
||||||
return lrt
|
return lrt
|
||||||
|
|
|
@ -15,8 +15,6 @@ import (
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
const localHTTPSPort = 9443
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
mainCtx context.Context
|
mainCtx context.Context
|
||||||
testcluster *cluster.Cluster
|
testcluster *cluster.Cluster
|
||||||
|
@ -39,8 +37,7 @@ func TestMain(m *testing.M) {
|
||||||
mainCtx, clearTimeout = context.WithTimeout(mainCtx, time.Minute*10)
|
mainCtx, clearTimeout = context.WithTimeout(mainCtx, time.Minute*10)
|
||||||
defer clearTimeout()
|
defer clearTimeout()
|
||||||
|
|
||||||
_, mainTestFilePath, _, _ := runtime.Caller(0)
|
testcluster = cluster.New(getBaseDir())
|
||||||
testcluster = cluster.New(filepath.Dir(mainTestFilePath))
|
|
||||||
if err := testcluster.Setup(mainCtx); err != nil {
|
if err := testcluster.Setup(mainCtx); err != nil {
|
||||||
log.Fatal().Err(err).Send()
|
log.Fatal().Err(err).Send()
|
||||||
}
|
}
|
||||||
|
@ -50,3 +47,9 @@ func TestMain(m *testing.M) {
|
||||||
gocleanup.Cleanup()
|
gocleanup.Cleanup()
|
||||||
os.Exit(status)
|
os.Exit(status)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getBaseDir returns the directory that main_test resides in
|
||||||
|
func getBaseDir() string {
|
||||||
|
_, file, _, _ := runtime.Caller(0) //nolint
|
||||||
|
return filepath.Dir(file)
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue