-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Artifacts Manifest Extension (#1649)
Explicitly list main container image in artifacts extension
- Loading branch information
Showing
7 changed files
with
208 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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,5 @@ | ||
type: improvement | ||
improvement: | ||
description: add artifacts manifest extension | ||
links: | ||
- https://github.com/palantir/sls-packaging/pull/1649 |
This file contains 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
46 changes: 46 additions & 0 deletions
46
gradle-sls-packaging/src/main/java/com/palantir/gradle/dist/artifacts/ArtifactLocator.java
This file contains 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,46 @@ | ||
/* | ||
* (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. | ||
* | ||
* 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 com.palantir.gradle.dist.artifacts; | ||
|
||
import com.google.common.base.Preconditions; | ||
import com.palantir.logsafe.exceptions.SafeIllegalArgumentException; | ||
import java.net.URI; | ||
import org.gradle.api.provider.Property; | ||
import org.gradle.api.tasks.Input; | ||
|
||
public interface ArtifactLocator { | ||
@Input | ||
Property<String> getType(); | ||
|
||
@Input | ||
Property<String> getUri(); | ||
|
||
default void isValid() { | ||
Preconditions.checkNotNull(getType().get(), "type must be specified"); | ||
Preconditions.checkNotNull(getUri().get(), "uri must be specified"); | ||
uriIsValid(getUri().get()); | ||
} | ||
|
||
private static void uriIsValid(String uri) { | ||
try { | ||
// Throws IllegalArgumentException if URI does not conform to RFC 2396 | ||
URI.create(uri); | ||
} catch (IllegalArgumentException e) { | ||
throw new SafeIllegalArgumentException("uri is not valid", e); | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...e-sls-packaging/src/main/java/com/palantir/gradle/dist/artifacts/JsonArtifactLocator.java
This file contains 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,42 @@ | ||
/* | ||
* (c) Copyright 2024 Palantir Technologies Inc. All rights reserved. | ||
* | ||
* 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 com.palantir.gradle.dist.artifacts; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public final class JsonArtifactLocator { | ||
|
||
@JsonProperty("type") | ||
@SuppressWarnings("unused") | ||
private String type; | ||
|
||
@JsonProperty("uri") | ||
@SuppressWarnings("unused") | ||
private String uri; | ||
|
||
public JsonArtifactLocator(String type, String uri) { | ||
this.type = type; | ||
this.uri = uri; | ||
} | ||
|
||
public static JsonArtifactLocator from(ArtifactLocator artifactLocator) { | ||
return new JsonArtifactLocator( | ||
artifactLocator.getType().get(), artifactLocator.getUri().get()); | ||
} | ||
} |
This file contains 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 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 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