refactor(agentapi): rename module_dir_name to module_directory for consistency
This commit is contained in:
parent
36701a3538
commit
3d778472e7
@ -8,7 +8,6 @@ variables {
|
||||
cli_app_display_name = "Test CLI"
|
||||
cli_app_slug = "test-cli"
|
||||
start_script = "echo test"
|
||||
module_dir_name = ".test-module"
|
||||
}
|
||||
|
||||
run "default_values" {
|
||||
@ -51,11 +50,6 @@ run "default_values" {
|
||||
error_message = "shutdown script should contain ARG_PID_FILE_PATH"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = can(regex("ARG_MODULE_DIR_NAME", coder_script.agentapi_shutdown.script))
|
||||
error_message = "shutdown script should contain ARG_MODULE_DIR_NAME"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = can(regex("ARG_ENABLE_STATE_PERSISTENCE", coder_script.agentapi_shutdown.script))
|
||||
error_message = "shutdown script should contain ARG_ENABLE_STATE_PERSISTENCE"
|
||||
|
||||
@ -142,11 +142,6 @@ variable "agentapi_subdomain" {
|
||||
}
|
||||
}
|
||||
|
||||
variable "module_dir_name" {
|
||||
type = string
|
||||
description = "Name of the subdirectory in the home directory for module files."
|
||||
}
|
||||
|
||||
variable "enable_state_persistence" {
|
||||
type = bool
|
||||
description = "Enable AgentAPI conversation state persistence across restarts."
|
||||
@ -155,13 +150,13 @@ variable "enable_state_persistence" {
|
||||
|
||||
variable "state_file_path" {
|
||||
type = string
|
||||
description = "Path to the AgentAPI state file. Defaults to $HOME/<module_dir_name>/agentapi-state.json."
|
||||
description = "Path to the AgentAPI state file. Defaults to <module_directory>/agentapi-state.json."
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "pid_file_path" {
|
||||
type = string
|
||||
description = "Path to the AgentAPI PID file. Defaults to $HOME/<module_dir_name>/agentapi.pid."
|
||||
description = "Path to the AgentAPI PID file. Defaults to <module_directory>/agentapi.pid."
|
||||
default = ""
|
||||
}
|
||||
|
||||
@ -210,7 +205,7 @@ resource "coder_script" "agentapi" {
|
||||
chmod +x "${local.main_script_destination}"
|
||||
echo -n '${base64encode(local.lib_script)}' | base64 -d > "${local.lib_script_destination}"
|
||||
|
||||
ARG_MODULE_DIR_NAME='${var.module_dir_name}' \
|
||||
ARG_MODULE_DIRECTORY='${var.module_directory}' \
|
||||
ARG_WORKDIR="$(echo -n '${base64encode(local.workdir)}' | base64 -d)" \
|
||||
ARG_INSTALL_AGENTAPI='${var.install_agentapi}' \
|
||||
ARG_AGENTAPI_VERSION='${var.agentapi_version}' \
|
||||
@ -242,11 +237,11 @@ resource "coder_script" "agentapi_shutdown" {
|
||||
chmod +x "${local.shutdown_script_destination}"
|
||||
echo -n '${base64encode(local.lib_script)}' | base64 -d > "${local.lib_script_destination}"
|
||||
|
||||
ARG_MODULE_DIRECTORY='${var.module_directory}' \
|
||||
ARG_TASK_ID='${try(data.coder_task.me.id, "")}' \
|
||||
ARG_TASK_LOG_SNAPSHOT='${var.task_log_snapshot}' \
|
||||
ARG_AGENTAPI_PORT='${var.agentapi_port}' \
|
||||
ARG_ENABLE_STATE_PERSISTENCE='${var.enable_state_persistence}' \
|
||||
ARG_MODULE_DIR_NAME='${var.module_dir_name}' \
|
||||
ARG_PID_FILE_PATH='${var.pid_file_path}' \
|
||||
ARG_LIB_SCRIPT_PATH="${local.lib_script_destination}" \
|
||||
"${local.shutdown_script_destination}"
|
||||
|
||||
@ -12,8 +12,8 @@ readonly TASK_ID="${ARG_TASK_ID:-}"
|
||||
readonly TASK_LOG_SNAPSHOT="${ARG_TASK_LOG_SNAPSHOT:-true}"
|
||||
readonly AGENTAPI_PORT="${ARG_AGENTAPI_PORT:-3284}"
|
||||
readonly ENABLE_STATE_PERSISTENCE="${ARG_ENABLE_STATE_PERSISTENCE:-false}"
|
||||
readonly MODULE_DIR_NAME="${ARG_MODULE_DIR_NAME:-}"
|
||||
readonly PID_FILE_PATH="${ARG_PID_FILE_PATH:-${MODULE_DIR_NAME:+$HOME/$MODULE_DIR_NAME/agentapi.pid}}"
|
||||
readonly MODULE_DIRECTORY="${ARG_MODULE_DIRECTORY:-}"
|
||||
readonly PID_FILE_PATH="${ARG_PID_FILE_PATH:-${MODULE_DIRECTORY:+${MODULE_DIRECTORY}/agentapi.pid}}"
|
||||
readonly LIB_SCRIPT_PATH="${ARG_LIB_SCRIPT_PATH}"
|
||||
|
||||
# Source shared utilities (written by the coder_script wrapper).
|
||||
|
||||
@ -3,7 +3,7 @@ set -e
|
||||
set -x
|
||||
|
||||
set -o nounset
|
||||
MODULE_DIR_NAME="$ARG_MODULE_DIR_NAME"
|
||||
MODULE_DIRECTORY="$ARG_MODULE_DIRECTORY"
|
||||
WORKDIR="$ARG_WORKDIR"
|
||||
INSTALL_AGENTAPI="$ARG_INSTALL_AGENTAPI"
|
||||
AGENTAPI_VERSION="$ARG_AGENTAPI_VERSION"
|
||||
@ -25,8 +25,7 @@ command_exists() {
|
||||
command -v "$1" > /dev/null 2>&1
|
||||
}
|
||||
|
||||
module_path="$HOME/${MODULE_DIR_NAME}"
|
||||
mkdir -p "$module_path/scripts"
|
||||
mkdir -p "${MODULE_DIRECTORY}/scripts"
|
||||
|
||||
# Check for jq dependency if task log snapshot is enabled.
|
||||
if [[ $TASK_LOG_SNAPSHOT == true ]] && [[ -n $TASK_ID ]]; then
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user