Remove package to generate UUIDs
This commit is contained in:
parent
e803907066
commit
03a1e20fde
1 changed files with 17 additions and 9 deletions
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package template
|
package template
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/rand"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -31,8 +32,6 @@ import (
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/pborman/uuid"
|
|
||||||
|
|
||||||
extensions "k8s.io/api/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/ingress-nginx/internal/file"
|
"k8s.io/ingress-nginx/internal/file"
|
||||||
|
@ -494,7 +493,12 @@ func buildDenyVariable(a interface{}) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := denyPathSlugMap[l]; !ok {
|
if _, ok := denyPathSlugMap[l]; !ok {
|
||||||
denyPathSlugMap[l] = buildRandomUUID()
|
s, err := randomString()
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
denyPathSlugMap[l] = s
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("$deny_%v", denyPathSlugMap[l])
|
return fmt.Sprintf("$deny_%v", denyPathSlugMap[l])
|
||||||
|
@ -573,12 +577,6 @@ func buildNextUpstream(i, r interface{}) string {
|
||||||
return strings.Join(nextUpstreamCodes, " ")
|
return strings.Join(nextUpstreamCodes, " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
// buildRandomUUID return a random string to be used in the template
|
|
||||||
func buildRandomUUID() string {
|
|
||||||
s := uuid.New()
|
|
||||||
return strings.Replace(s, "-", "", -1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func isValidClientBodyBufferSize(input interface{}) bool {
|
func isValidClientBodyBufferSize(input interface{}) bool {
|
||||||
s, ok := input.(string)
|
s, ok := input.(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -694,3 +692,13 @@ func buildAuthSignURL(input interface{}) string {
|
||||||
|
|
||||||
return fmt.Sprintf("%v&rd=$pass_access_scheme://$http_host$request_uri", s)
|
return fmt.Sprintf("%v&rd=$pass_access_scheme://$http_host$request_uri", s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func randomString() (string, error) {
|
||||||
|
b := make([]byte, 16)
|
||||||
|
_, err := rand.Read(b)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(b), nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue