-
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.
Merge pull request #12 from TykTechnologies/feature/TT-5906/prehook-l…
…icense-validation [TT-5906] Add pre-install package that verifies dashboard license
- Loading branch information
Showing
8 changed files
with
125 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM scratch | ||
|
||
ADD bootstrapapp-pre-install /app/bin/bootstrap-app-pre-install |
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
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/preinstallation" | ||
) | ||
|
||
func main() { | ||
err := preinstallation.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 preinstallation 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 preinstallation | ||
|
||
import ( | ||
"errors" | ||
"tyk/tyk/bootstrap/license" | ||
) | ||
|
||
// PreHookInstall runs all required license validation 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 | ||
} |