Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): implement --prefix argument #913

Merged
merged 3 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/meta-cli/src/cli/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ async fn load_tg_at(
let init = TaskManagerInit::<SerializeAction>::new(
config.clone(),
SerializeActionGenerator::new(
None,
config_dir.clone(),
dir.into(),
config
Expand Down
1 change: 1 addition & 0 deletions src/meta-cli/src/cli/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ impl Action for List {
let console = ConsoleActor::new(Arc::clone(&config)).start();

let action_generator = ListActionGenerator::new(
node.prefix.clone(),
config.dir().unwrap_or_log().into(),
dir.clone().into(),
config
Expand Down
1 change: 1 addition & 0 deletions src/meta-cli/src/cli/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ impl Action for Serialize {
let console = ConsoleActor::new(Arc::clone(&config)).start();

let action_generator = SerializeActionGenerator::new(
self.prefix.clone(),
config.dir().unwrap_or_log().into(),
dir.into(),
config
Expand Down
1 change: 1 addition & 0 deletions src/meta-cli/src/deploy/actors/task/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use tokio::process::Command;
#[derive(Debug, Clone)]
pub struct SharedActionConfig {
pub command: &'static str,
pub prefix: Option<String>,
pub config_dir: Arc<Path>,
pub working_dir: Arc<Path>,
pub migrations_dir: Arc<Path>,
Expand Down
7 changes: 7 additions & 0 deletions src/meta-cli/src/deploy/actors/task/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ impl CommandContext {
path,
} = self;

let optional_envs = [("MCLI_PREFIX", shared_config.prefix.clone())];

luckasRanarison marked this conversation as resolved.
Show resolved Hide resolved
command
.current_dir(shared_config.working_dir.to_str().unwrap())
.env("MCLI_VERSION", crate::build::PKG_VERSION)
Expand All @@ -122,6 +124,11 @@ impl CommandContext {
"MCLI_ARTIFACT_RESOLUTION",
shared_config.artifact_resolution.to_string(),
)
.envs(
optional_envs
.into_iter()
.filter_map(|(k, v)| v.map(|v| (k, v))),
)
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::piped());
Expand Down
3 changes: 2 additions & 1 deletion src/meta-cli/src/deploy/actors/task/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ impl DeployActionGenerator {
destructive_migrations: bool, // TODO enum { Fail, Reset, Ask }
) -> Self {
Self {
node,
secrets,
shared_config: SharedActionConfig {
command: "deploy",
prefix: node.prefix.clone(),
config_dir,
working_dir,
migrations_dir,
Expand All @@ -76,6 +76,7 @@ impl DeployActionGenerator {
artifact_resolution: true,
}
.into(),
node,
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/meta-cli/src/deploy/actors/task/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub struct ListActionGenerator {

impl ListActionGenerator {
pub fn new(
prefix: Option<String>,
config_dir: Arc<Path>,
working_dir: Arc<Path>,
migrations_dir: Arc<Path>,
Expand All @@ -39,6 +40,7 @@ impl ListActionGenerator {
Self {
shared_config: SharedActionConfig {
command: "list",
prefix,
config_dir,
working_dir,
migrations_dir,
Expand Down
2 changes: 2 additions & 0 deletions src/meta-cli/src/deploy/actors/task/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub struct SerializeActionGenerator {

impl SerializeActionGenerator {
pub fn new(
prefix: Option<String>,
config_dir: Arc<Path>,
working_dir: Arc<Path>,
migrations_dir: Arc<Path>,
Expand All @@ -40,6 +41,7 @@ impl SerializeActionGenerator {
Self {
shared_config: SharedActionConfig {
command: "serialize",
prefix,
config_dir,
working_dir,
migrations_dir,
Expand Down
2 changes: 1 addition & 1 deletion src/typegraph/deno/src/envs/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function loadCliEnv(): CliEnv | null {
for (const key of optionalCliEnvs) {
const name = `MCLI_${key.toLocaleUpperCase()}`;
const envValue = env[name];
if (envValue != null) {
if (envValue) {
luckasRanarison marked this conversation as resolved.
Show resolved Hide resolved
record[key] = envValue;
}
}
Expand Down
1 change: 0 additions & 1 deletion src/typegraph/python/typegraph/envs/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def load(cls) -> Optional["CliEnv"]:
for key in _optional_cli_envs:
env_name = "MCLI_" + key.upper()
d[key] = environ.get(env_name)

try:
d["command"] = Command(d["command"])
except ValueError as e:
Expand Down
Loading