-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(podman): add podman completion spec #2158
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
Overviewsrc/podman.ts:Info:Single Functions:postProcess: function (out) {
return out
.split("\n")
.map((line) => JSON.parse(line))
.map((i) => ({
name: `${i.Id}`,
displayName: `${i.repository} - ${i.Id}`,
icon: "fig://icon?type=docker",
}));
} postProcess: function (out) {
return out
.split("\n")
.map((line) => JSON.parse(line))
.map((i) => ({
name: i.repository,
displayName: `${i.repository} - ${i.Id}`,
icon: "fig://icon?type=docker",
}));
} script: function (context) {
if (context[context.length - 1] === "") return undefined;
const searchTerm = context[context.length - 1];
return ["podman", "search", searchTerm, "--format", "{{ json . }}"];
} postProcess: function (out) {
return out
.split("\n")
.map((line) => JSON.parse(line))
.map((i) => ({
name: `${i.Name}`,
icon: "fig://icon?type=docker",
}));
} trigger: function () {
return true;
} postProcess: function (out) {
return out
.split("\n")
.map((line) => JSON.parse(line))
.map((i) => ({
name: i.Name,
icon: "fig://icon?type=docker",
}));
} trigger: function () {
return true;
} script: function (context) {
let fileFlagIndex, dockerfilePath;
if (context.includes("-f")) {
fileFlagIndex = context.indexOf("-f");
dockerfilePath = context[fileFlagIndex + 1];
} else if (context.includes("--file")) {
fileFlagIndex = context.indexOf("--file");
dockerfilePath = context[fileFlagIndex + 1];
} else {
dockerfilePath = "Dockerfile";
}
return ["grep", "-iE", "FROM.*AS", dockerfilePath];
} postProcess: function (out) {
// This just searches the Dockerfile for the alias name after AS,
// and due to the grep above, will only match lines where FROM and AS
// are on the same line. This could certainly be made more robust
// down the line.
const imageNameRegexp = /(?:[aA][sS]\s+)([\w:.-]+)/;
return out
.split("\n")
.map((i) => {
const result = imageNameRegexp.exec(i);
if (result) {
return {
name: result[1],
};
}
})
.filter((i) => i !== undefined);
} postProcess: function (out) {
return out.split("\n").map((image) => {
const [repo, size, tag, id] = image.split(" ");
return {
name: repo,
description: `${id}@${tag} - ${size}`,
icon: "fig://icon?type=docker",
};
});
} postProcess: function (out) {
const allLines = out.split("\n").map((line) => JSON.parse(line));
return allLines.map((i) => ({
name: i.Id,
displayName: `[con] ${i.Id} (${i.Image})`,
}));
} postProcess: function (out) {
const allLines = out.split("\n").map((line) => JSON.parse(line));
return allLines.map((i) => {
let displayName;
if (i.repository === "\u003cnone\u003e") {
displayName = i.Id;
} else {
displayName = i.repository;
if (i.Tag !== "\u003cnone\u003e") {
displayName += `:${i.tag}`;
}
}
return {
name: i.ID,
displayName: `[img] ${displayName}`,
};
});
} postProcess: function (out) {
const allLines = out.split("\n").map((line) => JSON.parse(line));
return allLines.map((i) => ({
name: i.Name,
displayName: `[vol] ${i.Name}`,
}));
} |
Hello @diegofcornejo,
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 |
Hey @diegofcornejo, we change the definition of the |
Seems like the type check is still failing |
Hi @grant0417 , I'm not sure what's wrong because I've checked the code and types in docker.ts. The linter is showing errors. On the other hand, every autocomplete with script (function way) has the same implementation, but in those cases, it seems like the type check doesn't fail." // podman.ts
script: function (context) {
if (context[context.length - 1] === "") return undefined;
const searchTerm = context[context.length - 1];
return ["podman", "search", searchTerm, "--format", "{{ json . }}"];
}
script: function (context) {
let fileFlagIndex, dockerfilePath;
if (context.includes("-f")) {
fileFlagIndex = context.indexOf("-f");
dockerfilePath = context[fileFlagIndex + 1];
} else if (context.includes("--file")) {
fileFlagIndex = context.indexOf("--file");
dockerfilePath = context[fileFlagIndex + 1];
} else {
dockerfilePath = "$PWD/Dockerfile";
}
return `\\grep -iE 'FROM.*AS' "${dockerfilePath}"`;
} // docker.ts
script: function (context) {
if (context[context.length - 1] === "") return undefined;
const searchTerm = context[context.length - 1];
return ["docker", "search", searchTerm, "--format", "{{ json . }}"];
}
script: function (context) {
let fileFlagIndex, dockerfilePath;
if (context.includes("-f")) {
fileFlagIndex = context.indexOf("-f");
dockerfilePath = context[fileFlagIndex + 1];
} else if (context.includes("--file")) {
fileFlagIndex = context.indexOf("--file");
dockerfilePath = context[fileFlagIndex + 1];
} else {
dockerfilePath = "Dockerfile";
}
return ["grep", "-iE", "FROM.*AS", dockerfilePath];
} |
If the linter is showing errors for docker you may need to run |
I understand now, I fixed the line, everything should be fine! |
In addition to the specs for Podman, 'pretty-quick --staged' was removed from package.json. It was not possible to run the pre-commit because it was giving the error '_prettier.resolveConfig.sync is not a function', which is documented at prettier/pretty-quick#164. The package has not been updated for more than 2 years.