@ -69,6 +69,7 @@ var (
sourceBucketSecretKey string
sourceBucketSecretKey string
sourceBucketRegion string
sourceBucketRegion string
sourceBucketInsecure bool
sourceBucketInsecure bool
sourceBucketSecretRef string
)
)
func init ( ) {
func init ( ) {
@ -79,6 +80,7 @@ func init() {
createSourceBucketCmd . Flags ( ) . StringVar ( & sourceBucketSecretKey , "secret-key" , "" , "the bucket secret key" )
createSourceBucketCmd . Flags ( ) . StringVar ( & sourceBucketSecretKey , "secret-key" , "" , "the bucket secret key" )
createSourceBucketCmd . Flags ( ) . StringVar ( & sourceBucketRegion , "region" , "" , "the bucket region" )
createSourceBucketCmd . Flags ( ) . StringVar ( & sourceBucketRegion , "region" , "" , "the bucket region" )
createSourceBucketCmd . Flags ( ) . BoolVar ( & sourceBucketInsecure , "insecure" , false , "for when connecting to a non-TLS S3 HTTP endpoint" )
createSourceBucketCmd . Flags ( ) . BoolVar ( & sourceBucketInsecure , "insecure" , false , "for when connecting to a non-TLS S3 HTTP endpoint" )
createSourceBucketCmd . Flags ( ) . StringVar ( & sourceBucketSecretRef , "secret-ref" , "" , "the name of an existing secret containing credentials" )
createSourceCmd . AddCommand ( createSourceBucketCmd )
createSourceCmd . AddCommand ( createSourceBucketCmd )
}
}
@ -88,7 +90,6 @@ func createSourceBucketCmdRun(cmd *cobra.Command, args []string) error {
return fmt . Errorf ( "Bucket source name is required" )
return fmt . Errorf ( "Bucket source name is required" )
}
}
name := args [ 0 ]
name := args [ 0 ]
secretName := fmt . Sprintf ( "bucket-%s" , name )
if sourceBucketName == "" {
if sourceBucketName == "" {
return fmt . Errorf ( "bucket-name is required" )
return fmt . Errorf ( "bucket-name is required" )
@ -126,6 +127,11 @@ func createSourceBucketCmdRun(cmd *cobra.Command, args []string) error {
} ,
} ,
} ,
} ,
}
}
if sourceHelmSecretRef != "" {
bucket . Spec . SecretRef = & corev1 . LocalObjectReference {
Name : sourceBucketSecretRef ,
}
}
if export {
if export {
return exportBucket ( * bucket )
return exportBucket ( * bucket )
@ -141,6 +147,9 @@ func createSourceBucketCmdRun(cmd *cobra.Command, args []string) error {
logger . Generatef ( "generating Bucket source" )
logger . Generatef ( "generating Bucket source" )
if sourceBucketSecretRef == "" {
secretName := fmt . Sprintf ( "bucket-%s" , name )
secret := corev1 . Secret {
secret := corev1 . Secret {
ObjectMeta : metav1 . ObjectMeta {
ObjectMeta : metav1 . ObjectMeta {
Name : secretName ,
Name : secretName ,
@ -164,6 +173,7 @@ func createSourceBucketCmdRun(cmd *cobra.Command, args []string) error {
}
}
logger . Successf ( "authentication configured" )
logger . Successf ( "authentication configured" )
}
}
}
logger . Actionf ( "applying Bucket source" )
logger . Actionf ( "applying Bucket source" )
namespacedName , err := upsertBucket ( ctx , kubeClient , bucket )
namespacedName , err := upsertBucket ( ctx , kubeClient , bucket )