Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repositories {
}
}

final targetJavaVersion = JavaVersion.VERSION_21
final targetJavaVersion = JavaVersion.VERSION_25

java {
sourceCompatibility = targetJavaVersion
Expand Down
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
<<<<<<< Updated upstream
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad stash?

version=1.2.2-SNAPSHOT
kestraVersion=1.2.1
=======
version=1.1.6
kestraVersion=1.3.0-SNAPSHOT
>>>>>>> Stashed changes
35 changes: 33 additions & 2 deletions src/main/java/io/kestra/plugin/git/AbstractKestraTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,30 @@ protected KestraClient kestraClient(RunContext runContext) throws IllegalVariabl
builder.basicAuth(maybeUsername.get(), maybePassword.get());
return builder.build();
}
throw new IllegalArgumentException("Both username and password are required for HTTP Basic authentication");

if (maybeUsername.isPresent() || maybePassword.isPresent()) {
throw new IllegalArgumentException("Both username and password are required for HTTP Basic authentication");
}

if (runContext.render(auth.auto).as(Boolean.class).orElse(Boolean.TRUE)) {
Optional<SDK.Auth> autoAuth = runContext.sdk().defaultAuthentication();
if (autoAuth.isPresent()) {
if (autoAuth.get().username().isPresent() && autoAuth.get().password().isPresent()) {
return builder.basicAuth(autoAuth.get().username().get(), autoAuth.get().password().get()).build();
}
}
}
throw new IllegalArgumentException("No authentication method provided");
} else {
throw new IllegalArgumentException("Auth is required");
// try automatic authentication
Optional<SDK.Auth> autoAuth = runContext.sdk().defaultAuthentication();
if (autoAuth.isPresent()) {
if (autoAuth.get().username().isPresent() && autoAuth.get().password().isPresent()) {
return builder.basicAuth(autoAuth.get().username().get(), autoAuth.get().password().get()).build();
}
}
}
return builder.build();
}

@Builder
Expand All @@ -65,5 +85,16 @@ public static class Auth {

@Schema(title = "Password for HTTP Basic authentication.")
private Property<String> password;

@Schema(
title = "Automatically retrieve credentials from Kestra's configuration if available",
description = """
The default configuration can be configured globally inside the Kestra configuration file:
- Set `kestra.tasks.sdk.authentication.api-token` to use an API token
- Set `kestra.tasks.sdk.authentication.username` and `kestra.tasks.sdk.authentication.password` for HTTP basic authentication
The Enterprise edition also provides setting a default configuration at the Namespace of Tenant level by an administrator."""
)
@Builder.Default
private Property<Boolean> auto = Property.ofValue(Boolean.TRUE);
}
}
Loading