Enum Class CredentialProviders

java.lang.Object
java.lang.Enum<CredentialProviders>
io.github.duckasteroid.gradle.githubpackages.CredentialProviders
All Implemented Interfaces:
Serializable, Comparable<CredentialProviders>, Constable

public enum CredentialProviders extends Enum<CredentialProviders>
Provides standardised routes to get the authentication credentials for GitHub Packages.

Uses a three-tier fallback chain:

  1. Tier 1 (Gradle Properties): gpr.user / gpr.key from gradle.properties - or, when a named profile is given, gpr.<profile>.user / gpr.<profile>.key instead (deliberately not falling back to the unqualified gpr.user/gpr.key, so a mistyped profile name can't silently pick up the wrong identity)
  2. Tier 2 (Read-Only): GH_PACKAGES_READ_USER / GH_PACKAGES_READ_TOKEN environment variables
  3. Tier 3 (GitHub Actions): GITHUB_ACTOR / GITHUB_TOKEN environment variables

The first available source in this chain is used. Once a value is found at any tier, lower tiers are not consulted.

  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Resolves the GitHub token for authentication.
    Resolves the GitHub username for authentication.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.gradle.api.provider.Provider<String>
    apply(org.gradle.api.provider.ProviderFactory providers)
    Resolves credentials using no named profile - i.e.
    org.gradle.api.provider.Provider<String>
    apply(org.gradle.api.provider.ProviderFactory providers, org.gradle.api.provider.Provider<String> profile)
    Resolves credentials, preferring a named profile's gradle properties over the unqualified ones when profile has a value.
    Returns the enum constant of this class with the specified name.
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • USER

      public static final CredentialProviders USER
      Resolves the GitHub username for authentication. The search path is:
      1. Gradle property: gpr.user, or gpr.<profile>.user when a profile is given
      2. Environment variable: GH_PACKAGES_READ_USER
      3. Environment variable: GITHUB_ACTOR
    • TOKEN

      public static final CredentialProviders TOKEN
      Resolves the GitHub token for authentication. The search path is:
      1. Gradle property: gpr.key, or gpr.<profile>.key when a profile is given
      2. Environment variable: GH_PACKAGES_READ_TOKEN
      3. Environment variable: GITHUB_TOKEN
  • Method Details

    • values

      public static CredentialProviders[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static CredentialProviders valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • apply

      public org.gradle.api.provider.Provider<String> apply(org.gradle.api.provider.ProviderFactory providers)
      Resolves credentials using no named profile - i.e. today's default gpr.user/gpr.key chain.
    • apply

      public org.gradle.api.provider.Provider<String> apply(org.gradle.api.provider.ProviderFactory providers, org.gradle.api.provider.Provider<String> profile)
      Resolves credentials, preferring a named profile's gradle properties over the unqualified ones when profile has a value. An absent or blank profile behaves the same as apply(ProviderFactory).