Skip to content

Commit

Permalink
[release] v0.14.1-unstable1
Browse files Browse the repository at this point in the history
  • Loading branch information
azukaar committed Feb 10, 2024
1 parent 9473dfd commit 54dea32
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 16 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Version 0.14.1
- Puppet migration for non-host mode
- Add config UI for puppet mode

## Version 0.14.0
- Cosmos is now fully functional dockerless
- Reworked Cosmos Compose for better compatibility with docker-compose.yml files
Expand Down
86 changes: 85 additions & 1 deletion client/src/pages/config/users/configman.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
} from '@mui/material';
import RestartModal from './restart';
import { DeleteOutlined, SyncOutlined } from '@ant-design/icons';
import { CosmosCheckbox, CosmosFormDivider, CosmosInputPassword, CosmosInputText, CosmosSelect } from './formShortcuts';
import { CosmosCheckbox, CosmosCollapse, CosmosFormDivider, CosmosInputPassword, CosmosInputText, CosmosSelect } from './formShortcuts';
import CountrySelect from '../../../components/countrySelect';
import { DnsChallengeComp } from '../../../utils/dns-challenge-comp';

Expand Down Expand Up @@ -129,6 +129,14 @@ const ConfigManagement = () => {

AdminWhitelistIPs: config.AdminWhitelistIPs && config.AdminWhitelistIPs.join(', '),
AdminConstellationOnly: config.AdminConstellationOnly,

PuppetModeEnabled: config.Database.PuppetMode,
PuppetModeHostname: config.Database.Hostname,
PuppetModeDbVolume: config.Database.DbVolume,
PuppetModeConfigVolume: config.Database.ConfigVolume,
PuppetModeVersion: config.Database.Version,
PuppetModeUsername: config.Database.Username,
PuppetModePassword: config.Database.Password,
}}

validationSchema={Yup.object().shape({
Expand All @@ -143,6 +151,16 @@ const ConfigManagement = () => {
let toSave = {
...config,
MongoDB: values.MongoDB,
Database: {
...config.Database,
PuppetMode: values.PuppetModeEnabled,
Hostname: values.PuppetModeHostname,
DbVolume: values.PuppetModeDbVolume,
ConfigVolume: values.PuppetModeConfigVolume,
Version: values.PuppetModeVersion,
Username: values.PuppetModeUsername,
Password: values.PuppetModePassword,
},
LoggingLevel: values.LoggingLevel,
RequireMFA: values.RequireMFA,
// AutoUpdate: values.AutoUpdate,
Expand Down Expand Up @@ -275,6 +293,72 @@ const ConfigManagement = () => {
{formik.errors.MongoDB}
</FormHelperText>
)}
<CosmosCollapse title="Puppet Mode">
<Grid container spacing={3}>
<Grid item xs={12}>
<CosmosCheckbox
label="Puppet Mode Enabled"
name="PuppetModeEnabled"
formik={formik}
helperText="Enable Puppet Mode"
/>

{formik.values.PuppetModeEnabled && (
<Grid container spacing={3}>
<Grid item xs={12}>
<CosmosInputText
label="Puppet Mode Hostname"
name="PuppetModeHostname"
formik={formik}
helperText="Puppet Mode Hostname"
/>
</Grid>

<Grid item xs={12}>
<CosmosInputText
label="Puppet Mode Database Volume"
name="PuppetModeDbVolume"
formik={formik}
helperText="Puppet Mode Database Volume"
/>

<CosmosInputText
label="Puppet Mode Config Volume"
name="PuppetModeConfigVolume"
formik={formik}
helperText="Puppet Mode Config Volume"
/>

<CosmosInputText
label="Puppet Mode Version"
name="PuppetModeVersion"
formik={formik}
helperText="Puppet Mode Version"
/>
</Grid>

<Grid item xs={12}>
<CosmosInputText
label="Puppet Mode Username"
name="PuppetModeUsername"
formik={formik}
helperText="Puppet Mode Username"
/>

<CosmosInputPassword
label="Puppet Mode Password"
name="PuppetModePassword"
autoComplete='new-password'
formik={formik}
helperText="Puppet Mode Password"
noStrength
/>
</Grid>
</Grid>
)}
</Grid>
</Grid>
</CosmosCollapse>
</Stack>
</Grid>

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cosmos-server",
"version": "0.14.0",
"version": "0.14.1",
"description": "",
"main": "test-server.js",
"bugs": {
Expand Down
15 changes: 15 additions & 0 deletions src/docker/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,19 @@ func GetContainerIPByName(containerName string) (ip string, err error) {

utils.Debug("Docker - Docker IP " + containerName + " : " + ip)
return ip, nil
}

func DoesContainerExist(containerName string) bool {
errD := Connect()
if errD != nil {
return false
}

_, err := DockerClient.ContainerInspect(DockerContext, containerName)

if err != nil {
return false
}

return true
}
1 change: 1 addition & 0 deletions src/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func main() {
// utils.ReBootstrapContainer = docker.BootstrapContainerFromTags
utils.PushShieldMetrics = metrics.PushShieldMetrics
utils.GetContainerIPByName = docker.GetContainerIPByName
utils.DoesContainerExist = docker.DoesContainerExist
utils.CheckDockerNetworkMode = docker.CheckDockerNetworkMode

rand.Seed(time.Now().UnixNano())
Expand Down
33 changes: 19 additions & 14 deletions src/utils/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,24 @@ func DB() error {
opts := options.Client().ApplyURI(mongoURL).SetRetryWrites(true).SetWriteConcern(writeconcern.New(writeconcern.WMajority()))

opts.SetConnectTimeout(5 * time.Second)

hostname := ""
port := "27017"

if os.Getenv("HOSTNAME") == "" || IsHostNetwork {
hostname := ""
port := "27017"

if !isPuppetMode {
hostname = opts.Hosts[0]
// split port
hostnameParts := strings.Split(hostname, ":")
hostname = hostnameParts[0]
if !isPuppetMode {
hostname = opts.Hosts[0]
// split port
hostnameParts := strings.Split(hostname, ":")
hostname = hostnameParts[0]

if len(hostnameParts) > 1 {
port = hostnameParts[1]
}
} else {
hostname = puppetHostname
if len(hostnameParts) > 1 {
port = hostnameParts[1]
}
} else {
hostname = puppetHostname
}

if os.Getenv("HOSTNAME") == "" || IsHostNetwork {
Log("Getting Mongo DB IP from name : " + hostname + " (port " + port + ")")

ip, _ := GetContainerIPByName(hostname)
Expand All @@ -87,6 +87,11 @@ func DB() error {
opts.SetHosts([]string{ip + ":" + port})
Log("Mongo DB IP : " + ip)
}
} else {
if DoesContainerExist(hostname) {
Debug("MongoDB is running in a container")
DBContainerName = hostname
}
}

client, err = mongo.Connect(context.TODO(), opts)
Expand Down
1 change: 1 addition & 0 deletions src/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var UpdateAvailable = map[string]bool{}
var RestartHTTPServer func()
// var ReBootstrapContainer func(string) error
var GetContainerIPByName func(string) (string, error)
var DoesContainerExist func(string) bool
var CheckDockerNetworkMode func() string

var LetsEncryptErrors = []string{}
Expand Down

0 comments on commit 54dea32

Please sign in to comment.