-
Notifications
You must be signed in to change notification settings - Fork 34
refactor: extract sigstore-common module #1288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| dev.sigstore.common.http.HttpClients#newHttpTransport(dev.sigstore.common.http.HttpParams) @ Use dev.sigstore.common.http.HttpClients#newRequestFactory(...) instead | ||
| java.net.URI#resolve(java.lang.String) @ Use dev.sigstore.common.http.URIFormat#appendPath(java.net.URI, java.lang.String) instead | ||
| java.net.URI#resolve(java.net.URI) @ Use dev.sigstore.common.http.URIFormat#appendPath(java.net.URI, java.lang.String) instead |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,2 @@ | ||
| com.google.protobuf.util.JsonFormat#parser() @ Use dev.sigstore.json.ProtoJson#parser() instead | ||
| dev.sigstore.http.HttpClients#newHttpTransport(dev.sigstore.http.HttpParams) @ Use dev.sigstore.http.HttpClients#newRequestFactory(...) instead | ||
| com.google.gson.GsonBuilder @ Use dev.sigstore.json.GsonSupplier.GSON instead | ||
| java.net.URI#resolve(java.lang.String) @ Use dev.sigstore.http.URIFormat#appendPath(java.net.URI, java.lang.String) instead | ||
| java.net.URI#resolve(java.net.URI) @ Use dev.sigstore.http.URIFormat#appendPath(java.net.URI, java.lang.String) instead |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| plugins { | ||
| `java-base` | ||
| id("java") | ||
| } | ||
|
|
||
| group = "com.example.sigstore-gradle-sandbox" | ||
| version = "1.0.0" | ||
|
|
||
| repositories { | ||
| mavenLocal() | ||
| mavenCentral() | ||
| } | ||
|
|
||
| val sigstoreVersion = "2.4.0-SNAPSHOT" | ||
|
|
||
| dependencies { | ||
| implementation("dev.sigstore:sigstore-common:$sigstoreVersion") | ||
| implementation("dev.sigstore:sigstore-java:$sigstoreVersion") | ||
| } | ||
|
|
||
| tasks.compileJava { | ||
| options.compilerArgumentProviders.add(CommandLineArgumentProvider { | ||
| listOf( | ||
| "--module-path", classpath.asPath, | ||
| ) | ||
| }) | ||
| } | ||
26 changes: 26 additions & 0 deletions
26
sandbox/module-test/src/main/java/dev/sigstore/sandbox/modular/Main.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /* | ||
| * Copyright 2026 The Sigstore Authors. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package dev.sigstore.sandbox.modular; | ||
|
|
||
| import dev.sigstore.KeylessSigner; | ||
| import dev.sigstore.common.json.GsonChecked; | ||
|
|
||
| public class Main { | ||
| public static void main(String[] args) { | ||
| System.out.println(KeylessSigner.class.getName()); | ||
| System.out.println(GsonChecked.class.getName()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /* | ||
| * Copyright 2026 The Sigstore Authors. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| module dev.sigstore.sandbox.modular { | ||
| requires dev.sigstore; | ||
| requires dev.sigstore.common; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| plugins { | ||
| id("build-logic.java-published-library") | ||
| id("build-logic.test-junit5") | ||
| id("build-logic.build-info") | ||
| } | ||
|
|
||
| description = "Common utilities for Sigstore Java" | ||
|
|
||
| tasks.jar { | ||
| manifest { | ||
| attributes["Automatic-Module-Name"] = "dev.sigstore.common" | ||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
| compileOnly("org.immutables:value-annotations:2.12.2") | ||
| annotationProcessor("org.immutables:value:2.12.2") | ||
| api(platform("com.google.http-client:google-http-client-bom:2.2.0")) | ||
| api("com.google.http-client:google-http-client-apache-v5") | ||
| api("com.google.http-client:google-http-client-gson") | ||
| api("com.google.code.gson:gson:2.14.0") | ||
|
|
||
| testImplementation(platform("org.junit:junit-bom:5.14.4")) | ||
| testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") | ||
| testImplementation("org.assertj:assertj-core:3.27.7") | ||
| testImplementation(platform("org.mockito:mockito-bom:5.23.0")) | ||
| testImplementation("org.mockito:mockito-core") | ||
| testImplementation("org.mockito:mockito-junit-jupiter") | ||
| } | ||
|
|
||
| forbiddenApis { | ||
| signaturesFiles = files("$rootDir/config/forbiddenApis-common.txt") | ||
| suppressAnnotations = setOf("dev.sigstore.common.forbidden.SuppressForbidden") | ||
| } | ||
|
|
||
| tasks.generateBuildInfo { | ||
| packageName.set("dev.sigstore.common.buildinfo") | ||
| } | ||
|
|
||
| spotless { | ||
| java { | ||
| targetExclude( | ||
| "build/**/*.java", | ||
| "src/*/java/dev/sigstore/common/json/canonicalizer/*.java", | ||
| ) | ||
| } | ||
| format("webPki", com.diffplug.gradle.spotless.JavaExtension::class.java) { | ||
| googleJavaFormat("1.35.0") | ||
| licenseHeaderFile("$rootDir/config/webPKILicenseHeader") | ||
| target("src/*/java/dev/sigstore/common/json/canonicalizer/*.java") | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ | |
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package dev.sigstore.http; | ||
| package dev.sigstore.common.http; | ||
|
|
||
| import com.google.api.client.http.HttpRequest; | ||
| import com.google.api.client.http.HttpResponse; | ||
|
|
@@ -22,7 +22,6 @@ | |
| import com.google.api.client.util.BackOffUtils; | ||
| import com.google.api.client.util.ExponentialBackOff; | ||
| import com.google.api.client.util.Sleeper; | ||
| import com.google.common.annotations.VisibleForTesting; | ||
| import java.io.IOException; | ||
| import java.time.Instant; | ||
| import java.util.logging.Logger; | ||
|
|
@@ -50,7 +49,7 @@ public static UnsuccessfulResponseHandler newUnsuccessfulResponseHandler() { | |
| return new UnsuccessfulResponseHandler(Sleeper.DEFAULT, new ExponentialBackOff()); | ||
| } | ||
|
|
||
| @VisibleForTesting | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps a comment here if we're removing the annotation
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a comment. |
||
| // package-private for testing | ||
| UnsuccessfulResponseHandler(Sleeper sleeper, ExponentialBackOff exponentialBackOff) { | ||
| this.sleeper = sleeper; | ||
| this.exponentialBackOff = exponentialBackOff; | ||
|
|
@@ -110,7 +109,6 @@ private boolean handleRetryAfter(String retryAfter) throws InterruptedException, | |
| } | ||
|
|
||
| // backoff in milliseconds | ||
| @VisibleForTesting | ||
| long calculateBackoff(String retryAfter, Instant now) throws NumberFormatException { | ||
| // parse as httpdate | ||
| var date = DateUtils.parseDate(retryAfter); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we check that this actually fails? like if we add a conflicting package somewhere and then checking for failure?