Files
grafana/pkg/build/daggerbuild/e2e/validate_license.go
Kevin Minehart 13f4cf162e CI: move grafana-build into pkg/build (#105640)
* move grafana-build into pkg/build
2025-05-20 10:48:00 -05:00

32 lines
767 B
Go

package e2e
import (
"context"
"fmt"
"strings"
"dagger.io/dagger"
)
// validateLicense uses the given container and license path to validate the license for each edition (enterprise or oss)
func ValidateLicense(ctx context.Context, service *dagger.Container, licensePath string, enterprise bool) error {
license, err := service.File(licensePath).Contents(ctx)
if err != nil {
return err
}
if enterprise {
if !strings.Contains(license, "Grafana Enterprise") {
return fmt.Errorf("license in package is not the Grafana Enterprise license agreement")
}
return nil
}
if !strings.Contains(license, "GNU AFFERO GENERAL PUBLIC LICENSE") {
return fmt.Errorf("license in package is not the Grafana open-source license agreement")
}
return nil
}