-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(naming): Rename Trust Engine to System Trust (#5217)
* rename package * make unexported * rename all occurrences --------- Co-authored-by: Gulom Alimov <gulomjon.alimov@sap.com>
- Loading branch information
Showing
10 changed files
with
111 additions
and
112 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,66 @@ | ||
package config | ||
|
||
import ( | ||
"errors" | ||
|
||
piperhttp "github.com/SAP/jenkins-library/pkg/http" | ||
"github.com/SAP/jenkins-library/pkg/log" | ||
"github.com/SAP/jenkins-library/pkg/systemtrust" | ||
) | ||
|
||
const RefTypeSystemTrustSecret = "systemTrustSecret" | ||
|
||
// resolveAllSystemTrustReferences retrieves all the step's secrets from the System Trust | ||
func resolveAllSystemTrustReferences(config *StepConfig, params []StepParameters, systemTrustConfiguration systemtrust.Configuration, client *piperhttp.Client) { | ||
for _, param := range params { | ||
if ref := param.GetReference(RefTypeSystemTrustSecret); ref != nil { | ||
if config.Config[param.Name] == "" { | ||
log.Entry().Infof("Getting '%s' from System Trust", param.Name) | ||
token, err := systemtrust.GetToken(ref.Default, client, systemTrustConfiguration) | ||
if err != nil { | ||
log.Entry().Info(" failed") | ||
log.Entry().WithError(err).Debugf("Couldn't get '%s' token from System Trust", ref.Default) | ||
continue | ||
} | ||
log.RegisterSecret(token) | ||
config.Config[param.Name] = token | ||
log.Entry().Info(" succeeded") | ||
} else { | ||
log.Entry().Debugf("Skipping retrieval of '%s' from System Trust: parameter already set", param.Name) | ||
} | ||
} | ||
} | ||
} | ||
|
||
// setSystemTrustConfiguration sets the server URL for the System Trust by taking it from the hooks | ||
func (c *Config) setSystemTrustConfiguration(hookConfig map[string]interface{}) error { | ||
systemTrustHook, ok := hookConfig["systemtrust"].(map[string]interface{}) | ||
if !ok { | ||
return errors.New("no System Trust hook configuration found") | ||
} | ||
if serverURL, ok := systemTrustHook["serverURL"].(string); ok { | ||
c.systemTrustConfiguration.ServerURL = serverURL | ||
} else { | ||
return errors.New("no System Trust server URL found") | ||
} | ||
if tokenEndPoint, ok := systemTrustHook["tokenEndPoint"].(string); ok { | ||
c.systemTrustConfiguration.TokenEndPoint = tokenEndPoint | ||
} else { | ||
return errors.New("no System Trust service endpoint found") | ||
} | ||
if tokenQueryParamName, ok := systemTrustHook["tokenQueryParamName"].(string); ok { | ||
c.systemTrustConfiguration.TokenQueryParamName = tokenQueryParamName | ||
} else { | ||
return errors.New("no System Trust query parameter name found") | ||
} | ||
|
||
if len(c.systemTrustConfiguration.Token) == 0 { | ||
return errors.New("no System Trust token found and envvar is empty") | ||
} | ||
return nil | ||
} | ||
|
||
// SetSystemTrustToken sets the token for the System Trust | ||
func (c *Config) SetSystemTrustToken(token string) { | ||
c.systemTrustConfiguration.Token = token | ||
} |
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.