Skip to content

Commit 29e8a2a

Browse files
authored
Merge pull request #209 from galasa-dev/mcobbett-dev-containers
initial pass at a dev container.
2 parents 6daedf8 + 8c2f327 commit 29e8a2a

File tree

8 files changed

+87
-4
lines changed

8 files changed

+87
-4
lines changed

.devcontainer/Dockerfile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM ubuntu:jammy
2+
3+
RUN apt-get update \
4+
&& apt-get install -y curl wget unzip zip
5+
6+
RUN mkdir -p /workspace
7+
WORKDIR /workspace
8+

.devcontainer/devcontainer.json

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "Galasa CLI devcontainer",
3+
"build": {
4+
"dockerfile": "Dockerfile"
5+
},
6+
"features": {
7+
"ghcr.io/devcontainers/features/git:1": {},
8+
"ghcr.io/devcontainers/features/common-utils:2": {},
9+
"ghcr.io/devcontainers/features/go:1": {
10+
"version": "1.19.1"
11+
},
12+
"ghcr.io/devcontainers/features/java:1": {
13+
"version": "11.0.18-sem",
14+
"jdkDistro": "sem",
15+
"installGradle" : true,
16+
"gradleVersion": "6.9.2",
17+
"installMaven": true,
18+
"mavenVersion": "3.8.6"
19+
}
20+
},
21+
"forwardPorts": [9080,9443],
22+
"privileged": true,
23+
"remoteUser": "root",
24+
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace/,type=bind",
25+
"workspaceFolder": "/workspace",
26+
"postStartCommand": "git config --global --add safe.directory /workspace",
27+
"mounts": [
28+
"source=${localEnv:HOME}/.galasa,target=/root/.galasa,type=bind,consistency=cached",
29+
"source=${localEnv:HOME}/.m2,target=/root/.m2,type=bind,consistency=cached"
30+
],
31+
"postCreateCommand": "./.devcontainer/setup-env.sh"
32+
}

.devcontainer/setup-env.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
# Go get the public IBM certificates and install them
3+
curl -k -o carootcert.der https://ibmca-prod.dal.cpc.ibm.com:9443/cybersecurity/ibmcert/web/downloadCarootCert.do?file=carootcert.der
4+
curl -k -o caintermediatecert.der https://ibmca-prod.dal.cpc.ibm.com:9443/cybersecurity/ibmcert/web/downloadCarootCert.do?file=caintermediatecert.der
5+
6+
cp carootcert.der $JAVA_HOME/lib/security
7+
cp caintermediatecert.der $JAVA_HOME/lib/security
8+
9+
cd $JAVA_HOME/lib/security;
10+
keytool -keystore cacerts -storepass changeit -noprompt -trustcacerts -importcert -alias ibmca -file carootcert.der
11+
keytool -keystore cacerts -storepass changeit -noprompt -trustcacerts -importcert -alias ibminter -file caintermediatecert.der
12+

.github/dependabot.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for more information:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
# https://containers.dev/guide/dependabot
6+
7+
version: 2
8+
updates:
9+
- package-ecosystem: "devcontainers"
10+
directory: "/"
11+
schedule:
12+
interval: weekly

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,8 @@ pkg/embedded/templates/version/build.properties
3838
# The galasaapi package is generated.
3939
pkg/galasaapi/
4040

41+
*.directory
42+
.attach_pid807
43+
44+
# Don't check-in certificates
45+
*.der

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ galasactl: \
1515

1616
# 'gendocs-galasactl' is a command-line tool which generates documentation about the galasactl tool.
1717
# When executed, the .md produced contain up-to-date information on tool syntax.
18-
gendocs-galasactl: bin/gendocs-galasactl-darwin-arm64 bin/gendocs-galasactl-darwin-x86_64 bin/gendocs-galasactl-linux-x86_64
18+
gendocs-galasactl: bin/gendocs-galasactl-darwin-arm64 bin/gendocs-galasactl-linux-arm64 bin/gendocs-galasactl-darwin-x86_64 bin/gendocs-galasactl-linux-x86_64
1919

2020
tests: galasactl-source build/coverage.txt build/coverage.html
2121

@@ -93,6 +93,9 @@ bin/galasactl-linux-s390x : galasactl-source
9393
bin/gendocs-galasactl-darwin-arm64 : galasactl-source
9494
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o bin/gendocs-galasactl-darwin-arm64 ./cmd/gendocs-galasactl
9595

96+
bin/gendocs-galasactl-linux-arm64 : galasactl-source
97+
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o bin/gendocs-galasactl-linux-arm64 ./cmd/gendocs-galasactl
98+
9699
bin/gendocs-galasactl-linux-x86_64 : galasactl-source
97100
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/gendocs-galasactl-linux-x86_64 ./cmd/gendocs-galasactl
98101

build-locally.sh

+9
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ function calculate_galasactl_executable {
228228
esac
229229

230230
architecture=$(uname -m)
231+
case $architecture in
232+
aarch64)
233+
architecture="arm64"
234+
;;
235+
esac
231236

232237
export galasactl_command="galasactl-${os}-${architecture}"
233238
info "galasactl command is ${galasactl_command}"
@@ -448,7 +453,11 @@ function generate_galasactl_documentation {
448453
*) error "Unknown machine type ${unameOut}"
449454
exit 1
450455
esac
456+
451457
architecture="$(uname -m)"
458+
case $architecture in
459+
aarch64) architecture=arm64
460+
esac
452461

453462
# Call the documentation generator, which builds .md files
454463
info "Using program ${BASEDIR}/bin/gendocs-galasactl-${machine}-${architecture} to generate the documentation..."

pkg/resources/resourcesApplier.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,17 @@ func sendResourcesRequestToServer(payloadJsonToSend []byte, apiServerUrl string)
5454
var responseBody []byte
5555
resourcesApiServerUrl := apiServerUrl + "/resources/"
5656

57-
var req *http.Request
58-
req, err = http.NewRequest("POST", resourcesApiServerUrl, bytes.NewBuffer(payloadJsonToSend))
57+
var req *http.Request
58+
req, err = http.NewRequest("POST", resourcesApiServerUrl, bytes.NewBuffer(payloadJsonToSend))
5959

6060
if err == nil {
6161
req.Header.Set("Content-Type", "application/json")
6262
req.Header.Set("Accept", "application/json")
6363
req.Header.Set("Accept-Encoding", "gzip,deflate,br")
6464

65-
log.Printf("sendResourcesRequestToServer url:%s - headers:%s - payload: '%s'", resourcesApiServerUrl, req.Header, string(payloadJsonToSend))
65+
// WARNING:
66+
// Don't leave the following log statement enabled. It might log secret namespace property values, which would be a security violation.
67+
// log.Printf("sendResourcesRequestToServer url:%s - headers:%s - payload: '%s'", resourcesApiServerUrl, req.Header, string(payloadJsonToSend))
6668

6769
var resp *http.Response
6870
client := &http.Client{}

0 commit comments

Comments
 (0)