feat: add SQL/SQLite, AppSec, Capstone incident-tracker, Gitea Actions CI and spaced repetition
Test and Lint / quality (push) Successful in 2m13s
Test and Lint / quality (push) Successful in 2m13s
This commit is contained in:
1 parent
011f23e637
commit
33082598fc
19 files changed
+496
-6
No files matched your search
@@ -0,0 +1,65 @@
|
||||
package incidenttracker
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
_ "modernc.org/sqlite"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrInvalidIncident = errors.New("invalid incident input")
|
||||
ErrNotFound = errors.New("incident not found")
|
||||
)
|
||||
|
||||
type Incident struct {
|
||||
ID int64 `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Severity string `json:"severity"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
type IncidentStore struct {
|
||||
//lint:ignore U1000 używane po zaimplementowaniu metod
|
||||
db *sql.DB
|
||||
}
|
||||
|
||||
func OpenStore(dbPath string) (*IncidentStore, error) {
|
||||
db, err := sql.Open("sqlite", dbPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &IncidentStore{db: db}, nil
|
||||
}
|
||||
|
||||
func (s *IncidentStore) Close() error {
|
||||
return s.db.Close()
|
||||
}
|
||||
|
||||
func (s *IncidentStore) InitSchema() error {
|
||||
panic("TODO: CREATE TABLE IF NOT EXISTS incidents (...)")
|
||||
}
|
||||
|
||||
func (s *IncidentStore) Add(title, severity string) (Incident, error) {
|
||||
panic("TODO: zwaliduj title i severity (low|medium|high|critical), zapisz w SQLite")
|
||||
}
|
||||
|
||||
func (s *IncidentStore) List(severity string) ([]Incident, error) {
|
||||
panic("TODO: zwróć incydenty (jeśli severity != '' to przefiltruj)")
|
||||
}
|
||||
|
||||
func (s *IncidentStore) Resolve(id int64) (Incident, error) {
|
||||
panic("TODO: ustaw status='resolved' lub zwróć ErrNotFound")
|
||||
}
|
||||
|
||||
func (s *IncidentStore) Stats() (map[string]int, error) {
|
||||
panic("TODO: zwróć map[string]int{\"open\": X, \"resolved\": Y}")
|
||||
}
|
||||
|
||||
func NewCLI(dbPath string, out io.Writer) *cobra.Command {
|
||||
root := &cobra.Command{Use: "incident-tracker", SilenceUsage: true, SilenceErrors: true}
|
||||
root.SetOut(out)
|
||||
panic("TODO: dodaj podkomendy add, list, resolve, stats wypisujące JSON do out")
|
||||
}
|
||||
Reference in new issue
Block a user