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

Enable and document the insecure field for Helm Repos #4660

Merged
merged 2 commits into from
Jun 25, 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
13 changes: 13 additions & 0 deletions docs/helm-charts.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ Each chart is processed the same way CLI tool does with following options:

It is possible to customize the timeout by using the `timeout' field.

### Repository configuration

| Field | Default value | Description |
|----------|---------------|--------------------------------------------------------------------------|
| name | _(required)_ | The repository name |
| url | _(required)_ | The repository URL |
| insecure | true | Whether to skip TLS certificate checks when connecting to the repository |
| caFile | - | CA bundle file to use when verifying HTTPS-enabled servers |
| certFile | - | The TLS certificate file to use for HTTPS client authentication |
| keyfile | - | The TLS key file to use for HTTPS client authentication |
| username | - | Username for Basic HTTP authentication |
| password | - | Password for Basic HTTP authentication |

### Chart configuration

| Field | Default value | Description |
Expand Down
34 changes: 25 additions & 9 deletions pkg/apis/k0s/v1beta1/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,34 @@ func (c Chart) Validate() error {

// Repository describes single repository entry. Fields map to the CLI flags for the "helm add" command
type Repository struct {
Name string `json:"name"`
URL string `json:"url"`
CAFile string `json:"caFile"`
CertFile string `json:"certFile"`
Insecure bool `json:"insecure"`
KeyFile string `json:"keyfile"`
Username string `json:"username"`
Password string `json:"password"`
// The repository name.
// +kubebuilder:Validation:Required
Name string `json:"name"`
// The repository URL.
// +kubebuilder:Validation:Required
URL string `json:"url"`
// Whether to skip TLS certificate checks when connecting to the repository.
Insecure *bool `json:"insecure,omitempty"`
// CA bundle file to use when verifying HTTPS-enabled servers.
CAFile string `json:"caFile,omitempty"`
// The TLS certificate file to use for HTTPS client authentication.
CertFile string `json:"certFile,omitempty"`
// The TLS key file to use for HTTPS client authentication.
KeyFile string `json:"keyfile,omitempty"`
// Username for Basic HTTP authentication.
Username string `json:"username,omitempty"`
// Password for Basic HTTP authentication.
Password string `json:"password,omitempty"`
}

func (r *Repository) IsInsecure() bool {
// This defaults to true when not explicitly set to false.
// Better have this the other way round in the next API version.
return r == nil || r.Insecure == nil || *r.Insecure
}

// Validate performs validation
func (r Repository) Validate() error {
func (r *Repository) Validate() error {
if r.Name == "" {
return errors.New("repository must have Name field not empty")
}
Expand Down
13 changes: 11 additions & 2 deletions pkg/apis/k0s/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/helm/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (hc *Commands) AddRepository(repoCfg v1beta1.Repository) error {
CertFile: repoCfg.CertFile,
KeyFile: repoCfg.KeyFile,
CAFile: repoCfg.CAFile,
InsecureSkipTLSverify: true,
InsecureSkipTLSverify: repoCfg.IsInsecure(),
}

r, err := repo.NewChartRepository(&c, getters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,32 @@ spec:
Fields map to the CLI flags for the "helm add" command
properties:
caFile:
description: CA bundle file to use when verifying HTTPS-enabled
servers.
type: string
certFile:
description: The TLS certificate file to use for HTTPS
client authentication.
type: string
insecure:
description: Whether to skip TLS certificate checks
when connecting to the repository.
type: boolean
keyfile:
description: The TLS key file to use for HTTPS client
authentication.
type: string
name:
description: The repository name.
type: string
password:
description: Password for Basic HTTP authentication.
type: string
url:
description: The repository URL.
type: string
username:
description: Username for Basic HTTP authentication.
type: string
type: object
type: array
Expand Down
Loading