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

Refactor StorageConfig to make code cleaner #223

Open
lstocchi opened this issue Nov 25, 2024 · 0 comments
Open

Refactor StorageConfig to make code cleaner #223

lstocchi opened this issue Nov 25, 2024 · 0 comments
Assignees

Comments

@lstocchi
Copy link
Contributor

lstocchi commented Nov 25, 2024

Based on a comment made by @cfergeau on #212.
Open this issue to make that PR easier to review. I'm going to refactor it in a follow-up PR

Only a comment (or just me thinking out loud), I'm not asking for changes in response to this comment.
We could having both ImagePath and URI in StorageConfig, and avoid these checks with something like:

type StorageConfig struct {
	DevName   string `json:"devName"`
	ReadOnly  bool   `json:"readOnly,omitempty"`
}

type DiskStorageConfig {
    StorageConfig
    ImagePath string `json:"imagePath,omitempty"`
}

type NetworkBlockDevice {
    StorageConfig
    URI       string `json:"uri,omitempty"`
}

If it works, this makes sure we'll never get a NetworkBlockDevice with ImagePath set as it does not have this member at all.
This adds one more almost empty type though, and may be breaking unserializing json on upgrades (?).

Originally posted by @cfergeau in #212 (comment)

@lstocchi lstocchi self-assigned this Nov 25, 2024
@lstocchi lstocchi moved this to Ready for review in Project planning: crc Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready for review
Development

No branches or pull requests

1 participant