1. Packages
  2. GitHub
  3. API Docs
  4. getTree
GitHub v6.3.0 published on Monday, Sep 16, 2024 by Pulumi

github.getTree

Explore with Pulumi AI

github logo
GitHub v6.3.0 published on Monday, Sep 16, 2024 by Pulumi

    Use this data source to retrieve information about a single tree.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as github from "@pulumi/github";
    
    const this = github.getRepository({
        name: "example",
    });
    const thisGetBranch = Promise.all([_this, _this]).then(([_this, _this1]) => github.getBranch({
        branch: _this.defaultBranch,
        repository: _this1.name,
    }));
    const thisGetTree = Promise.all([_this, thisGetBranch]).then(([_this, thisGetBranch]) => github.getTree({
        recursive: false,
        repository: _this.name,
        treeSha: thisGetBranch.sha,
    }));
    export const entries = thisGetTree.then(thisGetTree => thisGetTree.entries);
    
    import pulumi
    import pulumi_github as github
    
    this = github.get_repository(name="example")
    this_get_branch = github.get_branch(branch=this.default_branch,
        repository=this.name)
    this_get_tree = github.get_tree(recursive=False,
        repository=this.name,
        tree_sha=this_get_branch.sha)
    pulumi.export("entries", this_get_tree.entries)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-github/sdk/v6/go/github"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		this, err := github.LookupRepository(ctx, &github.LookupRepositoryArgs{
    			Name: pulumi.StringRef("example"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		thisGetBranch, err := github.LookupBranch(ctx, &github.LookupBranchArgs{
    			Branch:     this.DefaultBranch,
    			Repository: this.Name,
    		}, nil)
    		if err != nil {
    			return err
    		}
    		thisGetTree, err := github.GetTree(ctx, &github.GetTreeArgs{
    			Recursive:  pulumi.BoolRef(false),
    			Repository: this.Name,
    			TreeSha:    thisGetBranch.Sha,
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("entries", thisGetTree.Entries)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Github = Pulumi.Github;
    
    return await Deployment.RunAsync(() => 
    {
        var @this = Github.GetRepository.Invoke(new()
        {
            Name = "example",
        });
    
        var thisGetBranch = Github.GetBranch.Invoke(new()
        {
            Branch = @this.Apply(getRepositoryResult => getRepositoryResult.DefaultBranch),
            Repository = @this.Apply(getRepositoryResult => getRepositoryResult.Name),
        });
    
        var thisGetTree = Github.GetTree.Invoke(new()
        {
            Recursive = false,
            Repository = @this.Apply(getRepositoryResult => getRepositoryResult.Name),
            TreeSha = thisGetBranch.Apply(getBranchResult => getBranchResult.Sha),
        });
    
        return new Dictionary<string, object?>
        {
            ["entries"] = thisGetTree.Apply(getTreeResult => getTreeResult.Entries),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.github.GithubFunctions;
    import com.pulumi.github.inputs.GetRepositoryArgs;
    import com.pulumi.github.inputs.GetBranchArgs;
    import com.pulumi.github.inputs.GetTreeArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var this = GithubFunctions.getRepository(GetRepositoryArgs.builder()
                .name("example")
                .build());
    
            final var thisGetBranch = GithubFunctions.getBranch(GetBranchArgs.builder()
                .branch(this_.defaultBranch())
                .repository(this_.name())
                .build());
    
            final var thisGetTree = GithubFunctions.getTree(GetTreeArgs.builder()
                .recursive(false)
                .repository(this_.name())
                .treeSha(thisGetBranch.applyValue(getBranchResult -> getBranchResult.sha()))
                .build());
    
            ctx.export("entries", thisGetTree.applyValue(getTreeResult -> getTreeResult.entries()));
        }
    }
    
    variables:
      this:
        fn::invoke:
          Function: github:getRepository
          Arguments:
            name: example
      thisGetBranch:
        fn::invoke:
          Function: github:getBranch
          Arguments:
            branch: ${this.defaultBranch}
            repository: ${this.name}
      thisGetTree:
        fn::invoke:
          Function: github:getTree
          Arguments:
            recursive: false
            repository: ${this.name}
            treeSha: ${thisGetBranch.sha}
    outputs:
      entries: ${thisGetTree.entries}
    

    Using getTree

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getTree(args: GetTreeArgs, opts?: InvokeOptions): Promise<GetTreeResult>
    function getTreeOutput(args: GetTreeOutputArgs, opts?: InvokeOptions): Output<GetTreeResult>
    def get_tree(recursive: Optional[bool] = None,
                 repository: Optional[str] = None,
                 tree_sha: Optional[str] = None,
                 opts: Optional[InvokeOptions] = None) -> GetTreeResult
    def get_tree_output(recursive: Optional[pulumi.Input[bool]] = None,
                 repository: Optional[pulumi.Input[str]] = None,
                 tree_sha: Optional[pulumi.Input[str]] = None,
                 opts: Optional[InvokeOptions] = None) -> Output[GetTreeResult]
    func GetTree(ctx *Context, args *GetTreeArgs, opts ...InvokeOption) (*GetTreeResult, error)
    func GetTreeOutput(ctx *Context, args *GetTreeOutputArgs, opts ...InvokeOption) GetTreeResultOutput

    > Note: This function is named GetTree in the Go SDK.

    public static class GetTree 
    {
        public static Task<GetTreeResult> InvokeAsync(GetTreeArgs args, InvokeOptions? opts = null)
        public static Output<GetTreeResult> Invoke(GetTreeInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetTreeResult> getTree(GetTreeArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: github:index/getTree:getTree
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Repository string
    The name of the repository.
    TreeSha string
    The SHA1 value for the tree.
    Recursive bool
    Setting this parameter to true returns the objects or subtrees referenced by the tree specified in tree_sha.
    Repository string
    The name of the repository.
    TreeSha string
    The SHA1 value for the tree.
    Recursive bool
    Setting this parameter to true returns the objects or subtrees referenced by the tree specified in tree_sha.
    repository String
    The name of the repository.
    treeSha String
    The SHA1 value for the tree.
    recursive Boolean
    Setting this parameter to true returns the objects or subtrees referenced by the tree specified in tree_sha.
    repository string
    The name of the repository.
    treeSha string
    The SHA1 value for the tree.
    recursive boolean
    Setting this parameter to true returns the objects or subtrees referenced by the tree specified in tree_sha.
    repository str
    The name of the repository.
    tree_sha str
    The SHA1 value for the tree.
    recursive bool
    Setting this parameter to true returns the objects or subtrees referenced by the tree specified in tree_sha.
    repository String
    The name of the repository.
    treeSha String
    The SHA1 value for the tree.
    recursive Boolean
    Setting this parameter to true returns the objects or subtrees referenced by the tree specified in tree_sha.

    getTree Result

    The following output properties are available:

    Entries List<GetTreeEntry>
    Objects (of path, mode, type, size, and sha) specifying a tree structure.
    Id string
    The provider-assigned unique ID for this managed resource.
    Repository string
    TreeSha string
    Recursive bool
    Entries []GetTreeEntry
    Objects (of path, mode, type, size, and sha) specifying a tree structure.
    Id string
    The provider-assigned unique ID for this managed resource.
    Repository string
    TreeSha string
    Recursive bool
    entries List<GetTreeEntry>
    Objects (of path, mode, type, size, and sha) specifying a tree structure.
    id String
    The provider-assigned unique ID for this managed resource.
    repository String
    treeSha String
    recursive Boolean
    entries GetTreeEntry[]
    Objects (of path, mode, type, size, and sha) specifying a tree structure.
    id string
    The provider-assigned unique ID for this managed resource.
    repository string
    treeSha string
    recursive boolean
    entries Sequence[GetTreeEntry]
    Objects (of path, mode, type, size, and sha) specifying a tree structure.
    id str
    The provider-assigned unique ID for this managed resource.
    repository str
    tree_sha str
    recursive bool
    entries List<Property Map>
    Objects (of path, mode, type, size, and sha) specifying a tree structure.
    id String
    The provider-assigned unique ID for this managed resource.
    repository String
    treeSha String
    recursive Boolean

    Supporting Types

    GetTreeEntry

    Mode string
    Path string
    Sha string
    Size int
    Type string
    Mode string
    Path string
    Sha string
    Size int
    Type string
    mode String
    path String
    sha String
    size Integer
    type String
    mode string
    path string
    sha string
    size number
    type string
    mode str
    path str
    sha str
    size int
    type str
    mode String
    path String
    sha String
    size Number
    type String

    Package Details

    Repository
    GitHub pulumi/pulumi-github
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the github Terraform Provider.
    github logo
    GitHub v6.3.0 published on Monday, Sep 16, 2024 by Pulumi