Skip to content

Commit

Permalink
Merge pull request #8 from starkandwayne/Remove-HostKey-Check-Default
Browse files Browse the repository at this point in the history
Remove host key check default
  • Loading branch information
TheDigitalEagle authored Dec 7, 2022
2 parents 26b4240 + eebbeff commit fbba27d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ $cf create-service config-server default test-service -c "whatever json configur

## History ##

* v1.1.0 - Added default settings for the hostKey to not be needed by defaut for CloudFoundry instances
* v1.0.0 - Full release with support for SR Actuators
* v0.0.5 - Services as configurable objects
* v0.0.4 - Now with configurable package names
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.1.0
36 changes: 23 additions & 13 deletions broker/update_app_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@ import (
// Updates the app enviornment variables for creating or updating an instance.
func (broker *SCSBroker) UpdateAppEnvironment(cfClient *ccv3.Client, app *ccv3.Application, info *ccv3.Info, kind string, instanceId string, jsonparams string, params map[string]string) error {

var hostKeySetSSH bool = false
var profiles []string
envVarToSet := make(ccv3.EnvironmentVariables)
for key, value := range params {
_, _, err := cfClient.UpdateApplicationEnvironmentVariables(app.GUID, ccv3.EnvironmentVariables{
key: *types.NewFilteredString(value),
})

envVarToSet[key] = *types.NewFilteredString(value)

if key == "SPRING_CLOUD_CONFIG_SERVER_GIT_URI" {
profiles = append(profiles, "git")
}

if key == "SPRING_CLOUD_CONFIG_SERVER_GIT_HOSTKEY" {
hostKeySetSSH = true
}

if key == "SPRING_CLOUD_CONFIG_SERVER_VAULT_HOST" {
profiles = append(profiles, "vault")
}
Expand All @@ -34,9 +39,6 @@ func (broker *SCSBroker) UpdateAppEnvironment(cfClient *ccv3.Client, app *ccv3.A
profiles = append(profiles, "credhub")
}

if err != nil {
return err
}
}

var profileString strings.Builder
Expand All @@ -48,13 +50,21 @@ func (broker *SCSBroker) UpdateAppEnvironment(cfClient *ccv3.Client, app *ccv3.A
}
}

_, _, err := cfClient.UpdateApplicationEnvironmentVariables(app.GUID, ccv3.EnvironmentVariables{
"SPRING_APPLICATION_JSON": *types.NewFilteredString(jsonparams),
"JWK_SET_URI": *types.NewFilteredString(fmt.Sprintf("%v/token_keys", info.UAA())),
"SKIP_SSL_VALIDATION": *types.NewFilteredString(strconv.FormatBool(broker.Config.CfConfig.SkipSslValidation)),
"REQUIRED_AUDIENCE": *types.NewFilteredString(fmt.Sprintf("%s.%v", kind, instanceId)),
"SPRING_PROFILES_ACTIVE": *types.NewFilteredString(profileString.String()),
})
envVarToSet["SPRING_CLOUD_CONFIG_SERVER_GIT_IGNORELOCALSSHSETTINGS"] = *types.NewFilteredString("true")

if !hostKeySetSSH {
envVarToSet["SPRING_CLOUD_CONFIG_SERVER_GIT_STRICTHOSTKEYCHECKING"] = *types.NewFilteredString("false")
} else {
envVarToSet["SPRING_CLOUD_CONFIG_SERVER_GIT_STRICTHOSTKEYCHECKING"] = *types.NewFilteredString("true")
}

envVarToSet["SPRING_APPLICATION_JSON"] = *types.NewFilteredString(jsonparams)
envVarToSet["JWK_SET_URI"] = *types.NewFilteredString(fmt.Sprintf("%v/token_keys", info.UAA()))
envVarToSet["SKIP_SSL_VALIDATION"] = *types.NewFilteredString(strconv.FormatBool(broker.Config.CfConfig.SkipSslValidation))
envVarToSet["REQUIRED_AUDIENCE"] = *types.NewFilteredString(fmt.Sprintf("%s.%v", kind, instanceId))
envVarToSet["SPRING_PROFILES_ACTIVE"] = *types.NewFilteredString(profileString.String())

_, _, err := cfClient.UpdateApplicationEnvironmentVariables(app.GUID, envVarToSet)
if err != nil {
return err
}
Expand Down

0 comments on commit fbba27d

Please sign in to comment.