-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add pre-install hook that verifies dashboard licenses
Signed-off-by: Burak Sekili <buraksekili@gmail.com>
- Loading branch information
1 parent
7a12edb
commit 14262e1
Showing
5 changed files
with
48 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"tyk/tyk/bootstrap/license/preinstall" | ||
) | ||
|
||
func main() { | ||
err := preinstall.PreHookInstall() | ||
if err != nil { | ||
fmt.Printf("Failed to run pre-hook job, err: %v", err) | ||
os.Exit(1) | ||
} | ||
|
||
fmt.Println("Pre-Hook bootstrapping succeeded, the provided license is valid!") | ||
} |
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,28 @@ | ||
// Package preinstall exposes an API to run necessary operations required in pre-install hook job of bootstrapping. | ||
// While bootstrapping Tyk Stack, users need to provide a valida Tyk License key. | ||
// In the pre-hook installation, the helper functions defined in this package verifies the validity of the license. | ||
package preinstall | ||
|
||
import ( | ||
"errors" | ||
"tyk/tyk/bootstrap/license" | ||
) | ||
|
||
// PreHookInstall runs all required License validity operations that are required in pre-install hook. | ||
func PreHookInstall() error { | ||
dashboardLicenseKey, err := license.GetDashboardLicense() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
licenseIsValid, err := license.ValidateDashboardLicense(dashboardLicenseKey) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if !licenseIsValid { | ||
return errors.New("provided license is invalid") | ||
} | ||
|
||
return nil | ||
} |