Skip to content

Commit

Permalink
fix: service_id renamed to service_name & exec recipe over struct (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
h4ck3rk3y committed Jan 26, 2023
1 parent aa3b41e commit 1a667a1
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 27 deletions.
8 changes: 4 additions & 4 deletions src/service_url.star
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
PUBLIC_IP_ADDRESS = "127.0.0.1"

def get_private_and_public_url_for_port_id(
service_id,
service_name,
service_result,
service_config,
port_id,
protocol,
path):

if port_id not in service_result.ports:
fail("Expected service with ID {0} to have private port with port id {1}", service_id, port_id)
fail("Expected service with name {0} to have private port with port id {1}", service_name, port_id)

private_port = service_result.ports[port_id]

private_url = new_service_url(protocol, service_id, private_port.number, path)
private_url = new_service_url(protocol, service_name, private_port.number, path)

public_url = None

Expand All @@ -25,7 +25,7 @@ def get_private_and_public_url_for_port_id(
public_ports = service_config.public_ports

if port_id not in public_ports:
fail("Expected service with ID {0} to have public port with port id {1}", service_id, port_id)
fail("Expected service with name {0} to have public port with port id {1}", service_name, port_id)

public_port = public_ports[port_id]

Expand Down
6 changes: 3 additions & 3 deletions src/services/contract_helper.star
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ constants = import_module("github.com/kurtosis-tech/near-package/src/constants.s
service_url = import_module("github.com/kurtosis-tech/near-package/src/service_url.star")


SERVICE_ID = "contract-helper-service"
SERVICE_NAME = "contract-helper-service"
PORT_ID = "rest"
PRIVATE_PORT_NUM = 3000
PUBLIC_PORT_NUM = 8330
Expand Down Expand Up @@ -117,13 +117,13 @@ def add_contract_helper_service(
env_vars = env_vars
)

add_service_result = plan.add_service(SERVICE_ID, config)
add_service_result = plan.add_service(SERVICE_NAME, config)

# TODO add productized wait for port vailability
# also missing on old repo

private_url, public_url = service_url.get_private_and_public_url_for_port_id(
SERVICE_ID,
SERVICE_NAME,
add_service_result,
config,
PORT_ID,
Expand Down
6 changes: 3 additions & 3 deletions src/services/contract_helper_dynamodb.star
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
shared_utils = import_module("github.com/kurtosis-tech/near-package/src/shared_utils.star")
service_url = import_module("github.com/kurtosis-tech/near-package/src/service_url.star")

SERVICE_ID = "contract-helper-dynamo-db"
SERVICE_NAME = "contract-helper-dynamo-db"
IMAGE = "amazon/dynamodb-local:1.20.0"

PORT_ID = "default"
Expand All @@ -20,10 +20,10 @@ def add_contract_helper_dynamo_db(plan):
}
)

add_service_result = plan.add_service(SERVICE_ID, config)
add_service_result = plan.add_service(SERVICE_NAME, config)

private_url, _ = service_url.get_private_and_public_url_for_port_id(
SERVICE_ID,
SERVICE_NAME,
add_service_result,
config,
PORT_ID,
Expand Down
10 changes: 5 additions & 5 deletions src/services/contract_helper_postgresql.star
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ constants = import_module("github.com/kurtosis-tech/near-package/src/constants.s
service_url = import_module("github.com/kurtosis-tech/near-package/src/service_url.star")


SERVICE_ID = "contract-helper-db"
SERVICE_NAME = "contract-helper-db"
PORT_ID = "postgres"
PORT_PROTOCOL = "postgres"
IMAGE = "postgres:13.4-alpine3.14"
Expand Down Expand Up @@ -51,9 +51,9 @@ def add_contract_helper_db(plan):
ports = ports
)

add_service_result = plan.add_service(SERVICE_ID, config)
add_service_result = plan.add_service(SERVICE_NAME, config)

plan.wait(struct(service_id=SERVICE_ID, command=AVAILABILITY_CMD), "code", "==", constants.EXEC_COMMAND_SUCCESS_EXIT_CODE)
plan.wait(ExecRecipe(service_name=SERVICE_NAME, command=AVAILABILITY_CMD), "code", "==", constants.EXEC_COMMAND_SUCCESS_EXIT_CODE)

for database_to_create in DBS_TO_INITIALIZE:
create_db_command = [
Expand All @@ -63,11 +63,11 @@ def add_contract_helper_db(plan):
"-c",
"create database " + database_to_create + " with owner=" + POSTGRES_USER
]
create_db_command_result = plan.exec(struct(service_id=SERVICE_ID, command=create_db_command))
create_db_command_result = plan.exec(ExecRecipe(service_name=SERVICE_NAME, command=create_db_command))
plan.assert(create_db_command_result["code"], "==", constants.EXEC_COMMAND_SUCCESS_EXIT_CODE)

private_url, _ = service_url.get_private_and_public_url_for_port_id(
SERVICE_ID,
SERVICE_NAME,
add_service_result,
config,
PORT_ID,
Expand Down
6 changes: 3 additions & 3 deletions src/services/explorer_backend.star
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ constants = import_module("github.com/kurtosis-tech/near-package/src/constants.s
service_url = import_module("github.com/kurtosis-tech/near-package/src/service_url.star")

# Explorer Backend
SERVICE_ID = "explorer-backend"
SERVICE_NAME = "explorer-backend"
IMAGE = "kurtosistech/near-explorer_backend:836d8d7"
PORT_ID = "http"
PORT_APP_PROTOCOL = "http"
Expand Down Expand Up @@ -105,10 +105,10 @@ def add_explorer_backend_service(
public_ports = public_ports,
)

add_service_result = plan.add_service(SERVICE_ID, config)
add_service_result = plan.add_service(SERVICE_NAME, config)

private_url, public_url = service_url.get_private_and_public_url_for_port_id(
SERVICE_ID,
SERVICE_NAME,
add_service_result,
config,
PORT_ID,
Expand Down
6 changes: 3 additions & 3 deletions src/services/explorer_frontend.star
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ service_url = import_module("github.com/kurtosis-tech/near-package/src/service_u
wallet = import_module("github.com/kurtosis-tech/near-package/src/services/wallet.star")


SERVICE_ID = "explorer-frontend"
SERVICE_NAME = "explorer-frontend"
PORT_ID = "http"
PORT_PROTOCOL = "http"
IMAGE= "kurtosistech/near-explorer_frontend:836d8d7"
Expand Down Expand Up @@ -98,13 +98,13 @@ def add_explorer_frontend_service(
)


add_service_result = plan.add_service(SERVICE_ID, config)
add_service_result = plan.add_service(SERVICE_NAME, config)

# TODO add a productized way to wait for port availability
# Note this is broken on the old module as well

private_url, public_url = service_url.get_private_and_public_url_for_port_id(
SERVICE_ID,
SERVICE_NAME,
add_service_result,
config,
PORT_ID,
Expand Down
6 changes: 3 additions & 3 deletions src/services/indexer.star
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ shared_utils = import_module("github.com/kurtosis-tech/near-package/src/shared_u
constants = import_module("github.com/kurtosis-tech/near-package/src/constants.star")
service_url = import_module("github.com/kurtosis-tech/near-package/src/service_url.star")

SERVICE_ID = "indexer-node"
SERVICE_NAME = "indexer-node"
IMAGE = "kurtosistech/near-indexer-for-explorer:2d66461"
RPC_PRIVATE_PORT_NUM = 3030
RPC_PUBLIC_PORT_NUM = 8332
Expand Down Expand Up @@ -71,13 +71,13 @@ def add_indexer(plan, db_private_url, db_username, db_password, db_name):
files = files
)

add_service_result = plan.add_service(SERVICE_ID, config)
add_service_result = plan.add_service(SERVICE_NAME, config)

validator_key_json = read_file(LOCALNET_CONFIG_DIRPATH_ON_PACKAGE + "/validator_key.json")
validator_key = json.decode(validator_key_json)

private_rpc_url, public_rpc_url = service_url.get_private_and_public_url_for_port_id(
SERVICE_ID,
SERVICE_NAME,
add_service_result,
config,
RPC_PORT_ID,
Expand Down
6 changes: 3 additions & 3 deletions src/services/wallet.star
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ constants = import_module("github.com/kurtosis-tech/near-package/src/constants.s
service_url = import_module("github.com/kurtosis-tech/near-package/src/service_url.star")


SERVICE_ID = "wallet"
SERVICE_NAME = "wallet"
IMAGE = "kurtosistech/near-wallet:169ccfb61"
PORT_ID = "http"
PORT_PROTOCOL = "http"
Expand Down Expand Up @@ -81,13 +81,13 @@ def add_wallet(
cmd = [single_command_to_run],
)

add_service_result = plan.add_service(SERVICE_ID, config)
add_service_result = plan.add_service(SERVICE_NAME, config)

# TODO add a productized wait for availability for PORT_ID
# Note, doesn't work in old repo either

_, public_url = service_url.get_private_and_public_url_for_port_id(
SERVICE_ID,
SERVICE_NAME,
add_service_result,
config,
PORT_ID,
Expand Down

0 comments on commit 1a667a1

Please sign in to comment.