---
apiVersion: v1
kind: ConfigMap
metadata:
  labels:
    funktion.fabric8.io/kind: Connector
  name: github
data:
  deployment.yml: |
    ---
    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      labels:
        funktion.fabric8.io/kind: Subscription
        connector: github
    spec:
      replicas: 1
      template:
        metadata:
          labels:
            funktion.fabric8.io/kind: Subscription
            connector: github
        spec:
          containers:
          - image: funktion/connector-github:${project.version}
            name: connector
  schema.yml: |
    ---
    component:
      kind: component
      scheme: github
      syntax: github:type/branchName
      title: GitHub
      description: The github component is used for integrating Camel with github.
      label: api,file
      deprecated: false
      async: false
      javaType: org.apache.camel.component.github.GitHubComponent
      groupId: org.apache.camel
      artifactId: camel-github
      version: 2.18.3
    componentProperties: {}
    properties:
      type:
        kind: path
        group: common
        required: true
        type: string
        javaType: org.apache.camel.component.github.GitHubType
        enum:
        - CLOSEPULLREQUEST
        - PULLREQUESTCOMMENT
        - COMMIT
        - PULLREQUEST
        - TAG
        - PULLREQUESTSTATE
        - PULLREQUESTFILES
        - GETCOMMITFILE
        - CREATEISSUE
        deprecated: false
        secret: false
        description: What git operation to execute
        order: 0
      branchName:
        kind: path
        group: consumer
        label: consumer
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: Name of branch
        order: 1
      oauthToken:
        kind: parameter
        group: common
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: GitHub OAuth token required unless username & password are provided
        order: 2
      password:
        kind: parameter
        group: common
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: GitHub password required unless oauthToken is provided
        order: 3
      repoName:
        kind: parameter
        group: common
        required: true
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: GitHub repository name
        order: 4
      repoOwner:
        kind: parameter
        group: common
        required: true
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: GitHub repository owner (organization)
        order: 5
      username:
        kind: parameter
        group: common
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: GitHub username required unless oauthToken is provided
        order: 6
      bridgeErrorHandler:
        kind: parameter
        group: consumer
        label: consumer
        type: boolean
        javaType: boolean
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        defaultValue: false
        description: Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN/ERROR level and ignored.
        order: 7
      exceptionHandler:
        kind: parameter
        group: consumer (advanced)
        label: consumer,advanced
        type: object
        javaType: org.apache.camel.spi.ExceptionHandler
        optionalPrefix: consumer.
        deprecated: false
        secret: false
        description: To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored.
        order: 8
      exchangePattern:
        kind: parameter
        group: consumer (advanced)
        label: consumer,advanced
        type: string
        javaType: org.apache.camel.ExchangePattern
        enum:
        - InOnly
        - RobustInOnly
        - InOut
        - InOptionalOut
        - OutOnly
        - RobustOutOnly
        - OutIn
        - OutOptionalIn
        deprecated: false
        secret: false
        description: Sets the exchange pattern when the consumer creates an exchange.
        order: 9
      encoding:
        kind: parameter
        group: producer
        label: producer
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: To use the given encoding when getting a git commit file
        order: 10
      state:
        kind: parameter
        group: producer
        label: producer
        type: string
        javaType: java.lang.String
        enum:
        - error
        - failure
        - pending
        - success
        deprecated: false
        secret: false
        description: To set git commit status state
        order: 11
      targetUrl:
        kind: parameter
        group: producer
        label: producer
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: To set git commit status target url
        order: 12
      synchronous:
        kind: parameter
        group: advanced
        label: advanced
        type: boolean
        javaType: boolean
        deprecated: false
        secret: false
        defaultValue: false
        description: Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).
        order: 13
  documentation.adoc: |
    [[GitHub-GitHub]]
    GitHub
    ~~~~~~

    *Available as of Camel 2.15*

    The GitHub component interacts with the GitHub API by
    encapsulating http://org.eclipse.egit.github.core[egit-github]. It
    currently provides polling for new pull requests, pull request comments,
    tags, and commits.  It is also able to produce comments on pull
    requests, as well as close the pull request entirely.

    Rather than webhooks, this endpoint relies on simple polling. Reasons
    include:

    * Concern for reliability/stability
    * The types of payloads we're polling aren't typically large (plus,
    paging is available in the API)
    * The need to support apps running somewhere not publicly accessible
    where a webhook would fail

    Note that the GitHub API is fairly expansive.  Therefore, this component
    could be easily expanded to provide additional interactions.

    Maven users will need to add the following dependency to their pom.xml
    for this component:

    [source,xml]
    -----------------------------------------
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-github</artifactId>
        <version>${camel-version}</version>
    </dependency>
    -----------------------------------------

    [[GitHub-URIformat]]
    URI format
    ^^^^^^^^^^

    [source,text]
    ---------------------------
    github://endpoint[?options]
    ---------------------------

    [[GitHub-MandatoryOptions:]]
    Mandatory Options:
    ^^^^^^^^^^^^^^^^^^

    Note that these can be configured directly through the endpoint.


    // component options: START
    The GitHub component has no options.
    // component options: END



    // endpoint options: START
    The GitHub component supports 14 endpoint options which are listed below:

    {% raw %}
    [width="100%",cols="2,1,1m,1m,5",options="header"]
    |=======================================================================
    | Name | Group | Default | Java Type | Description
    | type | common |  | GitHubType | *Required* What git operation to execute
    | branchName | consumer |  | String | Name of branch
    | oauthToken | common |  | String | GitHub OAuth token required unless username & password are provided
    | password | common |  | String | GitHub password required unless oauthToken is provided
    | repoName | common |  | String | *Required* GitHub repository name
    | repoOwner | common |  | String | *Required* GitHub repository owner (organization)
    | username | common |  | String | GitHub username required unless oauthToken is provided
    | bridgeErrorHandler | consumer | false | boolean | Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN/ERROR level and ignored.
    | exceptionHandler | consumer (advanced) |  | ExceptionHandler | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored.
    | exchangePattern | consumer (advanced) |  | ExchangePattern | Sets the exchange pattern when the consumer creates an exchange.
    | encoding | producer |  | String | To use the given encoding when getting a git commit file
    | state | producer |  | String | To set git commit status state
    | targetUrl | producer |  | String | To set git commit status target url
    | synchronous | advanced | false | boolean | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).
    |=======================================================================
    {% endraw %}
    // endpoint options: END



    [[GitHub-ConsumerEndpoints:]]
    Consumer Endpoints:
    ^^^^^^^^^^^^^^^^^^^

    [width="100%",cols="20%,20%,60%",options="header",]
    |=======================================================================
    |Endpoint |Context |Body Type

    |pullRequest |polling |org.eclipse.egit.github.core.PullRequest

    |pullRequestComment |polling |org.eclipse.egit.github.core.Comment (comment on the general pull
    request discussion) or org.eclipse.egit.github.core.CommitComment
    (inline comment on a pull request diff)

    |tag |polling |org.eclipse.egit.github.core.RepositoryTag

    |commit |polling |org.eclipse.egit.github.core.RepositoryCommit
    |=======================================================================

    [[GitHub-ProducerEndpoints:]]
    Producer Endpoints:
    ^^^^^^^^^^^^^^^^^^^

    [width="100%",cols="20%,20%,60%",options="header",]
    |=======================================================================
    |Endpoint |Body |Message Headers

    |pullRequestComment |String (comment text) | - GitHubPullRequest (integer) (REQUIRED): Pull request number.

    - GitHubInResponseTo (integer): Required if responding to another inline
    comment on the pull request diff. If left off, a general comment on the
    pull request discussion is assumed.

    |closePullRequest |none | - GitHubPullRequest (integer) (REQUIRED): Pull request number.

    |createIssue (From Camel 2.18) |String (issue body text) | - GitHubIssueTitle (String) (REQUIRED): Issue Title.
    |=======================================================================
