Skip to content

Commit

Permalink
Update controller-runtime
Browse files Browse the repository at this point in the history
Signed-off-by: David VIEJO <[email protected]>
  • Loading branch information
dviejokfs committed Oct 14, 2024
1 parent b2ffdd6 commit fd043ca
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 233 deletions.
7 changes: 1 addition & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ require (
k8s.io/code-generator v0.31.1
k8s.io/kubernetes v1.13.0
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8
sigs.k8s.io/controller-runtime v0.18.4
sigs.k8s.io/controller-runtime v0.19.0
sigs.k8s.io/yaml v1.4.0
)

Expand All @@ -66,14 +66,12 @@ require (
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/gobuffalo/flect v1.0.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 // indirect
sigs.k8s.io/controller-tools v0.15.0 // indirect
)

require (
Expand Down Expand Up @@ -104,7 +102,6 @@ require (
github.com/docker/docker-credential-helpers v0.7.0 // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-metrics v0.0.1 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v5.9.0+incompatible // indirect
Expand Down Expand Up @@ -155,7 +152,6 @@ require (
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/miekg/pkcs11 v1.1.1
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
Expand All @@ -167,7 +163,6 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/nxadm/tail v1.4.8 // indirect
Expand Down
185 changes: 10 additions & 175 deletions go.sum

Large diffs are not rendered by default.

35 changes: 19 additions & 16 deletions internal/github.com/hyperledger/fabric-ca/lib/server/ldap/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,13 +536,16 @@ func (ue *userExpr) functions() map[string]govaluate.ExpressionFunction {

// Get an LDAP attribute's value.
// The usage is:
// attrFunction <attrName> [<separator>]
//
// attrFunction <attrName> [<separator>]
//
// If attribute <attrName> has multiple values, return the values in a single
// string separated by the <separator> string, which is a comma by default.
// Example:
// Assume attribute "foo" has two values "bar1" and "bar2".
// attrFunction("foo") returns "bar1,bar2"
// attrFunction("foo",":") returns "bar1:bar2"
//
// Assume attribute "foo" has two values "bar1" and "bar2".
// attrFunction("foo") returns "bar1,bar2"
// attrFunction("foo",":") returns "bar1:bar2"
func (ue *userExpr) attrFunction(args ...interface{}) (interface{}, error) {
if len(args) < 1 || len(args) > 2 {
return nil, fmt.Errorf("Expecting 1 or 2 arguments for 'attr' but found %d", len(args))
Expand Down Expand Up @@ -573,21 +576,21 @@ func (ue *userExpr) attrFunction(args ...interface{}) (interface{}, error) {
// three values: "foo1", "foo2", and "foo3". Further assume the following
// LDAP configuration.
//
// converters:
// - name: myAttr
// value: map(attr("myLDAPAttr"), myMap)
// maps:
// myMap:
// foo1: bar1
// foo2: bar2
// converters:
// - name: myAttr
// value: map(attr("myLDAPAttr"), myMap)
// maps:
// myMap:
// foo1: bar1
// foo2: bar2
//
// The value of the user's "myAttr" attribute is then "bar1,bar2,foo3".
// This value is computed as follows:
// 1) The value of 'attr("myLDAPAttr")' is "foo1,foo2,foo3" by joining
// the values using the default separator character ",".
// 2) The value of 'map("foo1,foo2,foo3", "myMap")' is "foo1,foo2,foo3"
// because it maps or substitutes "bar1" for "foo1" and "bar2" for "foo2"
// according to the entries in the "myMap" map.
// 1. The value of 'attr("myLDAPAttr")' is "foo1,foo2,foo3" by joining
// the values using the default separator character ",".
// 2. The value of 'map("foo1,foo2,foo3", "myMap")' is "foo1,foo2,foo3"
// because it maps or substitutes "bar1" for "foo1" and "bar2" for "foo2"
// according to the entries in the "myMap" map.
func (ue *userExpr) mapFunction(args ...interface{}) (interface{}, error) {
if len(args) != 2 {
return nil, errors.Errorf("Expecting two arguments but found %d", len(args))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
4 changes: 3 additions & 1 deletion internal/github.com/hyperledger/fabric-ca/util/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ func GetServerPort() string {
// specified option and returns the following value if found; otherwise
// it returns "".
// For example, if command line is:
// fabric-ca client enroll -config myconfig.json
//
// fabric-ca client enroll -config myconfig.json
//
// getCommandLineOptValue("-config") returns "myconfig.json"
func getCommandLineOptValue(optName string) string {
for i := 0; i < len(os.Args)-1; i++ {
Expand Down
21 changes: 12 additions & 9 deletions internal/github.com/hyperledger/fabric-ca/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,17 @@ func Unmarshal(from []byte, to interface{}, what string) error {

// CreateToken creates a JWT-like token.
// In a normal JWT token, the format of the token created is:
// <algorithm,claims,signature>
//
// <algorithm,claims,signature>
//
// where each part is base64-encoded string separated by a period.
// In this JWT-like token, there are two differences:
// 1) the claims section is a certificate, so the format is:
// <certificate,signature>
// 2) the signature uses the private key associated with the certificate,
// and the signature is across both the certificate and the "body" argument,
// which is the body of an HTTP request, though could be any arbitrary bytes.
// 1. the claims section is a certificate, so the format is:
// <certificate,signature>
// 2. the signature uses the private key associated with the certificate,
// and the signature is across both the certificate and the "body" argument,
// which is the body of an HTTP request, though could be any arbitrary bytes.
//
// @param cert The pem-encoded certificate
// @param key The pem-encoded key
// @param method http method of the request
Expand Down Expand Up @@ -164,7 +167,7 @@ func CreateToken(csp bccsp.BCCSP, cert []byte, key bccsp.Key, method, uri string
return token, nil
}

//GenECDSAToken signs the http body and cert with ECDSA using EC private key
// GenECDSAToken signs the http body and cert with ECDSA using EC private key
func GenECDSAToken(csp bccsp.BCCSP, cert []byte, key bccsp.Key, method, uri string, body []byte) (string, error) {
b64body := B64Encode(body)
b64cert := B64Encode(cert)
Expand Down Expand Up @@ -272,7 +275,7 @@ func decodeToken(token string) (*x509.Certificate, string, string, error) {
return x509Cert, b64cert, parts[1], nil
}

//GetECPrivateKey get *ecdsa.PrivateKey from key pem
// GetECPrivateKey get *ecdsa.PrivateKey from key pem
func GetECPrivateKey(raw []byte) (*ecdsa.PrivateKey, error) {
decoded, _ := pem.Decode(raw)
if decoded == nil {
Expand All @@ -296,7 +299,7 @@ func GetECPrivateKey(raw []byte) (*ecdsa.PrivateKey, error) {
return nil, errors.Wrap(err2, "Failed parsing EC private key")
}

//GetRSAPrivateKey get *rsa.PrivateKey from key pem
// GetRSAPrivateKey get *rsa.PrivateKey from key pem
func GetRSAPrivateKey(raw []byte) (*rsa.PrivateKey, error) {
decoded, _ := pem.Decode(raw)
if decoded == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ func (ap *ApplicationProvider) V1_3Validation() bool {

// V2_0Validation returns true if this channel supports transaction validation
// as introduced in v2.0. This includes:
// - new chaincode lifecycle
// - implicit per-org collections
// - new chaincode lifecycle
// - implicit per-org collections
func (ap *ApplicationProvider) V2_0Validation() bool {
return ap.v20
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func SignedByMspAdmin(mspId string) *cb.SignaturePolicyEnvelope {
return p
}

//wrapper for generating "any of a given role" type policies
// wrapper for generating "any of a given role" type policies
func signedByAnyOfGivenRole(role mb.MSPRole_MSPRoleType, ids []string) *cb.SignaturePolicyEnvelope {
return SignedByNOutOfGivenRole(1, role, ids)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,17 @@ func newContext() *context {
// GATE(P[, P])
//
// where:
// - GATE is either "and" or "or"
// - P is either a principal or another nested call to GATE
// - GATE is either "and" or "or"
// - P is either a principal or another nested call to GATE
//
// A principal is defined as:
//
// ORG.ROLE
// # ORG.ROLE
//
// where:
// - ORG is a string (representing the MSP identifier)
// - ROLE takes the value of any of the RoleXXX constants representing
// the required role
// - ORG is a string (representing the MSP identifier)
// - ROLE takes the value of any of the RoleXXX constants representing
// the required role
func FromString(policy string) (*cb.SignaturePolicyEnvelope, error) {
// first we translate the and/or business into outof gates
intermediate, err := govaluate.NewEvaluableExpressionWithFunctions(
Expand Down
2 changes: 1 addition & 1 deletion internal/github.com/hyperledger/fabric/msp/mspimpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type validateIdentityOUsFuncType func(id *identity) error
// satisfiesPrincipalInternalFuncType is the prototype of the function to check if principals are satisfied
type satisfiesPrincipalInternalFuncType func(id Identity, principal *m.MSPPrincipal) error

//setupAdminInternalFuncType is a prototype of the function to setup the admins
// setupAdminInternalFuncType is a prototype of the function to setup the admins
type setupAdminInternalFuncType func(conf *m.FabricMSPConfig) error

// This is an instantiation of an MSP that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type KeyPairCacheKey struct {
KeyType bool
}

//String return string value for keyPairCacheKey
// String return string value for keyPairCacheKey
func (keyPairCacheKey *KeyPairCacheKey) String() string {
return fmt.Sprintf("%x_%t", keyPairCacheKey.SKI, keyPairCacheKey.KeyType)
}
Expand All @@ -47,7 +47,7 @@ type SessionCacheKey struct {
SessionID string
}

//String return string value for SessionCacheKey
// String return string value for SessionCacheKey
func (SessionCacheKey *SessionCacheKey) String() string {
return SessionCacheKey.SessionID
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,32 +47,32 @@ func NewCspSigner(csp core.CryptoSuite, key core.Key) (crypto.Signer, error) {
return cspsigner.New(csp, key)
}

//GetDefault creates new cryptosuite from bccsp factory default
// GetDefault creates new cryptosuite from bccsp factory default
func GetDefault() core.CryptoSuite {
return cryptosuite.GetDefault()
}

//SignatureToLowS is a bridge for bccsp utils.SignatureToLowS()
// SignatureToLowS is a bridge for bccsp utils.SignatureToLowS()
func SignatureToLowS(k *ecdsa.PublicKey, signature []byte) ([]byte, error) {
return utils.SignatureToLowS(k, signature)
}

//GetHashOpt is a bridge for bccsp util GetHashOpt
// GetHashOpt is a bridge for bccsp util GetHashOpt
func GetHashOpt(hashFunction string) (core.HashOpts, error) {
return bccsp.GetHashOpt(hashFunction)
}

//GetSHAOpts returns options for computing SHA.
// GetSHAOpts returns options for computing SHA.
func GetSHAOpts() core.HashOpts {
return &bccsp.SHAOpts{}
}

//GetSHA256Opts returns options relating to SHA-256.
// GetSHA256Opts returns options relating to SHA-256.
func GetSHA256Opts() core.HashOpts {
return &bccsp.SHA256Opts{}
}

//GetSHA3256Opts returns options relating to SHA-256.
// GetSHA3256Opts returns options relating to SHA-256.
func GetSHA3256Opts() core.HashOpts {
return &bccsp.SHA3_256Opts{}
}
Expand All @@ -82,22 +82,22 @@ func GetECDSAKeyGenOpts(ephemeral bool) core.KeyGenOpts {
return &bccsp.ECDSAKeyGenOpts{Temporary: ephemeral}
}

//GetECDSAP256KeyGenOpts returns options for ECDSA key generation with curve P-256.
// GetECDSAP256KeyGenOpts returns options for ECDSA key generation with curve P-256.
func GetECDSAP256KeyGenOpts(ephemeral bool) core.KeyGenOpts {
return &bccsp.ECDSAP256KeyGenOpts{Temporary: ephemeral}
}

//GetECDSAP384KeyGenOpts options for ECDSA key generation with curve P-384.
// GetECDSAP384KeyGenOpts options for ECDSA key generation with curve P-384.
func GetECDSAP384KeyGenOpts(ephemeral bool) core.KeyGenOpts {
return &bccsp.ECDSAP384KeyGenOpts{Temporary: ephemeral}
}

//GetX509PublicKeyImportOpts options for importing public keys from an x509 certificate
// GetX509PublicKeyImportOpts options for importing public keys from an x509 certificate
func GetX509PublicKeyImportOpts(ephemeral bool) core.KeyImportOpts {
return &bccsp.X509PublicKeyImportOpts{Temporary: ephemeral}
}

//GetECDSAPrivateKeyImportOpts options for ECDSA secret key importation in DER format
// GetECDSAPrivateKeyImportOpts options for ECDSA secret key importation in DER format
// or PKCS#8 format.
func GetECDSAPrivateKeyImportOpts(ephemeral bool) core.KeyImportOpts {
return &bccsp.ECDSAPrivateKeyImportOpts{Temporary: ephemeral}
Expand Down
2 changes: 1 addition & 1 deletion kubectl-hlf/cmd/chaincodecrd/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ func newCommitCmd(out io.Writer, errOut io.Writer) *cobra.Command {
},
}
return cmd
}
}
2 changes: 1 addition & 1 deletion kubectl-hlf/cmd/chaincodecrd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ func newInstallCmd(out io.Writer, errOut io.Writer) *cobra.Command {
},
}
return cmd
}
}

0 comments on commit fd043ca

Please sign in to comment.