-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add npm, ssh, kitty, and kubernetes dotfile support #89
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package model | ||
|
|
||
| import "context" | ||
|
|
||
| // KittyApp handles Kitty terminal configuration files | ||
| type KittyApp struct { | ||
| BaseApp | ||
| } | ||
|
|
||
| func NewKittyApp() DotfileApp { | ||
| return &KittyApp{} | ||
| } | ||
|
|
||
| func (k *KittyApp) Name() string { | ||
| return "kitty" | ||
| } | ||
|
|
||
| func (k *KittyApp) GetConfigPaths() []string { | ||
| return []string{ | ||
| "~/.config/kitty/", | ||
| } | ||
| } | ||
|
|
||
| func (k *KittyApp) CollectDotfiles(ctx context.Context) ([]DotfileItem, error) { | ||
| return k.CollectFromPaths(ctx, k.Name(), k.GetConfigPaths()) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package model | ||
|
|
||
| import "context" | ||
|
|
||
| // KubernetesApp handles Kubernetes configuration files | ||
| type KubernetesApp struct { | ||
| BaseApp | ||
| } | ||
|
|
||
| func NewKubernetesApp() DotfileApp { | ||
| return &KubernetesApp{} | ||
| } | ||
|
|
||
| func (k *KubernetesApp) Name() string { | ||
| return "kubernetes" | ||
| } | ||
|
|
||
| func (k *KubernetesApp) GetConfigPaths() []string { | ||
| return []string{ | ||
| "~/.kube/config", | ||
| } | ||
| } | ||
|
|
||
| func (k *KubernetesApp) CollectDotfiles(ctx context.Context) ([]DotfileItem, error) { | ||
| return k.CollectFromPaths(ctx, k.Name(), k.GetConfigPaths()) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package model | ||
|
|
||
| import "context" | ||
|
|
||
| // NpmApp handles npm configuration files | ||
| type NpmApp struct { | ||
| BaseApp | ||
| } | ||
|
|
||
| func NewNpmApp() DotfileApp { | ||
| return &NpmApp{} | ||
| } | ||
|
|
||
| func (n *NpmApp) Name() string { | ||
| return "npm" | ||
| } | ||
|
|
||
| func (n *NpmApp) GetConfigPaths() []string { | ||
| return []string{ | ||
| "~/.npmrc", | ||
| } | ||
| } | ||
|
|
||
| func (n *NpmApp) CollectDotfiles(ctx context.Context) ([]DotfileItem, error) { | ||
| return n.CollectFromPaths(ctx, n.Name(), n.GetConfigPaths()) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package model | ||
|
|
||
| import "context" | ||
|
|
||
| // SshApp handles SSH configuration files | ||
| type SshApp struct { | ||
| BaseApp | ||
| } | ||
|
|
||
| func NewSshApp() DotfileApp { | ||
| return &SshApp{} | ||
| } | ||
|
|
||
| func (s *SshApp) Name() string { | ||
| return "ssh" | ||
| } | ||
|
|
||
| func (s *SshApp) GetConfigPaths() []string { | ||
| return []string{ | ||
| "~/.ssh/config", | ||
| } | ||
| } | ||
|
|
||
| func (s *SshApp) CollectDotfiles(ctx context.Context) ([]DotfileItem, error) { | ||
| return s.CollectFromPaths(ctx, s.Name(), s.GetConfigPaths()) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This file, along with
dotfile_kubernetes.go,dotfile_npm.go, anddotfile_ssh.go, contains a lot of boilerplate code. All these new application implementations are almost identical, only differing in the application name and configuration paths. This pattern will make it cumbersome to add more simple applications in the future.To improve maintainability and reduce code duplication, I suggest creating a generic
DotfileAppimplementation that can be configured with a name and paths. For example:With this, you could remove the new
dotfile_*.gofiles and instantiate the apps directly where they are needed, for example incommands/dotfiles_pull.go:This would significantly simplify adding new applications that follow this simple file/directory pattern.