fleet/server/datastore/s3/bootstrap_package.go
Lucas Manuel Rodriguez 9297acdf72
Fix GCS for remaining features that use S3 (#32743)
For #32571.

Original PR from the community:
https://github.com/fleetdm/fleet/pull/32573.

Changes on this PR:
- Only setting the checksum algorithm when using GCS as backend (to not
break other S3 backends).
- Changes for carves, bootstrap packages, and software icons which also
use S3.

## Testing

- [X] QA'd all new/changed functionality manually

```sh
FLEET_S3_SOFTWARE_INSTALLERS_BUCKET=some-software-installers-bucket \
FLEET_S3_SOFTWARE_INSTALLERS_ACCESS_KEY_ID=... \
FLEET_S3_SOFTWARE_INSTALLERS_SECRET_ACCESS_KEY=... \
FLEET_S3_SOFTWARE_INSTALLERS_ENDPOINT_URL=https://storage.googleapis.com \
FLEET_S3_SOFTWARE_INSTALLERS_REGION=us \
FLEET_S3_SOFTWARE_INSTALLERS_FORCE_S3_PATH_STYLE=true \
FLEET_S3_CARVES_BUCKET=some-carves-bucket \
FLEET_S3_CARVES_ACCESS_KEY_ID=... \
FLEET_S3_CARVES_SECRET_ACCESS_KEY=... \
FLEET_S3_CARVES_ENDPOINT_URL=https://storage.googleapis.com \
FLEET_S3_CARVES_REGION=us \
FLEET_S3_CARVES_FORCE_S3_PATH_STYLE=true \
./build/fleet serve --dev --dev_license --logging_debug 2>&1 | tee ~/fleet.txt
```
2025-09-09 11:22:04 -03:00

27 lines
718 B
Go

package s3
import "github.com/fleetdm/fleet/v4/server/config"
const bootstrapPackagePrefix = "bootstrap-packages"
type BootstrapPackageStore struct {
*commonFileStore
}
// NewBootstrapPackageStore creates a new instance with the given S3 config.
func NewBootstrapPackageStore(config config.S3Config) (*BootstrapPackageStore, error) {
// bootstrap packages use the same S3 config as software installers
s3store, err := newS3Store(config.SoftwareInstallersToInternalCfg())
if err != nil {
return nil, err
}
return &BootstrapPackageStore{
&commonFileStore{
s3store: s3store,
pathPrefix: bootstrapPackagePrefix,
fileLabel: "bootstrap package",
gcs: isGCS(config.EndpointURL),
},
}, nil
}