Skip to content

Commit

Permalink
Have charts be specified as raw strings
Browse files Browse the repository at this point in the history
These aren't large or secret data, so just an inline string is the appropriate typing here.
  • Loading branch information
michaeljguarino committed Jan 2, 2024
1 parent 108bca9 commit ac096df
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 60 deletions.
19 changes: 1 addition & 18 deletions charts/controller/crds/servicedeployment-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,23 +160,7 @@ spec:
helm:
properties:
chart:
description: Selects a key from a ConfigMap.
properties:
key:
description: The key to select.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
optional:
description: Specify whether the ConfigMap or its key must
be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
type: string
repository:
properties:
name:
Expand Down Expand Up @@ -301,7 +285,6 @@ spec:
required:
- clusterRef
- repositoryRef
- version
type: object
status:
properties:
Expand Down
2 changes: 1 addition & 1 deletion charts/controller/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ spec:
seccompProfile:
type: RuntimeDefault
serviceAccountName: {{ include "controller.fullname" . }}-controller-manager
terminationGracePeriodSeconds: 10
terminationGracePeriodSeconds: 10
3 changes: 2 additions & 1 deletion controller/api/v1alpha1/servicedeployment_types.go.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type ServiceHelm struct {
// +optional
ValuesFiles []*string `json:"valuesFiles,omitempty"`
// +optional
ChartRef *corev1.ConfigMapKeySelector `json:"chart,omitempty"`
Chart *string `json:"chart,omitempty"`
// +optional
Version *string `json:"version,omitempty"`
// +optional
Expand All @@ -51,6 +51,7 @@ type SyncConfigAttributes struct {
type ServiceSpec struct {
// +optional
DocsPath *string `json:"docsPath,omitempty"`
// +kubebuilder:validation:Optional
// +kubebuilder:default:='0.0.1'
Version string `json:"version"`
// +optional
Expand Down
8 changes: 4 additions & 4 deletions controller/api/v1alpha1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -157,23 +157,7 @@ spec:
helm:
properties:
chart:
description: Selects a key from a ConfigMap.
properties:
key:
description: The key to select.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
optional:
description: Specify whether the ConfigMap or its key must
be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
type: string
repository:
properties:
name:
Expand Down Expand Up @@ -298,7 +282,6 @@ spec:
required:
- clusterRef
- repositoryRef
- version
type: object
status:
properties:
Expand Down
20 changes: 2 additions & 18 deletions controller/internal/controller/servicedeployment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,8 @@ func (r *ServiceReconciler) genServiceAttributes(ctx context.Context, service *v
}
attr.Helm.Values = &val
}
if service.Spec.Helm.ChartRef != nil {
val, err := utils.GetConfigMapData(ctx, r.Client, service.Namespace, service.Spec.Helm.ChartRef)
if err != nil {
return nil, err
}
attr.Helm.Chart = &val
if service.Spec.Helm.Chart != nil {
attr.Helm.Chart = service.Spec.Helm.Chart
}
}
if service.Spec.SyncConfig != nil {
Expand Down Expand Up @@ -331,18 +327,6 @@ func (r *ServiceReconciler) addOwnerReferences(ctx context.Context, service *v1a
return err
}
}
if service.Spec.Helm != nil && service.Spec.Helm.ChartRef != nil {
configMap := &corev1.ConfigMap{}
name := types.NamespacedName{Name: service.Spec.Helm.ChartRef.Name, Namespace: service.Namespace}
err := r.Get(ctx, name, configMap)
if err != nil {
return err
}
err = utils.TryAddControllerRef(ctx, r.Client, service, configMap, r.Scheme)
if err != nil {
return err
}
}

return nil
}
Expand Down

0 comments on commit ac096df

Please sign in to comment.