Skip to content
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
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,3 @@ examples/databricks/serverless dev \
-e DATABRICKS_ACCOUNT_ID=${DATABRICKS_ACCOUNT_ID} \
-e DATABRICKS_AWS_ACCOUNT_ID=${DATABRICKS_AWS_ACCOUNT_ID} \
--dry-run

C:\LocalGitRepos\stackql\stackql-deploy-rs\examples\databricks\serverless\stackql_manifest.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*+ exists */
SELECT count(*) as count --should use list
SELECT count(*) as count
FROM databricks_account.provisioning.credentials
WHERE account_id = '{{ account_id }}'
AND credentials_name = '{{ credentials_name }}'
Expand All @@ -18,16 +18,17 @@ SELECT
;

/*+ statecheck, retries=5, retry_delay=10 */
SELECT count(*) as count --should use list
SELECT count(*) as count
FROM databricks_account.provisioning.credentials
WHERE
credentials_name = '{{ credentials_name }}' AND --where are the ''
aws_credentials = '{{ aws_credentials }}' AND --where are the ''
credentials_name = '{{ credentials_name }}' AND
aws_credentials = '{{ aws_credentials.sts_role.role_arn }}' AND
account_id = '{{ account_id }}';


-- {"sts_role":{"external_id":"ebfcc5a9-9d49-4c93-b651-b3ee6cf1c9ce","role_arn":"arn:aws:iam::824532806693:role/stackql-serverless-dev-role"}}


/*+ exports */
SELECT -- account_id, -- dont get account_id back from exports, but do get credentials_id back, which is needed for updates and deletes
credentials_name,
Expand Down
28 changes: 1 addition & 27 deletions src/commands/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use log::{debug, error, info};
use pgwire_lite::PgwireLite;

use crate::core::config::{
get_full_context, get_resource_type, render_globals, render_string_value,
get_full_context, render_globals, render_string_value,
};
use crate::core::env::load_env_vars;
use crate::core::templating::{self, ParsedQuery};
Expand All @@ -24,7 +24,6 @@ use crate::core::utils::{
};
use crate::resource::manifest::{Manifest, Resource};
use crate::template::engine::TemplateEngine;
// display imports available for future use

/// Core state for all command operations, equivalent to Python's StackQLBase.
pub struct CommandRunner {
Expand Down Expand Up @@ -85,12 +84,6 @@ impl CommandRunner {
)
}

/// Get resource type string, validated.
#[allow(dead_code)]
pub fn get_resource_type(&self, resource: &Resource) -> String {
get_resource_type(resource).to_string()
}

/// Evaluate a resource's `if` condition. Returns true if the resource should be processed.
pub fn evaluate_condition(
&self,
Expand Down Expand Up @@ -812,22 +805,3 @@ fn evaluate_simple_condition(condition: &str) -> Option<bool> {
None
}

/// Helper to get export names as strings from YAML values.
#[allow(dead_code)]
pub fn get_export_names(exports: &[serde_yaml::Value]) -> Vec<String> {
exports
.iter()
.filter_map(|e| {
if let Some(s) = e.as_str() {
Some(s.to_string())
} else if let Some(map) = e.as_mapping() {
// For dict exports, get the value (the lookup key)
map.values()
.next()
.and_then(|v| v.as_str().map(|s| s.to_string()))
} else {
None
}
})
.collect()
}
35 changes: 1 addition & 34 deletions src/commands/common_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! This module defines common command-line arguments that can be reused across
//! different commands in the application.

use clap::{value_parser, Arg, ArgAction, ArgMatches};
use clap::{value_parser, Arg, ArgAction};
use std::str::FromStr;

/// Possible actions to take on failure
Expand Down Expand Up @@ -99,36 +99,3 @@ pub fn on_failure() -> Arg {
.default_value("error")
}

/// Structure to hold common command arguments
#[derive(Debug)]
#[allow(dead_code)]
pub struct CommonCommandArgs<'a> {
/// Directory containing stack configuration
pub stack_dir: &'a str,
/// Environment to operate on
pub stack_env: &'a str,
/// Logging level
pub log_level: &'a str,
/// Environment file path
pub env_file: &'a str,
/// Whether to run in dry-run mode
pub dry_run: bool,
/// Whether to show queries
pub show_queries: bool,
/// What to do on failure
pub on_failure: &'a FailureAction,
}

/// Create CommonCommandArgs from ArgMatches
#[allow(dead_code)]
pub fn args_from_matches(matches: &ArgMatches) -> CommonCommandArgs<'_> {
CommonCommandArgs {
stack_dir: matches.get_one::<String>("stack_dir").unwrap(),
stack_env: matches.get_one::<String>("stack_env").unwrap(),
log_level: matches.get_one::<String>("log-level").unwrap(),
env_file: matches.get_one::<String>("env-file").unwrap(),
dry_run: matches.get_flag("dry-run"),
show_queries: matches.get_flag("show-queries"),
on_failure: matches.get_one::<FailureAction>("on-failure").unwrap(),
}
}
8 changes: 0 additions & 8 deletions src/commands/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ enum TemplateSource {
}

impl TemplateSource {
#[allow(dead_code)]
fn provider_or_path(&self) -> &str {
match self {
TemplateSource::Embedded(provider) => provider,
TemplateSource::Custom(path) => path,
}
}

fn get_sample_res_name(&self) -> &str {
match self {
TemplateSource::Embedded(provider) => match provider.as_str() {
Expand Down
6 changes: 3 additions & 3 deletions src/core/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,15 +486,15 @@ pub fn export_vars(

// --- resource-scoped key (immutable: only written if not already set) ---
let scoped_key = format!("{}.{}", resource_name, key);
if !global_context.contains_key(&scoped_key) {
global_context.entry(scoped_key.clone()).or_insert_with(|| {
info!(
"set {} [{}] to [{}] in exports",
if is_protected { "protected variable" } else { "variable" },
scoped_key,
display_value,
);
global_context.insert(scoped_key, value.clone());
}
value.clone()
});

// --- global (unscoped) key (can be overridden by later resources) ---
info!(
Expand Down
18 changes: 0 additions & 18 deletions src/globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,3 @@ pub fn server_port() -> u16 {
.unwrap_or(DEFAULT_SERVER_PORT)
}

/// Retrieves the configured global connection string.
///
/// The connection string is generated during initialization via `init_globals`.
/// If not initialized, it returns an empty string.
///
/// # Returns
/// - `&'static str` - The configured connection string or an empty string if not initialized.
///
/// # Example
/// ```rust
/// use crate::globals::{init_globals, connection_string};
/// init_globals("localhost".to_string(), 5444);
/// println!("Connection String: {}", connection_string());
/// ```
#[allow(dead_code)]
pub fn connection_string() -> &'static str {
STACKQL_CONNECTION_STRING.get().map_or("", |s| s.as_str())
}
Loading
Loading