Skip to content

Commit

Permalink
chore: separate Errata and Pyxis caches and use new config for svc pr…
Browse files Browse the repository at this point in the history
…incipal
  • Loading branch information
vibe13 committed Dec 17, 2024
1 parent 1dd390a commit 27db71e
Show file tree
Hide file tree
Showing 16 changed files with 528 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@
public interface FeatureConfig {

UmbConfig umb();

KerberosServiceConfig kerberos();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2023 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* 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 org.jboss.sbomer.service.feature.sbom.config.features;

import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithDefault;
import io.smallrye.config.WithName;
import jakarta.enterprise.context.ApplicationScoped;

/**
* @author Andrea Vibelli
*/
@ApplicationScoped
@ConfigMapping(prefix = "sbomer.features.kerberos")
public interface KerberosServiceConfig {

@WithDefault("false")
@WithName("enabled")
boolean isEnabled();

ErrataServiceConfig errata();

PyxisServiceConfig pyxis();

interface ErrataServiceConfig {
String servicePrincipalName();
}

interface PyxisServiceConfig {
String servicePrincipalName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.jboss.sbomer.service.feature.sbom.errata.dto.ErrataProduct;
import org.jboss.sbomer.service.feature.sbom.errata.dto.ErrataRelease;
import org.jboss.sbomer.service.feature.sbom.errata.dto.ErrataVariant;
import org.jboss.sbomer.service.feature.sbom.kerberos.Krb5ClientRequestFilter;
import org.jboss.sbomer.service.feature.sbom.kerberos.ErrataKrb5ClientRequestFilter;

import io.quarkus.rest.client.reactive.ClientExceptionMapper;
import io.smallrye.reactive.messaging.annotations.Blocking;
Expand All @@ -60,7 +60,7 @@
@ClientHeaderParam(name = "User-Agent", value = "SBOMer")
@RegisterRestClient(configKey = "errata")
@Path("/api/v1")
@RegisterProvider(Krb5ClientRequestFilter.class)
@RegisterProvider(ErrataKrb5ClientRequestFilter.class)
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public interface ErrataClient {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,11 @@
import org.jboss.sbomer.core.features.sbom.utils.SbomUtils;
import org.jboss.sbomer.service.feature.sbom.errata.ErrataClient;
import org.jboss.sbomer.service.feature.sbom.errata.dto.Errata;
import org.jboss.sbomer.service.feature.sbom.errata.dto.Errata.Details;
import org.jboss.sbomer.service.feature.sbom.errata.dto.ErrataBuildList;
import org.jboss.sbomer.service.feature.sbom.errata.dto.ErrataBuildList.BuildItem;
import org.jboss.sbomer.service.feature.sbom.errata.dto.ErrataBuildList.ProductVersionEntry;
import org.jboss.sbomer.service.feature.sbom.errata.event.AdvisoryEventUtils;
import org.jboss.sbomer.service.feature.sbom.k8s.model.SbomGenerationStatus;
import org.jboss.sbomer.service.feature.sbom.model.RandomStringIdGenerator;
import org.jboss.sbomer.service.feature.sbom.model.RequestEvent;
import org.jboss.sbomer.service.feature.sbom.model.Sbom;
import org.jboss.sbomer.service.feature.sbom.model.SbomGenerationRequest;
Expand Down Expand Up @@ -117,7 +115,7 @@ public void onReleaseAdvisoryEvent(@ObservesAsync AdvisoryReleaseEvent event) {
Map<ProductVersionEntry, List<BuildItem>> advisoryBuildDetails = getAdvisoryBuildDetails(
advisoryRequestConfig.getAdvisoryId());
V1Beta1RequestRecord advisoryManifestsRecord = sbomService
.searchLastSuccessfulAdvisoryRequestRecord(advisoryRequestConfig.getAdvisoryId());
.searchLastSuccessfulAdvisoryRequestRecord(requestEvent.getId(), advisoryRequestConfig.getAdvisoryId());

if (erratum.getDetails().get().getContentTypes().contains("docker")) {

Expand Down Expand Up @@ -491,7 +489,9 @@ private Map<ProductVersionEntry, Set<String>> mapProductVersionToCPEs(

private List<RepositoryCoordinates> getRepositoriesDetails(String nvr) {

PyxisRepositoryDetails repositoriesDetails = pyxisClient.getRepositoriesDetails(nvr);
log.debug("Getting repositories details from Pyxis for NVR '{}'", nvr);
PyxisRepositoryDetails repositoriesDetails = pyxisClient
.getRepositoriesDetails(nvr, PyxisClient.REPOSITORIES_DETAILS_INCLUDES);
return repositoriesDetails.getData()
.stream()
.flatMap(dataSection -> dataSection.getRepositories().stream())
Expand All @@ -515,7 +515,7 @@ private List<RepositoryCoordinates> getRepositoriesDetails(String nvr) {
* accessible without authentication
*/
private PyxisRepository getRepository(String registry, String repository) {
return pyxisClient.getRepository(registry, repository);
return pyxisClient.getRepository(registry, repository, PyxisClient.REPOSITORIES_REGISTRY_INCLUDES);
}

}
Loading

0 comments on commit 27db71e

Please sign in to comment.