Skip to content

Commit 788358b

Browse files
author
Tim Middleton
authored
Fix CI/CD, bump version to 1.10.0 (#315)
* Fix CI/CD, bump version to 1.10.0 * Fix file perms * Fix sonarcloud
1 parent 49debd4 commit 788358b

5 files changed

Lines changed: 54 additions & 33 deletions

File tree

.github/workflows/build-monitoring.yaml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# ---------------------------------------------------------------------------
66
# Coherence CLI GitHub Actions CI Build Monitoring
77
# ---------------------------------------------------------------------------
8-
name: Build Monitoring
8+
name: CI Build Monitoring
99

1010
on:
1111
workflow_dispatch:
@@ -24,17 +24,6 @@ jobs:
2424
with:
2525
fetch-depth: 0
2626

27-
- name: Get Docker Images
28-
shell: bash
29-
run: |
30-
docker pull gcr.io/distroless/java17
31-
32-
- name: Set up JDK
33-
uses: actions/setup-java@v4
34-
with:
35-
java-version: '17'
36-
distribution: 'zulu'
37-
3827
- name: Cache Go Modules
3928
uses: actions/cache@v4
4029
with:
@@ -62,10 +51,12 @@ jobs:
6251
export PATH=`pwd`/bin:$PATH
6352
cohctl init monitoring -y
6453
cohctl start monitoring
65-
sleep 30
54+
sleep 15
55+
netstat -an | grep 9090
56+
netstat -an | grep 3000
6657
cohctl get monitoring
67-
curl -s http://localhost:9090/-/healthy
68-
curl -s http://localhost:3000/api/health
58+
curl -s http://127.0.0.1:9090/-/healthy
59+
curl -s http://127.0.0.1:3000/api/health
6960
cohctl stop monitoring
7061
7162
- uses: actions/upload-artifact@v4

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# ======================================================================================================================
1616

1717
# The version of the CLI being build - this should be a valid SemVer format
18-
VERSION ?= 1.9.2
18+
VERSION ?= 1.10.0
1919
MILESTONE ?=
2020
SHELL := /bin/bash
2121

docs/sitegen.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ engine:
1111
attributes:
1212
plantumlconfig: "_plantuml-config.txt"
1313
commercial-docs-base-url: "https://docs.oracle.com/en/middleware/fusion-middleware/coherence/14.1.2"
14-
cli-version: "1.9.2"
14+
cli-version: "1.10.0"
1515
coherence-version: "14.1.2-0-2"
1616
coherence-default-version: "14.1.2-0-2"
1717
assets:
@@ -35,7 +35,7 @@ backend:
3535
name: "vuetify"
3636
homePage: "docs/about/overview.adoc"
3737
releases:
38-
- "1.9.2"
38+
- "1.10.0"
3939
navigation:
4040
type: "ROOT"
4141
title: "Coherence CLI"

pkg/cmd/monitoring.go

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ import (
2222
)
2323

2424
const (
25-
monitoringDirectory = "monitoring"
26-
dashboardsDirectory = "dashboards"
27-
dashboardBaseURL = "https://raw.githubusercontent.com/oracle/coherence-operator/refs/heads/main/dashboards/grafana"
28-
configBaseURL = "https://raw.githubusercontent.com/oracle/coherence-cli/refs/heads/main/monitoring"
29-
grafanaPort = 3000
30-
prometheusPort = 9090
31-
dockerComposeYAML = "docker-compose.yaml"
25+
monitoringDirectory = "monitoring"
26+
dashboardsDirectory = "dashboards"
27+
dashboardBaseURL = "https://raw.githubusercontent.com/oracle/coherence-operator/refs/heads/main/dashboards/grafana"
28+
configBaseURL = "https://raw.githubusercontent.com/oracle/coherence-cli/refs/heads/main/monitoring"
29+
grafanaPort = 3000
30+
prometheusPort = 9090
31+
dockerComposeYAML = "docker-compose.yaml"
32+
localhost = "127.0.0.1"
33+
useDockerComposeMessage = "use docker-compose instead of docker compose"
34+
dockerCompose = "docker-compose"
3235
)
3336

3437
var (
@@ -66,6 +69,8 @@ var (
6669
dockerComposeYAML,
6770
"prometheus.yaml",
6871
}
72+
73+
useDockerCompose bool
6974
)
7075

7176
// initMonitoringCmd represents the init monitoring command.
@@ -151,10 +156,10 @@ the environment is setup correctly.`,
151156
grafanaOutput string
152157
promOutput string
153158
err = mon.validateEnvironment()
154-
promURL = fmt.Sprintf("http://localhost:%v/", prometheusPort)
159+
promURL = fmt.Sprintf("http://%s:%v/", localhost, prometheusPort)
155160
promHealthURL = fmt.Sprintf("%s-/healthy", promURL)
156-
grafanaURL = fmt.Sprintf("http://localhost:%v/d/coh-main/coherence-dashboard-main", grafanaPort)
157-
grafanaHealthURL = fmt.Sprintf("http://localhost:%d/api/health", grafanaPort)
161+
grafanaURL = fmt.Sprintf("http://%s:%v/d/coh-main/coherence-dashboard-main", localhost, grafanaPort)
162+
grafanaHealthURL = fmt.Sprintf("http://%s:%d/api/health", localhost, grafanaPort)
158163
)
159164

160165
if err != nil {
@@ -211,7 +216,7 @@ Prometheus using docker compose.`,
211216
return err
212217
}
213218

