autocomplete
autocomplete copied to clipboard
Better Teleport CLI support
This PR has two areas of focus, both meant to significantly improve usability for the "tsh" and "tctl" Teleport CLI tools. These two areas of focus are:
- Improving username@hostname autocomplete for
tsh ssh - Full support for the
tctlbinary, which was non existent
This is my first autocompletion spec PR, so please do be gentle. I've been using these completions for a little bit myself and found them incredibly useful. Certainly the updates I did for tsh ssh has been an incredible productivity enhancer.
A small question, and maybe a worry: The custom generator and trigger I use for tsh ssh might decrease performance based on the past iteration, but I do feel that improved UX is worth it. On my M1/M2 macs I do not notice any performance issues.
And P.S. I don't think your Git pre-commit hooks are properly working, as they cause a big error to popup. Let me know if you want to investigate this, but I just used "--no-verify" and ran the checks manually, not a big deal.
CLA Assistant Lite bot:
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.
I have read the CLA Document and I hereby sign the CLA
1 out of 2 committers have signed the CLA.
:white_check_mark: (kanersps)[https://github.com/kanersps]
:x: @superbryntendo
You can retrigger this bot by commenting recheck in this Pull Request
Overview
src/tsh.ts:
Info:
src/tctl.ts:
Info:
Script:
tctl bots ls --format json
postProcess(function):
function (out) {
const bots = JSON.parse(out);
return bots.map((bot: Bot) => {
return {
name: bot.metadata.name.slice(4),
description: bot.metadata.description,
};
});
}
Script:
tctl acl ls --format json
postProcess(function):
function (out) {
const acl = JSON.parse(out);
return acl.map((acl: ACL) => {
return {
name: acl.metadata.name,
description: acl.metadata.description,
};
});
}
Script:
tctl alerts list --format json
postProcess(function):
function (out) {
const alerts = JSON.parse(out);
return alerts.map((alert: Alert) => {
return {
name: alert.metadata.name,
description: alert.metadata.description,
};
});
}
Script:
tctl get namespaces --format json
postProcess(function):
function (out) {
const namespaces = JSON.parse(out);
return namespaces.map((namespace: Namespace) => {
return {
name: namespace.metadata.name,
description: namespace.metadata.description,
};
});
}
Script:
tctl get tokens --format json
postProcess(function):
function (out) {
const tokens = JSON.parse(out);
return tokens.map((token: Token) => {
return {
name: token.metadata.name,
description: token.metadata.description,
};
});
}
Script:
tctl get tokens --format json
postProcess(function):
function (out) {
const clusters = JSON.parse(out);
return clusters.map((cluster: Cluster) => {
return {
name: cluster.kube_cluster_name,
description: "Kubernetes cluster connected to Teleport",
};
});
}
Script:
tctl get tokens --format json
postProcess(function):
function (out) {
const bots = JSON.parse(out);
return bots.map((bot: Bot) => {
return {
name: bot.metadata.name.slice(4),
description: "A bot with this name already exists",
};
});
}
Single Functions:
filterTemplateSuggestions:
function (paths) {
return paths.filter(
(file) =>
file.name.endsWith("/") ||
file.name.endsWith(".yaml") ||
file.name.endsWith(".yml")
);
}
URLs:
http://127.0.0.1:3000
Hello @kanersps, thank you very much for creating a Pull Request! Here is a small checklist to get this PR merged as quickly as possible:
- [ ] Do all subcommands / options which take arguments include the
argsproperty (args: {})? - [ ] Are all options modular? E.g.
-a-u-xinstead of-aux - [ ] Have all other checks passed?
Please add a 👍 as a reaction to this comment to show that you read this.
I have read the CLA Document and I hereby sign the CLA
This should be all the features I wanted to implement, I'm not sure if I'm entirely done with messing with the Teleport autocompletions specs, but this will do for this MR.
Let me know if there are any changes required!
@mschrage Was there anything else that needs to be changed here, or can we merge? Locally 'publishing' this spec constantly is becoming a lil' annoying (probably a bug too, I presume, every so often I need to re-publish to my local namespace to ensure I have use these specs vs the one in this repo)
Good morning @superbryntendo . I see you made a quick commit, and I think that will break the functionality. I've specifically used a custom trigger, because I need to know the "username" portion as well to make a proper autocomplete suggestion.
Right now, with your change, the "username" variable does not exist and this will error out.