Skip to content

Commit

Permalink
Add spec.insecure to OCIRepository API
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
  • Loading branch information
stefanprodan committed Aug 31, 2022
1 parent 181b217 commit a87cb24
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 3 deletions.
4 changes: 4 additions & 0 deletions api/v1beta2/ocirepository_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ type OCIRepositorySpec struct {
// +optional
Ignore *string `json:"ignore,omitempty"`

// Insecure allows connecting to a non-TLS HTTP container registry.
// +optional
Insecure bool `json:"insecure,omitempty"`

// This flag tells the controller to suspend the reconciliation of this source.
// +optional
Suspend bool `json:"suspend,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ spec:
a default will be used, consult the documentation for your version
to find out what those are.
type: string
insecure:
description: Insecure allows connecting to a non-TLS HTTP container
registry.
type: boolean
interval:
description: The interval at which to check for image updates.
type: string
Expand Down
10 changes: 7 additions & 3 deletions controllers/ocirepository_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func (r *OCIRepositoryReconciler) reconcileSource(ctx context.Context, obj *sour
ctxTimeout, cancel := context.WithTimeout(ctx, obj.Spec.Timeout.Duration)
defer cancel()

options := r.craneOptions(ctxTimeout)
options := r.craneOptions(ctxTimeout, obj.Spec.Insecure)

// Generate the registry credential keychain either from static credentials or using cloud OIDC
keychain, err := r.keychain(ctx, obj)
Expand Down Expand Up @@ -684,12 +684,16 @@ func (r *OCIRepositoryReconciler) oidcAuth(ctx context.Context, obj *sourcev1.OC

// craneOptions sets the auth headers, timeout and user agent
// for all operations against remote container registries.
func (r *OCIRepositoryReconciler) craneOptions(ctx context.Context) []crane.Option {
func (r *OCIRepositoryReconciler) craneOptions(ctx context.Context, insecure bool) []crane.Option {
options := []crane.Option{
crane.WithContext(ctx),
crane.WithUserAgent(oci.UserAgent),
}
options = append(options, crane.Insecure)

if insecure {
options = append(options, crane.Insecure)
}

return options
}

Expand Down
24 changes: 24 additions & 0 deletions docs/api/source.md
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,18 @@ consult the documentation for your version to find out what those are.</p>
</tr>
<tr>
<td>
<code>insecure</code><br>
<em>
bool
</em>
</td>
<td>
<em>(Optional)</em>
<p>Insecure allows connecting to a non-TLS HTTP container registry.</p>
</td>
</tr>
<tr>
<td>
<code>suspend</code><br>
<em>
bool
Expand Down Expand Up @@ -2839,6 +2851,18 @@ consult the documentation for your version to find out what those are.</p>
</tr>
<tr>
<td>
<code>insecure</code><br>
<em>
bool
</em>
</td>
<td>
<em>(Optional)</em>
<p>Insecure allows connecting to a non-TLS HTTP container registry.</p>
</td>
</tr>
<tr>
<td>
<code>suspend</code><br>
<em>
bool
Expand Down
6 changes: 6 additions & 0 deletions docs/spec/v1beta2/ocirepositories.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,12 @@ kubectl create secret generic tls-certs \
--from-file=caFile=ca.crt
```

### Insecure

`.spec.insecure` is an optional field to allow connecting to an insecure (HTTP)
container registry server, if set to `true`. The default value is `false`,
denying insecure (HTTP) connections.

### Interval

`.spec.interval` is a required field that specifies the interval at which the
Expand Down

0 comments on commit a87cb24

Please sign in to comment.