This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
358 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2023 D2iQ, Inc. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package variables | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" | ||
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" | ||
) | ||
|
||
func MarshalToClusterVariable[T any](name string, obj T) (*clusterv1.ClusterVariable, error) { | ||
marshaled, err := json.Marshal(obj) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to marshal variable value %q: %w", name, err) | ||
} | ||
return &clusterv1.ClusterVariable{ | ||
Name: name, | ||
Value: v1.JSON{Raw: marshaled}, | ||
}, nil | ||
} | ||
|
||
func UnmarshalClusterVariable[T any](clusterVariable *clusterv1.ClusterVariable, obj *T) error { | ||
err := json.Unmarshal(clusterVariable.Value.Raw, obj) | ||
if err != nil { | ||
return fmt.Errorf("error unmarshalling variable: %w", err) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func GetClusterVariableByName( | ||
name string, | ||
clusterVariables []clusterv1.ClusterVariable, | ||
) (*clusterv1.ClusterVariable, int) { | ||
for i, clusterVar := range clusterVariables { | ||
if clusterVar.Name == name { | ||
return &clusterVar, i | ||
} | ||
} | ||
return nil, -1 | ||
} | ||
|
||
func GetMachineDeploymentVariableByName( | ||
name string, | ||
machineDeploymentVariables *clusterv1.MachineDeploymentVariables, | ||
) (*clusterv1.ClusterVariable, int) { | ||
if machineDeploymentVariables == nil { | ||
return nil, -1 | ||
} | ||
for i, mdVar := range machineDeploymentVariables.Overrides { | ||
if mdVar.Name == name { | ||
return &mdVar, i | ||
} | ||
} | ||
return nil, -1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
charts/cluster-api-runtime-extensions-nutanix/templates/webhook-service.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright 2023 D2iQ, Inc. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
annotations: | ||
{{- with .Values.webhooks.service.annotations }} | ||
{{ toYaml . | nindent 4 }} | ||
{{- end }} | ||
labels: | ||
{{- include "chart.labels" . | nindent 4 }} | ||
name: {{ template "chart.name" . }}-webhook-service | ||
namespace: {{ .Release.Namespace }} | ||
spec: | ||
type: {{.Values.webhooks.service.type}} | ||
ports: | ||
- name: https | ||
port: {{ .Values.webhooks.service.port }} | ||
protocol: TCP | ||
targetPort: webhook-server | ||
{{- if and .Values.webhooks.service.nodePort (eq "NodePort" .Values.service.type) }} | ||
nodePort: {{ .Values.webhooks.service.nodePort }} | ||
{{- end }} | ||
selector: | ||
{{- include "chart.selectorLabels" . | nindent 4 }} |
32 changes: 32 additions & 0 deletions
32
charts/cluster-api-runtime-extensions-nutanix/templates/webhook.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright 2023 D2iQ, Inc. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
apiVersion: admissionregistration.k8s.io/v1 | ||
kind: MutatingWebhookConfiguration | ||
metadata: | ||
name: {{ template "chart.name" . }}-webhook-configuration | ||
annotations: | ||
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ template "chart.name" . }}-service-cert | ||
webhooks: | ||
- admissionReviewVersions: | ||
- v1 | ||
- v1beta1 | ||
clientConfig: | ||
service: | ||
name: {{ template "chart.name" . }}-webhook-service | ||
namespace: {{ .Release.Namespace }} | ||
path: /mutate-cluster-x-k8s-io-v1beta1-cluster | ||
failurePolicy: Fail | ||
matchPolicy: Equivalent | ||
name: default.cluster.cluster.x-k8s.io | ||
rules: | ||
- apiGroups: | ||
- cluster.x-k8s.io | ||
apiVersions: | ||
- v1beta1 | ||
operations: | ||
- CREATE | ||
- UPDATE | ||
resources: | ||
- clusters | ||
sideEffects: None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.