Skip to content

Commit

Permalink
Use explicit SSL related variables in the template
Browse files Browse the repository at this point in the history
Signed-off-by: Marcelo Henrique Neppel <[email protected]>
  • Loading branch information
marceloneppel committed Jun 4, 2024
1 parent 2aee678 commit ac27b53
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion microceph/ceph/configwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ auth allow insecure global id reclaim = false
[client.radosgw.gateway]
rgw init timeout = 1200
rgw frontends = beast port={{.rgwPort}} {{.sslConfig}}
rgw frontends = beast port={{.rgwPort}}{{if and .sslCertificate .sslPrivateKey}} ssl_port={{.sslPort}}{{end}}{{if .sslCertificate}} ssl_certificate={{.sslCertificate}}{{end}}{{if .sslPrivateKey}} ssl_private_key={{.sslPrivateKey}}{{end}}
`)),
configFile: "radosgw.conf",
configDir: configDir,
Expand Down
10 changes: 6 additions & 4 deletions microceph/ceph/configwriter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,19 @@ func (s *configWriterSuite) TestWriteRadosGWConfig() {
data, err := os.ReadFile(config.GetPath())
assert.Equal(s.T(), nil, err)
assert.Contains(s.T(), string(data), "foohost")
assert.Contains(s.T(), string(data), "rgw frontends = beast port=80 <no value>")
assert.Contains(s.T(), string(data), "rgw frontends = beast port=80\n")
}

// Test ceph config writing
func (s *configWriterSuite) TestWriteRadosGWSSLConfig() {
config := newRadosGWConfig(s.Tmp)
err := config.WriteConfig(
map[string]any{
"monitors": "foohost",
"rgwPort": 80,
"sslConfig": "ssl_port=443 ssl_certificate=/var/snap/microceph/common/server.crt ssl_private_key=/var/snap/microceph/common/server.key",
"monitors": "foohost",
"rgwPort": 80,
"sslPort": 443,
"sslCertificate": "/var/snap/microceph/common/server.crt",
"sslPrivateKey": "/var/snap/microceph/common/server.key",
},
0644,
)
Expand Down
14 changes: 6 additions & 8 deletions microceph/ceph/rgw.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@ func EnableRGW(s interfaces.StateInterface, port int, sslPort int, sslCertificat

// Create RGW configuration.
conf := newRadosGWConfig(pathConsts.ConfPath)
sslConfig := ""
if sslCertificate != "" && sslPrivateKey != "" {
sslConfig = fmt.Sprintf("ssl_port=%d ssl_certificate=%s ssl_private_key=%s", sslPort, sslCertificate, sslPrivateKey)
}
err := conf.WriteConfig(
map[string]any{
"runDir": pathConsts.RunPath,
"monitors": s.ClusterState().Address().Hostname(),
"rgwPort": port,
"sslConfig": sslConfig,
"runDir": pathConsts.RunPath,
"monitors": s.ClusterState().Address().Hostname(),
"rgwPort": port,
"sslPort": sslPort,
"sslCertificate": sslCertificate,
"sslPrivateKey": sslPrivateKey,
},
0644,
)
Expand Down
2 changes: 1 addition & 1 deletion microceph/ceph/rgw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (s *rgwSuite) TestEnableRGW() {

// check that the radosgw.conf file contains expected values
conf := s.ReadCephConfig("radosgw.conf")
assert.Contains(s.T(), conf, "rgw frontends = beast port=80 \n")
assert.Contains(s.T(), conf, "rgw frontends = beast port=80\n")
}

// Test enabling RGW
Expand Down

0 comments on commit ac27b53

Please sign in to comment.