Skip to content

Commit bf84780

Browse files
author
datacore-bolt-ci
committed
ci(stability): merge the develop branch
2 parents 28f23e6 + ad9ed3a commit bf84780

File tree

12 files changed

+75
-37
lines changed

12 files changed

+75
-37
lines changed

k8s/plugin/src/main.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,15 @@ impl CliArgs {
4040
let path = args.kube_config_path.clone();
4141
args.args.kubeconfig = path.clone();
4242
if let Operations::Dump(ref mut dump_args) = args.operations {
43-
dump_args.args.set_kube_config_path(path);
43+
dump_args
44+
.args
45+
.set_kube_config(path.clone(), args.context.clone());
4446
}
4547
args.args.context = args.context.clone();
4648
args.args.namespace = if let Some(namespace) = &args.namespace {
4749
namespace.to_string()
4850
} else if args.namespace_from_context {
49-
let client = kube_proxy::client_from_kubeconfig(
50-
args.kube_config_path.clone(),
51-
args.context.clone(),
52-
)
53-
.await?;
51+
let client = kube_proxy::client_from_kubeconfig(path, args.context.clone()).await?;
5452
client.default_namespace().to_string()
5553
} else {
5654
constants::DEFAULT_PLUGIN_NAMESPACE.to_string()

k8s/plugin/src/resources/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ impl ExecuteOperation for Operations {
182182
preflight_validations::preflight_check(
183183
&cli_args.namespace,
184184
cli_args.kubeconfig.clone(),
185+
cli_args.context.clone(),
185186
cli_args.timeout,
186187
resources,
187188
)

k8s/supportability/src/collect/common.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ pub struct DumpConfig {
1515
etcd_uri: Option<String>,
1616
/// Period states to collect logs from specified duration
1717
since: humantime::Duration,
18-
/// Path to kubeconfig file, which requires to interact with Kube-Apiserver
19-
kube_config_path: Option<std::path::PathBuf>,
18+
/// The kubeconfig options
19+
kubeconfig: crate::KubeConfigArgs,
2020
/// Specifies the timeout value to interact with other systems
2121
timeout: humantime::Duration,
2222
/// Specfies the output format, i.e tar, stdout.
@@ -37,7 +37,7 @@ impl DumpConfig {
3737
/// * `loki_uri` - Optional address of the Loki service endpoint.
3838
/// * `etcd_uri` - Optional address of the etcd service endpoint.
3939
/// * `since` - Duration from which to collect logs.
40-
/// * `kube_config_path` - Optional path to the kubeconfig file.
40+
/// * `kubeconfig` - kubeconfig file and options.
4141
/// * `timeout` - Timeout duration for interacting with external systems.
4242
/// * `output_format` - Output format (e.g., tar, stdout).
4343
/// * `tenant_id` - Tenant ID used while querying.
@@ -49,7 +49,7 @@ impl DumpConfig {
4949
loki_uri: Option<String>,
5050
etcd_uri: Option<String>,
5151
since: humantime::Duration,
52-
kube_config_path: Option<std::path::PathBuf>,
52+
kubeconfig: crate::KubeConfigArgs,
5353
timeout: humantime::Duration,
5454
output_format: OutputFormat,
5555
tenant_id: String,
@@ -61,7 +61,7 @@ impl DumpConfig {
6161
loki_uri,
6262
etcd_uri,
6363
since,
64-
kube_config_path,
64+
kubeconfig,
6565
timeout,
6666
output_format,
6767
tenant_id,
@@ -94,9 +94,19 @@ impl DumpConfig {
9494
&self.since
9595
}
9696

97+
/// Returns a reference to the [`crate::KubeConfigArgs`].
98+
pub fn kubeconfig(&self) -> &crate::KubeConfigArgs {
99+
&self.kubeconfig
100+
}
101+
97102
/// Returns the optional path to the kubeconfig file used to interact with the Kube-Apiserver.
98103
pub fn kube_config_path(&self) -> Option<&std::path::PathBuf> {
99-
self.kube_config_path.as_ref()
104+
self.kubeconfig.path.as_ref()
105+
}
106+
107+
/// Returns the optional context to the kubeconfig file used to interact with the Kube-Apiserver.
108+
pub fn kube_config_opts(&self) -> &kube::config::KubeConfigOptions {
109+
&self.kubeconfig.opts
100110
}
101111

102112
/// Returns the timeout duration used to interact with external systems.

k8s/supportability/src/collect/k8s_resources/client.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,16 @@ pub struct ClientSet {
8282
impl ClientSet {
8383
/// Create a new ClientSet, from the config file if provided, otherwise with default.
8484
pub(crate) async fn new(
85-
kube_config_path: Option<std::path::PathBuf>,
85+
kubeconfig: crate::KubeConfigArgs,
8686
namespace: String,
8787
) -> Result<Self, K8sResourceError> {
88-
let config = match kube_config_path {
88+
let config = match kubeconfig.path {
8989
Some(config_path) => {
9090
let kube_config = kube::config::Kubeconfig::read_from(&config_path)
9191
.map_err(|e| -> K8sResourceError { e.into() })?;
92-
kube::Config::from_custom_kubeconfig(kube_config, &Default::default()).await?
92+
kube::Config::from_custom_kubeconfig(kube_config, &kubeconfig.opts).await?
9393
}
94-
None => kube::Config::infer().await?,
94+
None => kube::Config::from_kubeconfig(&kubeconfig.opts).await?,
9595
};
9696
let client = Client::try_from(config)?;
9797
Ok(Self { client, namespace })

k8s/supportability/src/collect/k8s_resources/k8s_resource_dump.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ impl EntityName for StatefulSet {
9797
impl K8sResourceDumperClient {
9898
/// get a new k8s resource dumper client
9999
pub(crate) async fn new(
100-
kube_config_path: Option<std::path::PathBuf>,
100+
kubeconfig_args: crate::KubeConfigArgs,
101101
namespace: String,
102102
) -> Result<Self, K8sResourceDumperError> {
103-
let k8s_client = ClientSet::new(kube_config_path, namespace).await?;
103+
let k8s_client = ClientSet::new(kubeconfig_args, namespace).await?;
104104
Ok(Self { k8s_client })
105105
}
106106

k8s/supportability/src/collect/logs/loki.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl LokiClient {
140140
/// Instantiate new instance of Http Loki client
141141
pub(crate) async fn new(
142142
uri: Option<String>,
143-
kube_config_path: Option<std::path::PathBuf>,
143+
kubeconfig_args: crate::KubeConfigArgs,
144144
namespace: String,
145145
since: humantime::Duration,
146146
timeout: humantime::Duration,
@@ -149,7 +149,8 @@ impl LokiClient {
149149
let (uri, client) = match uri {
150150
None => {
151151
let (uri, svc) = match kube_proxy::ConfigBuilder::default_loki()
152-
.with_kube_config(kube_config_path)
152+
.with_kube_config(kubeconfig_args.path.clone())
153+
.with_context(kubeconfig_args.opts.context.clone())
153154
.with_target_mod(|t| t.with_namespace(namespace))
154155
.build()
155156
.await

k8s/supportability/src/collect/logs/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,18 @@ impl LogCollection {
8484
/// param 'timeout' --> Specifies the timeout while interacting with Loki Service
8585
/// param 'tenant_id' --> Specifies the tenant_id while interacting with Loki Service
8686
pub(crate) async fn new_logger(
87-
kube_config_path: Option<std::path::PathBuf>,
87+
kubeconfig_args: crate::KubeConfigArgs,
8888
namespace: String,
8989
loki_uri: Option<String>,
9090
since: humantime::Duration,
9191
timeout: humantime::Duration,
9292
tenant_id: String,
9393
) -> Result<Box<dyn Logger>, LogError> {
94-
let client_set = ClientSet::new(kube_config_path.clone(), namespace.clone()).await?;
94+
let client_set = ClientSet::new(kubeconfig_args.clone(), namespace.clone()).await?;
9595
Ok(Box::new(Self {
9696
loki_client: loki::LokiClient::new(
9797
loki_uri,
98-
kube_config_path,
98+
kubeconfig_args,
9999
namespace,
100100
since,
101101
timeout,

k8s/supportability/src/collect/persistent_store/etcd.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ impl EtcdStore {
1616
/// The provided namespace will be used to search for etcd service, if the
1717
/// etcd point is not provided
1818
pub(crate) async fn new(
19-
kube_config_path: Option<std::path::PathBuf>,
19+
kubeconfig: crate::KubeConfigArgs,
2020
etcd_endpoint: Option<String>,
2121
namespace: String,
2222
) -> Result<Self, EtcdError> {
23-
let client_set = ClientSet::new(kube_config_path.clone(), namespace.clone()).await?;
23+
let client_set = ClientSet::new(kubeconfig.clone(), namespace.clone()).await?;
2424
let platform_info =
2525
platform::k8s::K8s::from_custom(client_set.kube_client(), client_set.namespace())
2626
.await
@@ -33,7 +33,8 @@ impl EtcdStore {
3333
endpoint
3434
} else {
3535
let uri = kube_proxy::ConfigBuilder::default_etcd()
36-
.with_kube_config(kube_config_path)
36+
.with_kube_config(kubeconfig.path)
37+
.with_context(kubeconfig.opts.context)
3738
.with_target_mod(|t| t.with_namespace(namespace))
3839
.build()
3940
.await

k8s/supportability/src/collect/resource_dump.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl ResourceDumper {
7171
};
7272

7373
let etcd_dumper = match EtcdStore::new(
74-
config.kube_config_path().cloned(),
74+
config.kubeconfig().clone(),
7575
config.etcd_uri().cloned(),
7676
config.namespace().to_string(),
7777
)

k8s/supportability/src/collect/system_dump.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl SystemDumper {
7171
};
7272

7373
let logger = match LogCollection::new_logger(
74-
config.kube_config_path().cloned(),
74+
config.kubeconfig().clone(),
7575
config.namespace().to_string(),
7676
config.loki_uri().cloned(),
7777
*config.since(),
@@ -90,7 +90,7 @@ impl SystemDumper {
9090
};
9191

9292
let k8s_resource_dumper = match K8sResourceDumperClient::new(
93-
config.kube_config_path().cloned(),
93+
config.kubeconfig().clone(),
9494
config.namespace().to_string(),
9595
)
9696
.await
@@ -105,7 +105,7 @@ impl SystemDumper {
105105
};
106106

107107
let etcd_dumper = match EtcdStore::new(
108-
config.kube_config_path().cloned(),
108+
config.kubeconfig().clone(),
109109
config.etcd_uri().cloned(),
110110
config.namespace().to_string(),
111111
)
@@ -120,6 +120,7 @@ impl SystemDumper {
120120

121121
let rest_client = match kube_proxy::ConfigBuilder::default_api_rest()
122122
.with_kube_config(config.kube_config_path().cloned())
123+
.with_context(config.kube_config_opts().context.clone())
123124
.with_timeout(Some((*config.timeout()).into()))
124125
.with_target_mod(|t| t.with_namespace(config.namespace()))
125126
.build()

0 commit comments

Comments
 (0)