Skip to content

Commit

Permalink
feat: scrape plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe authored and moshloop committed Nov 29, 2024
1 parent 1dafecf commit d3b75a3
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 7 deletions.
20 changes: 20 additions & 0 deletions models/scrape_plugin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package models

import (
"time"

"github.com/flanksource/duty/types"
"github.com/google/uuid"
)

type ScrapePlugin struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
Namespace string `json:"namespace"`
Spec types.JSON `json:"spec,omitempty"`
Source string `json:"source,omitempty"`
CreatedBy *uuid.UUID `json:"created_by,omitempty"`
CreatedAt time.Time `json:"created_at" gorm:"<-:create"`
UpdatedAt *time.Time `json:"updated_at" gorm:"autoUpdateTime:false"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
}
65 changes: 58 additions & 7 deletions schema/config.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ table "config_analysis" {
type = text
}
column "status" {
null = true
type = text
null = true
type = text
default = "open"
}
column "message" {
Expand Down Expand Up @@ -182,8 +182,8 @@ table "config_changes" {
comment = "is_pushed when set to true indicates that the config changes has been pushed to upstream."
}
column "inserted_at" {
null = false
type = timestamptz
null = false
type = timestamptz
default = sql("now()")
}

Expand Down Expand Up @@ -352,8 +352,8 @@ table "config_items" {
type = text
}
column "inserted_at" {
null = false
type = timestamptz
null = false
type = timestamptz
default = sql("now()")
}
primary_key {
Expand Down Expand Up @@ -405,7 +405,7 @@ table "config_items" {
}
index "idx_config_items_scraper_id_deleted_at_null" {
columns = [column.scraper_id]
where = "deleted_at IS NULL"
where = "deleted_at IS NULL"
}
index "idx_config_items_path" {
columns = [column.path]
Expand Down Expand Up @@ -616,3 +616,54 @@ table "config_scrapers" {
where = "is_pushed IS FALSE"
}
}

table "scrape_plugins" {
schema = schema.public
column "id" {
null = false
type = uuid
default = sql("generate_ulid()")
}
column "name" {
type = text
}
column "namespace" {
null = true
type = text
}
column "spec" {
null = false
type = jsonb
}
column "source" {
null = false
type = enum.source
}
column "created_by" {
null = true
type = uuid
}
column "created_at" {
null = false
type = timestamptz
default = sql("now()")
}
column "updated_at" {
null = true
type = timestamptz
default = sql("now()")
}
column "deleted_at" {
null = true
type = timestamptz
}
primary_key {
columns = [column.id]
}
foreign_key "config_scraper_plugins_created_by_fkey" {
columns = [column.created_by]
ref_columns = [table.people.column.id]
on_update = NO_ACTION
on_delete = NO_ACTION
}
}

0 comments on commit d3b75a3

Please sign in to comment.