Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atlas plugin #23

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
69b04fb
Signed-off-by: Sajit Kunnumkal <[email protected]>
Aug 16, 2024
09bb7a3
boilerplate for plugin interface (#1)
ameijer Sep 1, 2024
5fe974f
Added tests for atlasconfig.go
Sep 2, 2024
7e00bca
Get costs
Sep 27, 2024
5d26705
Signed-off-by: Sajit Kunnumkal <[email protected]>
Oct 4, 2024
d8f1adb
Add unit tests
Oct 4, 2024
cfd8a56
more tests
Oct 5, 2024
bdf1210
migrate mongo plugin to use harness (#4)
ameijer Oct 12, 2024
24aed3e
fix atlas_config_test
Oct 12, 2024
0f305cf
have a working version. Need to change the function signature
Oct 14, 2024
9013769
working unit tests
Oct 14, 2024
011320b
unit tests
Oct 14, 2024
493bc4e
optional integration test
Oct 14, 2024
2581ed9
Fixing DCO error Signed-off-by: sajit <[email protected]>
ameijer Oct 2, 2024
7e562b1
checkout current branch for now
ameijer Oct 2, 2024
dbaf3f6
JPHM Signed-off-by: sajit <[email protected]>
ameijer Oct 2, 2024
2cde737
repro on branch Signed-off-by: Alex Meijer <[email protected]>
ameijer Oct 2, 2024
f74a1f0
use branch
ameijer Oct 2, 2024
9f5de8c
us PAT to commit Signed-off-by: Alex Meijer <[email protected]>
ameijer Oct 3, 2024
7d679a7
update manifest
Oct 3, 2024
1b9f1f7
update manifest
Oct 3, 2024
448825e
OpenAI Plugin MVP (#38)
ameijer Oct 10, 2024
c8a4a44
update manifest
Oct 10, 2024
9ff32f3
fix harness to support multiple plugins (#39)
ameijer Oct 10, 2024
b29c8b9
implement validator, small bugfix (#6)
ameijer Oct 14, 2024
27c8385
fixing tests; remove .gitmessage.txt from source control
Oct 14, 2024
b81730a
fix tests
Oct 14, 2024
52e0d61
address PR comments: change error to warnings Signed-off-by: Sajit K…
Oct 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/run-integration-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Run Integration Tests

on:
push:
branches:
- main
schedule:
- cron: "0 5 * * *"

jobs:
integration-test-runner:
runs-on: ubuntu-latest
steps:
- uses: oNaiPs/secrets-to-env-action@v1
with:
secrets: ${{ toJSON(secrets) }}
- uses: actions/checkout@v4
with:
path: ./
#ref: main
- name: Install just
uses: extractions/setup-just@v2
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: "stable"
- name: prep workspace
run: |
just init-workspace
- name: run integration tests
run: |
just integration-test-all-plugins


notify-fail:
needs: [integration-test-runner]
runs-on: ubuntu-latest
if: failure()
steps:
- name: Slack notify
id: slack
uses: slackapi/slack-github-action@v1
with:
payload: |
{
"workflow": "${{github.workflow}}",
"message": "Plugin Integration tests have failed! Please check the logs for more information."
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
notify-success:
needs: [integration-test-runner]
runs-on: ubuntu-latest
if: success()
steps:
- name: Slack notify
id: slack
uses: slackapi/slack-github-action@v1
with:
payload: |
{
"workflow": "${{github.workflow}}",
"message": "Plugin Integration tests have passed! :tada:"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
47 changes: 47 additions & 0 deletions .github/workflows/update-manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Update Manifest

on:
push:
branches:
- main

jobs:
update-manifest:
runs-on: ubuntu-latest
steps:
- name: echo actor
run: echo "actor is ${{ github.actor }}"
- uses: actions/checkout@v4
with:
path: ./
ssh-key: ${{ secrets.GH_SSH_KEY}}
persist-credentials: true
- name: update current plugin list
run: |
plugins=$(ls pkg/plugins | tr -s ' ' | sort)
echo "got plugins: $plugins"
echo '# this manifest contains the name of every currently implemented plugin. it can be pulled via https://github.com/opencost/opencost-plugins/raw/main/manifest to get an up to date list of current plugins.
' > manifest
echo "$plugins" >> manifest
echo "manifest updated"
echo "manifest contents:"
cat manifest

- name: Commit changes
run: |
git config --local user.email "github-actions[bot]@noreply.example.com"
git config --local user.name "github-actions[bot]"
git add manifest || true
git commit -m "update manifest" || true

- name: update manifest
uses: ad-m/github-push-action@master
with:
ssh: true
directory: .
repository: opencost/opencost-plugins
branch: main




2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
build
*.out
mongodb-atlas/scripts
.vscode
10 changes: 10 additions & 0 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# OpenCost Plugins Committers and Maintainers

Official list of OpenCost Plugins Maintainers

## Maintainers

| Maintainer | GitHub ID | Affiliation | Email |
| --------------- | --------- | ----------- | ----------- |
| Nik Willwerth | @nik-kc | Kubecost | <[email protected]> |
| Alex Meijer | @ameijer | Kubecost | <[email protected]> |
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ Once the configuration is designed, it's time to write the plugin. Within `<repo
## Implement tests (highly recommended)
Write some unit tests to validate the functionality of your new plugin. See the [Datadog unit tests](https://github.com/opencost/opencost-plugins/blob/main/datadog/tests/datadog_test.go) for reference.

## Add your plugin to the manifest
Add a new line to the [`opencost-plugins` manifest](https://github.com/opencost/opencost-plugins/blob/main/manifest) containing the name of your new plugin. This manifest is used to automatically retrieve the list of available OpenCost plugins.

## Submit it!
Now that your plugin is implemented and tested, all that's left is to get it submitted for review. Create a PR based off your branch and submit it, and an OpenCost developer will review it for you.

Expand Down
14 changes: 11 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,25 @@ commonenv := "CGO_ENABLED=0"

version := `./tools/image-tag`
commit := `git rev-parse --short HEAD`

pluginPaths := `find ./pkg/plugins -type f -iname "go.mod" -print0 | xargs -0 dirname | xargs -I{} basename {} | tr ' ' ',' | tr '\n' ','`
default:
just --list

# Run unit tests
test-all-plugins:
{{commonenv}} find . -type f -iname "go.mod" -print0 | xargs -0 -I{} ./tools/run-tests {}
{{commonenv}} find ./pkg/plugins -type f -iname "go.mod" -print0 | xargs -0 -I{} ./tools/run-tests {}

build-all-plugins: clean test-all-plugins
mkdir -p ./build
find . -type f -iname "go.mod" -print0 | {{commonenv}} VERSION={{version}} COMMIT={{commit}} xargs -0 -I{} ./tools/build-plugins {}
find ./pkg/plugins -type f -iname "go.mod" -print0 | {{commonenv}} VERSION={{version}} COMMIT={{commit}} xargs -0 -I{} ./tools/build-plugins {}

init-workspace:
go work init
find . -type f -iname "go.mod" -print0 | xargs -0 dirname | xargs -I{} go work use {}

integration-test-all-plugins:
echo "pluginPaths: {{pluginPaths}}"
{{commonenv}} go run pkg/test/pkg/executor/main/main.go --plugins={{pluginPaths}}

clean:
rm -rf ./build
Expand Down
1 change: 1 addition & 0 deletions manifest
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# this manifest contains the name of every currently implemented plugin. it can be pulled via https://github.com/opencost/opencost-plugins/raw/main/manifest to get an up to date list of current plugins.

datadog
openai
22 changes: 22 additions & 0 deletions pkg/common/config/config_helpers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package config

import (
"fmt"
"os"
)

func GetConfigFilePath() (string, error) {
// plugins expect exactly 2 args: the executable itself,
// and a path to the config file to use
// all config for the plugin must come through the config file
if len(os.Args) != 2 {
return "", fmt.Errorf("plugins require 2 args: the plugin itself, and the full path to its config file. Got %d args", len(os.Args))
}

_, err := os.Stat(os.Args[1])
if err != nil {
return "", fmt.Errorf("error reading config file at %s: %v", os.Args[1], err)
}

return os.Args[1], nil
}
3 changes: 3 additions & 0 deletions pkg/common/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/opencost/opencost-plugins/common

go 1.22.2
Loading