Skip to content

Commit

Permalink
Refreshing examples to leverage env and new storage.
Browse files Browse the repository at this point in the history
  • Loading branch information
andream16 committed Nov 4, 2024
1 parent f6b197c commit 0c8ee2e
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 63 deletions.
4 changes: 4 additions & 0 deletions sdk/component/examples/enricher/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SMITHY_COMPONENT_NAME=sample-enricher
SMITHY_INSTANCE_ID=8d719c1c-c569-4078-87b3-4951bd4012ee
SMITHY_LOG_LEVEL=debug
SMITHY_BACKEND_STORE_TYPE=local
15 changes: 1 addition & 14 deletions sdk/component/examples/enricher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"time"

"github.com/smithy-security/smithy/sdk/component"
"github.com/smithy-security/smithy/sdk/component/internal/storer/local"
"github.com/smithy-security/smithy/sdk/component/internal/uuid"
ocsf "github.com/smithy-security/smithy/sdk/gen/com/github/ocsf/ocsf_schema/v1"
)

Expand All @@ -22,18 +20,7 @@ func main() {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()

storageManager, err := local.NewStoreManager()
if err != nil {
log.Fatalf("failed to create storage manager: %v", err)
}

if err := component.RunEnricher(
ctx,
sampleEnricher{},
component.RunnerWithComponentName("sample-enricher"),
component.RunnerWithStorer("local", storageManager),
component.RunnerWithWorkflowID(uuid.New()),
); err != nil {
if err := component.RunEnricher(ctx, sampleEnricher{}); err != nil {
log.Fatalf("unexpected run error: %v", err)
}
}
4 changes: 4 additions & 0 deletions sdk/component/examples/filter/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SMITHY_COMPONENT_NAME=sample-filter
SMITHY_INSTANCE_ID=8d719c1c-c569-4078-87b3-4951bd4012ee
SMITHY_LOG_LEVEL=debug
SMITHY_BACKEND_STORE_TYPE=local
15 changes: 1 addition & 14 deletions sdk/component/examples/filter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"time"

"github.com/smithy-security/smithy/sdk/component"
"github.com/smithy-security/smithy/sdk/component/internal/storer/local"
"github.com/smithy-security/smithy/sdk/component/internal/uuid"
ocsf "github.com/smithy-security/smithy/sdk/gen/com/github/ocsf/ocsf_schema/v1"
)

Expand All @@ -22,18 +20,7 @@ func main() {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()

storageManager, err := local.NewStoreManager()
if err != nil {
log.Fatalf("failed to create storage manager: %v", err)
}

if err := component.RunFilter(
ctx,
sampleFilter{},
component.RunnerWithComponentName("sample-filter"),
component.RunnerWithStorer("local", storageManager),
component.RunnerWithWorkflowID(uuid.New()),
); err != nil {
if err := component.RunFilter(ctx, sampleFilter{}); err != nil {
log.Fatalf("unexpected run error: %v", err)
}
}
4 changes: 4 additions & 0 deletions sdk/component/examples/reporter/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SMITHY_COMPONENT_NAME=sample-reporter
SMITHY_INSTANCE_ID=8d719c1c-c569-4078-87b3-4951bd4012ee
SMITHY_LOG_LEVEL=debug
SMITHY_BACKEND_STORE_TYPE=local
15 changes: 1 addition & 14 deletions sdk/component/examples/reporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"time"

"github.com/smithy-security/smithy/sdk/component"
"github.com/smithy-security/smithy/sdk/component/internal/storer/local"
"github.com/smithy-security/smithy/sdk/component/internal/uuid"
ocsf "github.com/smithy-security/smithy/sdk/gen/com/github/ocsf/ocsf_schema/v1"
)

Expand All @@ -22,18 +20,7 @@ func main() {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()

storageManager, err := local.NewStoreManager()
if err != nil {
log.Fatalf("failed to create storage manager: %v", err)
}

if err := component.RunReporter(
ctx,
sampleReporter{},
component.RunnerWithComponentName("sample-reporter"),
component.RunnerWithStorer("local", storageManager),
component.RunnerWithWorkflowID(uuid.New()),
); err != nil {
if err := component.RunReporter(ctx, sampleReporter{}); err != nil {
log.Fatalf("unexpected run error: %v", err)
}
}
4 changes: 4 additions & 0 deletions sdk/component/examples/scanner/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SMITHY_COMPONENT_NAME=sample-scanner
SMITHY_INSTANCE_ID=8d719c1c-c569-4078-87b3-4951bd4012ee
SMITHY_LOG_LEVEL=debug
SMITHY_BACKEND_STORE_TYPE=local
15 changes: 1 addition & 14 deletions sdk/component/examples/scanner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"time"

"github.com/smithy-security/smithy/sdk/component"
"github.com/smithy-security/smithy/sdk/component/internal/storer/local"
"github.com/smithy-security/smithy/sdk/component/internal/uuid"
ocsf "github.com/smithy-security/smithy/sdk/gen/com/github/ocsf/ocsf_schema/v1"
)

Expand All @@ -22,18 +20,7 @@ func main() {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()

storageManager, err := local.NewStoreManager()
if err != nil {
log.Fatalf("failed to create storage manager: %v", err)
}

if err := component.RunScanner(
ctx,
sampleScanner{},
component.RunnerWithComponentName("sample-scanner"),
component.RunnerWithStorer("local", storageManager),
component.RunnerWithWorkflowID(uuid.New()),
); err != nil {
if err := component.RunScanner(ctx, sampleScanner{}); err != nil {
log.Fatalf("unexpected run error: %v", err)
}
}
4 changes: 4 additions & 0 deletions sdk/component/examples/target/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SMITHY_COMPONENT_NAME=sample-target
SMITHY_INSTANCE_ID=8d719c1c-c569-4078-87b3-4951bd4012ee
SMITHY_LOG_LEVEL=debug
SMITHY_BACKEND_STORE_TYPE=local
8 changes: 1 addition & 7 deletions sdk/component/examples/target/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"time"

"github.com/smithy-security/smithy/sdk/component"
"github.com/smithy-security/smithy/sdk/component/internal/uuid"
)

type sampleTarget struct{}
Expand All @@ -20,12 +19,7 @@ func main() {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()

if err := component.RunTarget(
ctx,
sampleTarget{},
component.RunnerWithComponentName("sample-target"),
component.RunnerWithWorkflowID(uuid.New()),
); err != nil {
if err := component.RunTarget(ctx, sampleTarget{}); err != nil {
log.Fatalf("unexpected run error: %v", err)
}
}

0 comments on commit 0c8ee2e

Please sign in to comment.