Skip to content

Refactor vault handling - #642

Open
NautiluX wants to merge 2 commits into
mainfrom
refactor-vault-handling
Open

Refactor vault handling#642
NautiluX wants to merge 2 commits into
mainfrom
refactor-vault-handling

Conversation

@NautiluX

@NautiluX NautiluX commented Aug 5, 2026

Copy link
Copy Markdown
Member

Refactor vault handling to abstract the encryption handling. This will unify handling of vaults and allow to add new vault types in the future.
The TS installer requires an encrypted SOPS vault, so oms install codesphere only supports the sops type.
oms init install-config respects the vault type so allows to output an encrypted vault directly.

@NautiluX
NautiluX force-pushed the refactor-vault-handling branch 7 times, most recently from 68bf1d7 to 80bd471 Compare August 6, 2026 14:57
@NautiluX
NautiluX force-pushed the refactor-vault-handling branch from 80bd471 to cde3db2 Compare August 6, 2026 14:58

@joka134 joka134 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some minor questions. looks nice in general

type PlainFileVault struct{ options FileOptions }

// NewPlainFileVault returns a vault handler for interacting with a plain (unencrypted) file
func NewPlainFileVault(opts FileOptions) (*PlainFileVault, error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
func NewPlainFileVault(opts FileOptions) (*PlainFileVault, error) {
func NewPlainFileVault(opts FileOptions) (*Vault, error) {

You can return the interface type here

}

// NewSOPSVault creates a new vault handler for interacting with SOPS-encrypted vault files
func NewSOPSVault(opts SOPSOptions) (*SOPSVault, error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
func NewSOPSVault(opts SOPSOptions) (*SOPSVault, error) {
func NewSOPSVault(opts SOPSOptions) (*Vault, error) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think in general it's preferable to return the struct type instead of the interface, makes navigation easier. The caller can use the concrete type and you can jump to that instead of the interface directly.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That is true, but with this there is no actual verification if this is really implementing the interface. Or am I wrong?

type PlainFileVault struct{ options FileOptions }

// NewPlainFileVault returns a vault handler for interacting with a plain (unencrypted) file
func NewPlainFileVault(opts FileOptions) (*PlainFileVault, error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we could move the implementations of the interface into sub packages to import them like vault.sops.New

}

// NewFromString parses vaultType and creates the matching implementation.
func NewFromString(vaultType string, opts Options) (Vault, error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not fore the usage of the custom type?

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.

2 participants