Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffy-mathew committed Dec 29, 2023
1 parent f2e8683 commit e4b09bb
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 331 deletions.
24 changes: 2 additions & 22 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,16 +557,7 @@ func (pwl *PortsWhiteList) Decode(value string) error {

// Config is the configuration object used by Tyk to set up various parameters.
type Config struct {
<<<<<<< HEAD
// OriginalPath is the path to the config file that is read. If
// none was found, it's the path to the default config file that
// was written.
OriginalPath string `json:"-"`

// Force your Gateway to work only on a specifc domain name. Can be overriden by API custom domain.
=======
// Force your Gateway to work only on a specific domain name. Can be overridden by API custom domain.
>>>>>>> ee5dc29b... [TT-10826] self trim oAuth sorted set (#5907)
HostName string `json:"hostname"`

// If your machine has mulitple network devices or IPs you can force the Gateway to use the IP address you want.
Expand Down Expand Up @@ -1019,8 +1010,6 @@ type Config struct {

// Skip TLS verification for JWT JWKs url validation
JWTSSLInsecureSkipVerify bool `json:"jwt_ssl_insecure_skip_verify"`
<<<<<<< HEAD
=======

// ResourceSync configures mitigation strategy in case sync fails.
ResourceSync ResourceSyncConfig `json:"resource_sync"`
Expand All @@ -1033,10 +1022,6 @@ type ResourceSyncConfig struct {
// should perform during a resource sync (APIs or policies), defaulting
// to zero which means no retries are attempted.
RetryAttempts int `json:"retry_attempts"`

// Interval configures the interval in seconds between each retry on a resource sync error.
Interval int `json:"interval"`
>>>>>>> ee5dc29b... [TT-10826] self trim oAuth sorted set (#5907)
}

type TykError struct {
Expand Down Expand Up @@ -1193,17 +1178,12 @@ func WriteDefault(path string, conf *Config) error {
// An error will be returned only if any of the paths existed but was
// not a valid config file.
func Load(paths []string, conf *Config) error {
var r io.Reader
var r io.ReadCloser
for _, path := range paths {
f, err := os.Open(path)
if err == nil {
r = f
<<<<<<< HEAD
conf.OriginalPath = path
=======
defer r.Close()
conf.Private.OriginalPath = filename
>>>>>>> ee5dc29b... [TT-10826] self trim oAuth sorted set (#5907)
conf.Private.OriginalPath = path
break
}
if os.IsNotExist(err) {
Expand Down
59 changes: 0 additions & 59 deletions config/util.go
Original file line number Diff line number Diff line change
@@ -1,68 +1,9 @@
package config

import (
"errors"
"os"
"path"
"path/filepath"
"runtime"
"strconv"
)

// New produces a new config object by parsing
// the default configuration for the values.
func New() (*Config, error) {
cfg := new(Config)

cfgFile, err := findFile("tyk.conf")
if err != nil {
// Return cfg filled with environment
// if we don't have a config file.
if errors.Is(err, os.ErrNotExist) {
err := FillEnv(cfg)
return cfg, err
}

return nil, err
}

if err := Load([]string{cfgFile}, cfg); err != nil {
return nil, err
}

return cfg, nil
}

func findFile(filename string) (string, error) {
// Get folder in which current file lives
_, testFile, _, _ := runtime.Caller(0)
// Strip the filename and produce the dir
currentDir := path.Dir(testFile)

// Traverse the current directory and its parent directories
for {
// Check if the file exists in the current directory
filePath := filepath.Join(currentDir, filename)
_, err := os.Stat(filePath)
if err == nil {
// File found
return filePath, nil
}

// Move to the parent directory
parentDir := filepath.Dir(currentDir)
if parentDir == currentDir {
// No more parent directories remaining
break
}

currentDir = parentDir
}

// File not found
return "", os.ErrNotExist
}

// HostAddrs returns a sanitized list of hosts to connect to.
func (config *StorageOptionsConf) HostAddrs() (addrs []string) {
if len(config.Addrs) != 0 {
Expand Down
18 changes: 4 additions & 14 deletions gateway/oauth_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,18 @@ import (
"sync"
"time"

"strconv"

"github.com/TykTechnologies/tyk/request"
"github.com/hashicorp/go-multierror"
"github.com/lonelycode/osin"
"github.com/sirupsen/logrus"
"golang.org/x/crypto/bcrypt"

<<<<<<< HEAD
"strconv"

"github.com/TykTechnologies/tyk/internal/uuid"

"github.com/TykTechnologies/tyk/headers"
tykerrors "github.com/TykTechnologies/tyk/internal/errors"
=======
"github.com/TykTechnologies/tyk/internal/errors"
"github.com/TykTechnologies/tyk/internal/uuid"
"github.com/TykTechnologies/tyk/request"

"strconv"

"github.com/TykTechnologies/tyk/header"
>>>>>>> ee5dc29b... [TT-10826] self trim oAuth sorted set (#5907)
"github.com/TykTechnologies/tyk/storage"
"github.com/TykTechnologies/tyk/user"
)
Expand Down Expand Up @@ -243,8 +233,8 @@ const (
refreshToken = "refresh_token"
)

//in compliance with https://tools.ietf.org/html/rfc7009#section-2.1
//ToDo: set an authentication mechanism
// in compliance with https://tools.ietf.org/html/rfc7009#section-2.1
// ToDo: set an authentication mechanism
func (o *OAuthHandlers) HandleRevokeToken(w http.ResponseWriter, r *http.Request) {
err := r.ParseForm()
if err != nil {
Expand Down
9 changes: 2 additions & 7 deletions gateway/oauth_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,7 @@ func TestPurgeOAuthClientTokens(t *testing.T) {
storageKey1, storageKey2 := fmt.Sprintf("%s%s", prefixClientTokens, clientID1),
fmt.Sprintf("%s%s", prefixClientTokens, clientID2)

storageManager := ts.Gw.getGlobalMDCBStorageHandler(generateOAuthPrefix(spec.APIID), false)
storageManager := ts.Gw.getGlobalStorageHandler(generateOAuthPrefix(spec.APIID), false)
storageManager.Connect()

assertTokensLen(t, storageManager, storageKey1, 3)
Expand Down Expand Up @@ -1383,7 +1383,7 @@ func TestPurgeOAuthClientTokens(t *testing.T) {
storageKey1, storageKey2 := fmt.Sprintf("%s%s", prefixClientTokens, clientID1),
fmt.Sprintf("%s%s", prefixClientTokens, clientID2)

storageManager := ts.Gw.getGlobalMDCBStorageHandler(generateOAuthPrefix(spec.APIID), false)
storageManager := ts.Gw.getGlobalStorageHandler(generateOAuthPrefix(spec.APIID), false)
storageManager.Connect()

assertTokensLen(t, storageManager, storageKey1, 3)
Expand Down Expand Up @@ -1508,10 +1508,6 @@ func BenchmarkPurgeLapsedOAuthTokens(b *testing.B) {
})
}

<<<<<<< HEAD
storageManager := ts.Gw.getGlobalStorageHandler(generateOAuthPrefix(spec.APIID), false)
storageManager.Connect()
=======
setup := func(tb testing.TB, client redis.UniversalClient) {
tb.Helper()
now := time.Now()
Expand All @@ -1522,7 +1518,6 @@ func BenchmarkPurgeLapsedOAuthTokens(b *testing.B) {
copyZSet(client, "api", dst)
//tb.Logf("copy zet elapsed %f", time.Since(now).Seconds())
}
>>>>>>> ee5dc29b... [TT-10826] self trim oAuth sorted set (#5907)

}
tb.Logf("setup time elapsed %f", time.Since(now).Seconds())
Expand Down
13 changes: 1 addition & 12 deletions gateway/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,20 @@ import (
"strconv"
"strings"
"sync"
"time"

<<<<<<< HEAD
"github.com/TykTechnologies/tyk/internal/crypto"
"github.com/TykTechnologies/tyk/internal/httputil"

=======
>>>>>>> ee5dc29b... [TT-10826] self trim oAuth sorted set (#5907)
"sync/atomic"
textTemplate "text/template"
"time"

<<<<<<< HEAD
"github.com/TykTechnologies/again"
"github.com/TykTechnologies/drl"
gas "github.com/TykTechnologies/goautosocket"
"github.com/TykTechnologies/gorpc"
"github.com/TykTechnologies/goverify"
=======
"github.com/TykTechnologies/tyk/internal/crypto"
"github.com/TykTechnologies/tyk/internal/httputil"
"github.com/TykTechnologies/tyk/internal/otel"
"github.com/TykTechnologies/tyk/internal/scheduler"
"github.com/TykTechnologies/tyk/test"

>>>>>>> ee5dc29b... [TT-10826] self trim oAuth sorted set (#5907)
logstashHook "github.com/bshuster-repo/logrus-logstash-hook"
"github.com/evalphobia/logrus_sentry"
graylogHook "github.com/gemnasium/logrus-graylog-hook"
Expand Down
Loading

0 comments on commit e4b09bb

Please sign in to comment.