Skip to content

Commit

Permalink
feat: pass empty string for namespace add account name to log and fix…
Browse files Browse the repository at this point in the history
… up the readme

Signed-off-by: Shari Vietry <shari.vietry@anchore.com>
  • Loading branch information
svietry committed Mar 15, 2023
1 parent 008d2b4 commit 0261cc7
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 25 deletions.
29 changes: 23 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,40 @@ in the following order:

Anchore ECS Inventory can be configured with a configuration file. The default
location the configuration file is looked for is
`~/.anchore-ecs-inventory/config.yaml`. The configuration file can be overridden
`~/.anchore-ecs-inventory.yaml`. The configuration file can be overridden
with the `-c` flag.

```yaml
log:
level: "debug"
# location to write the log file (by default we log to STDOUT only)
# level of logging that anchore-ecs-inventory will do { 'error' | 'info' | 'debug }
level: "info"

# location to write the log file (default is not to have a log file)
file: "./anchore-ecs-inventory.log"

anchore:
url: <anchore enterprise api url> (e.g. http://localhost:8228)
user: <anchore enterprise username>
password: $ANCHORE_ENTERPRISE_API_PASSWORD
# anchore enterprise api url (e.g. http://localhost:8228)
url: $ANCHORE_ECS_INVENTORY_ANCHORE_URL

# anchore enterprise username
user: $ANCHORE_ECS_INVENTORY_ANCHORE_USER

# anchore enterprise password
password: ANCHORE_ECS_INVENTORY_ANCHORE_PASSWORD

# anchore enterprise account that the inventory will be sent
account: $ANCHORE_ECS_INVENTORY_ANCHORE_ACCOUNT

http:
insecure: true
timeout-seconds: 10

# the aws region
region: $ANCHORE_ECS_INVENTORY_REGION

# frequency of which to poll the region
polling-interval-seconds: 300

quiet: false
```

Expand Down
25 changes: 22 additions & 3 deletions docker-compose/config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
log:
# level of logging that anchore-ecs-inventory will do { 'error' | 'info' | 'debug }
level: "info"

# location to write the log file (default is not to have a log file)
file: "./anchore-ecs-inventory.log"

anchore:
url: http://localhost:8228
user: admin
password: $ANCHORE_ENTERPRISE_API_PASSWORD
# anchore enterprise api url (e.g. http://localhost:8228)
url: $ANCHORE_ECS_INVENTORY_ANCHORE_URL

# anchore enterprise username
user: $ANCHORE_ECS_INVENTORY_ANCHORE_USER

# anchore enterprise password
password: ANCHORE_ECS_INVENTORY_ANCHORE_PASSWORD

# anchore enterprise account that the inventory will be sent
account: $ANCHORE_ECS_INVENTORY_ANCHORE_ACCOUNT

http:
insecure: true
timeout-seconds: 10

# the aws region
region: $ANCHORE_ECS_INVENTORY_REGION

# frequency of which to poll the region
polling-interval-seconds: 300

quiet: false
23 changes: 10 additions & 13 deletions docker-compose/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
version: '2.1'

services:
anchore-ecs-inventory:
volumes:
- ./config.yaml:/config.yaml:ro
image: anchore/ecs-inventory:latest
image: docker.io/anchore/ecs-inventory:latest
container_name: anchore-ecs-inventory
volumes:
- ./anchore-ecs-inventory.yaml:/.anchore-ecs-inventory.yaml
- ./aws.config:/.aws/credentials
environment:
ANCHORE_ENTERPRISE_API_PASSWORD: ${ANCHORE_ENTERPRISE_API_PASSWORD:-foobar}
AWS_REGION: ${AWS_REGION:-us-west-2}
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID:-bar}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY:-foo}
command:
[
"--config=config.yaml",
"--polling-interval-seconds=300",
"-v"
]
ANCHORE_ECS_INVENTORY_ANCHORE_URL: ${ANCHORE_ECS_INVENTORY_ANCHORE_URL:-http://localhost:8228}
ANCHORE_ECS_INVENTORY_ANCHORE_USER: ${ANCHORE_ECS_INVENTORY_ANCHORE_USER:-admin}
ANCHORE_ECS_INVENTORY_ANCHORE_PASSWORD: ${ANCHORE_ECS_INVENTORY_ANCHORE_PASSWORD:-foobar}
ANCHORE_ECS_INVENTORY_ANCHORE_ACCOUNT: ${ANCHORE_ECS_INVENTORY_ANCHORE_ACCOUNT:-admin}
ANCHORE_ECS_INVENTORY_REGION: ${ANCHORE_ECS_INVENTORY_REGION:-eu-west-2}
4 changes: 2 additions & 2 deletions pkg/reporter/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const ReportAPIPath = "v1/enterprise/inventories"
//
//nolint:gosec
func Post(report Report, anchoreDetails connection.AnchoreInfo) error {
logger.Log.Info("Reporting results to Anchore")
logger.Log.Info("Reporting results to Anchore", "Account", anchoreDetails.Account)
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: anchoreDetails.HTTP.Insecure},
}
Expand Down Expand Up @@ -54,7 +54,7 @@ func Post(report Report, anchoreDetails connection.AnchoreInfo) error {
if resp.StatusCode != 200 {
return fmt.Errorf("failed to report data to Anchore: %+v", resp)
}
logger.Log.Debug("Successfully reported results to Anchore")
logger.Log.Debug("Successfully reported results to Anchore", "Account", anchoreDetails.Account)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/reporter/reportitem.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

// ReportItem represents a cluster and all it's unique images
type ReportItem struct {
Namespace string `json:"namespace,omitempty"` // NOTE The key is Namespace to match the Anchore API but it's actually passed as empty string
Namespace string `json:"namespace"` // NOTE The key is Namespace to match the Anchore API but it's actually passed as empty string
Images []ReportImage `json:"images"`
}

Expand Down

0 comments on commit 0261cc7

Please sign in to comment.