mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-11 19:08:20 +00:00
Add Config API Calls
This commit is contained in:
parent
390990af21
commit
081aeec142
2 changed files with 39 additions and 0 deletions
7
internal/api/config/config.go
Normal file
7
internal/api/config/config.go
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
package config
|
||||||
|
|
||||||
|
import "nfsense.net/nfsense/internal/config"
|
||||||
|
|
||||||
|
type Config struct {
|
||||||
|
ConfigManager *config.ConfigManager
|
||||||
|
}
|
32
internal/api/config/pending.go
Normal file
32
internal/api/config/pending.go
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/r3labs/diff/v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetPendingStatusResult struct {
|
||||||
|
Changed bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Config) GetPendingStatus(ctx context.Context, params struct{}) (GetPendingStatusResult, error) {
|
||||||
|
return GetPendingStatusResult{
|
||||||
|
Changed: c.ConfigManager.AreChangesPending(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetPendingChangelogResult struct {
|
||||||
|
Changelog diff.Changelog
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Config) GetPendingChangelog(ctx context.Context, params struct{}) (GetPendingChangelogResult, error) {
|
||||||
|
log, err := c.ConfigManager.GetPendingChangelog()
|
||||||
|
if err != nil {
|
||||||
|
return GetPendingChangelogResult{}, fmt.Errorf("Get Pending changelog %w", err)
|
||||||
|
}
|
||||||
|
return GetPendingChangelogResult{
|
||||||
|
Changelog: log,
|
||||||
|
}, nil
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue