Skip to content

Commit

Permalink
Fixes issue #1 (#3)
Browse files Browse the repository at this point in the history
* feat(cd): only run on release

Signed-off-by: widnyana <[email protected]>

* fixes #1 - use proxy from env var

Signed-off-by: widnyana <[email protected]>

* feat: bump version

Signed-off-by: widnyana <[email protected]>

---------

Signed-off-by: widnyana <[email protected]>
  • Loading branch information
widnyana authored Oct 9, 2024
1 parent 348e5d3 commit ccf90da
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
build_and_release:
needs: cache
uses: ./.github/workflows/build-release.yaml
# if: github.event_name == 'release'
if: github.event_name == 'release'
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "kubectl-ports"
edition = "2021"
version = "1.0.0"
version = "1.1.0"
authors = ["widnyana <[email protected]>"]
description = "A kubectl plugin to provide a list of exposed ports on kubernetes Pod resources"
homepage = "https://github.com/widnyana/kubectl-ports-rs"
Expand All @@ -15,6 +15,7 @@ exclude = [".github/*", ".vscode/*", "target", "bin"]

[dependencies]
anyhow = "1.0.89"
http = "1.1.0"
prettytable-rs = "0.10.0"
thiserror = "1.0.64"
tracing = "0.1.40"
Expand All @@ -32,7 +33,7 @@ optional = false

[dependencies.kube]
version = "0.95.0"
features = ["client", "oauth", "gzip", "openssl-tls", "runtime", "derive"]
features = ["client", "oauth", "gzip", "openssl-tls", "runtime", "derive", "http-proxy"]
optional = false
default-features = true

Expand Down
18 changes: 16 additions & 2 deletions src/k8s/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
use core::convert::TryFrom;
use std::{
env,
time::Duration,
};

use anyhow::Result;
use http::Uri;
use kube::Client;
use tracing::{
info,
Expand Down Expand Up @@ -46,7 +51,8 @@ async fn refresh_kube_config(context: &Option<String>) -> Result<(), AppError> {
#[instrument]
pub async fn new_client(cli_opts: &CliOpts) -> Result<Client, AppError> {
refresh_kube_config(&cli_opts.context).await?;
let client_config = match cli_opts.context {

let mut client_config = match cli_opts.context {
Some(ref context) => kube::Config::from_kubeconfig(&kube::config::KubeConfigOptions {
context: Some(context.clone()),
..Default::default()
Expand All @@ -62,7 +68,15 @@ pub async fn new_client(cli_opts: &CliOpts) -> Result<Client, AppError> {
})?,
};

info!(cluster_url = client_config.cluster_url.to_string().as_str());
if let Ok(https_proxy) = env::var("HTTPS_PROXY") {
info!("Using HTTPS_PROXY: {}", https_proxy);
client_config.proxy_url = https_proxy.parse::<Uri>().ok();
}

// lower down the timeout
client_config.connect_timeout = Some(Duration::from_secs(30));
client_config.read_timeout = Some(Duration::from_secs(15));

Client::try_from(client_config).map_err(|source| AppError::KubeError {
context: "create the kube client".to_string(),
source,
Expand Down
1 change: 0 additions & 1 deletion src/schemas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ impl Resource {
}

///
#[derive(Debug, Clone)]
pub struct ServiceResource {
pub name: String,
Expand Down

0 comments on commit ccf90da

Please sign in to comment.