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

Remodeled application architecture to use webpack to give ability to code in typescript and JSX React #14

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 14 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@
flare.tar.gz
venv
venv-tools
flare/local
flare/metadata/local.meta
packages/flare/local
packages/flare/metadata/local.meta
__pycache__/
.vscode/

flare/bin/vendor/*
packages/flare/python/vendor/*
.DS_Store
.idea/
lerna-debug.log
node_modules
npm-debug.log
test-reports
coverage_report
yarn-error.log
licenses.json
functional-temp
splunktional-temp
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
printWidth: 100
singleQuote: true
tabWidth: 4
overrides:
- files: "*.json"
options:
tabWidth: 2
64 changes: 35 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@
build:
$(MAKE) clean
$(MAKE) venv
$(MAKE) setup-web

setup-web: venv yarn.lock
yarn run setup

venv: requirements.txt
python -m venv venv
venv/bin/pip install --upgrade pip
venv/bin/pip install --target flare/bin/vendor -r requirements.txt
@find flare/bin/vendor -type d -name "*.dist-info" -exec rm -r {} +
@find flare/bin/vendor -type d -name "__pycache__" -exec rm -r {} +
@rm -rf flare/bin/vendor/bin
@rm -rf flare/bin/vendor/packaging
@rm -rf flare/bin/vendor/*-stubs
venv/bin/pip install --target packages/flare/python/vendor -r requirements.txt
@find packages/flare/python/vendor -type d -name "*.dist-info" -exec rm -r {} +
@find packages/flare/python/vendor -type d -name "__pycache__" -exec rm -r {} +
@rm -rf packages/flare/python/vendor/bin
@rm -rf packages/flare/python/vendor/packaging
@rm -rf packages/flare/python/vendor/*-stubs

venv-tools: requirements.tools.txt venv
rm -rf venv-tools
Expand All @@ -22,35 +26,39 @@ venv-tools: requirements.tools.txt venv
.PHONY: clean
clean:
@echo "Removing venv and venv-tools."
@rm -rf venv
@rm -rf venv-tools
@rm -rf flare/bin/vendor
rm -rf venv
rm -rf venv-tools
rm -rf packages/flare/python/vendor
@unlink "/Applications/Splunk/etc/apps/flare" || true
@find . -type d -name "node_modules" -exec rm -rf {} +
rm -rf packages/flare/flare
@rm -f flare.tar.gz
@echo "Done."

.PHONY: package
package: flare/bin/vendor
package: packages/flare/python/vendor
-@rm flare.tar.gz
@find flare/bin -type d -name "__pycache__" -exec rm -r {} +
@find packages/flare/python -type d -name "__pycache__" -exec rm -r {} +
COPYFILE_DISABLE=1 tar \
--exclude='flare/local' \
--exclude='flare/metadata/local.meta' \
--exclude='packages/flare/flare/local' \
--exclude='packages/flare/flare/metadata/local.meta' \
--format ustar \
-C packages/flare \
-cvzf \
"flare.tar.gz" \
"flare"

# This will not work until we get an APPID - need to submit in Splunkbase UI first.
.PHONY: publish
publish: flare.tar.gz
curl -u flaresystems --request POST https://splunkbase.splunk.com/api/v1/app/<APPID>/new_release/ -F "files[]=@./flare.tar.gz" -F "filename=flare.tar.gz" -F "cim_versions=4.9,4.7" -F "splunk_versions=9.3" -F "visibility=true"
publish: packages/flare.tar.gz
curl -u flaresystems --request POST https://splunkbase.splunk.com/api/v1/app/<APPID>/new_release/ -F "files[]=@./packages/flare.tar.gz" -F "filename=packages/flare.tar.gz" -F "cim_versions=4.9,4.7" -F "splunk_versions=9.3" -F "visibility=true"

# A manual review from the Splunk team will be required to know if we need to fix any of these tag warnings.
.PHONY: validate
validate: venv-tools
@echo "Running Splunk AppInspect..."
@echo "If you get an error about \"libmagic\", run \"brew install libmagic\""
@venv-tools/bin/splunk-appinspect inspect --ci "flare" || \
@venv-tools/bin/splunk-appinspect inspect --ci "packages/flare/flare" || \
if test "$$?" -eq "102" || "$$?" -eq "103" ; then \
exit 0 ; \
else \
Expand All @@ -63,7 +71,7 @@ TAGS = advanced_xml alert_actions_conf ast bias cloud csv custom_search_commands
inspect-tags:
@for TAG in $(TAGS); do \
echo "Tag: $$TAG" ; \
venv-tools/bin/splunk-appinspect inspect --ci --included-tags $$TAG "flare" ; \
venv-tools/bin/splunk-appinspect inspect --ci --included-tags $$TAG "packages/flare/flare" ; \
done

.PHONY: test
Expand All @@ -72,30 +80,28 @@ test: venv-tools
then venv-tools/bin/pytest ./**/*.py -vv ; \
fi

.PHONY: format
.PHONY: format setup-web
format: venv-tools
venv-tools/bin/ruff check --fix --unsafe-fixes
venv-tools/bin/ruff format
yarn run format

.PHONY: format-check
format-check: venv-tools
venv-tools/bin/ruff check
venv-tools/bin/ruff format --check
yarn run format:verify

.PHONY: lint
lint: mypy format-check
lint: setup-web venv-tools mypy format-check
yarn run lint

.PHONY: mypy
mypy: venv-tools
venv-tools/bin/mypy flare
venv-tools/bin/mypy packages/flare

.PHONY: splunk-local
splunk-local: venv
@echo "Create symlink from app to Splunk Enterprise"
@if [ ! -d "/Applications/Splunk/etc/apps" ]; then \
echo "Splunk Enterprise isn't installed"; \
exit 1; \
fi

@unlink "/Applications/Splunk/etc/apps/flare" || true
@ln -s "$(CURDIR)/flare" "/Applications/Splunk/etc/apps/flare"
splunk-local: venv setup-web
@echo "Create symlink from app to Splunk Enterprise and start watching files"
SPLUNK_HOME="/Applications/Splunk" yarn run link
yarn run start
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,32 @@ At the time of this writing, Splunk Enterprise is at version 9.3.0. This version
## Installation

For now, see (this confluence page)[https://flareio.atlassian.net/wiki/spaces/engineering/pages/384401447/Splunk+Enterprise] for instructions on how to install and configure this Splunk integration with your Splunk Enterprise instance.

## Architecture Overview

The project contains a variety of packages that are published and versioned collectively. Each package lives in its own
directory in the `/packages` directory. Each package is self contained, and defines its dependencies in a package.json file.

We use [Yarn Workspaces](https://yarnpkg.com/lang/en/docs/workspaces/) and [Lerna](https://github.com/lerna/lerna) for
managing and publishing multiple packages in the same repository.


## Development

If you have your own Splunk Enterprise installed locally, you can use

```
make splunk-local
```

to download the required dependencies, watch the file changes to re-compile on the fly and generate a symlink between the Splunk app and the Splunk Enterprise applications folder.

To be able to see your changes when refreshing, add this at the end of this file:
```
File: /Applications/Splunk/etc/system/local/web.conf

[settings]
cacheEntriesLimit = 0
cacheBytesLimit = 0
```
Then restart your Splunk Enterprise instance.
3 changes: 3 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
babelrcRoots: ['./packages/*'],
};
20 changes: 0 additions & 20 deletions flare/appserver/static/javascript/setupPage.js

This file was deleted.

Loading