Skip to content

Commit 41ae251

Browse files
authored
Merge pull request #427 from splunk/DVPL-8563
Replace .splunkrc with .env file in test and examples
2 parents 7ee8528 + 34421e9 commit 41ae251

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+114
-114
lines changed

.env

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Splunk host (default: localhost)
2+
host=localhost
3+
# Splunk admin port (default: 8089)
4+
port=8089
5+
# Splunk username
6+
username=admin
7+
# Splunk password
8+
password=changed!
9+
# Access scheme (default: https)
10+
scheme=https
11+
# Your version of Splunk (default: 6.2)
12+
version=8.0
13+
# Bearer token for authentication
14+
#bearerToken="<Bearer-token>"
15+
# Session key for authentication
16+
#sessionKey="<Session-Key>"

.github/workflows/test.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,6 @@ jobs:
3636
uses: actions/setup-python@v2
3737
with:
3838
python-version: ${{ matrix.python }}
39-
- name: Create .splunkrc file
40-
run: |
41-
cd ~
42-
echo host=localhost > .splunkrc
43-
echo port=8089 >> .splunkrc
44-
echo username=admin >> .splunkrc
45-
echo password=changed! >> .splunkrc
46-
echo scheme=https >> .splunkrc
47-
echo version=${{ matrix.splunk }} >> .splunkrc
4839
- name: Install tox
4940
run: pip install tox
5041
- name: Test Execution

Makefile

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,16 @@ test_smoke_no_app:
5656
@echo "$(ATTN_COLOR)==> test_smoke_no_app $(NO_COLOR)"
5757
@tox -e py27,py37 -- -m "smoke and not app"
5858

59-
.PHONY: splunkrc
60-
splunkrc:
61-
@echo "$(ATTN_COLOR)==> splunkrc $(NO_COLOR)"
62-
@echo "To make a .splunkrc:"
63-
@echo " [SPLUNK_INSTANCE_JSON] | python scripts/build-splunkrc.py ~/.splunkrc"
64-
65-
.PHONY: splunkrc_default
66-
splunkrc_default:
67-
@echo "$(ATTN_COLOR)==> splunkrc_default $(NO_COLOR)"
68-
@python scripts/build-splunkrc.py ~/.splunkrc
59+
.PHONY: env
60+
env:
61+
@echo "$(ATTN_COLOR)==> env $(NO_COLOR)"
62+
@echo "To make a .env:"
63+
@echo " [SPLUNK_INSTANCE_JSON] | python scripts/build-env.py"
64+
65+
.PHONY: env_default
66+
env_default:
67+
@echo "$(ATTN_COLOR)==> env_default $(NO_COLOR)"
68+
@python scripts/build-env.py
6969

7070
.PHONY: up
7171
up:

