-
Notifications
You must be signed in to change notification settings - Fork 81
Move Batch job structs from minio/cmd #135
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
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,213 @@ | ||
| // Copyright (c) 2015-2023 MinIO, Inc. | ||
| // | ||
| // This file is part of MinIO Object Storage stack | ||
| // | ||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU Affero General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
| // | ||
| // This program is distributed in the hope that it will be useful | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU Affero General Public License for more details. | ||
| // | ||
| // You should have received a copy of the GNU Affero General Public License | ||
| // along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| package batch | ||
|
|
||
| import ( | ||
| "context" | ||
| "time" | ||
|
|
||
| miniogo "github.com/minio/minio-go/v7" | ||
| "github.com/minio/pkg/v3/xtime" | ||
| ) | ||
|
|
||
| // BatchJobRequest to start batch job | ||
| type BatchJobRequest struct { | ||
| ID string `yaml:"-" json:"name"` | ||
| User string `yaml:"-" json:"user"` | ||
| Started time.Time `yaml:"-" json:"started"` | ||
| Replicate *BatchJobReplicateV1 `yaml:"replicate" json:"replicate"` | ||
| KeyRotate *BatchJobKeyRotateV1 `yaml:"keyrotate" json:"keyrotate"` | ||
| Expire *BatchJobExpire `yaml:"expire" json:"expire"` | ||
| ctx context.Context `msg:"-"` | ||
| } | ||
|
|
||
| // BatchJobReplicateV1 v1 of batch job replication | ||
| type BatchJobReplicateV1 struct { | ||
| APIVersion string `yaml:"apiVersion" json:"apiVersion"` | ||
| Flags BatchJobReplicateFlags `yaml:"flags" json:"flags"` | ||
| Target BatchJobReplicateTarget `yaml:"target" json:"target"` | ||
| Source BatchJobReplicateSource `yaml:"source" json:"source"` | ||
|
|
||
| clnt *miniogo.Core `msg:"-"` | ||
| } | ||
|
|
||
| // BatchJobReplicateFlags various configurations for replication job definition currently includes | ||
| type BatchJobReplicateFlags struct { | ||
| Filter BatchReplicateFilter `yaml:"filter" json:"filter"` | ||
| Notify BatchJobNotification `yaml:"notify" json:"notify"` | ||
| Retry BatchJobRetry `yaml:"retry" json:"retry"` | ||
| } | ||
|
|
||
| // BatchReplicateFilter holds all the filters currently supported for batch replication | ||
| type BatchReplicateFilter struct { | ||
| NewerThan xtime.Duration `yaml:"newerThan,omitempty" json:"newerThan"` | ||
| OlderThan xtime.Duration `yaml:"olderThan,omitempty" json:"olderThan"` | ||
| CreatedAfter time.Time `yaml:"createdAfter,omitempty" json:"createdAfter"` | ||
| CreatedBefore time.Time `yaml:"createdBefore,omitempty" json:"createdBefore"` | ||
| Tags []BatchJobKV `yaml:"tags,omitempty" json:"tags"` | ||
| Metadata []BatchJobKV `yaml:"metadata,omitempty" json:"metadata"` | ||
| } | ||
|
|
||
| // BatchJobKV is a key-value data type which supports wildcard matching | ||
| type BatchJobKV struct { | ||
| line, col int | ||
| Key string `yaml:"key" json:"key"` | ||
| Value string `yaml:"value" json:"value"` | ||
| } | ||
|
|
||
| // BatchJobNotification stores notification endpoint and token information. | ||
| // Used by batch jobs to notify of their status. | ||
| type BatchJobNotification struct { | ||
| line, col int | ||
| Endpoint string `yaml:"endpoint" json:"endpoint"` | ||
| Token string `yaml:"token" json:"token"` | ||
| } | ||
|
|
||
| // BatchJobRetry stores retry configuration used in the event of failures. | ||
| type BatchJobRetry struct { | ||
| line, col int | ||
| Attempts int `yaml:"attempts" json:"attempts"` // number of retry attempts | ||
| Delay time.Duration `yaml:"delay" json:"delay"` // delay between each retries | ||
| } | ||
|
|
||
| // BatchJobReplicateTarget describes target element of the replication job that receives | ||
| // the filtered data from source | ||
| type BatchJobReplicateTarget struct { | ||
| Type BatchJobReplicateResourceType `yaml:"type" json:"type"` | ||
| Bucket string `yaml:"bucket" json:"bucket"` | ||
| Prefix string `yaml:"prefix" json:"prefix"` | ||
| Endpoint string `yaml:"endpoint" json:"endpoint"` | ||
| Path string `yaml:"path" json:"path"` | ||
| Creds BatchJobReplicateCredentials `yaml:"credentials" json:"credentials"` | ||
| } | ||
|
|
||
| // BatchJobReplicateResourceType defines the type of batch jobs | ||
| type BatchJobReplicateResourceType string | ||
|
|
||
| // BatchJobReplicateCredentials access credentials for batch replication it may | ||
| // be either for target or source. | ||
| type BatchJobReplicateCredentials struct { | ||
| AccessKey string `xml:"AccessKeyId" json:"accessKey,omitempty" yaml:"accessKey"` | ||
| SecretKey string `xml:"SecretAccessKey" json:"secretKey,omitempty" yaml:"secretKey"` | ||
| SessionToken string `xml:"SessionToken" json:"sessionToken,omitempty" yaml:"sessionToken"` | ||
| } | ||
|
|
||
| // BatchJobReplicateSource describes source element of the replication job that is | ||
| // the source of the data for the target | ||
| type BatchJobReplicateSource struct { | ||
| Type BatchJobReplicateResourceType `yaml:"type" json:"type"` | ||
| Bucket string `yaml:"bucket" json:"bucket"` | ||
| Prefix BatchJobPrefix `yaml:"prefix" json:"prefix"` | ||
| Endpoint string `yaml:"endpoint" json:"endpoint"` | ||
| Path string `yaml:"path" json:"path"` | ||
| Creds BatchJobReplicateCredentials `yaml:"credentials" json:"credentials"` | ||
| Snowball BatchJobSnowball `yaml:"snowball" json:"snowball"` | ||
| } | ||
|
|
||
| // BatchJobPrefix - to support prefix field yaml unmarshalling with string or slice of strings | ||
| type BatchJobPrefix []string | ||
|
|
||
| // BatchJobSnowball describes the snowball feature when replicating objects from a local source to a remote target | ||
| type BatchJobSnowball struct { | ||
| line, col int | ||
| Disable *bool `yaml:"disable" json:"disable"` | ||
| Batch *int `yaml:"batch" json:"batch"` | ||
| InMemory *bool `yaml:"inmemory" json:"inmemory"` | ||
| Compress *bool `yaml:"compress" json:"compress"` | ||
| SmallerThan *string `yaml:"smallerThan" json:"smallerThan"` | ||
| SkipErrs *bool `yaml:"skipErrs" json:"skipErrs"` | ||
| } | ||
|
|
||
| // BatchJobKeyRotateV1 v1 of batch key rotation job | ||
| type BatchJobKeyRotateV1 struct { | ||
| APIVersion string `yaml:"apiVersion" json:"apiVersion"` | ||
| Flags BatchJobKeyRotateFlags `yaml:"flags" json:"flags"` | ||
| Bucket string `yaml:"bucket" json:"bucket"` | ||
| Prefix string `yaml:"prefix" json:"prefix"` | ||
| Encryption BatchJobKeyRotateEncryption `yaml:"encryption" json:"encryption"` | ||
| } | ||
|
|
||
| // BatchJobKeyRotateFlags various configurations for replication job definition currently includes | ||
| type BatchJobKeyRotateFlags struct { | ||
| Filter BatchKeyRotateFilter `yaml:"filter" json:"filter"` | ||
| Notify BatchJobNotification `yaml:"notify" json:"notify"` | ||
| Retry BatchJobRetry `yaml:"retry" json:"retry"` | ||
| } | ||
|
|
||
| // BatchKeyRotateFilter holds all the filters currently supported for batch replication | ||
| type BatchKeyRotateFilter struct { | ||
| NewerThan time.Duration `yaml:"newerThan,omitempty" json:"newerThan"` | ||
| OlderThan time.Duration `yaml:"olderThan,omitempty" json:"olderThan"` | ||
| CreatedAfter time.Time `yaml:"createdAfter,omitempty" json:"createdAfter"` | ||
| CreatedBefore time.Time `yaml:"createdBefore,omitempty" json:"createdBefore"` | ||
| Tags []BatchJobKV `yaml:"tags,omitempty" json:"tags"` | ||
| Metadata []BatchJobKV `yaml:"metadata,omitempty" json:"metadata"` | ||
| KMSKeyID string `yaml:"kmskeyid" json:"kmskey"` | ||
| } | ||
|
|
||
| // BatchJobKeyRotateEncryption defines key rotation encryption options passed | ||
| type BatchJobKeyRotateEncryption struct { | ||
| Type BatchKeyRotationType `yaml:"type" json:"type"` | ||
| Key string `yaml:"key" json:"key"` | ||
| Context string `yaml:"context" json:"context"` | ||
| kmsContext map[string]string `msg:"-"` | ||
| } | ||
|
|
||
| // BatchKeyRotationType defines key rotation type | ||
| type BatchKeyRotationType string | ||
|
|
||
| // BatchJobExpire represents configuration parameters for a batch expiration | ||
| // job typically supplied in yaml form | ||
| type BatchJobExpire struct { | ||
| line, col int | ||
| APIVersion string `yaml:"apiVersion" json:"apiVersion"` | ||
| Bucket string `yaml:"bucket" json:"bucket"` | ||
| Prefix BatchJobPrefix `yaml:"prefix" json:"prefix"` | ||
| NotificationCfg BatchJobNotification `yaml:"notify" json:"notify"` | ||
| Retry BatchJobRetry `yaml:"retry" json:"retry"` | ||
| Rules []BatchJobExpireFilter `yaml:"rules" json:"rules"` | ||
| } | ||
|
|
||
| // BatchJobExpireFilter holds all the filters currently supported for batch replication | ||
| type BatchJobExpireFilter struct { | ||
| line, col int | ||
| OlderThan xtime.Duration `yaml:"olderThan,omitempty" json:"olderThan"` | ||
| CreatedBefore *time.Time `yaml:"createdBefore,omitempty" json:"createdBefore"` | ||
| Tags []BatchJobKV `yaml:"tags,omitempty" json:"tags"` | ||
| Metadata []BatchJobKV `yaml:"metadata,omitempty" json:"metadata"` | ||
| Size BatchJobSizeFilter `yaml:"size" json:"size"` | ||
| Type string `yaml:"type" json:"type"` | ||
| Name string `yaml:"name" json:"name"` | ||
| Purge BatchJobExpirePurge `yaml:"purge" json:"purge"` | ||
| } | ||
|
|
||
| // BatchJobSizeFilter supports size based filters - LesserThan and GreaterThan | ||
| type BatchJobSizeFilter struct { | ||
| line, col int | ||
| UpperBound BatchJobSize `yaml:"lessThan" json:"lessThan"` | ||
| LowerBound BatchJobSize `yaml:"greaterThan" json:"greaterThan"` | ||
| } | ||
|
|
||
| // BatchJobExpirePurge type accepts non-negative versions to be retained | ||
| type BatchJobExpirePurge struct { | ||
| line, col int | ||
| RetainVersions int `yaml:"retainVersions" json:"retainVersions"` | ||
| } | ||
|
|
||
| // BatchJobSize supports humanized byte values in yaml files type BatchJobSize uint64 | ||
| type BatchJobSize int64 | ||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no reason to move this to a sub-folder? what is the reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh I see this is needed for external usage? the best place for this is in
madmin-gonot in this project @SSushmitha8Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want both minio (remove existing structs in minio) and aistor to point to these same structs @harshavardhana , if we have these in madmin-go then there would be circular dependency