Skip to content

Commit

Permalink
Remove deprecated libraries, update other libs, add ci v1.23
Browse files Browse the repository at this point in the history
  • Loading branch information
rikatz committed Jan 9, 2022
1 parent c917ffa commit cd31c4c
Show file tree
Hide file tree
Showing 19 changed files with 97 additions and 311 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ jobs:
strategy:
matrix:
k8s: [v1.19.11, v1.20.7, v1.21.2, v1.22.0]
k8s: [v1.19.11, v1.20.7, v1.21.2, v1.22.0, v1.23.0]

steps:

Expand Down
43 changes: 21 additions & 22 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,33 @@ require (
github.com/mitchellh/hashstructure v1.1.0
github.com/mitchellh/mapstructure v1.4.3
github.com/moul/pb v0.0.0-20180404114147-54bdd96e6a52
github.com/ncabatoff/process-exporter v0.7.9
github.com/ncabatoff/process-exporter v0.7.10
github.com/onsi/ginkgo v1.16.4
github.com/opencontainers/runc v1.0.2
github.com/pkg/errors v0.9.1
github.com/opencontainers/runc v1.0.3
github.com/pmezard/go-difflib v1.0.0
github.com/prometheus/client_golang v1.11.0
github.com/prometheus/client_model v0.2.0
github.com/prometheus/common v0.31.1
github.com/spf13/cobra v1.3.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.7.0
github.com/zakjan/cert-chain-resolver v0.0.0-20210427055340-87e10242a981
github.com/zakjan/cert-chain-resolver v0.0.0-20211122211144-c6b0b792af9a
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d
golang.org/x/net v0.0.0-20211209124913-491a49abca63
google.golang.org/grpc v1.43.0
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
gopkg.in/go-playground/pool.v3 v3.1.1
k8s.io/api v0.22.2
k8s.io/apiextensions-apiserver v0.22.2
k8s.io/apimachinery v0.22.2
k8s.io/apiserver v0.22.2
k8s.io/cli-runtime v0.21.5
k8s.io/client-go v0.22.2
k8s.io/code-generator v0.22.2
k8s.io/component-base v0.22.2
k8s.io/klog/v2 v2.10.0
k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a // indirect
k8s.io/api v0.22.5
k8s.io/apiextensions-apiserver v0.22.5
k8s.io/apimachinery v0.22.5
k8s.io/apiserver v0.22.5
k8s.io/cli-runtime v0.22.5
k8s.io/client-go v0.22.5
k8s.io/code-generator v0.22.5
k8s.io/component-base v0.22.5
k8s.io/klog/v2 v2.9.0
pault.ag/go/sniff v0.0.0-20200207005214-cf7e4d167732
sigs.k8s.io/controller-runtime v0.10.3
sigs.k8s.io/mdtoc v1.0.1
sigs.k8s.io/mdtoc v1.1.0
)