README.md

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ You'll need `docker` and `docker-compose` to get up and running using this metho
6060
```
6161
make up SPLUNK_VERSION=8.0
6262
make wait_up
63-
make splunkrc_default
6463
make test
6564
make down
6665
```
@@ -91,13 +90,13 @@ service = client.connect(host=<host_url>, token=<session_key>, autologin=True)
9190
```
9291

9392
###
94-
#### Create a .splunkrc convenience file
93+
#### Update a .env file
9594

96-
To connect to Splunk Enterprise, many of the SDK examples and unit tests take command-line arguments that specify values for the host, port, and login credentials for Splunk Enterprise. For convenience during development, you can store these arguments as key-value pairs in a text file named **.splunkrc**. Then, the SDK examples and unit tests use the values from the **.splunkrc** file when you don't specify them.
95+
To connect to Splunk Enterprise, many of the SDK examples and unit tests take command-line arguments that specify values for the host, port, and login credentials for Splunk Enterprise. For convenience during development, you can store these arguments as key-value pairs in a **.env** file. Then, the SDK examples and unit tests use the values from the **.env** file when you don't specify them.
9796

98-
>**Note**: Storing login credentials in the **.splunkrc** file is only for convenience during development. This file isn't part of the Splunk platform and shouldn't be used for storing user credentials for production. And, if you're at all concerned about the security of your credentials, enter them at the command line rather than saving them in this file.
97+
>**Note**: Storing login credentials in the **.env** file is only for convenience during development. This file isn't part of the Splunk platform and shouldn't be used for storing user credentials for production. And, if you're at all concerned about the security of your credentials, enter them at the command line rather than saving them in this file.
9998
100-
To use this convenience file, create a text file with the following format:
99+
here is an example of .env file:
101100

102101
# Splunk Enterprise host (default: localhost)
103102
host=localhost
@@ -106,27 +105,15 @@ To use this convenience file, create a text file with the following format:
106105
# Splunk Enterprise username
107106
username=admin
108107
# Splunk Enterprise password
109-
password=changeme
108+
password=changed!
110109
# Access scheme (default: https)
111110
scheme=https
112111
# Your version of Splunk Enterprise
113112
version=8.0
114-
115-
Save the file as **.splunkrc** in the current user's home directory.
116-
117-
* For example on OS X, save the file as:
118-
119-
~/.splunkrc
120-
121-
* On Windows, save the file as:
122-
123-
C:\Users\currentusername\.splunkrc
124-
125-
You might get errors in Windows when you try to name the file because ".splunkrc" appears to be a nameless file with an extension. You can use the command line to create this file by going to the **C:\Users\\&lt;currentusername&gt;** directory and entering the following command:
126-
127-
Notepad.exe .splunkrc
128-
129-
Click **Yes**, then continue creating the file.
113+
# Bearer token for authentication
114+
#bearerToken=<Bearer-token>
115+
# Session key for authentication
116+
#sessionKey=<Session-Key>
130117

131118
#### Run the examples
132119

@@ -144,7 +131,7 @@ Using Session key
144131

145132
python examplename.py --sessionKey="<value>"
146133

147-
If you saved your login credentials in the **.splunkrc** file, you can omit those arguments:
134+
If you saved your login credentials in the **.env** file, you can omit those arguments:
148135

149136
python examplename.py
150137

examples/analytics/input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def main():
102102

103103
argv = sys.argv[1:]
104104

105-
splunk_opts = utils.parse(argv, {}, ".splunkrc", usage=usage)
105+
splunk_opts = utils.parse(argv, {}, ".env", usage=usage)
106106
tracker = AnalyticsTracker("cli_app", splunk_opts.kwargs)
107107

108108
#tracker.track("test_event", "abc123", foo="bar", bar="foo")

examples/analytics/output.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def main():
152152

153153
argv = sys.argv[1:]
154154

155-
opts = utils.parse(argv, {}, ".splunkrc", usage=usage)
155+
opts = utils.parse(argv, {}, ".env", usage=usage)
156156
retriever = AnalyticsRetriever(opts.args[0], opts.kwargs)
157157

158158
#events = retriever.events()

examples/analytics/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def application(name):
146146
def main():
147147
argv = sys.argv[1:]
148148

149-
opts = utils.parse(argv, {}, ".splunkrc")
149+
opts = utils.parse(argv, {}, ".env")
150150
global splunk_opts
151151
splunk_opts = opts.kwargs
152152

examples/async/async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def main(argv):
5151
usage = "async.py <sync | async>"
5252

5353
# Parse the command line args.
54-
opts = parse(argv, {}, ".splunkrc")
54+
opts = parse(argv, {}, ".env")
5555

5656
# We have to see if we got either the "sync" or
5757
# "async" command line arguments.

examples/binding1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def search(self, query, **kwargs):
5252
return self.context.post("search/jobs/export", search=query, **kwargs)
5353

5454
def main(argv):
55-
opts = parse(argv, {}, ".splunkrc")
55+
opts = parse(argv, {}, ".env")
5656
context = connect(**opts.kwargs)
5757
service = Service(context)
5858
assert service.apps().status == 200

examples/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def main():
151151
commands = ['create', 'delete', 'list']
152152

153153
# parse args, connect and setup
154-
opts = parse(argv, {}, ".splunkrc", usage=usage)
154+
opts = parse(argv, {}, ".env", usage=usage)
155155
service = connect(**opts.kwargs)
156156
program = Program(service)
157157

0 commit comments

Comments
 (0)