Skip to content

Commit

Permalink
Merge branch 'master' into issue-6912
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmcintosh authored Jan 29, 2024
2 parents 35e9557 + caabf08 commit 5056748
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 12 deletions.
1 change: 1 addition & 0 deletions kork-credentials-api/kork-credentials-api.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ apply from: "$rootDir/gradle/lombok.gradle"

dependencies {
implementation(platform(project(":spinnaker-dependencies")))
api project(":kork-plugins-api")
implementation project(":kork-annotations")
implementation project(":kork-exceptions")
implementation 'javax.annotation:javax.annotation-api'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@

package com.netflix.spinnaker.credentials;

import com.netflix.spinnaker.kork.plugins.api.internal.SpinnakerExtensionPoint;

/**
* After {@link Credentials} have been parsed, they can be activated, refreshed, or retired - e.g.
* adding agents. This happens before credentials are added or updated in the {@link
* CredentialsRepository} and after credentials are removed from the {@link CredentialsRepository}.
*
* @param <T>
*/
public interface CredentialsLifecycleHandler<T extends Credentials> {
public interface CredentialsLifecycleHandler<T extends Credentials>
extends SpinnakerExtensionPoint {

/**
* Credentials have been added. This is called before credentials are available in {@link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.netflix.spinnaker.credentials;

import com.netflix.spinnaker.kork.plugins.api.internal.SpinnakerExtensionPoint;
import java.util.Set;
import javax.annotation.Nullable;

Expand All @@ -24,7 +25,7 @@
*
* @param <T>
*/
public interface CredentialsRepository<T extends Credentials> {
public interface CredentialsRepository<T extends Credentials> extends SpinnakerExtensionPoint {
/**
* @param name
* @return Credentials with the given name or null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
import javax.annotation.PostConstruct;
import lombok.Getter;

public abstract class AbstractCredentialsLoader<T extends Credentials> {
public abstract class AbstractCredentialsLoader<T extends Credentials>
implements CredentialsLoader<T> {
@Getter protected final CredentialsRepository<T> credentialsRepository;

public AbstractCredentialsLoader(CredentialsRepository<T> credentialsRepository) {
Expand All @@ -34,5 +35,6 @@ public AbstractCredentialsLoader(CredentialsRepository<T> credentialsRepository)
* thereafter.
*/
@PostConstruct
@Override
public abstract void load();
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.netflix.spinnaker.credentials.definition;

import com.netflix.spinnaker.kork.plugins.api.internal.SpinnakerExtensionPoint;
import java.util.List;

/**
Expand All @@ -24,6 +25,7 @@
*
* @param <T>
*/
public interface CredentialsDefinitionSource<T extends CredentialsDefinition> {
public interface CredentialsDefinitionSource<T extends CredentialsDefinition>
extends SpinnakerExtensionPoint {
List<T> getCredentialsDefinitions();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2023 Apple Inc.
*
* 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.netflix.spinnaker.credentials.definition;

import com.netflix.spinnaker.credentials.Credentials;
import com.netflix.spinnaker.credentials.CredentialsRepository;
import com.netflix.spinnaker.kork.plugins.api.internal.SpinnakerExtensionPoint;

public interface CredentialsLoader<T extends Credentials> extends SpinnakerExtensionPoint {
CredentialsRepository<T> getCredentialsRepository();

void load();
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.netflix.spinnaker.credentials.definition;

import com.netflix.spinnaker.credentials.Credentials;
import com.netflix.spinnaker.kork.plugins.api.internal.SpinnakerExtensionPoint;
import javax.annotation.Nullable;

/**
Expand All @@ -25,7 +26,8 @@
* @param <T>
* @param <U>
*/
public interface CredentialsParser<T extends CredentialsDefinition, U extends Credentials> {
public interface CredentialsParser<T extends CredentialsDefinition, U extends Credentials>
extends SpinnakerExtensionPoint {
/** Parses a definition into credentials. Can return null if the definition is to be ignored. */
@Nullable
U parse(T credentials);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.netflix.spinnaker.credentials.poller;

import com.netflix.spinnaker.credentials.Credentials;
import com.netflix.spinnaker.credentials.definition.AbstractCredentialsLoader;
import com.netflix.spinnaker.credentials.definition.CredentialsLoader;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

Expand All @@ -34,7 +34,7 @@
@Slf4j
@RequiredArgsConstructor
public class Poller<T extends Credentials> implements Runnable {
private final AbstractCredentialsLoader<T> credentialsLoader;
private final CredentialsLoader<T> credentialsLoader;

public void run() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,23 @@

package com.netflix.spinnaker.credentials.poller;

import com.netflix.spinnaker.credentials.definition.AbstractCredentialsLoader;
import java.util.List;
import com.netflix.spinnaker.credentials.Credentials;
import com.netflix.spinnaker.credentials.definition.CredentialsLoader;
import com.netflix.spinnaker.kork.annotations.NonnullByDefault;
import java.util.concurrent.TimeUnit;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.scheduling.support.PeriodicTrigger;

@EnableConfigurationProperties(PollerConfigurationProperties.class)
@RequiredArgsConstructor
@Slf4j
@NonnullByDefault
public class PollerConfiguration implements SchedulingConfigurer {
private final PollerConfigurationProperties config;
private final List<AbstractCredentialsLoader<?>> pollers;
private final ObjectProvider<CredentialsLoader<? extends Credentials>> pollers;

@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
Expand Down

0 comments on commit 5056748

Please sign in to comment.