fix: pass along storage bucket credential id for sb update job (#4947)

This commit is contained in:
Damian Debkowski authored and GitHub committed 2024-07-22 12:06:35 -04:00
1 parent 59d5f854cb
commit 1be0e5d413
2 files changed
+37 -35

No files matched your search

@@ -5,27 +5,27 @@ begin;
create view update_worker_storage_bucket_credential as
select distinct
sb.scope_id as storage_bucket_scope_id,
sb.name as storage_bucket_name,
sb.description as storage_bucket_description,
sb.bucket_name as storage_bucket_bucket_name,
sb.bucket_prefix as storage_bucket_bucket_prefix,
sb.worker_filter as storage_bucket_worker_filter,
sb.attributes as storage_bucket_attributes,
sb.plugin_id as plugin_id,
sb.public_id,
sb.scope_id,
sb.name,
sb.description,
sb.bucket_name,
sb.bucket_prefix,
sb.worker_filter,
sb.attributes,
sb.version,
sb.plugin_id,
sb.storage_bucket_credential_id,
pl.name as plugin_name,
pl.description as plugin_description,
sbc.storage_bucket_id as storage_bucket_id,
sbcms.secrets_encrypted as ct_secrets,
sbcms.key_id as key_id
from storage_bucket_credential sbc
join storage_plugin_storage_bucket sb
on sbc.storage_bucket_id = sb.public_id
from storage_plugin_storage_bucket sb
join plugin pl
on sb.plugin_id = pl.public_id
left join storage_bucket_credential_managed_secret sbcms
on sbc.private_id = sbcms.private_id;
on sb.storage_bucket_credential_id = sbcms.private_id;
comment on view update_worker_storage_bucket_credential is
'update_worker_storage_bucket_credential is used find workers using storage bucket credentials that need to be updated to the latest version.';
+24 -22
View File
@@ -19,20 +19,21 @@ import (
const UpsertWorkerStorageBucketJobName = "upsert_worker_storage_bucket"
type UpdateStorageBucketCredential struct {
StorageBucketId string `gorm:"primary_key"`
Version int32
CtSecrets []byte
KeyId string
StorageBucketScopeId string
StorageBucketName string
StorageBucketDescription string
StorageBucketBucketName string
StorageBucketBucketPrefix string
StorageBucketWorkerFilter string
StorageBucketAttributes []byte
PublicId string `gorm:"primary_key"`
StorageBucketCredentialId string
ScopeId string
Name string
Description string
BucketName string
BucketPrefix string
WorkerFilter string
Attributes []byte
PluginId string
PluginName string
PluginDescription string
KeyId string
CtSecrets []byte
Version uint32
}
// TableName returns the table name for gorm
@@ -49,23 +50,24 @@ func ToPluginStorageBucket(ctx context.Context, usb *UpdateStorageBucketCredenti
}
sb := &storagebuckets.StorageBucket{
Id: usb.StorageBucketId,
ScopeId: usb.StorageBucketScopeId,
PluginId: usb.PluginId,
Name: wrapperspb.String(usb.StorageBucketBucketName),
Description: wrapperspb.String(usb.StorageBucketDescription),
BucketName: usb.StorageBucketBucketName,
BucketPrefix: usb.StorageBucketBucketPrefix,
WorkerFilter: usb.StorageBucketWorkerFilter,
Id: usb.PublicId,
StorageBucketCredentialId: usb.StorageBucketCredentialId,
ScopeId: usb.ScopeId,
PluginId: usb.PluginId,
Description: wrapperspb.String(usb.Description),
BucketName: usb.BucketName,
BucketPrefix: usb.BucketPrefix,
WorkerFilter: usb.WorkerFilter,
Plugin: &plugins.PluginInfo{
Id: usb.PluginId,
Name: usb.PluginName,
Description: usb.PluginDescription,
},
Version: usb.Version,
}
if usb.StorageBucketAttributes != nil {
if usb.Attributes != nil {
attrs := &structpb.Struct{}
if err := proto.Unmarshal(usb.StorageBucketAttributes, attrs); err != nil {
if err := proto.Unmarshal(usb.Attributes, attrs); err != nil {
return nil, errors.Wrap(ctx, err, op, errors.WithMsg("unable to unmarshal attributes"))
}
sb.Attributes = attrs
@@ -78,7 +80,7 @@ func ToPluginStorageBucket(ctx context.Context, usb *UpdateStorageBucketCredenti
sbc := allocFn()
sbc.SetKeyId(usb.KeyId)
sbc.SetStorageBucketId(usb.StorageBucketId)
sbc.SetStorageBucketId(usb.PublicId)
sbc.SetCtSecrets(usb.CtSecrets)
if sbc.Decrypt(ctx, wrapper) != nil {