-
Notifications
You must be signed in to change notification settings - Fork 8
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
1 parent
c9e9fc8
commit 77670d8
Showing
10 changed files
with
132 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM registry.access.redhat.com/ubi7 | ||
|
||
RUN yum install go-toolset-1.19 git make curl gzip tar --enablerepo=rhel-7-server-devtools-rpms -y | ||
|
||
COPY ./entrypoint.sh /usr/bin/ | ||
RUN chmod +x /usr/bin/entrypoint.sh | ||
|
||
COPY ./enable_go_scl.sh /etc/profile.d/ | ||
RUN chmod +x /etc/profile.d/enable_go_scl.sh | ||
|
||
ENTRYPOINT ["entrypoint.sh"] |
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,41 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/go | ||
{ | ||
"name": "Go", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
// "image": "mcr.microsoft.com/devcontainers/go:1.19", | ||
"build": { | ||
"dockerfile": "Dockerfile" | ||
}, | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
"features": { | ||
// "ghcr.io/devcontainers/features/common-utils:2": {} | ||
}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
// "postCreateCommand": "go version", | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
|
||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" | ||
|
||
"remoteUser": "root", | ||
"remoteEnv": { | ||
"HOME": "/home" | ||
}, | ||
"containerUser": "root", | ||
"containerEnv": { | ||
"HOME": "/home", | ||
"WORKDIR": "/workspaces/${localWorkspaceFolderBasename}" | ||
}, | ||
"workspaceMount": "", | ||
"runArgs": [ | ||
"--volume=${localWorkspaceFolder}:/workspaces/${localWorkspaceFolderBasename}:Z" | ||
] | ||
} |
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,2 @@ | ||
#!/bin/bash | ||
source scl_source enable go-toolset-1.19 |
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,9 @@ | ||
#!/bin/bash | ||
SCLS=go-toolset-1.19 | ||
|
||
if [ -x "$(command -v scl_source)" ]; then | ||
source scl_source enable $SCLS | ||
fi | ||
|
||
cd $WORKDIR | ||
exec "$@" |
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 |
---|---|---|
|
@@ -3,3 +3,7 @@ coverage.* | |
|
||
# Binary | ||
host-metering | ||
|
||
#dev | ||
mocks/subscription-manager-* | ||
mocks/consumer/ |
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,21 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Run once [mocked]", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"program": "${workspaceFolder}/main.go", | ||
"args": ["once"], | ||
"env": { | ||
"HOST_METERING_HOST_CERT_PATH": "${workspaceFolder}/mocks/consumer/cert.pem", | ||
"HOST_METERING_HOST_CERT_KEY_PATH": "${workspaceFolder}/mocks/consumer/key.pem", | ||
"PATH": "${workspaceFolder}/mocks:${env:PATH}" | ||
} | ||
} | ||
] | ||
} |
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 |
---|---|---|
@@ -1,3 +1,15 @@ | ||
# Host Metering | ||
|
||
Host metering client. | ||
|
||
## Running in a container | ||
This project has configuration for running inside VSCode container. | ||
|
||
You have to have a system with `subscription-manager` installed and registered correctly to use the UBI image (which is the base for this Dockerfile) and to have access to the relevan Red Hat repositories. | ||
|
||
## Mocking subscription-manager commands | ||
`mocked_run.sh` is a wrapper of `go run main.go` to execute the command in mocked context. | ||
|
||
### Preparing the mocks | ||
Inside the `mocks` folder run `./prepare_mock.sh` to generate outputs that will be used as mocks. | ||
You have to have a system with `subscription-manager` installed and registered correctly to generate the mocks. |
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,11 @@ | ||
#!/bin/bash | ||
|
||
pushd $(dirname "$0") | ||
#prepend path with the mocks folder | ||
MOCKS_PATH=$(pwd) | ||
PATH=$MOCKS_PATH:$PATH | ||
popd | ||
|
||
pushd $(dirname "$0")/.. | ||
HOST_METERING_HOST_CERT_PATH=$MOCKS_PATH/consumer/cert.pem HOST_METERING_HOST_CERT_KEY_PATH=$MOCKS_PATH/consumer/key.pem go run main.go $@ | ||
popd |
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,17 @@ | ||
#!/bin/bash | ||
|
||
ACTUAL_USER=$(id -u) | ||
ACTUAL_GROUP=$(id -g) | ||
|
||
echo running subscription-manager identity | ||
sudo subscription-manager identity > subscription-manager-identity | ||
echo running subscription-manager usage | ||
sudo subscription-manager usage > subscription-manager-usage | ||
echo running subscription-manager service-level | ||
sudo subscription-manager service-level > subscription-manager-service-level | ||
echo running subscription-manager facts | ||
sudo subscription-manager facts > subscription-manager-facts | ||
|
||
echo preparing /etc/pki/consumer | ||
sudo cp -r /etc/pki/consumer ./ | ||
sudo chown $ACTUAL_USER:$ACTUAL_GROUP -R ./consumer |
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,4 @@ | ||
#!/bin/bash | ||
|
||
echo "#######Mocked output#######" | ||
cat $(dirname "$0")/subscription-manager-$@ |