-
Notifications
You must be signed in to change notification settings - Fork 847
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3078 from redpanda-data/license-package
Add public license package
- Loading branch information
Showing
3 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2024 Redpanda Data, Inc. | ||
// | ||
// Licensed as a Redpanda Enterprise file under the Redpanda Community | ||
// License (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// https://github.com/redpanda-data/connect/blob/main/licenses/rcl.md | ||
|
||
package license | ||
|
||
import ( | ||
"github.com/redpanda-data/benthos/v4/public/service" | ||
|
||
"github.com/redpanda-data/connect/v4/internal/license" | ||
) | ||
|
||
// LocateLicenseOptBuilder represents options specified for a license locator. | ||
type LocateLicenseOptBuilder struct { | ||
c license.Config | ||
} | ||
|
||
// LocateLicenseOptFunc defines an option to pass through the LocateLicense | ||
// function call in order to customize its behavior. | ||
type LocateLicenseOptFunc func(*LocateLicenseOptBuilder) | ||
|
||
// LocateLicense attempts to locate a Redpanda Enteprise license from the | ||
// environment and, if successful, enriches the provided resources with | ||
// information of this license that enterprise components may reference. | ||
func LocateLicense(res *service.Resources, opts ...LocateLicenseOptFunc) { | ||
optBuilder := LocateLicenseOptBuilder{} | ||
for _, o := range opts { | ||
o(&optBuilder) | ||
} | ||
license.RegisterService(res, optBuilder.c) | ||
} | ||
|
||
// StoreCustomLicenseBytes attempts to parse a Redpanda Enterprise license | ||
// from a slice of bytes and, if successful, stores it within the provided | ||
// resources pointer for enterprise components to reference. | ||
func StoreCustomLicenseBytes(res *service.Resources, licenseBytes []byte) error { | ||
return license.InjectCustomLicenseBytes(res, licenseBytes) | ||
} |