Skip to content

Commit

Permalink
fix(obcluster): optimize the judge of existence for pointer fields
Browse files Browse the repository at this point in the history
  • Loading branch information
powerfooI committed Feb 29, 2024
1 parent 7037c9c commit 703c886
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions internal/dashboard/business/oceanbase/obcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,6 @@ func buildOBClusterResponse(ctx context.Context, obcluster *v1alpha1.OBCluster)
OBClusterExtra: response.OBClusterExtra{
RootPasswordSecret: obcluster.Spec.UserSecrets.Root,
Parameters: nil,
Monitor: &response.MonitorSpec{
Image: "",
Resource: modelcommon.ResourceSpec{},
},
BackupVolume: &response.NFSVolumeSpec{},
},
// TODO: add metrics
Metrics: nil,
Expand All @@ -195,13 +190,15 @@ func buildOBClusterResponse(ctx context.Context, obcluster *v1alpha1.OBCluster)
respCluster.Parameters = parameters

if obcluster.Spec.MonitorTemplate != nil {
respCluster.Monitor = &response.MonitorSpec{}
respCluster.Monitor.Image = obcluster.Spec.MonitorTemplate.Image
respCluster.Monitor.Resource = modelcommon.ResourceSpec{
Cpu: obcluster.Spec.MonitorTemplate.Resource.Cpu.Value(),
MemoryGB: obcluster.Spec.MonitorTemplate.Resource.Memory.Value() >> 30,
}
}
if obcluster.Spec.BackupVolume != nil {
respCluster.BackupVolume = &response.NFSVolumeSpec{}
respCluster.BackupVolume.Address = obcluster.Spec.BackupVolume.Volume.NFS.Server
respCluster.BackupVolume.Path = obcluster.Spec.BackupVolume.Volume.NFS.Path
}
Expand Down

0 comments on commit 703c886

Please sign in to comment.