214-
err = mon.dockerCommand([]string{"compose", "-f", path.Join(mon.monitoringDir, dockerComposeYAML), "up", "-d"})
219+
err = mon.dockerComposeCommand([]string{"-f", path.Join(mon.monitoringDir, dockerComposeYAML), "up", "-d"})
215220
if err != nil {
216221
return err
217222
}
@@ -244,7 +249,7 @@ using docker compose.`,
244249
return nil
245250
}
246251

247-
err = mon.dockerCommand([]string{"compose", "-f", path.Join(mon.monitoringDir, dockerComposeYAML), "down"})
252+
err = mon.dockerComposeCommand([]string{"-f", path.Join(mon.monitoringDir, dockerComposeYAML), "down"})
248253
if err != nil {
249254
return err
250255
}
@@ -392,6 +397,22 @@ func (m *monitoring) dockerCommand(args []string) error {
392397
return executeHostCommand(m.cmd, "docker", args...)
393398
}
394399

400+
func (m *monitoring) dockerComposeCommand(args []string) error {
401+
finalArgs := args
402+
command := "docker"
403+
404+
if useDockerCompose {
405+
command = dockerCompose
406+
} else {
407+
updatedArgs := []string{"compose"}
408+
finalArgs = append(updatedArgs, args...)
409+
}
410+
411+
m.cmd.Printf("Issuing %s %s\n", command, strings.Join(finalArgs, " "))
412+
413+
return executeHostCommand(m.cmd, command, finalArgs...)
414+
}
415+
395416
func monitoringNotValid(message string) error {
396417
return fmt.Errorf("unable to validate monitoring due to %s, please run 'cohctl init monitoring'", message)
397418
}
@@ -400,15 +421,16 @@ func monitoringNotValid(message string) error {
400421
func writeFileContents(base, file string, content []byte) error {
401422
destPath := filepath.Join(base, file)
402423

403-
if err := os.WriteFile(destPath, content, 0600); err != nil {
424+
// #nosec G306 -- file is meant to be readable by docker on Linux
425+
if err := os.WriteFile(destPath, content, 0644); err != nil {
404426
return fmt.Errorf("error writing file %s: %w", destPath, err)
405427
}
406428

407429
return nil
408430
}
409431

410432
func ensureDirectory(directory string) error {
411-
err := utils.EnsureDirectory(directory)
433+
err := utils.EnsureDirectoryWithPerms(directory, 0755)
412434
if err != nil {
413435
return fmt.Errorf("unable to create directory: %s, %v", directory, err)
414436
}
@@ -454,4 +476,6 @@ func streamOutput(r io.Reader, w io.Writer) {
454476
func init() {
455477
initMonitoringCmd.Flags().BoolVarP(&automaticallyConfirm, "yes", "y", false, confirmOptionMessage)
456478
stopMonitoringCmd.Flags().BoolVarP(&automaticallyConfirm, "yes", "y", false, confirmOptionMessage)
479+
stopMonitoringCmd.Flags().BoolVarP(&useDockerCompose, dockerCompose, "D", false, useDockerComposeMessage)
480+
startMonitoringCmd.Flags().BoolVarP(&useDockerCompose, dockerCompose, "D", false, useDockerComposeMessage)
457481
}

pkg/utils/utils.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/oracle/coherence-cli/pkg/constants"
1818
"go.uber.org/zap"
1919
"go.uber.org/zap/zapcore"
20+
"io/fs"
2021
"os"
2122
"path/filepath"
2223
"regexp"
@@ -149,9 +150,14 @@ func GetJSONPathResults(jsonData []byte, jsonPath string) (string, error) {
149150

150151
// EnsureDirectory ensures a directory exists and if not then will create it.
151152
func EnsureDirectory(directory string) error {
153+
return EnsureDirectoryWithPerms(directory, 0700)
154+
}
155+
156+
// EnsureDirectoryWithPerms ensures a directory exists and if not then will create it with specific permissions.
157+
func EnsureDirectoryWithPerms(directory string, perm fs.FileMode) error {
152158
if _, err := os.Stat(directory); err != nil {
153159
if os.IsNotExist(err) {
154-
err = os.Mkdir(directory, 0700)
160+
err = os.Mkdir(directory, perm)
155161
if err != nil {
156162
return GetError("unable to create directory "+directory, err)
157163
}

0 commit comments

Comments
 (0)