-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
134 additions
and
15 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
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,52 @@ | ||
// Copyright 2021 Clivern. All rights reserved. | ||
// Use of this source code is governed by the MIT | ||
// license that can be found in the LICENSE file. | ||
|
||
package definition | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
const ( | ||
// NagiosService const | ||
NagiosService = "nagios" | ||
|
||
// NagiosPort const | ||
NagiosPort = "80" | ||
|
||
// NagiosDockerImage const | ||
NagiosDockerImage = "jasonrivers/nagios" | ||
|
||
// NagiosDockerImageVersion const | ||
NagiosDockerImageVersion = "latest" | ||
|
||
// NagiosRestartPolicy const | ||
NagiosRestartPolicy = "unless-stopped" | ||
|
||
// NagiosRootUser const | ||
NagiosRootUser = "nagiosadmin" | ||
|
||
// NagiosRootPassword const | ||
NagiosRootPassword = "nagios" | ||
) | ||
|
||
// GetNagiosConfig gets yaml definition object | ||
func GetNagiosConfig(name, version string) DockerComposeConfig { | ||
services := make(map[string]Service) | ||
|
||
if version == "" { | ||
version = NagiosDockerImageVersion | ||
} | ||
|
||
services[name] = Service{ | ||
Image: fmt.Sprintf("%s:%s", NagiosDockerImage, version), | ||
Restart: NagiosRestartPolicy, | ||
Ports: []string{NagiosPort}, | ||
} | ||
|
||
return DockerComposeConfig{ | ||
Version: "3", | ||
Services: services, | ||
} | ||
} |
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,30 @@ | ||
// Copyright 2021 Clivern. All rights reserved. | ||
// Use of this source code is governed by the MIT | ||
// license that can be found in the LICENSE file. | ||
|
||
package definition | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/franela/goblin" | ||
) | ||
|
||
// TestUnitNagios test cases | ||
func TestUnitNagios(t *testing.T) { | ||
g := goblin.Goblin(t) | ||
|
||
g.Describe("#TestNagios", func() { | ||
g.It("It should satisfy all provided test cases", func() { | ||
httpbin := GetNagiosConfig("httpbin", "") | ||
result, err := httpbin.ToString() | ||
|
||
g.Assert(strings.Contains(result, fmt.Sprintf("image: %s", fmt.Sprintf("%s:%s", NagiosDockerImage, NagiosDockerImageVersion)))).Equal(true) | ||
g.Assert(strings.Contains(result, fmt.Sprintf(`- "%s"`, NagiosPort))).Equal(true) | ||
g.Assert(strings.Contains(result, fmt.Sprintf("restart: %s", NagiosRestartPolicy))).Equal(true) | ||
g.Assert(err).Equal(nil) | ||
}) | ||
}) | ||
} |
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