stoobly-agent 0.34.13__py3-none-any.whl → 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. stoobly_agent/__init__.py +1 -1
  2. stoobly_agent/app/cli/__init__.py +1 -0
  3. stoobly_agent/app/cli/helpers/openapi_endpoint_adapter.py +9 -7
  4. stoobly_agent/app/cli/helpers/shell.py +28 -0
  5. stoobly_agent/app/cli/main_group.py +1 -1
  6. stoobly_agent/app/cli/scaffold/__init__.py +0 -0
  7. stoobly_agent/app/cli/scaffold/app.py +106 -0
  8. stoobly_agent/app/cli/scaffold/app_command.py +82 -0
  9. stoobly_agent/app/cli/scaffold/app_config.py +32 -0
  10. stoobly_agent/app/cli/scaffold/app_create_command.py +24 -0
  11. stoobly_agent/app/cli/scaffold/command.py +15 -0
  12. stoobly_agent/app/cli/scaffold/config.py +35 -0
  13. stoobly_agent/app/cli/scaffold/constants.py +35 -0
  14. stoobly_agent/app/cli/scaffold/docker/__init__.py +0 -0
  15. stoobly_agent/app/cli/scaffold/docker/app_builder.py +26 -0
  16. stoobly_agent/app/cli/scaffold/docker/builder.py +117 -0
  17. stoobly_agent/app/cli/scaffold/docker/constants.py +7 -0
  18. stoobly_agent/app/cli/scaffold/docker/service/__init__.py +0 -0
  19. stoobly_agent/app/cli/scaffold/docker/service/build_decorator.py +37 -0
  20. stoobly_agent/app/cli/scaffold/docker/service/builder.py +117 -0
  21. stoobly_agent/app/cli/scaffold/docker/service/set_gateway_ports.py +47 -0
  22. stoobly_agent/app/cli/scaffold/docker/service/types.py +4 -0
  23. stoobly_agent/app/cli/scaffold/docker/workflow/__init__.py +0 -0
  24. stoobly_agent/app/cli/scaffold/docker/workflow/build_decorator.py +28 -0
  25. stoobly_agent/app/cli/scaffold/docker/workflow/builder.py +259 -0
  26. stoobly_agent/app/cli/scaffold/docker/workflow/decorators_factory.py +17 -0
  27. stoobly_agent/app/cli/scaffold/docker/workflow/mock_decorator.py +40 -0
  28. stoobly_agent/app/cli/scaffold/docker/workflow/reverse_proxy_decorator.py +51 -0
  29. stoobly_agent/app/cli/scaffold/env.py +49 -0
  30. stoobly_agent/app/cli/scaffold/service.py +25 -0
  31. stoobly_agent/app/cli/scaffold/service_command.py +50 -0
  32. stoobly_agent/app/cli/scaffold/service_config.py +207 -0
  33. stoobly_agent/app/cli/scaffold/service_create_command.py +77 -0
  34. stoobly_agent/app/cli/scaffold/service_workflow.py +18 -0
  35. stoobly_agent/app/cli/scaffold/templates/__init__.py +0 -0
  36. stoobly_agent/app/cli/scaffold/templates/app/.Dockerfile.context +8 -0
  37. stoobly_agent/app/cli/scaffold/templates/app/.Dockerfile.proxy +35 -0
  38. stoobly_agent/app/cli/scaffold/templates/app/.Makefile +118 -0
  39. stoobly_agent/app/cli/scaffold/templates/app/.docker-compose.base.yml +15 -0
  40. stoobly_agent/app/cli/scaffold/templates/app/Makefile +3 -0
  41. stoobly_agent/app/cli/scaffold/templates/app/build/.config.yml +1 -0
  42. stoobly_agent/app/cli/scaffold/templates/app/build/.docker-compose.base.yml +11 -0
  43. stoobly_agent/app/cli/scaffold/templates/app/build/mock/.docker-compose.mock.yml +22 -0
  44. stoobly_agent/app/cli/scaffold/templates/app/build/mock/bin/.configure +5 -0
  45. stoobly_agent/app/cli/scaffold/templates/app/build/mock/bin/.init +5 -0
  46. stoobly_agent/app/cli/scaffold/templates/app/build/mock/bin/configure +1 -0
  47. stoobly_agent/app/cli/scaffold/templates/app/build/mock/bin/init +1 -0
  48. stoobly_agent/app/cli/scaffold/templates/app/build/record/.docker-compose.record.yml +22 -0
  49. stoobly_agent/app/cli/scaffold/templates/app/build/record/bin/.configure +5 -0
  50. stoobly_agent/app/cli/scaffold/templates/app/build/record/bin/.init +5 -0
  51. stoobly_agent/app/cli/scaffold/templates/app/build/record/bin/configure +1 -0
  52. stoobly_agent/app/cli/scaffold/templates/app/build/record/bin/init +1 -0
  53. stoobly_agent/app/cli/scaffold/templates/app/build/test/.docker-compose.test.yml +22 -0
  54. stoobly_agent/app/cli/scaffold/templates/app/build/test/bin/.configure +5 -0
  55. stoobly_agent/app/cli/scaffold/templates/app/build/test/bin/.init +5 -0
  56. stoobly_agent/app/cli/scaffold/templates/app/build/test/bin/configure +1 -0
  57. stoobly_agent/app/cli/scaffold/templates/app/build/test/bin/init +1 -0
  58. stoobly_agent/app/cli/scaffold/templates/app/entrypoint/.config.yml +1 -0
  59. stoobly_agent/app/cli/scaffold/templates/app/entrypoint/.docker-compose.base.yml +17 -0
  60. stoobly_agent/app/cli/scaffold/templates/app/entrypoint/mock/.docker-compose.mock.yml +31 -0
  61. stoobly_agent/app/cli/scaffold/templates/app/entrypoint/mock/bin/.configure +10 -0
  62. stoobly_agent/app/cli/scaffold/templates/app/entrypoint/mock/bin/.init +5 -0
  63. stoobly_agent/app/cli/scaffold/templates/app/entrypoint/mock/bin/configure +1 -0
  64. stoobly_agent/app/cli/scaffold/templates/app/entrypoint/mock/bin/init +4 -0
  65. stoobly_agent/app/cli/scaffold/templates/app/entrypoint/mock/docker-compose.yml +1 -0
  66. stoobly_agent/app/cli/scaffold/templates/app/entrypoint/record/.docker-compose.record.yml +31 -0
  67. stoobly_agent/app/cli/scaffold/templates/app/entrypoint/record/bin/.configure +10 -0
  68. stoobly_agent/app/cli/scaffold/templates/app/entrypoint/record/bin/.init +5 -0
  69. stoobly_agent/app/cli/scaffold/templates/app/entrypoint/record/bin/configure +1 -0
  70. stoobly_agent/app/cli/scaffold/templates/app/entrypoint/record/bin/init +4 -0
  71. stoobly_agent/app/cli/scaffold/templates/app/entrypoint/record/docker-compose.yml +1 -0
  72. stoobly_agent/app/cli/scaffold/templates/app/entrypoint/test/.docker-compose.test.yml +31 -0
  73. stoobly_agent/app/cli/scaffold/templates/app/entrypoint/test/bin/.configure +10 -0
  74. stoobly_agent/app/cli/scaffold/templates/app/entrypoint/test/bin/.init +3 -0
  75. stoobly_agent/app/cli/scaffold/templates/app/entrypoint/test/bin/configure +1 -0
  76. stoobly_agent/app/cli/scaffold/templates/app/entrypoint/test/bin/init +4 -0
  77. stoobly_agent/app/cli/scaffold/templates/app/entrypoint/test/docker-compose.yml +1 -0
  78. stoobly_agent/app/cli/scaffold/templates/app/gateway/.config.yml +1 -0
  79. stoobly_agent/app/cli/scaffold/templates/app/gateway/.docker-compose.base.yml +11 -0
  80. stoobly_agent/app/cli/scaffold/templates/app/gateway/mock/.docker-compose.mock.yml +13 -0
  81. stoobly_agent/app/cli/scaffold/templates/app/gateway/record/.docker-compose.record.yml +13 -0
  82. stoobly_agent/app/cli/scaffold/templates/app/stoobly-ui/.config.yml +1 -0
  83. stoobly_agent/app/cli/scaffold/templates/app/stoobly-ui/.docker-compose.base.yml +5 -0
  84. stoobly_agent/app/cli/scaffold/templates/app/stoobly-ui/exec/.docker-compose.exec.yml +12 -0
  85. stoobly_agent/app/cli/scaffold/templates/app/stoobly-ui/exec/bin/.create +11 -0
  86. stoobly_agent/app/cli/scaffold/templates/app/stoobly-ui/exec/bin/.delete +12 -0
  87. stoobly_agent/app/cli/scaffold/templates/app/stoobly-ui/exec/bin/.disable +3 -0
  88. stoobly_agent/app/cli/scaffold/templates/app/stoobly-ui/exec/bin/.enable +10 -0
  89. stoobly_agent/app/cli/scaffold/templates/app/stoobly-ui/exec/bin/.reset +12 -0
  90. stoobly_agent/app/cli/scaffold/templates/app/stoobly-ui/exec/bin/.run +11 -0
  91. stoobly_agent/app/cli/scaffold/templates/app/stoobly-ui/exec/bin/.snapshot +12 -0
  92. stoobly_agent/app/cli/scaffold/templates/app/stoobly-ui/exec/bin/.stop +11 -0
  93. stoobly_agent/app/cli/scaffold/templates/app/stoobly-ui/mock/.docker-compose.mock.yml +12 -0
  94. stoobly_agent/app/cli/scaffold/templates/app/stoobly-ui/record/.docker-compose.record.yml +13 -0
  95. stoobly_agent/app/cli/scaffold/templates/constants.py +63 -0
  96. stoobly_agent/app/cli/scaffold/templates/factory.py +46 -0
  97. stoobly_agent/app/cli/scaffold/templates/workflow/mock/bin/.configure +3 -0
  98. stoobly_agent/app/cli/scaffold/templates/workflow/mock/bin/.init +3 -0
  99. stoobly_agent/app/cli/scaffold/templates/workflow/mock/bin/configure +18 -0
  100. stoobly_agent/app/cli/scaffold/templates/workflow/mock/bin/init +4 -0
  101. stoobly_agent/app/cli/scaffold/templates/workflow/mock/fixtures/.keep +0 -0
  102. stoobly_agent/app/cli/scaffold/templates/workflow/mock/fixtures.yml +5 -0
  103. stoobly_agent/app/cli/scaffold/templates/workflow/mock/lifecycle_hooks.py +12 -0
  104. stoobly_agent/app/cli/scaffold/templates/workflow/record/bin/.configure +3 -0
  105. stoobly_agent/app/cli/scaffold/templates/workflow/record/bin/.init +3 -0
  106. stoobly_agent/app/cli/scaffold/templates/workflow/record/bin/configure +29 -0
  107. stoobly_agent/app/cli/scaffold/templates/workflow/record/bin/init +4 -0
  108. stoobly_agent/app/cli/scaffold/templates/workflow/record/lifecycle_hooks.py +12 -0
  109. stoobly_agent/app/cli/scaffold/templates/workflow/test/bin/.configure +3 -0
  110. stoobly_agent/app/cli/scaffold/templates/workflow/test/bin/.init +3 -0
  111. stoobly_agent/app/cli/scaffold/templates/workflow/test/bin/configure +18 -0
  112. stoobly_agent/app/cli/scaffold/templates/workflow/test/bin/init +4 -0
  113. stoobly_agent/app/cli/scaffold/templates/workflow/test/fixtures/.keep +0 -0
  114. stoobly_agent/app/cli/scaffold/templates/workflow/test/fixtures.yml +5 -0
  115. stoobly_agent/app/cli/scaffold/templates/workflow/test/lifecycle_hooks.py +12 -0
  116. stoobly_agent/app/cli/scaffold/workflow.py +49 -0
  117. stoobly_agent/app/cli/scaffold/workflow_command.py +137 -0
  118. stoobly_agent/app/cli/scaffold/workflow_copy_command.py +45 -0
  119. stoobly_agent/app/cli/scaffold/workflow_create_command.py +94 -0
  120. stoobly_agent/app/cli/scaffold/workflow_log_command.py +21 -0
  121. stoobly_agent/app/cli/scaffold/workflow_run_command.py +134 -0
  122. stoobly_agent/app/cli/scaffold_cli.py +392 -0
  123. stoobly_agent/cli.py +3 -2
  124. stoobly_agent/config/data_dir.py +40 -14
  125. stoobly_agent/lib/logger.py +3 -2
  126. stoobly_agent/test/app/models/schemas/.stoobly/db/VERSION +1 -1
  127. stoobly_agent/test/config/data_dir_test.py +4 -4
  128. {stoobly_agent-0.34.13.dist-info → stoobly_agent-1.0.0.dist-info}/METADATA +8 -7
  129. {stoobly_agent-0.34.13.dist-info → stoobly_agent-1.0.0.dist-info}/RECORD +132 -14
  130. {stoobly_agent-0.34.13.dist-info → stoobly_agent-1.0.0.dist-info}/WHEEL +1 -1
  131. {stoobly_agent-0.34.13.dist-info → stoobly_agent-1.0.0.dist-info}/LICENSE +0 -0
  132. {stoobly_agent-0.34.13.dist-info → stoobly_agent-1.0.0.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,31 @@
1
+ networks:
2
+ entrypoint:
3
+ name: entrypoint
4
+ services:
5
+ entrypoint.configure:
6
+ build:
7
+ context: ./
8
+ dockerfile: ../../.Dockerfile.context
9
+ depends_on:
10
+ entrypoint.init:
11
+ condition: service_completed_successfully
12
+ environment: {}
13
+ extends:
14
+ file: ../.docker-compose.base.yml
15
+ service: entrypoint.configure_base
16
+ profiles:
17
+ - mock
18
+ volumes: []
19
+ entrypoint.init:
20
+ build:
21
+ context: ./
22
+ dockerfile: ../../.Dockerfile.context
23
+ environment: {}
24
+ extends:
25
+ file: ../.docker-compose.base.yml
26
+ service: entrypoint.init_base
27
+ profiles:
28
+ - mock
29
+ volumes:
30
+ - ./dist:/home/stoobly/dist
31
+ volumes: {}
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+
3
+ # Data
4
+ echo "Configuring intercept mode"
5
+ stoobly-agent intercept configure --mode mock --policy found
6
+
7
+ echo "Enabling intercept"
8
+ stoobly-agent intercept enable
9
+
10
+ cd $(dirname -- "$0") && ./configure
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+
3
+ stoobly-agent intercept enable
4
+
5
+ cd $(dirname -- "$0") && ./init
@@ -0,0 +1,4 @@
1
+ #! /bin/bash
2
+
3
+ # ARGV[1] = Path to 'dist' folder
4
+ # Contents within this folder will be shared
@@ -0,0 +1,31 @@
1
+ networks:
2
+ entrypoint:
3
+ name: entrypoint
4
+ services:
5
+ entrypoint.configure:
6
+ build:
7
+ context: ./
8
+ dockerfile: ../../.Dockerfile.context
9
+ depends_on:
10
+ entrypoint.init:
11
+ condition: service_completed_successfully
12
+ environment: {}
13
+ extends:
14
+ file: ../.docker-compose.base.yml
15
+ service: entrypoint.configure_base
16
+ profiles:
17
+ - record
18
+ volumes: []
19
+ entrypoint.init:
20
+ build:
21
+ context: ./
22
+ dockerfile: ../../.Dockerfile.context
23
+ environment: {}
24
+ extends:
25
+ file: ../.docker-compose.base.yml
26
+ service: entrypoint.init_base
27
+ profiles:
28
+ - record
29
+ volumes:
30
+ - ./dist:/home/stoobly/dist
31
+ volumes: {}
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+
3
+ # Data
4
+ echo "Configuring intercept mode"
5
+ stoobly-agent intercept configure --mode record --policy all
6
+
7
+ echo "Disabling intercept"
8
+ stoobly-agent intercept disable
9
+
10
+ cd $(dirname -- "$0") && ./configure
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+
3
+ stoobly-agent intercept enable
4
+
5
+ cd $(dirname -- "$0") && ./init
@@ -0,0 +1,4 @@
1
+ #! /bin/bash
2
+
3
+ # ARGV[1] = Path to 'dist' folder
4
+ # Contents within this folder will be shared
@@ -0,0 +1,31 @@
1
+ networks:
2
+ entrypoint:
3
+ name: entrypoint
4
+ services:
5
+ entrypoint.configure:
6
+ build:
7
+ context: ./
8
+ dockerfile: ../../.Dockerfile.context
9
+ depends_on:
10
+ entrypoint.init:
11
+ condition: service_completed_successfully
12
+ environment: {}
13
+ extends:
14
+ file: ../.docker-compose.base.yml
15
+ service: entrypoint.configure_base
16
+ profiles:
17
+ - test
18
+ volumes: []
19
+ entrypoint.init:
20
+ build:
21
+ context: ./
22
+ dockerfile: ../../.Dockerfile.context
23
+ environment: {}
24
+ extends:
25
+ file: ../.docker-compose.base.yml
26
+ service: entrypoint.init_base
27
+ profiles:
28
+ - test
29
+ volumes:
30
+ - ./dist:/home/stoobly/dist
31
+ volumes: {}
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+
3
+ # Data
4
+ echo "Configuring intercept mode"
5
+ stoobly-agent intercept configure --mode mock --policy found
6
+
7
+ echo "Enabling intercept"
8
+ stoobly-agent intercept enable
9
+
10
+ cd $(dirname -- "$0") && ./configure
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ cd $(dirname -- "$0") && ./init
@@ -0,0 +1,4 @@
1
+ #! /bin/bash
2
+
3
+ # ARGV[1] = Path to 'dist' folder
4
+ # Contents within this folder will be shared
@@ -0,0 +1 @@
1
+ SERVICE_PRIORITY: 1
@@ -0,0 +1,11 @@
1
+ services:
2
+ gateway_base:
3
+ image: nginxproxy/nginx-proxy:1.5
4
+ ports:
5
+ - '80:80'
6
+ - '443:443' # Entry port
7
+ profiles:
8
+ - gateway_base
9
+ volumes:
10
+ - /var/run/docker.sock:/tmp/docker.sock:ro
11
+ - ${CERTS_DIR}:/etc/nginx/certs
@@ -0,0 +1,13 @@
1
+ services:
2
+ gateway.service:
3
+ extends:
4
+ file: ../.docker-compose.base.yml
5
+ service: gateway_base
6
+ networks:
7
+ - gateway
8
+ profiles:
9
+ - mock
10
+ networks:
11
+ gateway:
12
+ name: ${APP_NETWORK}
13
+ external: true
@@ -0,0 +1,13 @@
1
+ services:
2
+ gateway.service:
3
+ extends:
4
+ file: ../.docker-compose.base.yml
5
+ service: gateway_base
6
+ networks:
7
+ - gateway
8
+ profiles:
9
+ - record
10
+ networks:
11
+ gateway:
12
+ name: ${APP_NETWORK}
13
+ external: true
@@ -0,0 +1 @@
1
+ SERVICE_PRIORITY: 1
@@ -0,0 +1,5 @@
1
+ services:
2
+ stoobly_ui.base:
3
+ extends:
4
+ file: ../.docker-compose.base.yml
5
+ service: context_base
@@ -0,0 +1,12 @@
1
+ services:
2
+ stoobly_ui.command:
3
+ build:
4
+ dockerfile: ../../.Dockerfile.context
5
+ command: ['${EXEC_COMMAND}', '${EXEC_ARGS}']
6
+ environment:
7
+ EXEC_OPTIONS: ${EXEC_OPTIONS}
8
+ extends:
9
+ file: ../.docker-compose.base.yml
10
+ service: stoobly_ui.base
11
+ profiles:
12
+ - exec
@@ -0,0 +1,11 @@
1
+ #!/bin/bash
2
+
3
+ extra_options=$EXEC_OPTIONS
4
+ scenario_name="$1"
5
+
6
+ if [ ! "$scenario_name" ]; then
7
+ echo "Missing argument 'scenario_name'"
8
+ exit
9
+ fi
10
+
11
+ stoobly-agent scenario create --select key --without-headers $extra_options "$scenario_name"
@@ -0,0 +1,12 @@
1
+ #!/bin/bash
2
+
3
+ scenario_key=$1
4
+
5
+ if [ ! "$scenario_key" ]; then
6
+ echo "Missing argument 'scenario_key'"
7
+ stoobly-agent scenario list
8
+ exit
9
+ fi
10
+
11
+ stoobly-agent scenario delete "$scenario_key"
12
+ stoobly-agent scenario snapshot --action DELETE "$scenario_key"
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ stoobly-agent intercept disable
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+
3
+ scenario_key=$1
4
+
5
+ if [ "$scenario_key" ]; then
6
+ echo "Using scenario $scenario_key"
7
+ stoobly-agent config scenario set "$scenario_key"
8
+ fi
9
+
10
+ stoobly-agent intercept enable
@@ -0,0 +1,12 @@
1
+ #!/bin/bash
2
+
3
+ extra_options=$EXEC_OPTIONS
4
+ scenario_key=$1
5
+
6
+ if [ ! "$scenario_key" ]; then
7
+ echo "Missing argument 'scenario_key'"
8
+ stoobly-agent scenario list
9
+ exit
10
+ fi
11
+
12
+ stoobly-agent scenario reset $extra_options "$scenario_key"
@@ -0,0 +1,11 @@
1
+ #!/bin/bash
2
+
3
+ extra_options=$EXEC_OPTIONS
4
+ workflow=$1
5
+
6
+ stoobly-agent scaffold workflow run \
7
+ --app-dir-path "$(pwd)" \
8
+ --dry-run \
9
+ --log-level warning \
10
+ $extra_options \
11
+ $workflow > .stoobly/tmp/run.sh
@@ -0,0 +1,12 @@
1
+ #!/bin/bash
2
+
3
+ extra_options=$EXEC_OPTIONS
4
+ scenario_key=$1
5
+
6
+ if [ ! "$scenario_key" ]; then
7
+ echo "Missing argument 'scenario_key'"
8
+ stoobly-agent scenario list
9
+ exit
10
+ fi
11
+
12
+ stoobly-agent scenario snapshot $extra_options "$scenario_key"
@@ -0,0 +1,11 @@
1
+ #!/bin/bash
2
+
3
+ extra_options=$EXEC_OPTIONS
4
+ workflow=$1
5
+
6
+ stoobly-agent scaffold workflow stop \
7
+ --app-dir-path "$(pwd)" \
8
+ --dry-run \
9
+ --log-level error \
10
+ $extra_options \
11
+ $workflow > .stoobly/tmp/run.sh
@@ -0,0 +1,12 @@
1
+ services:
2
+ stoobly_ui.service:
3
+ build:
4
+ dockerfile: ../../.Dockerfile.context
5
+ command: --ui-port 4200
6
+ extends:
7
+ file: ../.docker-compose.base.yml
8
+ service: stoobly_ui.base
9
+ ports:
10
+ - '4200:4200'
11
+ profiles:
12
+ - mock
@@ -0,0 +1,13 @@
1
+ services:
2
+ stoobly_ui.service:
3
+ build:
4
+ dockerfile: ../../.Dockerfile.context
5
+ command: --ui-port 4200
6
+ extends:
7
+ file: ../.docker-compose.base.yml
8
+ service: stoobly_ui.base
9
+ ports:
10
+ - '4200:4200'
11
+ profiles:
12
+ - record
13
+
@@ -0,0 +1,63 @@
1
+ import os
2
+
3
+ CORE_BUILD_SERVICE_NAME = 'build'
4
+ CORE_MOCK_UI_SERVICE_NAME = 'stoobly-ui'
5
+ CORE_GATEWAY_SERVICE_NAME = 'gateway'
6
+ CORE_ENTRYPOINT_SERVICE_NAME = 'entrypoint'
7
+ CORE_SERVICES = [
8
+ CORE_BUILD_SERVICE_NAME, CORE_ENTRYPOINT_SERVICE_NAME, CORE_MOCK_UI_SERVICE_NAME, CORE_GATEWAY_SERVICE_NAME
9
+ ]
10
+
11
+ CORE_MOCK_WORKFLOW = 'mock'
12
+ CORE_RECORD_WORKFLOW = 'record'
13
+
14
+ CUSTOM_BUILD = os.path.join('bin', 'build')
15
+ CUSTOM_CONFIGURE = os.path.join('bin', 'configure')
16
+ CUSTOM_INIT = os.path.join('bin', 'init')
17
+ CUSTOM_FIXTURES = 'fixtures.yml'
18
+ CUSTOM_LIFECYCLE_HOOKS = os.path.join('lifecycle_hooks.py')
19
+ MAINTAINED_CONFIGURE = os.path.join('bin', '.configure')
20
+ MAINTAINED_INIT = os.path.join('bin', '.init')
21
+ MAINTAINED_FIXTURES = os.path.join('fixtures', '.keep')
22
+
23
+ MOCK_WORKFLOW_MAINTAINED_FILES = [
24
+ MAINTAINED_CONFIGURE,
25
+ MAINTAINED_INIT,
26
+ MAINTAINED_FIXTURES
27
+ ]
28
+
29
+ MOCK_WORKFLOW_CUSTOM_FILES = [
30
+ CUSTOM_BUILD,
31
+ CUSTOM_CONFIGURE,
32
+ CUSTOM_FIXTURES,
33
+ CUSTOM_INIT,
34
+ CUSTOM_LIFECYCLE_HOOKS,
35
+ ]
36
+
37
+ RECORD_WORKFLOW_MAINTAINED_FILES = [
38
+ MAINTAINED_CONFIGURE,
39
+ MAINTAINED_INIT
40
+ ]
41
+
42
+ RECORD_WORKFLOW_CUSTOM_FILES = [
43
+ CUSTOM_BUILD,
44
+ CUSTOM_CONFIGURE,
45
+ CUSTOM_INIT,
46
+ CUSTOM_LIFECYCLE_HOOKS
47
+ ]
48
+
49
+ TEST_WORKFLOW_MAINTAINED_FILES = [
50
+ MAINTAINED_CONFIGURE,
51
+ MAINTAINED_INIT,
52
+ MAINTAINED_FIXTURES
53
+ ]
54
+
55
+ TEST_WORKFLOW_CUSTOM_FILES = [
56
+ CUSTOM_BUILD,
57
+ CUSTOM_CONFIGURE,
58
+ CUSTOM_FIXTURES,
59
+ CUSTOM_INIT,
60
+ CUSTOM_LIFECYCLE_HOOKS
61
+ ]
62
+
63
+ SERVICE_HOSTNAME_BUILD_ARG = 'SERVICE_HOSTNAME'
@@ -0,0 +1,46 @@
1
+ from ..constants import WORKFLOW_MOCK_TYPE, WORKFLOW_RECORD_TYPE, WORKFLOW_TEST_TYPE
2
+ from ..docker.workflow.builder import WorkflowBuilder
3
+ from .constants import (
4
+ CUSTOM_CONFIGURE, CUSTOM_INIT, MAINTAINED_CONFIGURE, MAINTAINED_FIXTURES, MOCK_WORKFLOW_CUSTOM_FILES, MOCK_WORKFLOW_MAINTAINED_FILES, RECORD_WORKFLOW_CUSTOM_FILES, RECORD_WORKFLOW_MAINTAINED_FILES, TEST_WORKFLOW_CUSTOM_FILES, TEST_WORKFLOW_MAINTAINED_FILES
5
+ )
6
+
7
+ def custom_files(workflow: str, workflow_builder: WorkflowBuilder):
8
+ files = []
9
+ if workflow == WORKFLOW_MOCK_TYPE:
10
+ files = MOCK_WORKFLOW_CUSTOM_FILES
11
+ elif workflow == WORKFLOW_RECORD_TYPE:
12
+ files = RECORD_WORKFLOW_CUSTOM_FILES
13
+ elif workflow == WORKFLOW_TEST_TYPE:
14
+ files = TEST_WORKFLOW_CUSTOM_FILES
15
+ else:
16
+ if workflow_builder.configure in workflow_builder.services:
17
+ files.append(CUSTOM_CONFIGURE)
18
+
19
+ if workflow_builder.init in workflow_builder.services:
20
+ files.append(CUSTOM_INIT)
21
+
22
+ # Fixtures are only relevant if the workflow is mock/test and if the service has a hostname
23
+ if not workflow_builder.config.hostname:
24
+ if MAINTAINED_FIXTURES in files:
25
+ files.remove(MAINTAINED_FIXTURES)
26
+
27
+ return files
28
+
29
+ def maintained_files(workflow: str, workflow_builder: WorkflowBuilder):
30
+ files = []
31
+
32
+ if workflow == WORKFLOW_MOCK_TYPE:
33
+ files = MOCK_WORKFLOW_MAINTAINED_FILES
34
+ elif workflow == WORKFLOW_RECORD_TYPE:
35
+ files = RECORD_WORKFLOW_MAINTAINED_FILES
36
+ elif workflow == WORKFLOW_TEST_TYPE:
37
+ files = TEST_WORKFLOW_MAINTAINED_FILES
38
+ else:
39
+ if workflow_builder.configure in workflow_builder.services:
40
+ files.append(MAINTAINED_CONFIGURE)
41
+
42
+ if not workflow_builder.config.hostname:
43
+ if MAINTAINED_FIXTURES in files:
44
+ files.remove(MAINTAINED_FIXTURES)
45
+
46
+ return files
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ cd $(dirname -- "$0") && ./configure
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ cd $(dirname -- "$0") && ./init
@@ -0,0 +1,18 @@
1
+ #!/bin/bash
2
+
3
+ scheme=$SERVICE_SCHEME
4
+ hostname=$SERVICE_HOSTNAME
5
+ port=$SERVICE_PORT
6
+
7
+ url="$scheme://$hostname"
8
+
9
+ if [ "$scheme" = 'http' -a "$port" != '80' ] || [ "$scheme" = 'https' -a "$port" != '443' ]; then
10
+ url="$url:$port"
11
+ fi
12
+
13
+ # Match
14
+ echo "Configuring match rules"
15
+ stoobly-agent config match set \
16
+ --method GET --method POST --method OPTIONS --method PUT --method DELETE \
17
+ --mode mock \
18
+ --pattern ".*?"
@@ -0,0 +1,4 @@
1
+ #! /bin/bash
2
+
3
+ # ARGV[1] = Path to 'dist' folder
4
+ # Contents within this folder will be shared
@@ -0,0 +1,5 @@
1
+ # The following example matches requests for GET /users/d+ (e.g. /users/1) with the contents of user-1.json
2
+ # Assumes that 'user-1.json' is created in the 'fixtures' folder
3
+ #GET:
4
+ # /users/d+:
5
+ # path: ./fixtures/user-1.json
@@ -0,0 +1,12 @@
1
+ # This file defines lifecyle hooks for when Stoobly intercepts a request
2
+ from stoobly_agent.app.proxy.mock.context import MockContext
3
+
4
+ def handle_before_request(context: MockContext):
5
+ intercept_settings = context.intercept_settings
6
+ flow = context.flow
7
+ request = flow.request
8
+
9
+ # For example, uncomment the following
10
+ #print(f"Agent running in {intercept_settings.mode} mode with {intercept_settings.policy} policy")
11
+ #print(dir(request))
12
+
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ cd $(dirname -- "$0") && ./configure
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ cd $(dirname -- "$0") && ./init
@@ -0,0 +1,29 @@
1
+ #!/bin/bash
2
+
3
+ scheme=$SERVICE_SCHEME
4
+ hostname=$SERVICE_HOSTNAME
5
+ port=$SERVICE_PORT
6
+
7
+ url="$scheme://$hostname"
8
+
9
+ if [ "$scheme" = 'http' -a "$port" != '80' ] || [ "$scheme" = 'https' -a "$port" != '443' ]; then
10
+ url="$url:$port"
11
+ fi
12
+
13
+ # Firewall
14
+ echo "Configuring firewall rules"
15
+ stoobly-agent config firewall set \
16
+ --action include \
17
+ --method GET --method POST --method OPTIONS --method PUT --method DELETE \
18
+ --mode record \
19
+ --pattern "$url/.*?"
20
+
21
+ # Rewrite
22
+ echo "Configuring rewrite rules"
23
+ stoobly-agent config rewrite set \
24
+ --method GET --method POST --method OPTIONS --method PUT --method DELETE \
25
+ --mode record \
26
+ --name cookie \
27
+ --pattern "$host/?.*?" \
28
+ --type Header \
29
+ --value '' \
@@ -0,0 +1,4 @@
1
+ #! /bin/bash
2
+
3
+ # ARGV[1] = Path to 'dist' folder
4
+ # Contents within this folder will be shared
@@ -0,0 +1,12 @@
1
+ # This file defines lifecyle hooks for when Stoobly intercepts a request
2
+ from stoobly_agent.app.proxy.record.context import RecordContext
3
+
4
+ def handle_before_request(context: RecordContext):
5
+ intercept_settings = context.intercept_settings
6
+ flow = context.flow
7
+ request = flow.request
8
+
9
+ # For example, uncomment the following
10
+ #print(f"Agent running in {intercept_settings.mode} mode with {intercept_settings.policy} policy")
11
+ #print(dir(request))
12
+
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ cd $(dirname -- "$0") && ./configure
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ cd $(dirname -- "$0") && ./init
@@ -0,0 +1,18 @@
1
+ #!/bin/bash
2
+
3
+ scheme=$SERVICE_SCHEME
4
+ hostname=$SERVICE_HOSTNAME
5
+ port=$SERVICE_PORT
6
+
7
+ url="$scheme://$hostname"
8
+
9
+ if [ "$scheme" = 'http' -a "$port" != '80' ] || [ "$scheme" = 'https' -a "$port" != '443' ]; then
10
+ url="$url:$port"
11
+ fi
12
+
13
+ # Match
14
+ echo "Configuring match rules"
15
+ stoobly-agent config match set \
16
+ --method GET --method POST --method OPTIONS --method PUT --method DELETE \
17
+ --mode mock \
18
+ --pattern ".*?"
@@ -0,0 +1,4 @@
1
+ #! /bin/bash
2
+
3
+ # ARGV[1] = Path to 'dist' folder
4
+ # Contents within this folder will be shared
@@ -0,0 +1,5 @@
1
+ # The following example matches requests for GET /users/d+ (e.g. /users/1) with the contents of user-1.json
2
+ # Assumes that 'user-1.json' is created in the 'fixtures' folder
3
+ #GET:
4
+ # /users/d+:
5
+ # path: ./fixtures/user-1.json