Skip to content

Commit

Permalink
fix python template generation
Browse files Browse the repository at this point in the history
  • Loading branch information
bakshi41c committed Aug 1, 2024
1 parent a9edbf0 commit ef28946
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 39 deletions.
17 changes: 11 additions & 6 deletions agent/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,32 @@ build-agent: build-agent-only build-go-syntest-plugins
## SDK - Creating new syntest plugin
.PHONY : new-go-syntest
new-go-syntest:
@echo Creating Directory plugins/syntests/$(name)
@echo "-> Creating Directory plugins/syntests/$(name)"
mkdir plugins/syntests/$(name)

@echo Creating file plugins/syntests/$(name)/$(name).go
@echo "-> Creating file plugins/syntests/$(name)/$(name).go"
cp plugins/templates/go/test.tpl.go plugins/syntests/$(name)/$(name).go

@echo "-> Replacing placeholders in $(name).go"
sed -i s/{{TestNameRaw}}/$(name)/g plugins/syntests/$(name)/$(name).go
sed -i s/{{TestName}}/$(call capitalize,$(name))/g plugins/syntests/$(name)/$(name).go

.PHONY : new-python-syntest
new-python-syntest:
@echo Creating Directory plugins/syntests-python/$(name)
@echo "-> Creating Directory plugins/syntests-python/$(name)"
mkdir -p plugins/syntests-python/$(name)

@echo Creating file plugins/syntests/$(name)/$(name).py
@echo "-> Creating file plugins/syntests/$(name)/$(name).py"
cp plugins/templates/python/test.tpl.py plugins/syntests-python/$(name)/test-$(name).py
cp plugins/templates/python/requirements.txt plugins/syntests-python/$(name)/requirements.txt

echo $(call camelcase,$(name))
@echo "-> Replacing placeholders in test-$(name).py"
sed -i.bak s/{{TestName}}/$(call camelcase,$(name))/g plugins/syntests-python/$(name)/test-$(name).py && rm plugins/syntests-python/$(name)/test-$(name).py.bak

sed -i s/{{TestName}}/$(call camelcase,$(name))/g plugins/syntests-python/$(name)/test-$(name).py
@echo "-> Creating virtual environment"
python3 -m venv plugins/syntests-python/$(name)/.venv

@echo "\nActivate virtual environment by running:\n \n source plugins/syntests-python/$(name)/.venv/bin/activate"

define capitalize
$(shell echo $(1) | awk '{$$1=toupper(substr($$1,0,1))substr($$1,2); print $$0}')
Expand Down
2 changes: 1 addition & 1 deletion agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,6 @@ For golang plugins:
For python plugins:

- Test name should be kebab-case or snake_case (in this example: `my-test`)
- Run `make new-python-test name=my-test`. This will create a new directory `./plugins/syntests-python/my-test` with a sample plugin.
- Run `make new-python-syntest name=my-test`. This will create a new directory `./plugins/syntests-python/my-test` with a sample plugin.

NOTE: Please add a README.md in the new plugin directory with description of the plugin, and how to configure
32 changes: 0 additions & 32 deletions push.sh

This file was deleted.

0 comments on commit ef28946

Please sign in to comment.