Skip to content

Commit b44bf1a

Browse files
Merge pull request #340 from otaviof/RHTAPINST-189
RHTAPINST-189: Bringing Latest Changes to Release 1.3
2 parents 4eb3ac4 + 183fde2 commit b44bf1a

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

docs/container-image.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
`rhtap-cli`: Container Image
2+
----------------------------
3+
4+
# Abstract
5+
6+
The `rhtap-cli` container image is a portable and easy-to-use tool to deploy RHTAP (Red Hat Trusted Application Pipeline) from a container manager running on your local machine. The container image is designed to enable the deployment process on Kubernetes Jobs, ArgoCD (GitOps), and other container orchestration tools.
7+
8+
9+
# Usage
10+
11+
The installer needs access to the target OpenShift/Kubernetes instance, therefore you either need to mount the local `~/.kube/config` file or provide the necessary environment variables to authenticate with the target cluster.
12+
13+
## Podman
14+
15+
For the `rhtap-cli integration github-app` you need to expose the callback port, used on the GitHub App registration, to the container. The GitHub App registration requires a personal access token, which should be created for the specific organization RHTAP will work on. In the example below, the token is passed as an environment variable `RHTAP_GITHUB_TOKEN`.
16+
17+
The OpenShift configuration and credentials are passed to the container by mounting the local `~/.kube` directory to the container's `/root/.kube` directory. And the user `root` is employed to avoid permission issues, although the mounted directory is read-only.
18+
19+
A interactive shell is started in the container, where you can run the `rhtap-cli` commands.
20+
21+
```bash
22+
podman run \
23+
--name="rhtap-cli" \
24+
--rm \
25+
--interactive \
26+
--tty \
27+
--env="RHTAP_GITHUB_TOKEN=${RHTAP_GITHUB_TOKEN}" \
28+
--publish="127.0.0.1:8228:8228" \
29+
--entrypoint="/bin/bash" \
30+
--user="root" \
31+
--volume="${HOME}/.kube:/root/.kube:ro" \
32+
ghcr.io/redhat-appstudio/rhtap-cli:latest
33+
```
34+
35+
Before the installation you should review the [`config.yaml`](../README.md#configuration) file to decide what's appropriate for your environment, in this example we are using the default configuration.
36+
37+
In the container, you can run the `rhtap-cli` commands, for example, creating a GitHub App integration on the organization `rhtap-ex`, and using the same name for the GitHub App:
38+
39+
```bash
40+
rhtap-cli integration github-app \
41+
--config="config.yaml" \
42+
--create \
43+
--token="${RHTAP_GITHUB_TOKEN}" \
44+
--org="rhtap-ex" \
45+
--webserver-addr="0.0.0.0" \
46+
rhtap-ex
47+
```
48+
49+
After configuring the integrations, you can proceed with the deployment:
50+
51+
```bash
52+
rhtap-cli deploy
53+
```

pkg/githubapp/githubapp.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type GitHubApp struct {
2525

2626
gitHubURL string // GitHub API URL
2727
gitHubOrgName string // GitHub organization name
28+
webServerAddr string // local webserver address
2829
webServerPort int // local webserver port
2930
}
3031

@@ -43,6 +44,8 @@ func (g *GitHubApp) PersistentFlags(p *pflag.FlagSet) {
4344
"GitHub URL")
4445
p.StringVar(&g.gitHubOrgName, "org", g.gitHubOrgName,
4546
"GitHub organization name")
47+
p.StringVar(&g.webServerAddr, "webserver-addr", g.webServerAddr,
48+
"Callback webserver listen address")
4649
p.IntVar(&g.webServerPort, "webserver-port", g.webServerPort,
4750
"Callback webserver port number")
4851
}
@@ -136,7 +139,7 @@ func (g *GitHubApp) oAuth2Workflow(
136139
})
137140

138141
webServer := &http.Server{
139-
Addr: fmt.Sprintf("127.0.0.1:%d", g.webServerPort),
142+
Addr: fmt.Sprintf("%s:%d", g.webServerAddr, g.webServerPort),
140143
Handler: serveMux,
141144
}
142145
// Opening the web browser while listening for the GitHub callback URL in the
@@ -198,6 +201,7 @@ func NewGitHubApp(logger *slog.Logger) *GitHubApp {
198201
return &GitHubApp{
199202
logger: logger,
200203
gitHubURL: defaultPublicGitHubURL,
204+
webServerAddr: "127.0.0.1",
201205
webServerPort: 8228,
202206
}
203207
}

0 commit comments

Comments
 (0)