fleet/server/datastore/s3/software_installer.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

49 lines
1.3 KiB
Go

package s3
import (
"github.com/fleetdm/fleet/v4/server/config"
)
const softwareInstallersPrefix = "software-installers"
type SoftwareInstallerStore struct {
*commonFileStore
}
// NewSoftwareInstallerStore creates a new instance with the given S3 config.
func NewSoftwareInstallerStore(config config.S3Config) (*SoftwareInstallerStore, error) {
s3store, err := newS3Store(config.SoftwareInstallersToInternalCfg())
if err != nil {
return nil, err
}
return &SoftwareInstallerStore{
&commonFileStore{
s3store: s3store,
pathPrefix: softwareInstallersPrefix,
fileLabel: "software installer",
gcs: isGCS(config.EndpointURL),
},
}, nil
}
// NewTestSoftwareInstallerStore is used in tests.
func NewTestSoftwareInstallerStore(conf config.S3Config) (*SoftwareInstallerStore, error) {
store := &s3store{
bucket: "test-bucket",
cloudFrontConfig: &config.S3CloudFrontConfig{
BaseURL: conf.SoftwareInstallersCloudFrontURL,
SigningPublicKeyID: conf.SoftwareInstallersCloudFrontURLSigningPublicKeyID,
Signer: conf.SoftwareInstallersCloudFrontSigner,
},
}
return &SoftwareInstallerStore{
&commonFileStore{
s3store: store,
pathPrefix: softwareInstallersPrefix,
fileLabel: "software installer",
gcs: isGCS(conf.EndpointURL),
},
}, nil
}