public abstract class AbstractBucketLifecycleManager extends AbstractUpload
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").
ExpiringBucketLifecycleManager
,
Serialized FormAbstractUpload.UploadSpec
ExtensionPoint.LegacyInstancesAreScopedToHudson
Constructor and Description |
---|
AbstractBucketLifecycleManager(String bucket,
UploadModule module)
Constructs the base bucket OLM plugin from the bucket name and module.
|
Modifier and Type | Method and 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 of
FilePath 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.
|
all, annotateObject, forResult, getBucket, getDetails, getMetadata, getModule, getPathPrefix, isForFailedJobs, isSharedPublicly, isShowInline, perform, perform, setForFailedJobs, setPathPrefix, setSharedPublicly, setShowInline
public AbstractBucketLifecycleManager(String bucket, @Nullable UploadModule module)
bucket
- GCS Bucket in which to alter the time to live.module
- Helper class methods to use for execution.@Nullable protected final AbstractUpload.UploadSpec getInclusions(Run<?,?> run, FilePath workspace, TaskListener listener) throws UploadException
FilePath
s the
core logic should upload.getInclusions
in class AbstractUpload
run
- Current job being run.workspace
- Workspace of node running the job.listener
- Listener for events of this job.FilePath
s to upload.UploadException
- If there was an issue fetching the inclusions.for further details.
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
getOrCreateBucket
in class AbstractUpload
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.UploadException
- if any issues are encounteredprotected abstract com.google.api.services.storage.model.Bucket checkBucket(com.google.api.services.storage.model.Bucket bucket) throws InvalidAnnotationException
bucket
- the pre-existing bucket whose annotations to validate.InvalidAnnotationException
- if not annotated properly.protected abstract com.google.api.services.storage.model.Bucket decorateBucket(com.google.api.services.storage.model.Bucket bucket)
bucket
- The bucket to annotate and return.public AbstractBucketLifecycleManagerDescriptor getDescriptor()
getDescriptor
in interface Describable<AbstractUpload>
getDescriptor
in class AbstractUpload
Copyright © 2016–2019. All rights reserved.