Class RegistrySpec

java.lang.Object
com.konfigyr.gradle.RegistrySpec
All Implemented Interfaces:
org.gradle.api.Named

@NullMarked public class RegistrySpec extends Object implements org.gradle.api.Named
Configures a single Konfigyr Artifactory registry within the registries { } container exposed by KonfigyrExtension.

Every registry needs exactly one seed value, its url - the OAuth2 token endpoint (and any other OAuth2 endpoint the plugin needs) is discovered from it at build time rather than configured directly, and the Artifactory API is reached via fixed, plugin-internal relative paths under that same origin.

Exactly one OAuth2 grant type must be configured, either client credentials:


 registries {
     registry("staging") {
         url = uri("https://staging.konfigyr.io")

         clientCredentials {
             clientId     = "acme-corp-client"
             clientSecret = "acme-corp-secret"
         }
     }
 }

or token exchange:


 registries {
     registry("staging") {
         url = uri("https://staging.konfigyr.io")

         tokenExchange {
             clientId         = "acme-corp-client"
             subjectToken     = "..."
             subjectTokenType = "urn:ietf:params:oauth:token-type:jwt"
         }
     }
 }

If both blocks are configured, tokenExchange takes priority, since it prefers the shorter-lived, revocable mechanism. Neither grant falls back to environment variables for a registry created via KonfigyrExtension.registry(String, Action). Every value must be set explicitly. The reserved registry created via KonfigyrExtension.konfigyrCentral() is the only exception, resolving unset values from the same KONFIGYR_CLIENT_ID / KONFIGYR_CLIENT_SECRET / KONFIGYR_SUBJECT_TOKEN environment variables the plugin has always supported.

The url must use https, unless the host is a loopback address. A registry that's only ever reachable over an otherwise secured channel, for example a service exposed exclusively on a private network or VPN, can opt out of this check with insecure:


 registries {
     registry("internal") {
         url      = uri("http://konfigyr.internal.acme.com")
         insecure = true

         clientCredentials {
             clientId     = "acme-corp-client"
             clientSecret = "acme-corp-secret"
         }
     }
 }
Since:
1.2.0
See Also:
  • Constructor Details

    • RegistrySpec

      @Inject public RegistrySpec(String name, org.gradle.api.model.ObjectFactory objects, org.gradle.api.provider.ProviderFactory providers, boolean useEnvironmentConventions)
      Creates a new RegistrySpec, instantiated by Gradle for each entry added to the KonfigyrExtension.getRegistries() container.
      Parameters:
      name - the registry name, cannot be null.
      objects - the Gradle object factory, cannot be null.
      providers - the Gradle provider factory, used to resolve environment variable conventions, cannot be null.
      useEnvironmentConventions - true only for the reserved "konfigyrCentral" registry, enabling its environment variable fallbacks.
  • Method Details

    • clientCredentials

      public void clientCredentials(org.gradle.api.Action<RegistrySpec.ClientCredentialsSpec> action)
      Configures ClientCredentials, for the OAuth2 client_credentials grant.
      Parameters:
      action - configures the client credentials, cannot be null.
    • tokenExchange

      public void tokenExchange(org.gradle.api.Action<RegistrySpec.TokenExchangeSpec> action)
      Configures a TokenExchange, for the OAuth2 Token Exchange grant.
      Parameters:
      action - configures the token exchange, cannot be null.
    • getName

      public String getName()
      The name under which this registry is declared in the registries { } container - either the reserved "konfigyrCentral" name, or a custom name passed to KonfigyrExtension.registry(String, Action). Also used to derive this registry's per-registry Gradle task names (e.g. publishArtifactMetadataToStaging).
      Specified by:
      getName in interface org.gradle.api.Named
    • getUrl

      public org.gradle.api.provider.Property<URI> getUrl()
      The registry's url. This is the sole discovery seed for this registry: its OAuth2 endpoints are resolved from it at build time, and the Artifactory API is reached via fixed relative paths under this same origin. Must use https, unless the host is a loopback address, or insecure is set to true.
    • getInsecure

      public org.gradle.api.provider.Property<Boolean> getInsecure()
      Whether this registry's url is allowed to use the plain http scheme, beyond the loopback exemption that's always granted for local testing. Defaults to false.

      Use with caution: enabling this sends credentials in plaintext, so only set it for a registry that's known to be reachable exclusively over an otherwise secured channel, for example a service that's only accessible over a private network or VPN.