Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial pass at a dev container. #209

Merged
merged 4 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM ubuntu:jammy

RUN apt-get update \
&& apt-get install -y curl wget unzip zip

RUN mkdir -p /workspace
WORKDIR /workspace

32 changes: 32 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "Galasa CLI devcontainer",
"build": {
"dockerfile": "Dockerfile"
},
"features": {
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/common-utils:2": {},
"ghcr.io/devcontainers/features/go:1": {
"version": "1.19.1"
},
"ghcr.io/devcontainers/features/java:1": {
"version": "11.0.18-sem",
"jdkDistro": "sem",
"installGradle" : true,
"gradleVersion": "6.9.2",
"installMaven": true,
"mavenVersion": "3.8.6"
}
},
"forwardPorts": [9080,9443],
"privileged": true,
"remoteUser": "root",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace/,type=bind",
"workspaceFolder": "/workspace",
"postStartCommand": "git config --global --add safe.directory /workspace",
"mounts": [
"source=${localEnv:HOME}/.galasa,target=/root/.galasa,type=bind,consistency=cached",
"source=${localEnv:HOME}/.m2,target=/root/.m2,type=bind,consistency=cached"
],
"postCreateCommand": "./.devcontainer/setup-env.sh"
}
12 changes: 12 additions & 0 deletions .devcontainer/setup-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

# Go get the public IBM certificates and install them
curl -k -o carootcert.der https://ibmca-prod.dal.cpc.ibm.com:9443/cybersecurity/ibmcert/web/downloadCarootCert.do?file=carootcert.der
curl -k -o caintermediatecert.der https://ibmca-prod.dal.cpc.ibm.com:9443/cybersecurity/ibmcert/web/downloadCarootCert.do?file=caintermediatecert.der

cp carootcert.der $JAVA_HOME/lib/security
cp caintermediatecert.der $JAVA_HOME/lib/security

cd $JAVA_HOME/lib/security;
keytool -keystore cacerts -storepass changeit -noprompt -trustcacerts -importcert -alias ibmca -file carootcert.der
keytool -keystore cacerts -storepass changeit -noprompt -trustcacerts -importcert -alias ibminter -file caintermediatecert.der

12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ pkg/embedded/templates/version/build.properties
# The galasaapi package is generated.
pkg/galasaapi/

*.directory
.attach_pid807

# Don't check-in certificates
*.der
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ galasactl: \

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

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

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

bin/gendocs-galasactl-linux-arm64 : galasactl-source
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o bin/gendocs-galasactl-linux-arm64 ./cmd/gendocs-galasactl

bin/gendocs-galasactl-linux-x86_64 : galasactl-source
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/gendocs-galasactl-linux-x86_64 ./cmd/gendocs-galasactl

Expand Down
9 changes: 9 additions & 0 deletions build-locally.sh
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ function calculate_galasactl_executable {
esac

architecture=$(uname -m)
case $architecture in
aarch64)
architecture="arm64"
;;
esac

export galasactl_command="galasactl-${os}-${architecture}"
info "galasactl command is ${galasactl_command}"
Expand Down Expand Up @@ -448,7 +453,11 @@ function generate_galasactl_documentation {
*) error "Unknown machine type ${unameOut}"
exit 1
esac

architecture="$(uname -m)"
case $architecture in
aarch64) architecture=arm64
esac

# Call the documentation generator, which builds .md files
info "Using program ${BASEDIR}/bin/gendocs-galasactl-${machine}-${architecture} to generate the documentation..."
Expand Down
8 changes: 5 additions & 3 deletions pkg/resources/resourcesApplier.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,17 @@ func sendResourcesRequestToServer(payloadJsonToSend []byte, apiServerUrl string)
var responseBody []byte
resourcesApiServerUrl := apiServerUrl + "/resources/"

var req *http.Request
req, err = http.NewRequest("POST", resourcesApiServerUrl, bytes.NewBuffer(payloadJsonToSend))
var req *http.Request
req, err = http.NewRequest("POST", resourcesApiServerUrl, bytes.NewBuffer(payloadJsonToSend))

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

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

var resp *http.Response
client := &http.Client{}
Expand Down