mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-28 18:06:34 +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"
|
||||
)
|
||||
|
||||
// TLSCerts holds the certificate authority, certificate and certificate key for a TLS connection.
|
||||
type TLSCerts struct {
|
||||
CA string
|
||||
Cert string
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// Package cluster is used to configure a kubernetes cluster for testing.
|
||||
package cluster
|
||||
|
||||
import (
|
||||
|
@ -8,6 +9,7 @@ import (
|
|||
"golang.org/x/net/publicsuffix"
|
||||
)
|
||||
|
||||
// A Cluster is used to configure a kubernetes cluster.
|
||||
type Cluster struct {
|
||||
workingDir string
|
||||
|
||||
|
@ -15,12 +17,15 @@ type Cluster struct {
|
|||
certs *TLSCerts
|
||||
}
|
||||
|
||||
// New creates a new Cluster.
|
||||
func New(workingDir string) *Cluster {
|
||||
return &Cluster{
|
||||
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 {
|
||||
jar, err := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
|
||||
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
|
||||
}
|
||||
|
||||
jsonsrc, err := cluster.generateManifests(ctx)
|
||||
jsonsrc, err := cluster.generateManifests()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ func (cluster *Cluster) getNodeHTTPSAddr(ctx context.Context) (hostport string,
|
|||
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"))
|
||||
if err != nil {
|
||||
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
|
||||
|
||||
import (
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// Package forms has helper functions for working with HTML forms.
|
||||
package forms
|
||||
|
||||
import (
|
||||
|
@ -69,6 +70,7 @@ func Parse(r io.Reader) []Form {
|
|||
return forms
|
||||
}
|
||||
|
||||
// NewRequestWithContext creates a new request from the form details.
|
||||
func (f *Form) NewRequestWithContext(ctx context.Context, baseURL *url.URL) (*http.Request, error) {
|
||||
actionURL, err := url.Parse(f.Action)
|
||||
if err != nil {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// Package httputil has helper functions for working with HTTP.
|
||||
package httputil
|
||||
|
||||
import (
|
||||
|
@ -11,6 +12,8 @@ type localRoundTripper struct {
|
|||
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 {
|
||||
lrt := &localRoundTripper{underlying: underlying, portToAddr: portToAddr}
|
||||
return lrt
|
||||
|
|
|
@ -15,8 +15,6 @@ import (
|
|||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
const localHTTPSPort = 9443
|
||||
|
||||
var (
|
||||
mainCtx context.Context
|
||||
testcluster *cluster.Cluster
|
||||
|
@ -39,8 +37,7 @@ func TestMain(m *testing.M) {
|
|||
mainCtx, clearTimeout = context.WithTimeout(mainCtx, time.Minute*10)
|
||||
defer clearTimeout()
|
||||
|
||||
_, mainTestFilePath, _, _ := runtime.Caller(0)
|
||||
testcluster = cluster.New(filepath.Dir(mainTestFilePath))
|
||||
testcluster = cluster.New(getBaseDir())
|
||||
if err := testcluster.Setup(mainCtx); err != nil {
|
||||
log.Fatal().Err(err).Send()
|
||||
}
|
||||
|
@ -50,3 +47,9 @@ func TestMain(m *testing.M) {
|
|||
gocleanup.Cleanup()
|
||||
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
Reference in a new issue