Skip to content

Commit

Permalink
refactor(kubernetes): Replace lombok annotation with explicit field (#…
Browse files Browse the repository at this point in the history
…4816)

The Lombok Slf4j annotation is just a tiny shortcut for creating the
following:
private static final Logger log = LoggerFactory.getLogger(MyClass.class)

It seems like this confused some static analysis tools (ex: error-prone);
given that the benefit of using this annotation instead of just writing
the field is small, let's just stop using that annotation.

In some places we weren't using the logger at all, so I've just deleted
the annotation without adding the field.
  • Loading branch information
ezimanyi committed Aug 19, 2020
1 parent 356da2f commit fbc4300
Show file tree
Hide file tree
Showing 46 changed files with 104 additions and 92 deletions.
Expand Up @@ -42,11 +42,12 @@
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import lombok.Value;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@ParametersAreNonnullByDefault
@Slf4j
public class ArtifactReplacer {
private static final Logger log = LoggerFactory.getLogger(ArtifactReplacer.class);
private static final ObjectMapper mapper = new ObjectMapper();
private static final Configuration configuration =
Configuration.builder()
Expand Down
Expand Up @@ -27,10 +27,12 @@
import java.util.Optional;
import java.util.OptionalInt;
import javax.annotation.Nonnull;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Slf4j
final class KubernetesVersionedArtifactConverter extends KubernetesArtifactConverter {
private static final Logger log =
LoggerFactory.getLogger(KubernetesVersionedArtifactConverter.class);
static final KubernetesVersionedArtifactConverter INSTANCE =
new KubernetesVersionedArtifactConverter();

Expand Down
Expand Up @@ -40,11 +40,13 @@
import javax.annotation.Nullable;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@NonnullByDefault
@Slf4j
public final class Replacer {
private static final Logger log = LoggerFactory.getLogger(Replacer.class);

private final KubernetesArtifactType type;
private final JsonPath findPath;
private final Function<Artifact, JsonPath> replacePathSupplier;
Expand Down
Expand Up @@ -29,10 +29,11 @@
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Slf4j
public class Keys {
private static final Logger log = LoggerFactory.getLogger(Keys.class);
/**
* Keys are split into "logical" and "infrastructure" kinds. "logical" keys are for spinnaker
* groupings that exist by naming/moniker convention, whereas "infrastructure" keys correspond to
Expand Down
Expand Up @@ -21,15 +21,13 @@
import com.netflix.spinnaker.cats.agent.AgentSchedulerAware;
import com.netflix.spinnaker.cats.provider.Provider;
import com.netflix.spinnaker.clouddriver.kubernetes.KubernetesCloudProvider;
import groovy.util.logging.Slf4j;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.ConcurrentHashMap;
import lombok.Data;
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
@Slf4j
@Data
public class KubernetesV2Provider extends AgentSchedulerAware implements Provider {
public static final String PROVIDER_NAME = KubernetesCloudProvider.ID;
Expand Down
Expand Up @@ -28,10 +28,12 @@
import java.util.*;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Slf4j
public class KubernetesV2ProviderSynchronizable implements CredentialsInitializerSynchronizable {
private static final Logger log =
LoggerFactory.getLogger(KubernetesV2ProviderSynchronizable.class);

private final KubernetesV2Provider kubernetesV2Provider;
private final AccountCredentialsRepository accountCredentialsRepository;
Expand Down
Expand Up @@ -44,10 +44,11 @@
import java.util.concurrent.TimeUnit;
import javax.annotation.ParametersAreNonnullByDefault;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Slf4j
public class KubernetesCacheDataConverter {
private static final Logger log = LoggerFactory.getLogger(KubernetesCacheDataConverter.class);
private static final ObjectMapper mapper = new ObjectMapper();
private static final JSON json = new JSON();
// TODO(lwander): make configurable
Expand Down
Expand Up @@ -29,9 +29,7 @@
import java.util.Collection;
import java.util.List;
import java.util.stream.Stream;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class KubernetesCoreCachingAgent extends KubernetesV2OnDemandCachingAgent {
public KubernetesCoreCachingAgent(
KubernetesNamedAccountCredentials namedAccountCredentials,
Expand Down
Expand Up @@ -27,9 +27,7 @@
import com.netflix.spinnaker.cats.agent.AgentDataType;
import com.netflix.spinnaker.clouddriver.kubernetes.description.manifest.KubernetesKind;
import com.netflix.spinnaker.clouddriver.kubernetes.security.KubernetesNamedAccountCredentials;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class KubernetesUnregisteredCustomResourceCachingAgent
extends KubernetesV2OnDemandCachingAgent {
public KubernetesUnregisteredCustomResourceCachingAgent(
Expand Down
Expand Up @@ -52,11 +52,13 @@
import java.util.stream.Stream;
import javax.annotation.Nonnull;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Slf4j
public abstract class KubernetesV2CachingAgent
implements AgentIntervalAware, CachingAgent, AccountAware {
private static final Logger log = LoggerFactory.getLogger(KubernetesV2CachingAgent.class);

@Getter @Nonnull protected final String accountName;
protected final Registry registry;
protected final KubernetesCredentials credentials;
Expand Down
Expand Up @@ -31,12 +31,10 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class KubernetesV2CachingAgentDispatcher {
private final ObjectMapper objectMapper;
private final Registry registry;
Expand Down
Expand Up @@ -43,11 +43,12 @@
import java.util.*;
import java.util.stream.Collectors;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Slf4j
public abstract class KubernetesV2OnDemandCachingAgent extends KubernetesV2CachingAgent
implements OnDemandAgent {
private static final Logger log = LoggerFactory.getLogger(KubernetesV2OnDemandCachingAgent.class);
@Getter protected final OnDemandMetricsSupport metricsSupport;

protected static final String ON_DEMAND_TYPE = "onDemand";
Expand Down
Expand Up @@ -38,11 +38,12 @@
import java.util.stream.Collectors;
import javax.validation.constraints.Null;
import lombok.Value;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Slf4j
@Value
public final class KubernetesV2Instance implements Instance, KubernetesResource {
private static final Logger log = LoggerFactory.getLogger(KubernetesV2Instance.class);
private final List<Map<String, Object>> health;
private final String account;
// An implementor of the Instance interface is implicitly expected to return a globally-unique ID
Expand Down
Expand Up @@ -34,12 +34,13 @@
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import lombok.Value;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Slf4j
@Value
public final class KubernetesV2LoadBalancer
implements KubernetesResource, LoadBalancer, LoadBalancerProvider.Details {
private static final Logger log = LoggerFactory.getLogger(KubernetesV2LoadBalancer.class);
private final Set<LoadBalancerServerGroup> serverGroups;
private final String account;
private final String name;
Expand Down
Expand Up @@ -55,11 +55,12 @@
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.Value;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Slf4j
@Value
public final class KubernetesV2SecurityGroup implements KubernetesResource, SecurityGroup {
private static final Logger log = LoggerFactory.getLogger(KubernetesV2SecurityGroup.class);
private static final ImmutableSet<KubernetesApiVersion> SUPPORTED_API_VERSIONS =
ImmutableSet.of(EXTENSIONS_V1BETA1, NETWORKING_K8S_IO_V1BETA1, NETWORKING_K8S_IO_V1);

Expand Down
Expand Up @@ -53,11 +53,12 @@
import java.util.stream.Collectors;
import javax.validation.constraints.Null;
import lombok.Value;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Slf4j
@Value
public final class KubernetesV2ServerGroup implements KubernetesResource, ServerGroup {
private static final Logger log = LoggerFactory.getLogger(KubernetesV2ServerGroup.class);
private final boolean disabled;
private final Set<KubernetesV2Instance> instances;
private final Set<String> loadBalancers;
Expand Down
Expand Up @@ -33,12 +33,13 @@
import java.util.Set;
import java.util.stream.Collectors;
import lombok.Value;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Slf4j
@Value
public final class KubernetesV2ServerGroupManager
implements KubernetesResource, ServerGroupManager {
private static final Logger log = LoggerFactory.getLogger(KubernetesV2ServerGroupManager.class);
// private final KubernetesManifest manifest;
private final String account;
private final Set<KubernetesV2ServerGroupSummary> serverGroups;
Expand Down
Expand Up @@ -47,13 +47,11 @@
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Stream;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@NonnullByDefault
@Slf4j
class KubernetesCacheUtils {
private final Cache cache;
private final KubernetesSpinnakerKindMap kindMap;
Expand Down
Expand Up @@ -44,13 +44,14 @@
import java.util.concurrent.Future;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class KubernetesManifestProvider {
private static final Logger log = LoggerFactory.getLogger(KubernetesManifestProvider.class);
private final KubernetesCacheUtils cacheUtils;
private final KubernetesAccountResolver accountResolver;
private final ExecutorService executorService =
Expand Down
Expand Up @@ -34,14 +34,15 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nonnull;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class KubernetesV2InstanceProvider
implements InstanceProvider<KubernetesV2Instance, List<ContainerLog>> {
private static final Logger log = LoggerFactory.getLogger(KubernetesV2InstanceProvider.class);
private final KubernetesCacheUtils cacheUtils;
private final KubernetesAccountResolver accountResolver;

Expand Down
Expand Up @@ -40,13 +40,11 @@
import java.util.Set;
import java.util.stream.Collectors;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.NotImplementedException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class KubernetesV2LoadBalancerProvider
implements LoadBalancerProvider<KubernetesV2LoadBalancer> {
private final KubernetesCacheUtils cacheUtils;
Expand Down
Expand Up @@ -45,13 +45,14 @@
import java.util.stream.Stream;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class KubernetesV2SearchProvider implements SearchProvider {
private static final Logger log = LoggerFactory.getLogger(KubernetesV2SearchProvider.class);
private final KubernetesCacheUtils cacheUtils;
private final ObjectMapper mapper;
private final KubernetesSpinnakerKindMap kindMap;
Expand Down
Expand Up @@ -29,12 +29,10 @@
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class KubernetesV2SecurityGroupProvider
implements SecurityGroupProvider<KubernetesV2SecurityGroup> {
private final KubernetesCacheUtils cacheUtils;
Expand Down
Expand Up @@ -25,7 +25,8 @@
import com.netflix.spinnaker.kork.web.exceptions.NotFoundException;
import java.util.List;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PreAuthorize;
Expand All @@ -35,10 +36,10 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/manifests")
public class ManifestController {
private static final Logger log = LoggerFactory.getLogger(ManifestController.class);
final KubernetesManifestProvider manifestProvider;

final RequestQueue requestQueue;
Expand Down
Expand Up @@ -27,10 +27,8 @@
import java.util.Objects;
import javax.annotation.Nonnull;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

@Getter
@Slf4j
public class KubernetesResourceProperties {
@Nonnull private final KubernetesHandler handler;
private final boolean versioned;
Expand Down
Expand Up @@ -24,11 +24,9 @@
import javax.annotation.ParametersAreNonnullByDefault;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

@EqualsAndHashCode
@ParametersAreNonnullByDefault
@Slf4j
public class KubernetesKindProperties {
public static List<KubernetesKindProperties> getGlobalKindProperties() {
return ImmutableList.of(
Expand Down
Expand Up @@ -32,12 +32,13 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Slf4j
public class KubernetesManifest extends HashMap<String, Object> {
private static final Logger log = LoggerFactory.getLogger(KubernetesManifest.class);
private static final ObjectMapper mapper = new ObjectMapper();

@Nullable private KubernetesKind computedKind;
Expand Down

0 comments on commit fbc4300

Please sign in to comment.