1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2025-11-29 22:48:19 +02:00

Fix Linting Errors (#1835)

* initial commit: add groups to azure

Signed-off-by: andrewphamade@gmail.com <andrewphamade@gmail.com>

* fix deprecations and linting errors

Signed-off-by: Andrew Hamade <andrewphamade@gmail.com>

* remove groups testing from azure provider

Signed-off-by: Andrew Hamade <andrewphamade@gmail.com>

* fix test error

Signed-off-by: Andrew Hamade <andrewphamade@gmail.com>

* verify-generate

Signed-off-by: Andrew Hamade <andrewphamade@gmail.com>

Signed-off-by: andrewphamade@gmail.com <andrewphamade@gmail.com>
Signed-off-by: Andrew Hamade <andrewphamade@gmail.com>
This commit is contained in:
Andrew Hamade
2022-10-21 12:57:51 +02:00
committed by GitHub
parent a6c8f6f04a
commit 7fe6384f38
43 changed files with 134 additions and 146 deletions

View File

@@ -3,7 +3,7 @@ package options
import (
"errors"
"fmt"
"io/ioutil"
"os"
"reflect"
"strings"
@@ -17,7 +17,9 @@ import (
// variables (prefixed with `OAUTH2_PROXY`) and finally merges in flags from the flagSet.
// If a config value is unset and the flag has a non-zero value default, this default will be used.
// Eg. A field defined:
// FooBar `cfg:"foo_bar" flag:"foo-bar"`
//
// FooBar `cfg:"foo_bar" flag:"foo-bar"`
//
// Can be set in the config file as `foo_bar="baz"`, in the environment as `OAUTH2_PROXY_FOO_BAR=baz`,
// or via the command line flag `--foo-bar=baz`.
func Load(configFileName string, flagSet *pflag.FlagSet, into interface{}) error {
@@ -147,7 +149,7 @@ func LoadYAML(configFileName string, into interface{}) error {
return errors.New("no configuration file provided")
}
data, err := ioutil.ReadFile(configFileName)
data, err := os.ReadFile(configFileName)
if err != nil {
return fmt.Errorf("unable to load config file: %w", err)
}

View File

@@ -3,7 +3,6 @@ package options
import (
"errors"
"fmt"
"io/ioutil"
"os"
"time"
@@ -118,7 +117,7 @@ var _ = Describe("Load", func() {
if o.configFile != nil {
By("Creating a config file")
configFile, err := ioutil.TempFile("", "oauth2-proxy-test-legacy-config-file")
configFile, err := os.CreateTemp("", "oauth2-proxy-test-legacy-config-file")
Expect(err).ToNot(HaveOccurred())
defer configFile.Close()
@@ -390,7 +389,7 @@ sub:
if in.configFile != nil {
By("Creating a config file")
configFile, err := ioutil.TempFile("", "oauth2-proxy-test-config-file")
configFile, err := os.CreateTemp("", "oauth2-proxy-test-config-file")
Expect(err).ToNot(HaveOccurred())
defer configFile.Close()
@@ -488,7 +487,7 @@ injectResponseHeaders:
`)
By("Creating a config file")
configFile, err := ioutil.TempFile("", "oauth2-proxy-test-alpha-config-file")
configFile, err := os.CreateTemp("", "oauth2-proxy-test-alpha-config-file")
Expect(err).ToNot(HaveOccurred())
defer configFile.Close()

View File

@@ -14,7 +14,7 @@ package options
//
// Examples:
//
// A parameter whose value is fixed
// # A parameter whose value is fixed
//
// ```
// name: organization
@@ -62,8 +62,9 @@ package options
// use the "chomped block" format `|-`:
//
// ```
// - pattern: |-
// - pattern: |-
// ^[^@]*@example\.com$
//
// ```
//
// The hyphen is important, a `|` block would have a trailing newline

View File

@@ -2,7 +2,6 @@ package util
import (
"errors"
"io/ioutil"
"os"
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
@@ -16,7 +15,7 @@ func GetSecretValue(source *options.SecretSource) ([]byte, error) {
case len(source.Value) == 0 && source.FromEnv != "" && source.FromFile == "":
return []byte(os.Getenv(source.FromEnv)), nil
case len(source.Value) == 0 && source.FromEnv == "" && source.FromFile != "":
return ioutil.ReadFile(source.FromFile)
return os.ReadFile(source.FromFile)
default:
return nil, errors.New("secret source is invalid: exactly one entry required, specify either value, fromEnv or fromFile")
}

View File

@@ -1,7 +1,6 @@
package util
import (
"io/ioutil"
"os"
"path"
@@ -20,9 +19,9 @@ var _ = Describe("GetSecretValue", func() {
os.Setenv(secretEnvKey, secretEnvValue)
var err error
fileDir, err = ioutil.TempDir("", "oauth2-proxy-util-get-secret-value")
fileDir, err = os.MkdirTemp("", "oauth2-proxy-util-get-secret-value")
Expect(err).ToNot(HaveOccurred())
Expect(ioutil.WriteFile(path.Join(fileDir, "secret-file"), secretFileValue, 0600)).To(Succeed())
Expect(os.WriteFile(path.Join(fileDir, "secret-file"), secretFileValue, 0600)).To(Succeed())
})
AfterEach(func() {