Skip to content

Commit

Permalink
Remodeled application architure to use webpack to give ability to cod…
Browse files Browse the repository at this point in the history
…e in typescript and JSX React

- Converted the static JSX-less configuration screen to React
  • Loading branch information
Marc-Antoine Hinse committed Oct 29, 2024
1 parent 7d8c9d2 commit a580300
Show file tree
Hide file tree
Showing 70 changed files with 30,515 additions and 947 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,15 @@ __pycache__/
.vscode/

flare_splunk_integration/bin/vendor/*
packages/flare-splunk-integration/bin/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
56 changes: 27 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
build:
$(MAKE) clean
$(MAKE) venv
yarn run setup

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

venv-tools: requirements.tools.txt venv
rm -rf venv-tools
Expand All @@ -24,33 +25,33 @@ clean:
@echo "Removing venv and venv-tools."
@rm -rf venv
@rm -rf venv-tools
@rm -rf flare_splunk_integration/bin/vendor
@unlink "/Applications/Splunk/etc/apps/flare_splunk_integration" || true
@rm -rf packages/flare-splunk-integration/bin/vendor
@yarn run unlink
@echo "Done."

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

# This will not work until we get an APPID - need to submit in Splunkbase UI first.
.PHONY: publish
publish: flare_splunk_integration.tar.gz
curl -u flaresystems --request POST https://splunkbase.splunk.com/api/v1/app/<APPID>/new_release/ -F "files[]=@./flare_splunk_integration.tar.gz" -F "filename=flare_splunk_integration.tar.gz" -F "cim_versions=4.9,4.7" -F "splunk_versions=9.3" -F "visibility=true"
publish: packages/flare-splunk-integration.tar.gz
curl -u flaresystems --request POST https://splunkbase.splunk.com/api/v1/app/<APPID>/new_release/ -F "files[]=@./packages/flare-splunk-integration.tar.gz" -F "filename=packages/flare-splunk-integration.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_splunk_integration" || \
@venv-tools/bin/splunk-appinspect inspect --ci "packages/flare-splunk-integration" || \
if test "$$?" -eq "102" || "$$?" -eq "103" ; then \
exit 0 ; \
else \
Expand All @@ -63,7 +64,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_splunk_integration" ; \
venv-tools/bin/splunk-appinspect inspect --ci --included-tags $$TAG "packages/flare-splunk-integration" ; \
done

.PHONY: test
Expand All @@ -76,26 +77,23 @@ test: venv-tools
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

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

.PHONY: mypy
mypy: venv-tools
venv-tools/bin/mypy flare_splunk_integration
venv-tools/bin/mypy packages/flare-splunk-integration

.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_splunk_integration" || true
@ln -s "$(CURDIR)/flare_splunk_integration" "/Applications/Splunk/etc/apps/flare_splunk_integration"
@echo "Create symlink from app to Splunk Enterprise and start watching files"
SPLUNK_HOME="/Applications/Splunk" yarn run link
yarn run start
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,44 @@ 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.


## Getting Started

1. Clone the repo.
2. Install yarn (>= 1.2) if you haven't already: `npm install --global yarn`.
3. Run the setup task: `yarn run setup`.

After this step, the following tasks will be available:

* `start` – Run the `start` task for each project
* `build` – Create a production bundle for all projects
* `lint` – Run JS and CSS linters for each project
* `format` – Run prettier to auto-format `*.js`, `*.jsx` and `*.css` files. This command will overwrite files without
asking, `format:verify` won't.

Running `yarn run setup` once is required to enable all other tasks. The command might take a few minutes to finish.


## Developer Scripts

Commands run from the root directory will be applied to all packages. This is handy when working on multiple packages
simultaneously. Commands can also be run from individual packages. This may be better for performance and reporting when
only working on a single package. All of the packages have similar developer scripts, but not all scripts are implemented
for every package. See the `package.json` of the package in question to see which scripts are available there.

For more granular control of development scripts, consider using [Lerna](https://github.com/lerna/lerna) directly.


## Code Formatting

splunk-integration uses [prettier](https://github.com/prettier/prettier) to ensure consistent code formatting. It is recommended
to [add a prettier plugin to your editor/ide](https://github.com/prettier/prettier#editor-integration).
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/*'],
};
30 changes: 0 additions & 30 deletions flare_splunk_integration/README

This file was deleted.

20 changes: 0 additions & 20 deletions flare_splunk_integration/appserver/static/javascript/setupPage.js

This file was deleted.

Loading

0 comments on commit a580300

Please sign in to comment.