Skip to content

Commit

Permalink
CLI: remove "repo-url"
Browse files Browse the repository at this point in the history
  • Loading branch information
s373r committed Apr 30, 2024
1 parent 9d05649 commit 4eaff6d
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 29 deletions.
28 changes: 24 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Kamu Compute Node is a set of [Kubernetes](https://kubernetes.io/)-native applic

Nodes are the building pieces of the [Open Data Fabric](https://docs.kamu.dev/odf/) and the primary way of contributing resources to the network. Unlike blockchain nodes that maintain a single ledger, Kamu nodes can form loosely connected clusters based on vested interests of their operators in certain data pipelines.

If you are new to ODF - we recommend you to start with [Kamu CLI](https://github.com/kamu-data/kamu-cli/) instead for a gradual introduction. You should consider Kamu Node when you want to:
If you are new to ODF - we recommend you to start with [Kamu CLI](https://github.com/kamu-data/kamu-cli/) instead of a gradual introduction. You should consider Kamu Node when you want to:
- Build a horizontally-scalable data lake for your data
- Need a decentralized infrastructure for sharing data with your partners or globally without intermediaries
- Want to continuously operate ODF data pipelines or verify data
Expand All @@ -35,7 +35,17 @@ Prerequisites:
To run API server using local `kamu` workspace:

```bash
cargo run --bin kamu-api-server -- --repo-url workspace/.kamu/datasets run | bunyan
# 1. Create a configuration file
{
echo 'repo:'
echo ' repoUrl: workspace/.kamu/datasets'
} > config.yaml
# 2. Run
cargo run --bin kamu-api-server -- --config config.yaml run | bunyan

# Alternative: pass the repo url via env:
KAMU_API_SERVER_CONFIG_repo__repoUrl=workspace/.kamu/datasets \
kamu-api-server run | bunyan
```

To control log verbosity use the standard `RUST_LOG` env var:
Expand All @@ -58,12 +68,22 @@ cargo run --bin kamu-api-server -- gql query '{ apiVersion }' | jq
To use it:

```bash
cargo run --bin kamu-api-server -- --repo-url s3://example.com/kamu_repo run | bunyan
# 1. Create a configuration file
{
echo 'repo:'
echo ' repoUrl: s3://example.com/kamu_repo'
} > config.yaml
# 2. Run
cargo run --bin kamu-api-server -- --config config.yaml run | bunyan

# Alternative: pass the repo url via env:
KAMU_API_SERVER_CONFIG_repo__repoUrls3://example.com/kamu_repo \
kamu-api-server run | bunyan
```


### GitHub Auth
To use API server for GitHub's OAuth you will need to set following environment variables:
To use API server for GitHub's OAuth, you will need to set the following environment variables:
- `KAMU_AUTH_GITHUB_CLIENT_ID` - Client ID of your GitHub OAuth app
- `KAMU_AUTH_GITHUB_CLIENT_SECRET` - Client secret of your GitHub OAuth app

Expand Down
2 changes: 1 addition & 1 deletion images/api-server-with-data-mt/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ COPY config.yaml /opt/kamu/config.yaml

ENTRYPOINT ["/usr/bin/tini", "--"]

CMD [ "/opt/kamu/kamu-api-server", "--config=/opt/kamu/config.yaml", "--repo-url=file:///opt/kamu/workspace/.kamu/datasets", "--multi-tenant", "run", "--address=0.0.0.0", "--http-port=8080" ]
CMD [ "/opt/kamu/kamu-api-server", "--multi-tenant", "run", "--address=0.0.0.0", "--http-port=8080" ]

EXPOSE 8080/tcp
2 changes: 2 additions & 0 deletions images/api-server-with-data-mt/config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
repo:
repoUrl: file:///opt/kamu/workspace/.kamu/datasets
auth:
providers:
# Dummy accounts for owners of example datasets
Expand Down
2 changes: 1 addition & 1 deletion images/api-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ RUN wget -q https://github.com/kamu-data/kamu-platform/releases/download/v${API_

ENTRYPOINT ["/usr/bin/tini", "--"]

CMD ["/opt/kamu/kamu-api-server", "--repo-url=file:///opt/kamu/workspace/.kamu/datasets", "run", "--address=0.0.0.0", "--http-port=8080"]
CMD ["/opt/kamu/kamu-api-server", "run", "--address=0.0.0.0", "--http-port=8080"]

EXPOSE 8080/tcp
2 changes: 2 additions & 0 deletions images/api-server/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
repo:
repoUrl: file:///opt/kamu/workspace/.kamu/datasets
8 changes: 4 additions & 4 deletions src/app/api-server/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const DEFAULT_LOGGING_CONFIG: &str = "info,tower_http=trace";
pub async fn run(matches: clap::ArgMatches, config: ApiServerConfig) -> Result<(), InternalError> {
init_logging();

let repo_url = if let Some(repo_url) = matches.get_one::<Url>("repo-url").cloned() {
let repo_url = if let Some(repo_url) = config.repo.repo_url.as_ref().cloned() {
repo_url
} else {
let workspace_dir = find_workspace();
Expand Down Expand Up @@ -60,8 +60,8 @@ pub async fn run(matches: clap::ArgMatches, config: ApiServerConfig) -> Result<(
);

let dependencies_graph_repository = prepare_dependencies_graph_repository(
kamu::domain::CurrentAccountSubject::logged(
opendatafabric::AccountName::new_unchecked(kamu::domain::auth::DEFAULT_ACCOUNT_NAME),
CurrentAccountSubject::logged(
AccountName::new_unchecked(kamu::domain::auth::DEFAULT_ACCOUNT_NAME),
true,
),
&repo_url,
Expand Down Expand Up @@ -146,7 +146,7 @@ pub async fn run(matches: clap::ArgMatches, config: ApiServerConfig) -> Result<(
.unwrap()
.now();

tracing::info!(
info!(
http_endpoint = format!("http://{}", http_server.local_addr()),
flightsql_endpoint = format!("flightsql://{}", flightsql_server.local_addr()),
"Serving traffic"
Expand Down
20 changes: 1 addition & 19 deletions src/app/api-server/src/cli_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,8 @@ pub fn cli() -> Command {
.args([
Arg::new("config")
.long("config")
.value_parser(value_parser!(std::path::PathBuf))
.value_parser(value_parser!(PathBuf))
.help("Path to the config file"),
Arg::new("repo-url")
.long("repo-url")
.value_parser(value_parse_repo_url)
.help("URL of the remote dataset repository"),
// TODO: This is temporary and will be removed soon
// See: https://github.com/kamu-data/kamu-cli/issues/342
Arg::new("multi-tenant")
Expand Down Expand Up @@ -79,17 +75,3 @@ pub fn cli() -> Command {
]),
])
}

/// Allows URLs or local paths
fn value_parse_repo_url(s: &str) -> Result<url::Url, String> {
match url::Url::parse(s) {
Ok(url) => Ok(url),
Err(_) => match PathBuf::from(s).canonicalize() {
Ok(path) => Ok(url::Url::from_file_path(path).unwrap()),
Err(_) => Err(
"Invalid repo-url, should be a path or a URL in form: file:///home/me/workspace"
.to_string(),
),
},
}
}

0 comments on commit 4eaff6d

Please sign in to comment.