refactor: move V1 code into v1/ subdirectory
- git mv cmd/ internal/ pkg/ test/ go.mod go.sum Makefile build.sh docs/ v1/ - Create v1/README.md with V1 documentation - Update root README for V1 + V2 structure - V1 still builds (cd v1 && go build ./cmd/hostkeeper) and 105 tests pass - Root is now clean for V2 development
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.tukangketik.id/swanadiva/hostkeeper/internal/models"
|
||||
)
|
||||
|
||||
// Storage defines the interface for data persistence
|
||||
type Storage interface {
|
||||
// Host operations
|
||||
ListHosts(ctx context.Context) ([]*models.Host, error)
|
||||
GetHost(ctx context.Context, id string) (*models.Host, error)
|
||||
SaveHost(ctx context.Context, host *models.Host) error
|
||||
DeleteHost(ctx context.Context, id string) error
|
||||
|
||||
// KeyPair operations
|
||||
ListKeyPairs(ctx context.Context) ([]*models.KeyPair, error)
|
||||
GetKeyPair(ctx context.Context, id string) (*models.KeyPair, error)
|
||||
SaveKeyPair(ctx context.Context, keyPair *models.KeyPair) error
|
||||
DeleteKeyPair(ctx context.Context, id string) error
|
||||
|
||||
// Snippet operations
|
||||
ListSnippets(ctx context.Context) ([]*models.Snippet, error)
|
||||
GetSnippet(ctx context.Context, id string) (*models.Snippet, error)
|
||||
SaveSnippet(ctx context.Context, snippet *models.Snippet) error
|
||||
DeleteSnippet(ctx context.Context, id string) error
|
||||
|
||||
// Export/Import
|
||||
ExportData(ctx context.Context) (*ExportData, error)
|
||||
ImportData(ctx context.Context, data *ExportData, strategy MergeStrategy) error
|
||||
}
|
||||
|
||||
// ExportData represents the data structure for export/import
|
||||
type ExportData struct {
|
||||
Hosts []*models.Host `json:"hosts"`
|
||||
KeyPairs []*models.KeyPair `json:"key_pairs"`
|
||||
Snippets []*models.Snippet `json:"snippets"`
|
||||
}
|
||||
|
||||
// MergeStrategy defines how imported data is merged with existing data
|
||||
type MergeStrategy string
|
||||
|
||||
const (
|
||||
// MergeStrategyReplace replaces all existing data with imported data
|
||||
MergeStrategyReplace MergeStrategy = "replace"
|
||||
// MergeStrategyMerge keeps existing data and adds only new items
|
||||
MergeStrategyMerge MergeStrategy = "merge"
|
||||
)
|
||||
Reference in New Issue
Block a user