Skip to content

Commit

Permalink
Merge pull request #16 from kaytu-io/fix/short-integration
Browse files Browse the repository at this point in the history
fix: add shorthand integration
  • Loading branch information
ADorigi authored Sep 17, 2024
2 parents 0316a5e + 9272a82 commit 9420e14
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 7 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ Non-interactive mode:
checktl configure --api-key <<api-key>> --app-endpoint https://path.to.app.endpoint --output json
```

---
**_NOTE:_** Pre-defined integartions can be manually added to the configuration file, by updating the `integrations` field inside `$HOME/.checkctl/config.json`.

config.json:
```
{
...
"integrations": {"acc3":"id_name=account3"}
}
```

---
## get

### benchmarks
Expand Down
11 changes: 9 additions & 2 deletions cmd/get/compliance_summary_for_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package get
import (
"encoding/json"
"fmt"
"io"
"net/http"

"github.com/adorigi/checkctl/pkg/config"
"github.com/adorigi/checkctl/pkg/request"
"github.com/adorigi/checkctl/pkg/types"
"github.com/adorigi/checkctl/pkg/utils"
"github.com/spf13/cobra"
"io"
"net/http"
)

// complianceSummaryForIntegrationCmd represents the benchmarks command
Expand Down Expand Up @@ -41,6 +42,12 @@ var complianceSummaryForIntegrationCmd = &cobra.Command{
Integration info in the form 'integration=AWS,id=123,id_name=name'`)
return nil
}

if _, ok := configuration.Integrations[integrationStr]; ok {
fmt.Printf("Found stored integration %s", integrationStr)
integrationStr = configuration.Integrations[integrationStr]
}

integration := types.ParseIntegrationInfo(integrationStr)

requestPayload := types.ComplianceSummaryOfIntegrationRequest{
Expand Down
4 changes: 4 additions & 0 deletions cmd/run/compliance.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ var complianceCmd = &cobra.Command{

var integrations []types.IntegrationFilterInfo
for _, integrationStr := range integrationsStr {
if _, ok := configuration.Integrations[integrationStr]; ok {
fmt.Printf("Found stored integration %s", integrationStr)
integrationStr = configuration.Integrations[integrationStr]
}
integrations = append(integrations, types.ParseIntegrationInfo(integrationStr))
}
req := types.RunBenchmarkByIdRequest{
Expand Down
6 changes: 5 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ build: clean
env GOOS=linux GOARCH=arm go build -o bin/checkctl-linux

goreleaser:
REPOSITORY_OWNER=local REPOSITORY_NAME=local goreleaser build --snapshot
REPOSITORY_OWNER=local REPOSITORY_NAME=local goreleaser build --snapshot

install:
rm $(GOPATH)/bin/checkctl
go install
10 changes: 6 additions & 4 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package config

type Configuration struct {
OutputFormat string `json:"output_format"`
ApiEndpoint string `json:"api_endpoint"`
UtilizationAnalyzerEndpoint string `json:"utilization_analyzer_endpoint"`
ApiKey string `json:"api_key"`
OutputFormat string `json:"output_format"`
ApiEndpoint string `json:"api_endpoint"`
UtilizationAnalyzerEndpoint string `json:"utilization_analyzer_endpoint"`
ApiKey string `json:"api_key"`
Integrations map[string]string `json:"integrations"`
}

func NewConfiguration(
Expand All @@ -18,5 +19,6 @@ func NewConfiguration(
ApiEndpoint: apiEndpoint,
UtilizationAnalyzerEndpoint: utilizationAnalyzerEndpoint,
ApiKey: apiKey,
Integrations: map[string]string{},
}
}

0 comments on commit 9420e14

Please sign in to comment.