Skip to content
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

Add helmoci repository support #391

Merged
merged 1 commit into from
Sep 27, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.jfrog.artifactory.client.model.repository.settings;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public interface HelmOciRepositorySettings extends DockerRepositorySettings {

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
@JsonSubTypes.Type(value = CondaRepositorySettingsImpl.class, name = "conda"),
@JsonSubTypes.Type(value = PuppetRepositorySettingsImpl.class, name = "puppet"),
@JsonSubTypes.Type(value = HelmRepositorySettingsImpl.class, name = "helm"),
@JsonSubTypes.Type(value = HelmOciRepositorySettingsImpl.class, name = "helmoci"),
@JsonSubTypes.Type(value = GoRepositorySettingsImpl.class, name = "go"),
@JsonSubTypes.Type(value = CargoRepositorySettingsImpl.class, name = "cargo"),
@JsonSubTypes.Type(value = TerraformRepositorySettingsImpl.class, name = "terraform"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
public class FederatedRepositoryBuilderImpl extends NonVirtualRepositoryBuilderBase<FederatedRepositoryBuilder, FederatedRepository> implements FederatedRepositoryBuilder {
private static Set<PackageType> federatedRepositorySupportedTypes = new HashSet<>(Arrays.asList(
bower, cocoapods, cran, conda, debian, docker, gems, generic, gitlfs, gradle, ivy, maven, npm, nuget, opkg, pypi, sbt, vagrant, yum, rpm, composer, conan, chef, puppet, helm, go, cargo, terraform, oci
bower, cocoapods, cran, conda, debian, docker, gems, generic, gitlfs, gradle, ivy, maven, npm, nuget, opkg, pypi, sbt, vagrant, yum, rpm, composer, conan, chef, puppet, helm, helmoci, go, cargo, terraform, oci
));

protected List<FederatedMember> members = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
public class LocalRepositoryBuilderImpl extends NonVirtualRepositoryBuilderBase<LocalRepositoryBuilder, LocalRepository> implements LocalRepositoryBuilder {
private static Set<PackageType> localRepositorySupportedTypes = new HashSet<PackageType>(Arrays.asList(
bower, cocoapods, cran, conda, debian, docker, gems, generic, gitlfs, gradle, ivy, maven, npm, nuget, opkg, pypi, sbt, vagrant, yum, rpm, composer, conan, chef, puppet, helm, go, cargo, terraform, oci
bower, cocoapods, cran, conda, debian, docker, gems, generic, gitlfs, gradle, ivy, maven, npm, nuget, opkg, pypi, sbt, vagrant, yum, rpm, composer, conan, chef, puppet, helm, helmoci, go, cargo, terraform, oci
));

protected LocalRepositoryBuilderImpl() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public enum PackageTypeImpl implements PackageType {
chef,
puppet,
helm,
helmoci,
go,
cargo,
terraform,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
public class RemoteRepositoryBuilderImpl extends NonVirtualRepositoryBuilderBase<RemoteRepositoryBuilder, RemoteRepository> implements RemoteRepositoryBuilder {
private static Set<PackageType> remoteRepositorySupportedTypes = new HashSet<PackageType>(Arrays.asList(
bower, cocoapods, cran, conda, debian, docker, gems, generic, gitlfs, gradle, ivy, maven, npm, nuget, opkg, p2, pypi, sbt, vcs, yum, rpm, composer, conan, chef, puppet, helm, go, cargo, terraform, oci
bower, cocoapods, cran, conda, debian, docker, gems, generic, gitlfs, gradle, ivy, maven, npm, nuget, opkg, p2, pypi, sbt, vcs, yum, rpm, composer, conan, chef, puppet, helm, helmoci, go, cargo, terraform, oci
));

private String url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
public class VirtualRepositoryBuilderImpl extends RepositoryBuilderBase<VirtualRepositoryBuilder, VirtualRepository> implements VirtualRepositoryBuilder {
private static Set<PackageType> virtualRepositorySupportedTypes = new HashSet<PackageType>(Arrays.asList(
bower, cran, conda, docker, debian, gems, generic, gitlfs, gradle, ivy, maven, npm, nuget, p2, pypi, sbt, yum, rpm, composer, conan, chef, puppet, helm, go, terraform, oci
bower, cran, conda, docker, debian, gems, generic, gitlfs, gradle, ivy, maven, npm, nuget, p2, pypi, sbt, yum, rpm, composer, conan, chef, puppet, helm, helmoci, go, terraform, oci
));

private Collection<String> repositories = Collections.emptyList();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.jfrog.artifactory.client.model.repository.settings.impl;

import org.jfrog.artifactory.client.model.PackageType;
import org.jfrog.artifactory.client.model.impl.PackageTypeImpl;
import org.jfrog.artifactory.client.model.repository.settings.OciRepositorySettings;

public class HelmOciRepositorySettingsImpl extends DockerRepositorySettingsImpl implements OciRepositorySettings {
public static String defaultLayout = "simple-default";

public PackageType getPackageType() {
return PackageTypeImpl.helmoci;
}

@Override
public boolean equals(Object o) {
if (!(o instanceof HelmOciRepositorySettingsImpl)) {
return false;
}
return super.equals(o);
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=2.18.0
version=2.18.x-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
package org.jfrog.artifactory.client

import org.hamcrest.CoreMatchers
import org.jfrog.artifactory.client.model.RepositoryType
import org.jfrog.artifactory.client.model.repository.settings.RepositorySettings
import org.jfrog.artifactory.client.model.repository.settings.docker.DockerApiVersion
import org.jfrog.artifactory.client.model.repository.settings.impl.HelmOciRepositorySettingsImpl
import org.testng.annotations.BeforeMethod
import org.testng.annotations.Test

/**
* test that client correctly sends and receives repository configuration with `helmoci` package type
*
*/
class HelmOciPackageTypeRepositoryTests extends BaseRepositoryTests {

HelmOciPackageTypeRepositoryTests() {
remoteRepoUrl = "https://registry-1.docker.io"
}

@Override
RepositorySettings getRepositorySettings(RepositoryType repositoryType) {
def settings = new HelmOciRepositorySettingsImpl()

settings.with {
// local
dockerApiVersion = DockerApiVersion.V2
dockerTagRetention = Math.abs(rnd.nextInt())

// remote
enableTokenAuthentication = rnd.nextBoolean()
listRemoteFolderItems = rnd.nextBoolean()
}

return settings
}

@BeforeMethod
protected void setUp() {
storeArtifactsLocallyInRemoteRepo = true
super.setUp()
}

@Test(groups = "helmOciPackageTypeRepo")
void testOciLocalRepo() {
artifactory.repositories().create(0, localRepo)
def expectedSettings = localRepo.repositorySettings

def resp = artifactory.repository(localRepo.getKey()).get()
assertThat(resp, CoreMatchers.notNullValue())
assertThat(resp.repoLayoutRef, CoreMatchers.is(HelmOciRepositorySettingsImpl.defaultLayout))
resp.getRepositorySettings().with {
assertThat(packageType, CoreMatchers.is(expectedSettings.getPackageType()))
assertThat(repoLayout, CoreMatchers.is(expectedSettings.getRepoLayout()))

// local
assertThat(dockerApiVersion, CoreMatchers.is(expectedSettings.getDockerApiVersion()))
assertThat(dockerTagRetention, CoreMatchers.is(expectedSettings.getDockerTagRetention()))

// remote
assertThat(enableTokenAuthentication, CoreMatchers.is(CoreMatchers.nullValue()))
assertThat(listRemoteFolderItems, CoreMatchers.is(CoreMatchers.nullValue()))
}
}

@Test(groups = "helmOciPackageTypeRepo")
void testOciFederatedRepo() {
artifactory.repositories().create(0, federatedRepo)
def expectedSettings = federatedRepo.repositorySettings

def resp = artifactory.repository(federatedRepo.getKey()).get()
assertThat(resp, CoreMatchers.notNullValue())
assertThat(resp.repoLayoutRef, CoreMatchers.is(HelmOciRepositorySettingsImpl.defaultLayout))
resp.getRepositorySettings().with {
assertThat(packageType, CoreMatchers.is(expectedSettings.getPackageType()))
assertThat(repoLayout, CoreMatchers.is(expectedSettings.getRepoLayout()))

// local
assertThat(dockerApiVersion, CoreMatchers.is(expectedSettings.getDockerApiVersion()))

// remote
assertThat(enableTokenAuthentication, CoreMatchers.is(CoreMatchers.nullValue()))
assertThat(listRemoteFolderItems, CoreMatchers.is(CoreMatchers.nullValue()))
}
}

@Test(groups = "helmOciPackageTypeRepo")
void testOciRemoteRepo() {
artifactory.repositories().create(0, remoteRepo)
def expectedSettings = remoteRepo.repositorySettings

def resp = artifactory.repository(remoteRepo.getKey()).get()
assertThat(resp, CoreMatchers.notNullValue())
assertThat(resp.repoLayoutRef, CoreMatchers.is(HelmOciRepositorySettingsImpl.defaultLayout))
resp.getRepositorySettings().with {
assertThat(packageType, CoreMatchers.is(expectedSettings.getPackageType()))
assertThat(repoLayout, CoreMatchers.is(expectedSettings.getRepoLayout()))

// local
assertThat(dockerApiVersion, CoreMatchers.is(expectedSettings.getDockerApiVersion()))
// always in resp payload

// remote
assertThat(enableTokenAuthentication, CoreMatchers.is(expectedSettings.getEnableTokenAuthentication()))
assertThat(listRemoteFolderItems, CoreMatchers.is(expectedSettings.getListRemoteFolderItems()))
}
}

@Test(groups = "helmOciPackageTypeRepo")
void testDockerVirtualRepo() {
artifactory.repositories().create(0, virtualRepo)
def expectedSettings = virtualRepo.repositorySettings

def resp = artifactory.repository(virtualRepo.getKey()).get()
assertThat(resp, CoreMatchers.notNullValue())
assertThat(resp.repoLayoutRef, CoreMatchers.is(HelmOciRepositorySettingsImpl.defaultLayout))
resp.getRepositorySettings().with {
assertThat(packageType, CoreMatchers.is(expectedSettings.getPackageType()))
assertThat(repoLayout, CoreMatchers.is(expectedSettings.getRepoLayout()))

// local
assertThat(dockerApiVersion, CoreMatchers.is(expectedSettings.getDockerApiVersion()))

// remote
assertThat(enableTokenAuthentication, CoreMatchers.is(CoreMatchers.nullValue()))
assertThat(listRemoteFolderItems, CoreMatchers.is(CoreMatchers.nullValue()))
}
}
}
Loading