Skip to content

Commit

Permalink
Upgrade to go 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
dviejokfs committed Jan 14, 2024
1 parent 5a0c106 commit 6749f47
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 111 deletions.
24 changes: 15 additions & 9 deletions api/hlf.kungfusoftware.es/v1alpha1/hlf_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ type ExternalBuilder struct {
PropagateEnvironment []string `json:"propagateEnvironment"`
}

const DefaultImagePullPolicy = corev1.PullAlways
const DefaultImagePullPolicy = corev1.PullIfNotPresent

type ServiceMonitor struct {
// +kubebuilder:default:=false
Expand Down Expand Up @@ -1799,14 +1799,25 @@ func (in *FabricChaincodeSpec) ApplyDefaultValuesFromTemplate(template *FabricCh
if in.Resources == nil {
in.Resources = template.Spec.Resources
}
if in.Credentials == nil {
in.Credentials = template.Spec.Credentials
}
if in.Replicas == 0 {
in.Replicas = template.Spec.Replicas
}
if in.Env == nil || len(in.Env) == 0 {
in.Env = template.Spec.Env
} else {
for _, env := range template.Spec.Env {
found := false
for _, e := range in.Env {
if e.Name == env.Name {
found = true
break
}
}
if !found {
in.Env = append(in.Env, env)
}

}
}
if in.ChaincodeServerPort == 0 {
in.ChaincodeServerPort = template.Spec.ChaincodeServerPort
Expand Down Expand Up @@ -2392,11 +2403,6 @@ type FabricChaincodeTemplateSpec struct {
// +optional
Resources *corev1.ResourceRequirements `json:"resources"`

// +nullable
// +kubebuilder:validation:Optional
// +optional
Credentials *TLS `json:"credentials"`

// +kubebuilder:validation:Default=1
Replicas int `json:"replicas"`

Expand Down
5 changes: 0 additions & 5 deletions api/hlf.kungfusoftware.es/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions charts/hlf-peer/templates/configmap--peer--core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ data:
# It sets the delivery service maximal delay between consecutive retries
reConnectBackoffThreshold: 3600s
blockGossipEnabled: false
# A list of orderer endpoint addresses which should be overridden
# when found in channel configurations.
addressOverrides:
Expand Down
2 changes: 1 addition & 1 deletion charts/hlf-peer/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ spec:
name: {{ include "hlf-peer.fullname" . }}--peer
volumeMounts:
# range volumeMounts
{{- if .Values.volumeMounts }}
{{- if .Values.peerVolumeMounts }}
{{ toYaml .Values.peerVolumeMounts | nindent 12 }}
{{- end }}
- name: peerconfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -884,77 +884,6 @@ spec:
items:
type: string
type: array
credentials:
nullable: true
properties:
cahost:
type: string
caname:
type: string
caport:
type: integer
catls:
properties:
cacert:
type: string
secretRef:
nullable: true
properties:
key:
type: string
name:
type: string
namespace:
type: string
required:
- key
- name
- namespace
type: object
required:
- cacert
type: object
csr:
properties:
cn:
type: string
hosts:
items:
type: string
type: array
type: object
enrollid:
type: string
enrollsecret:
type: string
external:
nullable: true
properties:
certificateKey:
type: string
privateKeyKey:
type: string
rootCertificateKey:
type: string
secretName:
type: string
secretNamespace:
type: string
required:
- certificateKey
- privateKeyKey
- rootCertificateKey
- secretName
- secretNamespace
type: object
required:
- cahost
- caname
- caport
- catls
- enrollid
- enrollsecret
type: object
env:
items:
description: EnvVar represents an environment variable present in
Expand Down
10 changes: 5 additions & 5 deletions controllers/mainchannel/mainchannel_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1252,12 +1252,9 @@ func updateApplicationChannelConfigTx(currentConfigTX configtx.ConfigTx, newConf
if err != nil {
return errors.Wrapf(err, "failed to set ACLs")
}
err = currentConfigTX.Orderer().SetBatchTimeout(newConfigTx.Orderer.BatchTimeout)
if err != nil {
return errors.Wrapf(err, "failed to set batch timeout")
}
return nil
}

func updateOrdererChannelConfigTx(currentConfigTX configtx.ConfigTx, newConfigTx configtx.Channel) error {
err := currentConfigTX.Orderer().SetPolicies(
newConfigTx.Orderer.Policies,
Expand Down Expand Up @@ -1402,7 +1399,10 @@ func updateOrdererChannelConfigTx(currentConfigTX configtx.ConfigTx, newConfigTx
if err != nil {
return errors.Wrap(err, "failed to set application policies")
}

err = currentConfigTX.Orderer().SetBatchTimeout(newConfigTx.Orderer.BatchTimeout)
if err != nil {
return errors.Wrapf(err, "failed to set batch timeout")
}
return nil
}

Expand Down
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/kfsoftware/hlf-operator

go 1.18
go 1.21

require (
github.com/IBM/idemix v0.0.0-20220113150823-80dd4cb2d74e
Expand Down Expand Up @@ -243,3 +243,6 @@ replace (
k8s.io/metrics => k8s.io/metrics v0.24.0
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.24.0
)
replace (
github.com/hyperledger/fabric-sdk-go => github.com/kfsoftware/fabric-sdk-go v0.0.0-20240114221414-98466038585d
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,8 @@ github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uia
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8=
github.com/karrick/godirwalk v1.16.1 h1:DynhcF+bztK8gooS0+NDJFrdNZjJ3gzVzC545UNA9iw=
github.com/karrick/godirwalk v1.16.1/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk=
github.com/kfsoftware/fabric-sdk-go v0.0.0-20240114221414-98466038585d h1:HcMV8Lve3QkZUIWYHP+rVIR4xtTdDPooj7Id0IdBj0o=
github.com/kfsoftware/fabric-sdk-go v0.0.0-20240114221414-98466038585d/go.mod h1:JRplpKBeAvXjsBhOCCM/KvMRUbdDyhsAh80qbXzKc10=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
Expand Down
39 changes: 24 additions & 15 deletions kubectl-hlf/cmd/chaincode/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"io"
"time"

"github.com/hyperledger/fabric-sdk-go/pkg/client/channel"
"github.com/hyperledger/fabric-sdk-go/pkg/core/config"
Expand All @@ -21,26 +22,32 @@ type queryChaincodeCmd struct {
fcn string
args []string
transient string
mspID string
}

func (c *queryChaincodeCmd) validate() error {
return nil
}
func (c *queryChaincodeCmd) run(out io.Writer) error {
oclient, err := helpers.GetKubeOperatorClient()
if err != nil {
return err
}
clientSet, err := helpers.GetKubeClient()
if err != nil {
return err
}
peer, err := helpers.GetPeerByFullName(clientSet, oclient, c.peer)
if err != nil {
return err
var mspID string
if c.mspID != "" {
mspID = c.mspID
} else {
oclient, err := helpers.GetKubeOperatorClient()
if err != nil {
return err
}
clientSet, err := helpers.GetKubeClient()
if err != nil {
return err
}
peer, err := helpers.GetPeerByFullName(clientSet, oclient, c.peer)
if err != nil {
return err
}
mspID = peer.Spec.MspID
}
mspID := peer.Spec.MspID
peerName := peer.Name
peerName := c.peer
configBackend := config.FromFile(c.configPath)
sdk, err := fabsdk.New(configBackend)
if err != nil {
Expand All @@ -63,10 +70,10 @@ func (c *queryChaincodeCmd) run(out io.Writer) error {
if c.transient != "" {
err = json.Unmarshal([]byte(c.transient), &transientMap)
if err != nil {
return err
return err
}
}

t := time.Now()
response, err := ch.Query(
channel.Request{
ChaincodeID: c.chaincode,
Expand All @@ -81,6 +88,7 @@ func (c *queryChaincodeCmd) run(out io.Writer) error {
if err != nil {
return err
}
fmt.Printf("Query took %s\n", time.Since(t))
_, err = fmt.Fprint(out, string(response.Payload))
if err != nil {
return err
Expand Down Expand Up @@ -108,6 +116,7 @@ func newQueryChaincodeCMD(out io.Writer, errOut io.Writer) *cobra.Command {
persistentFlags.StringVarP(&c.fcn, "fcn", "", "", "Function name")
persistentFlags.StringArrayVarP(&c.args, "args", "a", []string{}, "Function arguments")
persistentFlags.StringVarP(&c.transient, "transient", "t", "", "Transient map")
persistentFlags.StringVarP(&c.mspID, "mspID", "", "", "MSP ID")
cmd.MarkPersistentFlagRequired("user")
cmd.MarkPersistentFlagRequired("peer")
cmd.MarkPersistentFlagRequired("config")
Expand Down
4 changes: 2 additions & 2 deletions kubectl-hlf/cmd/console/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (c *createCmd) run() error {
Image: c.consoleOpts.Image,
ImagePullSecrets: imagePullSecrets,
Tag: c.consoleOpts.Version,
ImagePullPolicy: "Always",
ImagePullPolicy: "IfNotPresent",
Tolerations: []corev1.Toleration{},
Replicas: 1,
CouchDB: v1alpha1.FabricOperationsConsoleCouchDB{
Expand All @@ -134,7 +134,7 @@ func (c *createCmd) run() error {
ImagePullSecrets: []corev1.LocalObjectReference{},
Affinity: &corev1.Affinity{},
Tolerations: []corev1.Toleration{},
ImagePullPolicy: "Always",
ImagePullPolicy: "IfNotPresent",
},
Env: []corev1.EnvVar{},
Affinity: &corev1.Affinity{},
Expand Down
3 changes: 2 additions & 1 deletion kubectl-hlf/cmd/externalchaincode/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (c *syncExternalChaincodeCmd) validate() error {
func (c syncExternalChaincodeCmd) getFabricChaincodeSpec(ctx context.Context) (v1alpha1.FabricChaincodeSpec, error) {
fabricChaincodeSpec := v1alpha1.FabricChaincodeSpec{
Image: c.image,
ImagePullPolicy: corev1.PullAlways,
ImagePullPolicy: corev1.PullIfNotPresent,
PackageID: c.packageID,
ImagePullSecrets: []corev1.LocalObjectReference{},
Affinity: nil,
Expand Down Expand Up @@ -180,6 +180,7 @@ func (c *syncExternalChaincodeCmd) updateChaincode(ctx context.Context, fabricCh
}
fabricChaincode.Spec.Image = fabricChaincodeSpec.Image
fabricChaincode.Spec.ImagePullPolicy = fabricChaincodeSpec.ImagePullPolicy
fabricChaincode.Spec.Replicas = fabricChaincodeSpec.Replicas
fabricChaincode.Spec.PackageID = fabricChaincodeSpec.PackageID
fabricChaincode.Spec.ImagePullSecrets = fabricChaincodeSpec.ImagePullSecrets
if c.tlsRequired {
Expand Down
2 changes: 1 addition & 1 deletion kubectl-hlf/cmd/ordnode/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (c *createCmd) run(args []string) error {
Image: c.ordererOpts.Image,
ImagePullSecrets: imagePullSecrets,
Tag: c.ordererOpts.Version,
PullPolicy: corev1.PullAlways,
PullPolicy: corev1.PullIfNotPresent,
MspID: c.ordererOpts.MspID,
Genesis: "",
BootstrapMethod: v1alpha1.BootstrapMethodNone,
Expand Down

0 comments on commit 6749f47

Please sign in to comment.