-
Notifications
You must be signed in to change notification settings - Fork 22
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
Network support #39
base: main
Are you sure you want to change the base?
Network support #39
Conversation
Signed-off-by: Haardik Dharma <[email protected]>
Signed-off-by: satakshigarg <[email protected]>
// CivoNetworkSpec holds the networkConfig | ||
type CivoNetworkSpec struct { | ||
xpv1.ResourceSpec `json:",inline"` | ||
NetworkConfig CivoNetworkConfig `json:"networkConfig"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NetworkConfig CivoNetworkConfig `json:"networkConfig"` | |
Label string `json:"label"` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need the CivoNetworkConfig struct here tbh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove region
as that's something we get from ProviderConfig
if !ok { | ||
return managed.ExternalCreation{}, errors.New(errNotCivoNetwork) | ||
} | ||
civoNetwork, err := e.civoClient.GetNetwork(cr.Status.AtProvider.ID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not rely on Status here. We should do a FindNetworks call to find cr.Spec.Label
. If it's not found, create it
return managed.ExternalUpdate{}, errors.New(errNotCivoNetwork) | ||
} | ||
|
||
err := e.civoClient.UpdateNetwork(cr.Status.AtProvider.ID, cr.Spec.NetworkConfig.Label) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use FindNetworks call with cr.spec.label rather than relying on status
} | ||
cr.SetConditions(xpv1.Deleting()) | ||
err := e.civoClient.DeleteNetwork(cr.Status.AtProvider.ID) | ||
return errors.Wrap(err, errDeleteNetwork) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this not be just return err
if err != nil { | ||
return err | ||
} | ||
_, err = c.civoGoClient.DeleteNetwork(network.ID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the network is not found, we should return nil
rather than an error
Added example .yaml & IPv6 support to Network spec