Skip to content

Commit 7735453

Browse files
authored
Merge pull request #58 from leooamaral/fix/remove-type-spec
fix: remove unnecessary spec.helm.type
2 parents c8b0335 + 3ee9c58 commit 7735453

File tree

5 files changed

+37
-31
lines changed

5 files changed

+37
-31
lines changed

charts/suse-ai-operator/crds/installaiextensions.ai-platform.suse.com.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ spec:
4848
name:
4949
minLength: 1
5050
type: string
51-
namespace:
52-
type: string
5351
version:
5452
minLength: 1
5553
type: string
@@ -61,11 +59,14 @@ spec:
6159
properties:
6260
name:
6361
type: string
64-
namespace:
65-
type: string
66-
type:
67-
type: string
6862
url:
63+
description: |-
64+
URL of the Helm repository or OCI registry.
65+
Examples:
66+
oci://ghcr.io/my-org/charts
67+
https://charts.example.com
68+
minLength: 1
69+
pattern: ^(oci://|https?://).+
6970
type: string
7071
values:
7172
additionalProperties:
@@ -75,7 +76,6 @@ spec:
7576
type: string
7677
required:
7778
- name
78-
- type
7979
- url
8080
- version
8181
type: object

suse-ai-operator/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ metadata:
4949
spec:
5050
helm:
5151
name: suse-ai-lifecycle-manager
52-
url: "ghcr.io/suse/chart/suse-ai-lifecycle-manager"
52+
url: "oci://ghcr.io/suse/chart/suse-ai-lifecycle-manager"
5353
version: "1.0.0"
54-
type: "oci"
5554
extension:
5655
name: suse-ai-lifecycle-manager
5756
version: "1.0.0"

suse-ai-operator/api/v1alpha1/installaiextension_types.go

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,27 @@ type InstallAIExtensionSpec struct {
3232
Extension ExtensionSpec `json:"extension"`
3333
}
3434

35-
type HelmRepoType string
36-
37-
const (
38-
HelmRepoTypeOCI HelmRepoType = "oci"
39-
HelmRepoTypeHTTP HelmRepoType = "http"
40-
)
41-
4235
type HelmSpec struct {
43-
Name string `json:"name"`
44-
URL string `json:"url"`
45-
Namespace string `json:"namespace,omitempty"`
46-
Type HelmRepoType `json:"type"`
47-
Version string `json:"version"`
48-
Values map[string]apixv1.JSON `json:"values,omitempty"`
36+
Name string `json:"name"`
37+
// URL of the Helm repository or OCI registry.
38+
// Examples:
39+
// oci://ghcr.io/my-org/charts
40+
// https://charts.example.com
41+
//
42+
// +kubebuilder:validation:MinLength=1
43+
// +kubebuilder:validation:Pattern=`^(oci://|https?://).+`
44+
URL string `json:"url"`
45+
Version string `json:"version"`
46+
Values map[string]apixv1.JSON `json:"values,omitempty"`
4947
}
5048

5149
type ExtensionSpec struct {
5250
// +kubebuilder:validation:MinLength=1
5351
Name string `json:"name"`
5452

5553
// +kubebuilder:validation:MinLength=1
56-
Version string `json:"version"`
57-
Namespace string `json:"namespace,omitempty"`
58-
Metadata map[string]string `json:"metadata,omitempty"`
54+
Version string `json:"version"`
55+
Metadata map[string]string `json:"metadata,omitempty"`
5956
}
6057

6158
// InstallAIExtensionStatus defines the observed state of InstallAIExtension.

suse-ai-operator/internal/controller/installaiextension/installaiextension_controller.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import (
2020
"context"
2121
"fmt"
2222

23+
urlpkg "net/url"
24+
2325
"github.com/go-logr/logr"
2426
"helm.sh/helm/v3/pkg/cli"
2527
"k8s.io/apimachinery/pkg/runtime"
@@ -86,10 +88,19 @@ func (r *InstallAIExtensionReconciler) Reconcile(ctx context.Context, req ctrl.R
8688

8789
chart := ""
8890

89-
switch installExt.Spec.Helm.Type {
90-
case "oci":
91-
chart = "oci://" + installExt.Spec.Helm.URL
91+
url := installExt.Spec.Helm.URL
92+
93+
u, err := urlpkg.Parse(url)
94+
if err != nil {
95+
log.Error(err, "invalid helm url %q", url)
96+
}
97+
98+
switch u.Scheme {
99+
case "oci", "https":
100+
chart = url
92101
default:
102+
log.Error(err, "unsupported helm url scheme: %s", u.Scheme)
103+
return ctrl.Result{}, err
93104
}
94105

95106
settings := cli.New()

suse-ai-operator/samples/installaiextension.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ metadata:
55
spec:
66
helm:
77
name: suse-ai-lifecycle-manager
8-
url: "ghcr.io/suse/chart/suse-ai-lifecycle-manager"
8+
url: "oci://ghcr.io/suse/chart/suse-ai-lifecycle-manager"
99
version: "1.0.0"
10-
type: "oci"
1110
extension:
1211
name: suse-ai-lifecycle-manager
13-
version: "1.0.0"
12+
version: "1.0.0"

0 commit comments

Comments
 (0)