2022-10-15 16:41:07 +00:00
|
|
|
package bootstrap
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2023-08-05 21:53:17 +00:00
|
|
|
"isle/garage"
|
2022-10-15 16:41:07 +00:00
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
"github.com/minio/minio-go/v7"
|
|
|
|
)
|
|
|
|
|
2024-06-17 20:15:28 +00:00
|
|
|
// Paths within garage's global bucket.
|
|
|
|
//
|
|
|
|
// TODO this is getting moved into daemon package.
|
2022-10-15 16:41:07 +00:00
|
|
|
const (
|
|
|
|
garageGlobalBucketBootstrapHostsDirPath = "bootstrap/hosts"
|
|
|
|
)
|
|
|
|
|
2024-06-10 16:56:36 +00:00
|
|
|
// RemoveGarageBootstrapHost removes the <hostname>.json.signed for the given
|
2022-10-29 19:11:40 +00:00
|
|
|
// host from garage.
|
2022-10-15 16:41:07 +00:00
|
|
|
//
|
|
|
|
// The given client should be for the global bucket.
|
|
|
|
func RemoveGarageBootstrapHost(
|
|
|
|
ctx context.Context, client garage.S3APIClient, hostName string,
|
|
|
|
) error {
|
|
|
|
|
2022-10-29 19:11:40 +00:00
|
|
|
filePath := filepath.Join(
|
|
|
|
garageGlobalBucketBootstrapHostsDirPath,
|
2024-06-10 16:56:36 +00:00
|
|
|
hostName+".json.signed",
|
2022-10-29 19:11:40 +00:00
|
|
|
)
|
2022-10-15 16:41:07 +00:00
|
|
|
|
|
|
|
return client.RemoveObject(
|
|
|
|
ctx, garage.GlobalBucket, filePath,
|
|
|
|
minio.RemoveObjectOptions{},
|
|
|
|
)
|
|
|
|
}
|