Unverified Commit ade3880f authored by superherointj's avatar superherointj Committed by GitHub
Browse files

Merge pull request #223926 from lucasew/terraform-completion

terraform: add completion
parents 0953866c 4d0c1a91
Loading
Loading
Loading
Loading
+33 −19
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
, writeText
, terraform-providers
, fetchpatch
, installShellFiles
}:

let
@@ -28,12 +29,38 @@ let

      ldflags = [ "-s" "-w" ];

      subPackages = [ "." ];

      postConfigure = ''
        # speakeasy hardcodes /bin/stty https://github.com/bgentry/speakeasy/issues/22
        substituteInPlace vendor/github.com/bgentry/speakeasy/speakeasy_unix.go \
          --replace "/bin/stty" "${coreutils}/bin/stty"
      '';

      nativeBuildInputs = [ installShellFiles ];

      preCheck = ''
        export HOME=$TMPDIR
        export TF_SKIP_REMOTE_TESTS=1
      '';

      # https://github.com/posener/complete/blob/9a4745ac49b29530e07dc2581745a218b646b7a3/cmd/install/bash.go#L8
      completionBash = "complete -C terraform terraform\n";
      # https://github.com/posener/complete/blob/9a4745ac49b29530e07dc2581745a218b646b7a3/cmd/install/zsh.go
      completionZsh =  "complete -C terraform terraform\n";
      # https://github.com/posener/complete/blob/9a4745ac49b29530e07dc2581745a218b646b7a3/cmd/install/fish.go#L56
      completionFish = ''
        function __complete_terraform
            set -lx COMP_LINE (commandline -cp)
            test -z (commandline -ct)
            and set COMP_LINE "$COMP_LINE "
            terraform
        end
        complete -f -c terraform -a "(__complete_terraform)"
      '';

      passAsFile = [ "completionBash" "completionZsh" "completionFish" ];

      postInstall = ''
        # remove all plugins, they are part of the main binary now
        for i in $out/bin/*; do
@@ -41,32 +68,19 @@ let
            rm "$i"
          fi
        done
      '';

      preCheck = ''
        export HOME=$TMPDIR
        export TF_SKIP_REMOTE_TESTS=1
        installShellCompletion --bash --name terraform $completionBashPath
        installShellCompletion --zsh --name terraform $completionZshPath
        installShellCompletion --fish --name terraform $completionFishPath
      '';

      subPackages = [ "." ];

      meta = with lib; {
      meta = {
        description =
          "Tool for building, changing, and versioning infrastructure";
        homepage = "https://www.terraform.io/";
        changelog = "https://github.com/hashicorp/terraform/blob/v${version}/CHANGELOG.md";
        license = licenses.mpl20;
        maintainers = with maintainers; [
          Chili-Man
          babariviere
          kalbasit
          marsam
          maxeaubrey
          timstott
          zimbatm
          zowoq
          techknowlogick
        ];
        license = lib.licenses.mpl20;
        maintainers = with lib.maintainers; [ Chili-Man babariviere kalbasit marsam maxeaubrey techknowlogick timstott zimbatm zowoq ];
      };
    } // attrs');

+11 −9
Original line number Diff line number Diff line
@@ -29,12 +29,9 @@ buildGoModule rec {
    hash = "sha256-nRmEXR9fjDxvpbnT+qpGeM0Cc/qW/kN53sKOXwZiBXY=";
  };

  subPackages = [ "cmd/..." ];

  vendorHash = "sha256-+AvmJkZCFovE2+5Lg98tUvA7f2kBHUMzhl5IyrEGuy8=";

  # integration tests require network access
  doCheck = false;
  tags = [ "embed" ];

  ldflags = [
    "-s"
@@ -42,6 +39,8 @@ buildGoModule rec {
    "-X github.com/coder/coder/buildinfo.tag=${version}"
  ];

  subPackages = [ "cmd/..." ];

  preBuild = ''
    export HOME=$TEMPDIR

@@ -57,8 +56,6 @@ buildGoModule rec {
    popd
  '';

  tags = [ "embed" ];

  nativeBuildInputs = [
    fixup_yarn_lock
    installShellFiles
@@ -79,10 +76,15 @@ buildGoModule rec {
    wrapProgram $out/bin/coder --prefix PATH : ${lib.makeBinPath [ terraform ]}
  '';

  meta = with lib; {
  # integration tests require network access
  doCheck = false;

  meta = {
    description = "Provision software development environments via Terraform on Linux, macOS, Windows, X86, ARM, and of course, Kubernetes";
    homepage = "https://coder.com";
    license = licenses.agpl3;
    maintainers = with maintainers; [ ghuntley urandom ];
    license = lib.licenses.agpl3;
    maintainers = [ lib.maintainers.ghuntley lib.maintainers.urandom ];
    # Failed to download Chromium 109.0.5414.46
    broken = true; # At 2023-03-30
  };
}