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

Add option to accept self signed certificates #6

Merged
merged 2 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
with:
debug: 'false'
disable_output: 'false'
tls_skip_verification: 'false'
rancher_bearer_token: ${{ secrets.RANCHER_BEARER_TOKEN }}
rancher_cluster_id: 'c-qxyky'
rancher_namespace: 'namespace'
Expand All @@ -22,23 +23,25 @@

#### Inputs

| Variable | Required | Default value | Description |
|----------------------|:--------:|---------------|------------------------------------------------------------------------------------------------------|
| debug | | 'false' | Debug flag (useful when something fails) |
| disable_output | | 'false' | Disables outputting to stdout (useful if the logs are public, but you don't want to expose anything) |
| rancher_bearer_token | ✔ | | Bearer token used for authenticating on Rancher |
| rancher_cluster_id | ✔ | | Cluster's id on Rancher |
| rancher_namespace | ✔ | | Kubernetes namespace of the deployment to be updated |
| rancher_project_id | ✔ | | Project's id on Rancher |
| rancher_url | ✔ | | Base URL of the Rancher |
| rancher_workloads | ✔ | | Comma separated list of workloads to be updated (e.g. deployment1,deployment2) |
| Variable | Required | Default value | Description |
|-----------------------|:--------:|---------------|------------------------------------------------------------------------------------------------------|
| debug | | 'false' | Debug flag (useful when something fails) |
| disable_output | | 'false' | Disables outputting to stdout (useful if the logs are public, but you don't want to expose anything) |
| tls_skip_verification | | 'false' | Skipping host TLS verification |
piechpatrick marked this conversation as resolved.
Show resolved Hide resolved
| rancher_bearer_token | ✔ | | Bearer token used for authenticating on Rancher |
| rancher_cluster_id | ✔ | | Cluster's id on Rancher |
| rancher_namespace | ✔ | | Kubernetes namespace of the deployment to be updated |
| rancher_project_id | ✔ | | Project's id on Rancher |
| rancher_url | ✔ | | Base URL of the Rancher |
| rancher_workloads | ✔ | | Comma separated list of workloads to be updated (e.g. deployment1,deployment2) |

### Running as a docker container

```shell script
$ docker run --rm -it \
-e DEBUG="false" \
-e DISABLE_OUTPUT="false" \
-e TLS_SKIP_VERIFICATION="false" \
-e RANCHER_BEARER_TOKEN="token-xgskl:n45p7tmd47t9lfzh7xl8rw6rvtrfzzxrtdr6qvjg27r4sjcxvzss7d" \
-e RANCHER_CLUSTER_ID="c-qxyky" \
-e RANCHER_NAMESPACE="namespace" \
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ inputs:
description: "Debug flag"
disable_output:
description: "Disables outputting to stdout (useful if the logs are public, but you don't want to expose anything)"
tls_skip_verification:
description: "Skipping host TLS verification"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: "Skipping host TLS verification"
description: "Skips TLS verification for the outgoing HTTP request to Rancher"

rancher_bearer_token:
description: "Bearer token used for authenticating on Rancher"
rancher_cluster_id:
Expand Down
20 changes: 12 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"crypto/tls"
"errors"
"fmt"
v "github.com/RussellLuo/validating/v3"
Expand All @@ -12,14 +13,15 @@ import (
)

type Config struct {
Debug bool `env:"DEBUG"`
DisableOutput bool `env:"DISABLE_OUTPUT"`
RancherBearerToken string `env:"RANCHER_BEARER_TOKEN"`
RancherClusterId string `env:"RANCHER_CLUSTER_ID"`
RancherNamespace string `env:"RANCHER_NAMESPACE"`
RancherProjectId string `env:"RANCHER_PROJECT_ID"`
RancherUrl string `env:"RANCHER_URL"`
RancherWorkloads string `env:"RANCHER_WORKLOADS"`
Debug bool `env:"DEBUG"`
DisableOutput bool `env:"DISABLE_OUTPUT"`
TlsSkipVerification bool `env:"TLS_SKIP_VERIFICATION"`
RancherBearerToken string `env:"RANCHER_BEARER_TOKEN"`
RancherClusterId string `env:"RANCHER_CLUSTER_ID"`
RancherNamespace string `env:"RANCHER_NAMESPACE"`
RancherProjectId string `env:"RANCHER_PROJECT_ID"`
RancherUrl string `env:"RANCHER_URL"`
RancherWorkloads string `env:"RANCHER_WORKLOADS"`
th0th marked this conversation as resolved.
Show resolved Hide resolved
}

var config = &Config{}
Expand Down Expand Up @@ -70,6 +72,8 @@ func main() {

hasErrors := false

http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: config.TlsSkipVerification}

for _, workload := range workloads {
req, err2 := http.NewRequest(http.MethodPost, generateWorkloadRedeployUrl(workload), strings.NewReader("{}"))
if err2 != nil {
Expand Down