Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify if ID is present before using it #1733

Merged
merged 1 commit into from
May 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion cloud/scope/powervs_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,9 @@ func (s *PowerVSClusterScope) getNetwork() (*string, error) {
// isDHCPServerActive checks if the DHCP server status is active.
func (s *PowerVSClusterScope) isDHCPServerActive() (bool, error) {
dhcpID := *s.GetDHCPServerID()
if dhcpID == "" {
return false, fmt.Errorf("DHCP ID is nil")
}
dhcpServer, err := s.IBMPowerVSClient.GetDHCPServer(dhcpID)
if err != nil {
return false, err
Expand Down Expand Up @@ -1106,6 +1109,9 @@ func (s *PowerVSClusterScope) createVPCSubnet(subnet infrav1beta2.Subnet) (*stri

// create subnet
vpcID := s.GetVPCID()
if vpcID == nil {
return nil, fmt.Errorf("VPC ID is nil")
}
cidrBlock, err := s.IBMVPCClient.GetSubnetAddrPrefix(*vpcID, zone)
if err != nil {
return nil, err
Expand Down Expand Up @@ -1746,8 +1752,12 @@ func (s *PowerVSClusterScope) getVPCRegion() *string {

// fetchVPCCRN returns VPC CRN.
func (s *PowerVSClusterScope) fetchVPCCRN() (*string, error) {
vpcID := s.GetVPCID()
if vpcID == nil {
return nil, fmt.Errorf("VPC ID is nil")
}
vpcDetails, _, err := s.IBMVPCClient.GetVPC(&vpcv1.GetVPCOptions{
ID: s.GetVPCID(),
ID: vpcID,
})
if err != nil {
return nil, err
Expand Down