-
Notifications
You must be signed in to change notification settings - Fork 220
Dependent resources implementation #785
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
65 changes: 65 additions & 0 deletions
65
...re/src/main/java/io/javaoperatorsdk/operator/api/config/DefaultResourceConfiguration.java
This file contains hidden or 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,65 @@ | ||
package io.javaoperatorsdk.operator.api.config; | ||
|
||
import java.util.Collections; | ||
import java.util.Set; | ||
|
||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
|
||
public class DefaultResourceConfiguration<R extends HasMetadata> | ||
implements ResourceConfiguration<R> { | ||
|
||
private final String labelSelector; | ||
private final Set<String> namespaces; | ||
private final boolean watchAllNamespaces; | ||
private final Class<R> resourceClass; | ||
private ConfigurationService service; | ||
|
||
public DefaultResourceConfiguration(String labelSelector, Class<R> resourceClass, | ||
String... namespaces) { | ||
this(labelSelector, resourceClass, | ||
namespaces != null ? Set.of(namespaces) : Collections.emptySet()); | ||
} | ||
|
||
public DefaultResourceConfiguration(String labelSelector, Class<R> resourceClass, | ||
Set<String> namespaces) { | ||
this.labelSelector = labelSelector; | ||
this.resourceClass = resourceClass; | ||
this.namespaces = namespaces != null ? namespaces : Collections.emptySet(); | ||
this.watchAllNamespaces = this.namespaces.isEmpty(); | ||
} | ||
|
||
@Override | ||
public String getResourceTypeName() { | ||
return ResourceConfiguration.super.getResourceTypeName(); | ||
} | ||
|
||
@Override | ||
public String getLabelSelector() { | ||
return labelSelector; | ||
} | ||
|
||
@Override | ||
public Set<String> getNamespaces() { | ||
return namespaces; | ||
} | ||
|
||
@Override | ||
public boolean watchAllNamespaces() { | ||
return watchAllNamespaces; | ||
} | ||
|
||
@Override | ||
public ConfigurationService getConfigurationService() { | ||
return service; | ||
} | ||
|
||
@Override | ||
public Class<R> getResourceClass() { | ||
return resourceClass; | ||
} | ||
|
||
@Override | ||
public void setConfigurationService(ConfigurationService service) { | ||
this.service = service; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/Dependent.java
This file contains hidden or 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,8 @@ | ||
package io.javaoperatorsdk.operator.api.config; | ||
|
||
public @interface Dependent { | ||
|
||
Class<?> resourceType(); | ||
|
||
Class<? extends DependentResource> type(); | ||
} |
15 changes: 15 additions & 0 deletions
15
...ramework-core/src/main/java/io/javaoperatorsdk/operator/api/config/DependentResource.java
This file contains hidden or 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,15 @@ | ||
package io.javaoperatorsdk.operator.api.config; | ||
|
||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.javaoperatorsdk.operator.api.reconciler.EventSourceContext; | ||
import io.javaoperatorsdk.operator.processing.event.source.EventSource; | ||
|
||
public interface DependentResource<R, P extends HasMetadata> { | ||
default EventSource initEventSource(EventSourceContext<P> context) { | ||
throw new IllegalStateException("Must be implemented if not automatically provided by the SDK"); | ||
}; | ||
|
||
default Class<R> resourceType() { | ||
return (Class<R>) Utils.getFirstTypeArgumentFromInterface(getClass()); | ||
} | ||
} |
This file contains hidden or 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
34 changes: 34 additions & 0 deletions
34
...mework-core/src/main/java/io/javaoperatorsdk/operator/api/config/KubernetesDependent.java
This file contains hidden or 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,34 @@ | ||
package io.javaoperatorsdk.operator.api.config; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Target; | ||
|
||
import static io.javaoperatorsdk.operator.api.reconciler.Constants.EMPTY_STRING; | ||
|
||
@Target({ElementType.TYPE}) | ||
public @interface KubernetesDependent { | ||
|
||
boolean OWNED_DEFAULT = true; | ||
boolean SKIP_UPDATE_DEFAULT = true; | ||
|
||
boolean owned() default OWNED_DEFAULT; | ||
|
||
boolean skipUpdateIfUnchanged() default SKIP_UPDATE_DEFAULT; | ||
|
||
/** | ||
* Specified which namespaces this Controller monitors for custom resources events. If no | ||
* namespace is specified then the controller will monitor all namespaces by default. | ||
* | ||
* @return the list of namespaces this controller monitors | ||
*/ | ||
String[] namespaces() default {}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, the namespaces should not be here probably, should come from a central configuration |
||
|
||
/** | ||
* Optional label selector used to identify the set of custom resources the controller will acc | ||
* upon. The label selector can be made of multiple comma separated requirements that acts as a | ||
* logical AND operator. | ||
* | ||
* @return the label selector | ||
*/ | ||
String labelSelector() default EMPTY_STRING; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.