require (
Expand Down Expand Up @@ -75,13 +72,12 @@ require (
github.com/go-logr/logr v0.4.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
github.com/go-openapi/spec v0.19.5 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/godbus/dbus/v5 v5.0.4 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/gomarkdown/markdown v0.0.0-20200824053859-8c8b3816f167 // indirect
github.com/gomarkdown/markdown v0.0.0-20210514010506-3b9f47219fe7 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/go-querystring v1.0.0 // indirect
Expand All @@ -107,6 +103,7 @@ require (
github.com/nxadm/tail v1.4.8 // indirect
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
Expand All @@ -131,15 +128,17 @@ require (
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/gengo v0.0.0-20201214224949-b6c5ce23f027 // indirect
k8s.io/kube-openapi v0.0.0-20210421082810-95288971da7e // indirect
k8s.io/kube-openapi v0.0.0-20211109043538-20434351676c // indirect
k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a // indirect
moul.io/http2curl v1.0.1-0.20190925090545-5cd742060b0e // indirect
sigs.k8s.io/kustomize/api v0.8.8 // indirect
sigs.k8s.io/kustomize/kyaml v0.10.17 // indirect
sigs.k8s.io/kustomize/api v0.8.11 // indirect
sigs.k8s.io/kustomize/kyaml v0.11.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)
275 changes: 38 additions & 237 deletions go.sum

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions internal/file/structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ limitations under the License.
package file

import (
"fmt"
"os"

"github.com/pkg/errors"
)

const (
Expand Down Expand Up @@ -50,13 +49,13 @@ func CreateRequiredDirectories() error {
if os.IsNotExist(err) {
err = os.MkdirAll(directory, ReadWriteByUser)
if err != nil {
return errors.Wrapf(err, "creating directory '%v'", directory)
return fmt.Errorf("creating directory %s: %w", directory, err)
}

continue
}

return errors.Wrapf(err, "checking directory %v", directory)
return fmt.Errorf("checking directory %s: %w", directory, err)
}
}

Expand Down
15 changes: 7 additions & 8 deletions internal/ingress/annotations/auth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"regexp"
"strings"

"github.com/pkg/errors"
api "k8s.io/api/core/v1"
networking "k8s.io/api/networking/v1"
"k8s.io/client-go/tools/cache"
Expand Down Expand Up @@ -118,14 +117,14 @@ func (a auth) Parse(ing *networking.Ingress) (interface{}, error) {
s, err := parser.GetStringAnnotation("auth-secret", ing)
if err != nil {
return nil, ing_errors.LocationDenied{
Reason: errors.Wrap(err, "error reading secret name from annotation"),
Reason: fmt.Errorf("error reading secret name from annotation: %w", err),
}
}

sns, sname, err := cache.SplitMetaNamespaceKey(s)
if err != nil {
return nil, ing_errors.LocationDenied{
Reason: errors.Wrap(err, "error reading secret name from annotation"),
Reason: fmt.Errorf("error reading secret name from annotation: %w", err),
}
}

Expand All @@ -137,7 +136,7 @@ func (a auth) Parse(ing *networking.Ingress) (interface{}, error) {
secret, err := a.r.GetSecret(name)
if err != nil {
return nil, ing_errors.LocationDenied{
Reason: errors.Wrapf(err, "unexpected error reading secret %v", name),
Reason: fmt.Errorf("unexpected error reading secret %s: %w", name, err),
}
}

Expand All @@ -158,7 +157,7 @@ func (a auth) Parse(ing *networking.Ingress) (interface{}, error) {
}
default:
return nil, ing_errors.LocationDenied{
Reason: errors.Wrap(err, "invalid auth-secret-type in annotation, must be 'auth-file' or 'auth-map'"),
Reason: fmt.Errorf("invalid auth-secret-type in annotation, must be 'auth-file' or 'auth-map': %w", err),
}
}

Expand All @@ -179,14 +178,14 @@ func dumpSecretAuthFile(filename string, secret *api.Secret) error {
val, ok := secret.Data["auth"]
if !ok {
return ing_errors.LocationDenied{
Reason: errors.Errorf("the secret %v does not contain a key with value auth", secret.Name),
Reason: fmt.Errorf("the secret %s does not contain a key with value auth", secret.Name),
}
}

err := os.WriteFile(filename, val, file.ReadWriteByUser)
if err != nil {
return ing_errors.LocationDenied{
Reason: errors.Wrap(err, "unexpected error creating password file"),
Reason: fmt.Errorf("unexpected error creating password file: %w", err),
}
}

Expand All @@ -205,7 +204,7 @@ func dumpSecretAuthMap(filename string, secret *api.Secret) error {
err := os.WriteFile(filename, []byte(builder.String()), file.ReadWriteByUser)
if err != nil {
return ing_errors.LocationDenied{
Reason: errors.Wrap(err, "unexpected error creating password file"),
Reason: fmt.Errorf("unexpected error creating password file: %w", err),
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/ingress/annotations/auth/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"testing"
"time"

"github.com/pkg/errors"
"errors"

api "k8s.io/api/core/v1"
networking "k8s.io/api/networking/v1"
Expand Down Expand Up @@ -81,7 +81,7 @@ type mockSecret struct {

func (m mockSecret) GetSecret(name string) (*api.Secret, error) {
if name != "default/demo-secret" {
return nil, errors.Errorf("there is no secret with name %v", name)
return nil, fmt.Errorf("there is no secret with name %v", name)
}

return &api.Secret{
Expand Down
4 changes: 2 additions & 2 deletions internal/ingress/annotations/authtls/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package authtls

import (
"github.com/pkg/errors"
"fmt"
networking "k8s.io/api/networking/v1"

"regexp"
Expand Down Expand Up @@ -102,7 +102,7 @@ func (a authTLS) Parse(ing *networking.Ingress) (interface{}, error) {

authCert, err := a.r.GetAuthCertificate(tlsauthsecret)
if err != nil {
e := errors.Wrap(err, "error obtaining certificate")
e := fmt.Errorf("error obtaining certificate: %w", err)
return &Config{}, ing_errors.LocationDenied{Reason: e}
}
config.AuthSSLCert = *authCert
Expand Down
3 changes: 1 addition & 2 deletions internal/ingress/annotations/defaultbackend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package defaultbackend
import (
"fmt"

"github.com/pkg/errors"
networking "k8s.io/api/networking/v1"

"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
Expand All @@ -46,7 +45,7 @@ func (db backend) Parse(ing *networking.Ingress) (interface{}, error) {
name := fmt.Sprintf("%v/%v", ing.Namespace, s)
svc, err := db.r.GetService(name)
if err != nil {
return nil, errors.Wrapf(err, "unexpected error reading service %v", name)
return nil, fmt.Errorf("unexpected error reading service %s: %w", name, err)
}

return svc, nil
Expand Down
5 changes: 2 additions & 3 deletions internal/ingress/annotations/fastcgi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"fmt"
"reflect"

"github.com/pkg/errors"
networking "k8s.io/api/networking/v1"
"k8s.io/client-go/tools/cache"

Expand Down Expand Up @@ -85,7 +84,7 @@ func (a fastcgi) Parse(ing *networking.Ingress) (interface{}, error) {
cmns, cmn, err := cache.SplitMetaNamespaceKey(cm)
if err != nil {
return fcgiConfig, ing_errors.LocationDenied{
Reason: errors.Wrap(err, "error reading configmap name from annotation"),
Reason: fmt.Errorf("error reading configmap name from annotation: %w", err),
}
}

Expand All @@ -97,7 +96,7 @@ func (a fastcgi) Parse(ing *networking.Ingress) (interface{}, error) {
cmap, err := a.r.GetConfigMap(cm)
if err != nil {
return fcgiConfig, ing_errors.LocationDenied{
Reason: errors.Wrapf(err, "unexpected error reading configmap %v", cm),
Reason: fmt.Errorf("unexpected error reading configmap %s: %w", cm, err),
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/ingress/annotations/globalratelimit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ limitations under the License.
package globalratelimit

import (
"fmt"
"strings"
"time"

"github.com/pkg/errors"
networking "k8s.io/api/networking/v1"

"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
Expand Down Expand Up @@ -86,7 +86,7 @@ func (a globalratelimit) Parse(ing *networking.Ingress) (interface{}, error) {
windowSize, err := time.ParseDuration(rawWindowSize)
if err != nil {
return config, ing_errors.LocationDenied{
Reason: errors.Wrap(err, "failed to parse 'global-rate-limit-window' value"),
Reason: fmt.Errorf("failed to parse 'global-rate-limit-window' value: %w", err),
}
}

Expand Down
4 changes: 1 addition & 3 deletions internal/ingress/annotations/globalratelimit/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"fmt"
"testing"

"github.com/pkg/errors"
api "k8s.io/api/core/v1"
networking "k8s.io/api/networking/v1"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -159,8 +158,7 @@ func TestGlobalRateLimiting(t *testing.T) {
},
&Config{},
ing_errors.LocationDenied{
Reason: errors.Wrap(fmt.Errorf(`time: unknown unit "mb" in duration "2mb"`),
"failed to parse 'global-rate-limit-window' value"),
Reason: fmt.Errorf("failed to parse 'global-rate-limit-window' value: time: unknown unit \"mb\" in duration \"2mb\""),
},
},
}
Expand Down
5 changes: 2 additions & 3 deletions internal/ingress/annotations/ipwhitelist/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ limitations under the License.
package ipwhitelist

import (
"fmt"
"sort"
"strings"

"github.com/pkg/errors"

networking "k8s.io/api/networking/v1"
"k8s.io/ingress-nginx/internal/net"

Expand Down Expand Up @@ -75,7 +74,7 @@ func (a ipwhitelist) Parse(ing *networking.Ingress) (interface{}, error) {
ipnets, ips, err := net.ParseIPNets(values...)
if err != nil && len(ips) == 0 {
return &SourceRange{CIDR: defBackend.WhitelistSourceRange}, ing_errors.LocationDenied{
Reason: errors.Wrap(err, "the annotation does not contain a valid IP address or network"),
Reason: fmt.Errorf("the annotation does not contain a valid IP address or network: %w", err),
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/ingress/annotations/proxyssl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ limitations under the License.
package proxyssl

import (
"fmt"
"regexp"
"sort"
"strings"

"github.com/pkg/errors"
networking "k8s.io/api/networking/v1"
"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
ing_errors "k8s.io/ingress-nginx/internal/ingress/errors"
Expand Down Expand Up @@ -132,7 +132,7 @@ func (p proxySSL) Parse(ing *networking.Ingress) (interface{}, error) {

proxyCert, err := p.r.GetAuthCertificate(proxysslsecret)
if err != nil {
e := errors.Wrap(err, "error obtaining certificate")
e := fmt.Errorf("error obtaining certificate: %w", err)
return &Config{}, ing_errors.LocationDenied{Reason: e}
}
config.AuthSSLCert = *proxyCert
Expand Down

0 comments on commit cd31c4c

Please sign in to comment.