Class AbstractBucketLifecycleManager
- java.lang.Object
-
- com.google.jenkins.plugins.storage.AbstractUpload
-
- com.google.jenkins.plugins.storage.AbstractBucketLifecycleManager
-
- All Implemented Interfaces:
ExtensionPoint
,Describable<AbstractUpload>
,Serializable
- Direct Known Subclasses:
ExpiringBucketLifecycleManager
public abstract class AbstractBucketLifecycleManager extends AbstractUpload
This extension point may be implemented to surface the object lifecycle options available on cloud storage buckets. Generally the expectation is that the UI will ask for the bucket, and surface some additional UI for capturing the lifecycle features of the plugin.This is done by implementing these two overrides:
checkBucket
: Validated the annotations on a pre-existing bucket, returning it if they are satisfactory, and throwing a InvalidAnnotationException if we must update it.decorateBucket
: Annotates either a new or existing bucket with the lifecycle features of the plugin.
AbstractUpload
, but isn't really an upload. You could reason about it as an empty upload to a bucket with special bucket annotation properties.TODO(mattmoor): We should factor out a common AbstractStorageOperation base class that this and AbstractUpload can share. The current entrypoint is benign enough (see "perform").
- See Also:
ExpiringBucketLifecycleManager
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.jenkins.plugins.storage.AbstractUpload
AbstractUpload.UploadSpec
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Constructor Summary
Constructors Constructor Description AbstractBucketLifecycleManager(String bucket, UploadModule module)
Constructs the base bucket OLM plugin from the bucket name and module.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract com.google.api.services.storage.model.Bucket
checkBucket(com.google.api.services.storage.model.Bucket bucket)
This is intended to be an identity function that throws when the input is not adequately annotated.protected abstract com.google.api.services.storage.model.Bucket
decorateBucket(com.google.api.services.storage.model.Bucket bucket)
A hook by which extensions may annotate a new or existing bucket.AbstractBucketLifecycleManagerDescriptor
getDescriptor()
protected AbstractUpload.UploadSpec
getInclusions(Run<?,?> run, FilePath workspace, TaskListener listener)
Implementations override this interface in order to surface the set ofFilePath
s the core logic should upload.protected com.google.api.services.storage.model.Bucket
getOrCreateBucket(com.google.api.services.storage.Storage service, com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials credentials, com.google.jenkins.plugins.util.Executor executor, String bucketName)
This overrides the core implementation to provide additional hooks for decorating storage objects with lifecycle annotations.-
Methods inherited from class com.google.jenkins.plugins.storage.AbstractUpload
all, annotateObject, forResult, getBucket, getDetails, getMetadata, getModule, getPathPrefix, isForFailedJobs, isSharedPublicly, isShowInline, perform, perform, setForFailedJobs, setPathPrefix, setSharedPublicly, setShowInline
-
-
-
-
Constructor Detail
-
AbstractBucketLifecycleManager
public AbstractBucketLifecycleManager(String bucket, @Nullable UploadModule module)
Constructs the base bucket OLM plugin from the bucket name and module.- Parameters:
bucket
- GCS Bucket in which to alter the time to live.module
- Helper class methods to use for execution.
-
-
Method Detail
-
getInclusions
@Nullable protected final AbstractUpload.UploadSpec getInclusions(Run<?,?> run, FilePath workspace, TaskListener listener) throws UploadException
Implementations override this interface in order to surface the set ofFilePath
s the core logic should upload.- Specified by:
getInclusions
in classAbstractUpload
- Parameters:
run
- Current job being run.workspace
- Workspace of node running the job.listener
- Listener for events of this job.- Returns:
- Set of
FilePath
s to upload. - Throws:
UploadException
- If there was an issue fetching the inclusions.- See Also:
for further details.
-
getOrCreateBucket
protected com.google.api.services.storage.model.Bucket getOrCreateBucket(com.google.api.services.storage.Storage service, com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials credentials, com.google.jenkins.plugins.util.Executor executor, String bucketName) throws UploadException
This overrides the core implementation to provide additional hooks for decorating storage objects with lifecycle annotations.- Overrides:
getOrCreateBucket
in classAbstractUpload
- Parameters:
credentials
- The credentials with which to fetch/create the bucketbucketName
- The top-level bucket name to ensure existsservice
- Handle to the GCS API.executor
- Helper class to make calls to the GCS API.- Returns:
- an instance of the named bucket, created or retrieved.
- Throws:
UploadException
- if any issues are encountered
-
checkBucket
protected abstract com.google.api.services.storage.model.Bucket checkBucket(com.google.api.services.storage.model.Bucket bucket) throws InvalidAnnotationException
This is intended to be an identity function that throws when the input is not adequately annotated.- Parameters:
bucket
- the pre-existing bucket whose annotations to validate.- Returns:
- The bucket that was validated.
- Throws:
InvalidAnnotationException
- if not annotated properly.
-
decorateBucket
protected abstract com.google.api.services.storage.model.Bucket decorateBucket(com.google.api.services.storage.model.Bucket bucket)
A hook by which extensions may annotate a new or existing bucket.- Parameters:
bucket
- The bucket to annotate and return.- Returns:
- The bucket to annotate and return.
-
getDescriptor
public AbstractBucketLifecycleManagerDescriptor getDescriptor()
- Specified by:
getDescriptor
in interfaceDescribable<AbstractUpload>
- Overrides:
getDescriptor
in classAbstractUpload
-
-