Skip to content
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

fix(kubectl): Remove "--short" option from "version" #2425

Merged
merged 1 commit into from
Aug 1, 2024

Conversation

mbd-s
Copy link
Contributor

@mbd-s mbd-s commented Aug 1, 2024

The option was deprecated, then removed in version 1.28. Short is now the default.

The option was deprecated, then removed in version 1.28. Short is now
the default.
@withfig-bot
Copy link
Collaborator

Overview

src/kubectl.ts:

Info:

Single Functions:

typeWithoutName:

 function (type) {
    return ["kubectl", "get", type, "-o", "custom-columns=:.metadata.name"];
  }

script:

 function (context) {
        const resourceType = context[context.length - 2];
        return scripts.typeWithoutName(resourceType);
      }

script:

 function (context) {
        const index = context.indexOf("--kubeconfig");
        if (index !== -1) {
          return [
            "kubectl",
            "config",
            `--kubeconfig=${context[index + 1]}`,
            "get-contexts",
            "-o",
            "name",
          ];
        }
        return ["kubectl", "config", "get-contexts", "-o", "name"];
      }

script:

 function (context) {
        const index = context.indexOf("--kubeconfig");
        if (index !== -1) {
          return [
            "kubectl",
            "config",
            `--kubeconfig=${context[index + 1]}`,
            "get-clusters",
          ];
        }
        return ["kubectl", "config", "get-clusters"];
      }

postProcess:

 function (out) {
        if (
          sharedPostProcessChecks.connectedToCluster(out) ||
          sharedPostProcessChecks.generalError(out)
        ) {
          return [];
        }
        return out
          .split("\n")
          .filter((line) => line !== "NAME")
          .map((line) => ({
            name: line,
            icon: "fig://icon?type=kubernetes",
          }));
      }

script:

 function (context) {
        const lastInput = context[context.length - 1];
        if (lastInput.includes("/")) {
          return scripts.typeWithoutName(
            lastInput.substring(0, lastInput.indexOf("/"))
          );
        }
        return scripts.types;
      }

postProcess:

 function (out) {
        if (
          sharedPostProcessChecks.connectedToCluster(out) ||
          sharedPostProcessChecks.generalError(out)
        ) {
          return [];
        }
        return JSON.parse(out).spec.containers.map((item) => ({
          name: item.name,
          description: item.image,
          icon: "fig://icon?type=kubernetes",
        }));
      }

URLs:

  • http://golang.org/pkg/text/template/#pkg-overview

@mbd-s mbd-s changed the title fix(kubectl): Remove "--short" option from "kubectl version" fix(kubectl): Remove "--short" option from "version" Aug 1, 2024
@withfig-bot
Copy link
Collaborator

Hello @mbd-s,
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 args property (args: {})?
  • Are all options modular? E.g. -a -u -x instead of -aux
  • Have all other checks passed?

Please add a 👍 as a reaction to this comment to show that you read this.

@grant0417 grant0417 merged commit b3c59ae into withfig:master Aug 1, 2024
5 checks passed
@withfig withfig locked and limited conversation to collaborators Aug 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants