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

Network support #39

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

satakshigarg
Copy link

Added example .yaml & IPv6 support to Network spec

haardikdharma10 and others added 2 commits July 18, 2022 17:29
// CivoNetworkSpec holds the networkConfig
type CivoNetworkSpec struct {
xpv1.ResourceSpec `json:",inline"`
NetworkConfig CivoNetworkConfig `json:"networkConfig"`
Copy link
Collaborator

@RealHarshThakur RealHarshThakur Feb 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
NetworkConfig CivoNetworkConfig `json:"networkConfig"`
Label string `json:"label"`

Copy link
Collaborator

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

Copy link
Collaborator

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)
Copy link
Collaborator

@RealHarshThakur RealHarshThakur Feb 14, 2023

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)
Copy link
Collaborator

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)
Copy link
Collaborator

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)
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants