-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
590 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: nginx | ||
namespace: foo | ||
spec: | ||
selector: | ||
app.kubernetes.io/name: nginx | ||
ports: | ||
- protocol: TCP | ||
port: 80 | ||
targetPort: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use anyhow::anyhow; | ||
use clap::{Args, Subcommand}; | ||
use crate::skate::ConfigFileArgs; | ||
|
||
#[derive(Debug, Args)] | ||
pub struct ConfigArgs{ | ||
#[command(flatten)] | ||
config: ConfigFileArgs, | ||
#[command(subcommand)] | ||
command: ConfigCommands, | ||
} | ||
|
||
#[derive(Debug, Args)] | ||
pub struct UseContextArgs{ | ||
pub context: String | ||
|
||
} | ||
|
||
#[derive(Debug, Subcommand)] | ||
pub enum ConfigCommands { | ||
UseContext(UseContextArgs), | ||
} | ||
|
||
pub fn config(args: ConfigArgs) -> Result<(), Box<dyn std::error::Error>> { | ||
match args.command { | ||
ConfigCommands::UseContext(use_context_args) => { | ||
let mut config = crate::config::Config::load(Some(args.config.skateconfig.clone())).expect("failed to load skate config"); | ||
config.clusters.iter().any(|c| c.name == use_context_args.context) | ||
.then(|| ()) | ||
.ok_or(anyhow!("no context exists with the name {}", use_context_args.context))?; | ||
config.current_context = Some(use_context_args.context.clone()); | ||
config.persist(Some(args.config.skateconfig))?; | ||
println!("Switched to context \"{}\"", use_context_args.context.replace("\"", "")); | ||
} | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.