Disable user snippets per default (#10393)
* Disable user snippets per default * Enable snippet on tests
This commit is contained in:
parent
2d03da6334
commit
cf889c6c47
35 changed files with 494 additions and 288 deletions
|
|
@ -32,8 +32,10 @@ import (
|
|||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
const HelmChartPath = "charts/ingress-nginx/Chart.yaml"
|
||||
const HelmChartValues = "charts/ingress-nginx/values.yaml"
|
||||
const (
|
||||
HelmChartPath = "charts/ingress-nginx/Chart.yaml"
|
||||
HelmChartValues = "charts/ingress-nginx/values.yaml"
|
||||
)
|
||||
|
||||
type Helm mg.Namespace
|
||||
|
||||
|
|
@ -43,7 +45,6 @@ func (Helm) UpdateAppVersion() {
|
|||
}
|
||||
|
||||
func updateAppVersion() {
|
||||
|
||||
}
|
||||
|
||||
// UpdateVersion Update Helm Version of the Chart
|
||||
|
|
@ -69,11 +70,11 @@ func updateVersion(version string) {
|
|||
chart, err := chartutil.LoadChartfile(HelmChartPath)
|
||||
CheckIfError(err, "HELM Could not Load Chart")
|
||||
|
||||
//Get the current tag
|
||||
//appVersionV, err := getIngressNGINXVersion()
|
||||
//CheckIfError(err, "HELM Issue Retrieving the Current Ingress Nginx Version")
|
||||
// Get the current tag
|
||||
// appVersionV, err := getIngressNGINXVersion()
|
||||
// CheckIfError(err, "HELM Issue Retrieving the Current Ingress Nginx Version")
|
||||
|
||||
//remove the v from TAG
|
||||
// remove the v from TAG
|
||||
appVersion := version
|
||||
|
||||
Info("HELM Ingress-Nginx App Version: %s Chart AppVersion: %s", appVersion, chart.AppVersion)
|
||||
|
|
@ -82,7 +83,7 @@ func updateVersion(version string) {
|
|||
return
|
||||
}
|
||||
|
||||
//Update the helm chart
|
||||
// Update the helm chart
|
||||
chart.AppVersion = appVersion
|
||||
cTag, err := semver.Make(chart.Version)
|
||||
CheckIfError(err, "HELM Creating Chart Version: %v", err)
|
||||
|
|
@ -113,7 +114,6 @@ func updateChartReleaseNotes(releasesNotes []string) {
|
|||
}
|
||||
|
||||
func UpdateChartChangelog() {
|
||||
|
||||
}
|
||||
|
||||
// UpdateChartValue Updates the Helm ChartValue
|
||||
|
|
@ -124,16 +124,16 @@ func (Helm) UpdateChartValue(key, value string) {
|
|||
func updateChartValue(key, value string) {
|
||||
Info("HELM Updating Chart %s %s:%s", HelmChartValues, key, value)
|
||||
|
||||
//read current values.yaml
|
||||
// read current values.yaml
|
||||
data, err := os.ReadFile(HelmChartValues)
|
||||
CheckIfError(err, "HELM Could not Load Helm Chart Values files %s", HelmChartValues)
|
||||
|
||||
//var valuesStruct IngressChartValue
|
||||
// var valuesStruct IngressChartValue
|
||||
var n yaml.Node
|
||||
CheckIfError(yaml.Unmarshal(data, &n), "HELM Could not Unmarshal %s", HelmChartValues)
|
||||
|
||||
//update value
|
||||
//keyParse := parsePath(key)
|
||||
// update value
|
||||
// keyParse := parsePath(key)
|
||||
p, err := yamlpath.NewPath(key)
|
||||
CheckIfError(err, "HELM cannot create path")
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ func updateChartValue(key, value string) {
|
|||
yamlEncoder.SetIndent(2)
|
||||
err = yamlEncoder.Encode(&n)
|
||||
CheckIfError(err, "HELM Could not Marshal new Values file")
|
||||
err = os.WriteFile(HelmChartValues, b.Bytes(), 0644)
|
||||
err = os.WriteFile(HelmChartValues, b.Bytes(), 0o644)
|
||||
CheckIfError(err, "HELM Could not write new Values file to %s", HelmChartValues)
|
||||
|
||||
Info("HELM Ingress Nginx Helm Chart update %s %s", key, value)
|
||||
|
|
@ -161,6 +161,7 @@ func updateChartValue(key, value string) {
|
|||
func (Helm) Helmdocs() error {
|
||||
return runHelmDocs()
|
||||
}
|
||||
|
||||
func runHelmDocs() error {
|
||||
err := installHelmDocs()
|
||||
if err != nil {
|
||||
|
|
@ -175,7 +176,7 @@ func runHelmDocs() error {
|
|||
|
||||
func installHelmDocs() error {
|
||||
Info("HELM Install HelmDocs")
|
||||
var g0 = sh.RunCmd("go")
|
||||
g0 := sh.RunCmd("go")
|
||||
|
||||
err := g0("install", "github.com/norwoodj/helm-docs/cmd/helm-docs@v1.11.0")
|
||||
if err != nil {
|
||||
|
|
@ -186,13 +187,11 @@ func installHelmDocs() error {
|
|||
func parsePath(key string) []string { return strings.Split(key, ".") }
|
||||
|
||||
func updateHelmDocs() {
|
||||
|
||||
}
|
||||
|
||||
type IngressChartValue struct {
|
||||
CommonLabels struct {
|
||||
} `yaml:"commonLabels"`
|
||||
Controller struct {
|
||||
CommonLabels struct{} `yaml:"commonLabels"`
|
||||
Controller struct {
|
||||
Name string `yaml:"name"`
|
||||
Image struct {
|
||||
Chroot bool `yaml:"chroot"`
|
||||
|
|
@ -211,24 +210,18 @@ type IngressChartValue struct {
|
|||
HTTP int `yaml:"http"`
|
||||
HTTPS int `yaml:"https"`
|
||||
} `yaml:"containerPort"`
|
||||
Config struct {
|
||||
} `yaml:"config"`
|
||||
ConfigAnnotations struct {
|
||||
} `yaml:"configAnnotations"`
|
||||
ProxySetHeaders struct {
|
||||
} `yaml:"proxySetHeaders"`
|
||||
AddHeaders struct {
|
||||
} `yaml:"addHeaders"`
|
||||
DNSConfig struct {
|
||||
} `yaml:"dnsConfig"`
|
||||
Hostname struct {
|
||||
} `yaml:"hostname"`
|
||||
DNSPolicy string `yaml:"dnsPolicy"`
|
||||
ReportNodeInternalIP bool `yaml:"reportNodeInternalIp"`
|
||||
WatchIngressWithoutClass bool `yaml:"watchIngressWithoutClass"`
|
||||
IngressClassByName bool `yaml:"ingressClassByName"`
|
||||
AllowSnippetAnnotations bool `yaml:"allowSnippetAnnotations"`
|
||||
HostNetwork bool `yaml:"hostNetwork"`
|
||||
Config struct{} `yaml:"config"`
|
||||
ConfigAnnotations struct{} `yaml:"configAnnotations"`
|
||||
ProxySetHeaders struct{} `yaml:"proxySetHeaders"`
|
||||
AddHeaders struct{} `yaml:"addHeaders"`
|
||||
DNSConfig struct{} `yaml:"dnsConfig"`
|
||||
Hostname struct{} `yaml:"hostname"`
|
||||
DNSPolicy string `yaml:"dnsPolicy"`
|
||||
ReportNodeInternalIP bool `yaml:"reportNodeInternalIp"`
|
||||
WatchIngressWithoutClass bool `yaml:"watchIngressWithoutClass"`
|
||||
IngressClassByName bool `yaml:"ingressClassByName"`
|
||||
AllowSnippetAnnotations bool `yaml:"allowSnippetAnnotations"`
|
||||
HostNetwork bool `yaml:"hostNetwork"`
|
||||
HostPort struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
Ports struct {
|
||||
|
|
@ -238,21 +231,17 @@ type IngressChartValue struct {
|
|||
} `yaml:"hostPort"`
|
||||
ElectionID string `yaml:"electionID"`
|
||||
IngressClassResource struct {
|
||||
Name string `yaml:"name"`
|
||||
Enabled bool `yaml:"enabled"`
|
||||
Default bool `yaml:"default"`
|
||||
ControllerValue string `yaml:"controllerValue"`
|
||||
Parameters struct {
|
||||
} `yaml:"parameters"`
|
||||
Name string `yaml:"name"`
|
||||
Enabled bool `yaml:"enabled"`
|
||||
Default bool `yaml:"default"`
|
||||
ControllerValue string `yaml:"controllerValue"`
|
||||
Parameters struct{} `yaml:"parameters"`
|
||||
} `yaml:"ingressClassResource"`
|
||||
IngressClass string `yaml:"ingressClass"`
|
||||
PodLabels struct {
|
||||
} `yaml:"podLabels"`
|
||||
PodSecurityContext struct {
|
||||
} `yaml:"podSecurityContext"`
|
||||
Sysctls struct {
|
||||
} `yaml:"sysctls"`
|
||||
PublishService struct {
|
||||
IngressClass string `yaml:"ingressClass"`
|
||||
PodLabels struct{} `yaml:"podLabels"`
|
||||
PodSecurityContext struct{} `yaml:"podSecurityContext"`
|
||||
Sysctls struct{} `yaml:"sysctls"`
|
||||
PublishService struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
PathOverride string `yaml:"pathOverride"`
|
||||
} `yaml:"publishService"`
|
||||
|
|
@ -263,30 +252,23 @@ type IngressChartValue struct {
|
|||
} `yaml:"scope"`
|
||||
ConfigMapNamespace string `yaml:"configMapNamespace"`
|
||||
TCP struct {
|
||||
ConfigMapNamespace string `yaml:"configMapNamespace"`
|
||||
Annotations struct {
|
||||
} `yaml:"annotations"`
|
||||
ConfigMapNamespace string `yaml:"configMapNamespace"`
|
||||
Annotations struct{} `yaml:"annotations"`
|
||||
} `yaml:"tcp"`
|
||||
UDP struct {
|
||||
ConfigMapNamespace string `yaml:"configMapNamespace"`
|
||||
Annotations struct {
|
||||
} `yaml:"annotations"`
|
||||
ConfigMapNamespace string `yaml:"configMapNamespace"`
|
||||
Annotations struct{} `yaml:"annotations"`
|
||||
} `yaml:"udp"`
|
||||
MaxmindLicenseKey string `yaml:"maxmindLicenseKey"`
|
||||
ExtraArgs struct {
|
||||
} `yaml:"extraArgs"`
|
||||
ExtraEnvs []interface{} `yaml:"extraEnvs"`
|
||||
Kind string `yaml:"kind"`
|
||||
Annotations struct {
|
||||
} `yaml:"annotations"`
|
||||
Labels struct {
|
||||
} `yaml:"labels"`
|
||||
UpdateStrategy struct {
|
||||
} `yaml:"updateStrategy"`
|
||||
MinReadySeconds int `yaml:"minReadySeconds"`
|
||||
Tolerations []interface{} `yaml:"tolerations"`
|
||||
Affinity struct {
|
||||
} `yaml:"affinity"`
|
||||
MaxmindLicenseKey string `yaml:"maxmindLicenseKey"`
|
||||
ExtraArgs struct{} `yaml:"extraArgs"`
|
||||
ExtraEnvs []interface{} `yaml:"extraEnvs"`
|
||||
Kind string `yaml:"kind"`
|
||||
Annotations struct{} `yaml:"annotations"`
|
||||
Labels struct{} `yaml:"labels"`
|
||||
UpdateStrategy struct{} `yaml:"updateStrategy"`
|
||||
MinReadySeconds int `yaml:"minReadySeconds"`
|
||||
Tolerations []interface{} `yaml:"tolerations"`
|
||||
Affinity struct{} `yaml:"affinity"`
|
||||
TopologySpreadConstraints []interface{} `yaml:"topologySpreadConstraints"`
|
||||
TerminationGracePeriodSeconds int `yaml:"terminationGracePeriodSeconds"`
|
||||
NodeSelector struct {
|
||||
|
|
@ -316,29 +298,26 @@ type IngressChartValue struct {
|
|||
SuccessThreshold int `yaml:"successThreshold"`
|
||||
FailureThreshold int `yaml:"failureThreshold"`
|
||||
} `yaml:"readinessProbe"`
|
||||
HealthCheckPath string `yaml:"healthCheckPath"`
|
||||
HealthCheckHost string `yaml:"healthCheckHost"`
|
||||
PodAnnotations struct {
|
||||
} `yaml:"podAnnotations"`
|
||||
ReplicaCount int `yaml:"replicaCount"`
|
||||
MinAvailable int `yaml:"minAvailable"`
|
||||
Resources struct {
|
||||
HealthCheckPath string `yaml:"healthCheckPath"`
|
||||
HealthCheckHost string `yaml:"healthCheckHost"`
|
||||
PodAnnotations struct{} `yaml:"podAnnotations"`
|
||||
ReplicaCount int `yaml:"replicaCount"`
|
||||
MinAvailable int `yaml:"minAvailable"`
|
||||
Resources struct {
|
||||
Requests struct {
|
||||
CPU string `yaml:"cpu"`
|
||||
Memory string `yaml:"memory"`
|
||||
} `yaml:"requests"`
|
||||
} `yaml:"resources"`
|
||||
Autoscaling struct {
|
||||
APIVersion string `yaml:"apiVersion"`
|
||||
Enabled bool `yaml:"enabled"`
|
||||
Annotations struct {
|
||||
} `yaml:"annotations"`
|
||||
MinReplicas int `yaml:"minReplicas"`
|
||||
MaxReplicas int `yaml:"maxReplicas"`
|
||||
TargetCPUUtilizationPercentage int `yaml:"targetCPUUtilizationPercentage"`
|
||||
TargetMemoryUtilizationPercentage int `yaml:"targetMemoryUtilizationPercentage"`
|
||||
Behavior struct {
|
||||
} `yaml:"behavior"`
|
||||
APIVersion string `yaml:"apiVersion"`
|
||||
Enabled bool `yaml:"enabled"`
|
||||
Annotations struct{} `yaml:"annotations"`
|
||||
MinReplicas int `yaml:"minReplicas"`
|
||||
MaxReplicas int `yaml:"maxReplicas"`
|
||||
TargetCPUUtilizationPercentage int `yaml:"targetCPUUtilizationPercentage"`
|
||||
TargetMemoryUtilizationPercentage int `yaml:"targetMemoryUtilizationPercentage"`
|
||||
Behavior struct{} `yaml:"behavior"`
|
||||
} `yaml:"autoscaling"`
|
||||
AutoscalingTemplate []interface{} `yaml:"autoscalingTemplate"`
|
||||
Keda struct {
|
||||
|
|
@ -350,12 +329,10 @@ type IngressChartValue struct {
|
|||
CooldownPeriod int `yaml:"cooldownPeriod"`
|
||||
RestoreToOriginalReplicaCount bool `yaml:"restoreToOriginalReplicaCount"`
|
||||
ScaledObject struct {
|
||||
Annotations struct {
|
||||
} `yaml:"annotations"`
|
||||
Annotations struct{} `yaml:"annotations"`
|
||||
} `yaml:"scaledObject"`
|
||||
Triggers []interface{} `yaml:"triggers"`
|
||||
Behavior struct {
|
||||
} `yaml:"behavior"`
|
||||
Behavior struct{} `yaml:"behavior"`
|
||||
} `yaml:"keda"`
|
||||
EnableMimalloc bool `yaml:"enableMimalloc"`
|
||||
CustomTemplate struct {
|
||||
|
|
@ -363,12 +340,10 @@ type IngressChartValue struct {
|
|||
ConfigMapKey string `yaml:"configMapKey"`
|
||||
} `yaml:"customTemplate"`
|
||||
Service struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
AppProtocol bool `yaml:"appProtocol"`
|
||||
Annotations struct {
|
||||
} `yaml:"annotations"`
|
||||
Labels struct {
|
||||
} `yaml:"labels"`
|
||||
Enabled bool `yaml:"enabled"`
|
||||
AppProtocol bool `yaml:"appProtocol"`
|
||||
Annotations struct{} `yaml:"annotations"`
|
||||
Labels struct{} `yaml:"labels"`
|
||||
ExternalIPs []interface{} `yaml:"externalIPs"`
|
||||
LoadBalancerIP string `yaml:"loadBalancerIP"`
|
||||
LoadBalancerSourceRanges []interface{} `yaml:"loadBalancerSourceRanges"`
|
||||
|
|
@ -386,20 +361,17 @@ type IngressChartValue struct {
|
|||
} `yaml:"targetPorts"`
|
||||
Type string `yaml:"type"`
|
||||
NodePorts struct {
|
||||
HTTP string `yaml:"http"`
|
||||
HTTPS string `yaml:"https"`
|
||||
TCP struct {
|
||||
} `yaml:"tcp"`
|
||||
UDP struct {
|
||||
} `yaml:"udp"`
|
||||
HTTP string `yaml:"http"`
|
||||
HTTPS string `yaml:"https"`
|
||||
TCP struct{} `yaml:"tcp"`
|
||||
UDP struct{} `yaml:"udp"`
|
||||
} `yaml:"nodePorts"`
|
||||
External struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
} `yaml:"external"`
|
||||
Internal struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
Annotations struct {
|
||||
} `yaml:"annotations"`
|
||||
Enabled bool `yaml:"enabled"`
|
||||
Annotations struct{} `yaml:"annotations"`
|
||||
LoadBalancerSourceRanges []interface{} `yaml:"loadBalancerSourceRanges"`
|
||||
} `yaml:"internal"`
|
||||
} `yaml:"service"`
|
||||
|
|
@ -417,25 +389,20 @@ type IngressChartValue struct {
|
|||
} `yaml:"containerSecurityContext"`
|
||||
} `yaml:"opentelemetry"`
|
||||
AdmissionWebhooks struct {
|
||||
Annotations struct {
|
||||
} `yaml:"annotations"`
|
||||
Enabled bool `yaml:"enabled"`
|
||||
ExtraEnvs []interface{} `yaml:"extraEnvs"`
|
||||
FailurePolicy string `yaml:"failurePolicy"`
|
||||
Port int `yaml:"port"`
|
||||
Certificate string `yaml:"certificate"`
|
||||
Key string `yaml:"key"`
|
||||
NamespaceSelector struct {
|
||||
} `yaml:"namespaceSelector"`
|
||||
ObjectSelector struct {
|
||||
} `yaml:"objectSelector"`
|
||||
Labels struct {
|
||||
} `yaml:"labels"`
|
||||
ExistingPsp string `yaml:"existingPsp"`
|
||||
NetworkPolicyEnabled bool `yaml:"networkPolicyEnabled"`
|
||||
Annotations struct{} `yaml:"annotations"`
|
||||
Enabled bool `yaml:"enabled"`
|
||||
ExtraEnvs []interface{} `yaml:"extraEnvs"`
|
||||
FailurePolicy string `yaml:"failurePolicy"`
|
||||
Port int `yaml:"port"`
|
||||
Certificate string `yaml:"certificate"`
|
||||
Key string `yaml:"key"`
|
||||
NamespaceSelector struct{} `yaml:"namespaceSelector"`
|
||||
ObjectSelector struct{} `yaml:"objectSelector"`
|
||||
Labels struct{} `yaml:"labels"`
|
||||
ExistingPsp string `yaml:"existingPsp"`
|
||||
NetworkPolicyEnabled bool `yaml:"networkPolicyEnabled"`
|
||||
Service struct {
|
||||
Annotations struct {
|
||||
} `yaml:"annotations"`
|
||||
Annotations struct{} `yaml:"annotations"`
|
||||
ExternalIPs []interface{} `yaml:"externalIPs"`
|
||||
LoadBalancerSourceRanges []interface{} `yaml:"loadBalancerSourceRanges"`
|
||||
ServicePort int `yaml:"servicePort"`
|
||||
|
|
@ -445,15 +412,13 @@ type IngressChartValue struct {
|
|||
SecurityContext struct {
|
||||
AllowPrivilegeEscalation bool `yaml:"allowPrivilegeEscalation"`
|
||||
} `yaml:"securityContext"`
|
||||
Resources struct {
|
||||
} `yaml:"resources"`
|
||||
Resources struct{} `yaml:"resources"`
|
||||
} `yaml:"createSecretJob"`
|
||||
PatchWebhookJob struct {
|
||||
SecurityContext struct {
|
||||
AllowPrivilegeEscalation bool `yaml:"allowPrivilegeEscalation"`
|
||||
} `yaml:"securityContext"`
|
||||
Resources struct {
|
||||
} `yaml:"resources"`
|
||||
Resources struct{} `yaml:"resources"`
|
||||
} `yaml:"patchWebhookJob"`
|
||||
Patch struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
|
|
@ -464,15 +429,13 @@ type IngressChartValue struct {
|
|||
Digest string `yaml:"digest"`
|
||||
PullPolicy string `yaml:"pullPolicy"`
|
||||
} `yaml:"image"`
|
||||
PriorityClassName string `yaml:"priorityClassName"`
|
||||
PodAnnotations struct {
|
||||
} `yaml:"podAnnotations"`
|
||||
NodeSelector struct {
|
||||
PriorityClassName string `yaml:"priorityClassName"`
|
||||
PodAnnotations struct{} `yaml:"podAnnotations"`
|
||||
NodeSelector struct {
|
||||
KubernetesIoOs string `yaml:"kubernetes.io/os"`
|
||||
} `yaml:"nodeSelector"`
|
||||
Tolerations []interface{} `yaml:"tolerations"`
|
||||
Labels struct {
|
||||
} `yaml:"labels"`
|
||||
Tolerations []interface{} `yaml:"tolerations"`
|
||||
Labels struct{} `yaml:"labels"`
|
||||
SecurityContext struct {
|
||||
RunAsNonRoot bool `yaml:"runAsNonRoot"`
|
||||
RunAsUser int `yaml:"runAsUser"`
|
||||
|
|
@ -494,30 +457,26 @@ type IngressChartValue struct {
|
|||
PortName string `yaml:"portName"`
|
||||
Enabled bool `yaml:"enabled"`
|
||||
Service struct {
|
||||
Annotations struct {
|
||||
} `yaml:"annotations"`
|
||||
Annotations struct{} `yaml:"annotations"`
|
||||
ExternalIPs []interface{} `yaml:"externalIPs"`
|
||||
LoadBalancerSourceRanges []interface{} `yaml:"loadBalancerSourceRanges"`
|
||||
ServicePort int `yaml:"servicePort"`
|
||||
Type string `yaml:"type"`
|
||||
} `yaml:"service"`
|
||||
ServiceMonitor struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
AdditionalLabels struct {
|
||||
} `yaml:"additionalLabels"`
|
||||
Namespace string `yaml:"namespace"`
|
||||
NamespaceSelector struct {
|
||||
} `yaml:"namespaceSelector"`
|
||||
Enabled bool `yaml:"enabled"`
|
||||
AdditionalLabels struct{} `yaml:"additionalLabels"`
|
||||
Namespace string `yaml:"namespace"`
|
||||
NamespaceSelector struct{} `yaml:"namespaceSelector"`
|
||||
ScrapeInterval string `yaml:"scrapeInterval"`
|
||||
TargetLabels []interface{} `yaml:"targetLabels"`
|
||||
Relabelings []interface{} `yaml:"relabelings"`
|
||||
MetricRelabelings []interface{} `yaml:"metricRelabelings"`
|
||||
} `yaml:"serviceMonitor"`
|
||||
PrometheusRule struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
AdditionalLabels struct {
|
||||
} `yaml:"additionalLabels"`
|
||||
Rules []interface{} `yaml:"rules"`
|
||||
Enabled bool `yaml:"enabled"`
|
||||
AdditionalLabels struct{} `yaml:"additionalLabels"`
|
||||
Rules []interface{} `yaml:"rules"`
|
||||
} `yaml:"prometheusRule"`
|
||||
} `yaml:"metrics"`
|
||||
Lifecycle struct {
|
||||
|
|
@ -543,9 +502,8 @@ type IngressChartValue struct {
|
|||
ReadOnlyRootFilesystem bool `yaml:"readOnlyRootFilesystem"`
|
||||
AllowPrivilegeEscalation bool `yaml:"allowPrivilegeEscalation"`
|
||||
} `yaml:"image"`
|
||||
ExistingPsp string `yaml:"existingPsp"`
|
||||
ExtraArgs struct {
|
||||
} `yaml:"extraArgs"`
|
||||
ExistingPsp string `yaml:"existingPsp"`
|
||||
ExtraArgs struct{} `yaml:"extraArgs"`
|
||||
ServiceAccount struct {
|
||||
Create bool `yaml:"create"`
|
||||
Name string `yaml:"name"`
|
||||
|
|
@ -567,46 +525,37 @@ type IngressChartValue struct {
|
|||
SuccessThreshold int `yaml:"successThreshold"`
|
||||
TimeoutSeconds int `yaml:"timeoutSeconds"`
|
||||
} `yaml:"readinessProbe"`
|
||||
Tolerations []interface{} `yaml:"tolerations"`
|
||||
Affinity struct {
|
||||
} `yaml:"affinity"`
|
||||
PodSecurityContext struct {
|
||||
} `yaml:"podSecurityContext"`
|
||||
ContainerSecurityContext struct {
|
||||
} `yaml:"containerSecurityContext"`
|
||||
PodLabels struct {
|
||||
} `yaml:"podLabels"`
|
||||
NodeSelector struct {
|
||||
Tolerations []interface{} `yaml:"tolerations"`
|
||||
Affinity struct{} `yaml:"affinity"`
|
||||
PodSecurityContext struct{} `yaml:"podSecurityContext"`
|
||||
ContainerSecurityContext struct{} `yaml:"containerSecurityContext"`
|
||||
PodLabels struct{} `yaml:"podLabels"`
|
||||
NodeSelector struct {
|
||||
KubernetesIoOs string `yaml:"kubernetes.io/os"`
|
||||
} `yaml:"nodeSelector"`
|
||||
PodAnnotations struct {
|
||||
} `yaml:"podAnnotations"`
|
||||
ReplicaCount int `yaml:"replicaCount"`
|
||||
MinAvailable int `yaml:"minAvailable"`
|
||||
Resources struct {
|
||||
} `yaml:"resources"`
|
||||
PodAnnotations struct{} `yaml:"podAnnotations"`
|
||||
ReplicaCount int `yaml:"replicaCount"`
|
||||
MinAvailable int `yaml:"minAvailable"`
|
||||
Resources struct{} `yaml:"resources"`
|
||||
ExtraVolumeMounts []interface{} `yaml:"extraVolumeMounts"`
|
||||
ExtraVolumes []interface{} `yaml:"extraVolumes"`
|
||||
Autoscaling struct {
|
||||
Annotations struct {
|
||||
} `yaml:"annotations"`
|
||||
Enabled bool `yaml:"enabled"`
|
||||
MinReplicas int `yaml:"minReplicas"`
|
||||
MaxReplicas int `yaml:"maxReplicas"`
|
||||
TargetCPUUtilizationPercentage int `yaml:"targetCPUUtilizationPercentage"`
|
||||
TargetMemoryUtilizationPercentage int `yaml:"targetMemoryUtilizationPercentage"`
|
||||
Annotations struct{} `yaml:"annotations"`
|
||||
Enabled bool `yaml:"enabled"`
|
||||
MinReplicas int `yaml:"minReplicas"`
|
||||
MaxReplicas int `yaml:"maxReplicas"`
|
||||
TargetCPUUtilizationPercentage int `yaml:"targetCPUUtilizationPercentage"`
|
||||
TargetMemoryUtilizationPercentage int `yaml:"targetMemoryUtilizationPercentage"`
|
||||
} `yaml:"autoscaling"`
|
||||
Service struct {
|
||||
Annotations struct {
|
||||
} `yaml:"annotations"`
|
||||
Annotations struct{} `yaml:"annotations"`
|
||||
ExternalIPs []interface{} `yaml:"externalIPs"`
|
||||
LoadBalancerSourceRanges []interface{} `yaml:"loadBalancerSourceRanges"`
|
||||
ServicePort int `yaml:"servicePort"`
|
||||
Type string `yaml:"type"`
|
||||
} `yaml:"service"`
|
||||
PriorityClassName string `yaml:"priorityClassName"`
|
||||
Labels struct {
|
||||
} `yaml:"labels"`
|
||||
PriorityClassName string `yaml:"priorityClassName"`
|
||||
Labels struct{} `yaml:"labels"`
|
||||
} `yaml:"defaultBackend"`
|
||||
Rbac struct {
|
||||
Create bool `yaml:"create"`
|
||||
|
|
@ -616,17 +565,14 @@ type IngressChartValue struct {
|
|||
Enabled bool `yaml:"enabled"`
|
||||
} `yaml:"podSecurityPolicy"`
|
||||
ServiceAccount struct {
|
||||
Create bool `yaml:"create"`
|
||||
Name string `yaml:"name"`
|
||||
AutomountServiceAccountToken bool `yaml:"automountServiceAccountToken"`
|
||||
Annotations struct {
|
||||
} `yaml:"annotations"`
|
||||
Create bool `yaml:"create"`
|
||||
Name string `yaml:"name"`
|
||||
AutomountServiceAccountToken bool `yaml:"automountServiceAccountToken"`
|
||||
Annotations struct{} `yaml:"annotations"`
|
||||
} `yaml:"serviceAccount"`
|
||||
ImagePullSecrets []interface{} `yaml:"imagePullSecrets"`
|
||||
TCP struct {
|
||||
} `yaml:"tcp"`
|
||||
UDP struct {
|
||||
} `yaml:"udp"`
|
||||
PortNamePrefix string `yaml:"portNamePrefix"`
|
||||
DhParam interface{} `yaml:"dhParam"`
|
||||
TCP struct{} `yaml:"tcp"`
|
||||
UDP struct{} `yaml:"udp"`
|
||||
PortNamePrefix string `yaml:"portNamePrefix"`
|
||||
DhParam interface{} `yaml:"dhParam"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,9 @@ limitations under the License.
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/magefile/mage/mage"
|
||||
"os"
|
||||
|
||||
"github.com/magefile/mage/mage"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
|||
|
|
@ -22,39 +22,45 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
"github.com/google/go-github/v48/github"
|
||||
"github.com/magefile/mage/mg"
|
||||
"github.com/magefile/mage/sh"
|
||||
"golang.org/x/oauth2"
|
||||
"gopkg.in/yaml.v3"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"text/template"
|
||||
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Release mg.Namespace
|
||||
|
||||
var INGRESS_ORG = "kubernetes" // the owner so we can test from forks
|
||||
var INGRESS_REPO = "ingress-nginx" // the repo to pull from
|
||||
var RELEASE_BRANCH = "main" //we only release from main
|
||||
var GITHUB_TOKEN string // the Google/gogithub lib needs an PAT to access the GitHub API
|
||||
var K8S_IO_ORG = "kubernetes" //the owner or organization for the k8s.io repo
|
||||
var K8S_IO_REPO = "k8s.io" //the repo that holds the images yaml for production promotion
|
||||
var INGRESS_REGISTRY = "registry.k8s.io" //Container registry for storage Ingress-nginx images
|
||||
var KUSTOMIZE_INSTALL_VERSION = "sigs.k8s.io/kustomize/kustomize/v4@v4.5.4" //static deploys needs kustomize to generate the template
|
||||
var (
|
||||
INGRESS_ORG = "kubernetes" // the owner so we can test from forks
|
||||
INGRESS_REPO = "ingress-nginx" // the repo to pull from
|
||||
RELEASE_BRANCH = "main" // we only release from main
|
||||
GITHUB_TOKEN string // the Google/gogithub lib needs an PAT to access the GitHub API
|
||||
K8S_IO_ORG = "kubernetes" // the owner or organization for the k8s.io repo
|
||||
K8S_IO_REPO = "k8s.io" // the repo that holds the images yaml for production promotion
|
||||
INGRESS_REGISTRY = "registry.k8s.io" // Container registry for storage Ingress-nginx images
|
||||
KUSTOMIZE_INSTALL_VERSION = "sigs.k8s.io/kustomize/kustomize/v4@v4.5.4" // static deploys needs kustomize to generate the template
|
||||
)
|
||||
|
||||
// ingress-nginx releases start with a TAG then a cloudbuild, then a promotion through a PR, this the location of that PR
|
||||
var IMAGES_YAML = "https://raw.githubusercontent.com/kubernetes/k8s.io/main/registry.k8s.io/images/k8s-staging-ingress-nginx/images.yaml"
|
||||
var ctx = context.Background() // Context used for GitHub Client
|
||||
var (
|
||||
IMAGES_YAML = "https://raw.githubusercontent.com/kubernetes/k8s.io/main/registry.k8s.io/images/k8s-staging-ingress-nginx/images.yaml"
|
||||
ctx = context.Background() // Context used for GitHub Client
|
||||
)
|
||||
|
||||
const INDEX_DOCS = "docs/deploy/index.md" //index.md has a version of the controller and needs to updated
|
||||
const CHANGELOG = "Changelog.md" //Name of the changelog
|
||||
const (
|
||||
INDEX_DOCS = "docs/deploy/index.md" // index.md has a version of the controller and needs to updated
|
||||
CHANGELOG = "Changelog.md" // Name of the changelog
|
||||
)
|
||||
|
||||
// ControllerImage - struct with info about controllers
|
||||
type ControllerImage struct {
|
||||
|
|
@ -101,81 +107,80 @@ func init() {
|
|||
|
||||
// PromoteImage Creates PR into the k8s.io repo for promotion of ingress from staging to production
|
||||
func (Release) PromoteImage(version, sha string) {
|
||||
|
||||
}
|
||||
|
||||
// Release Create a new release of ingress nginx controller
|
||||
func (Release) NewRelease(version string) {
|
||||
//newRelease := Release{}
|
||||
// newRelease := Release{}
|
||||
|
||||
//update ingress-nginx version
|
||||
//This is the step that kicks all the release process
|
||||
//it is already done, so it kicks off the gcloud build of the controller images
|
||||
//mg.Deps(mg.F(Tag.BumpNginx, version))
|
||||
// update ingress-nginx version
|
||||
// This is the step that kicks all the release process
|
||||
// it is already done, so it kicks off the gcloud build of the controller images
|
||||
// mg.Deps(mg.F(Tag.BumpNginx, version))
|
||||
|
||||
tag, err := getIngressNGINXVersion()
|
||||
CheckIfError(err, "RELEASE Retrieving the current Ingress Nginx Version")
|
||||
|
||||
Info("RELEASE Checking Current Version %s to New Version %s", tag, version)
|
||||
//if the version were upgrading does not match the TAG file, lets update the TAG file
|
||||
// if the version were upgrading does not match the TAG file, lets update the TAG file
|
||||
if tag[1:] != version {
|
||||
Warning("RELEASE Ingress Nginx TAG %s and new version %s do not match", tag, version)
|
||||
mg.Deps(mg.F(Tag.BumpNginx, fmt.Sprintf("v%s", version)))
|
||||
}
|
||||
|
||||
//update git controller tag controller-v$version
|
||||
// update git controller tag controller-v$version
|
||||
mg.Deps(mg.F(Tag.NewControllerTag, version))
|
||||
|
||||
//make release notes
|
||||
// make release notes
|
||||
releaseNotes, err := makeReleaseNotes(version)
|
||||
CheckIfError(err, "RELEASE Creating Release Notes for version %s", version)
|
||||
Info("RELEASE Release Notes %s completed", releaseNotes.Version)
|
||||
|
||||
//update chart values.yaml new controller tag and image digest
|
||||
// update chart values.yaml new controller tag and image digest
|
||||
releaseNotes.PreviousHelmChartVersion = currentChartVersion()
|
||||
|
||||
//controller tag
|
||||
// controller tag
|
||||
updateChartValue("controller.image.tag", fmt.Sprintf("v%s", releaseNotes.Version))
|
||||
Debug("releaseNotes.ControllerImages[0].Name %s", releaseNotes.ControllerImages[0].Name)
|
||||
Debug("releaseNotes.ControllerImages[1].Name %s", releaseNotes.ControllerImages[1].Name)
|
||||
//controller digest
|
||||
// controller digest
|
||||
if releaseNotes.ControllerImages[0].Name == "ingress-nginx/controller" {
|
||||
Debug("Updating Chart Value %s with %s", "controller.image.digest", releaseNotes.ControllerImages[0].Digest)
|
||||
updateChartValue("controller.image.digest", releaseNotes.ControllerImages[0].Digest)
|
||||
}
|
||||
//controller chroot digest
|
||||
// controller chroot digest
|
||||
if releaseNotes.ControllerImages[1].Name == "ingress-nginx/controller-chroot" {
|
||||
Debug("Updating Chart Value %s with %s", "controller.image.digestChroot", releaseNotes.ControllerImages[1].Digest)
|
||||
updateChartValue("controller.image.digestChroot", releaseNotes.ControllerImages[1].Digest)
|
||||
}
|
||||
|
||||
//update helm chart app version
|
||||
// update helm chart app version
|
||||
mg.Deps(mg.F(Helm.UpdateVersion, version))
|
||||
|
||||
releaseNotes.NewHelmChartVersion = currentChartVersion()
|
||||
|
||||
//update helm chart release notes
|
||||
// update helm chart release notes
|
||||
updateChartReleaseNotes(releaseNotes.HelmUpdates)
|
||||
|
||||
//Run helm docs update
|
||||
// Run helm docs update
|
||||
CheckIfError(runHelmDocs(), "Error Updating Helm Docs ")
|
||||
|
||||
releaseNotes.helmTemplate()
|
||||
|
||||
//update static manifest
|
||||
// update static manifest
|
||||
CheckIfError(updateStaticManifest(), "Error Updating Static manifests")
|
||||
|
||||
////update e2e docs
|
||||
updateE2EDocs()
|
||||
|
||||
//update documentation with ingress-nginx version
|
||||
// update documentation with ingress-nginx version
|
||||
CheckIfError(updateIndexMD(releaseNotes.PreviousControllerVersion, releaseNotes.NewControllerVersion), "Error Updating %s", INDEX_DOCS)
|
||||
|
||||
//keeping these manual for now
|
||||
//git commit TODO
|
||||
//make Pull Request TODO
|
||||
//make release TODO
|
||||
//mg.Deps(mg.F(Release.CreateRelease, version))
|
||||
// keeping these manual for now
|
||||
// git commit TODO
|
||||
// make Pull Request TODO
|
||||
// make release TODO
|
||||
// mg.Deps(mg.F(Release.CreateRelease, version))
|
||||
}
|
||||
|
||||
// the index.md doc needs the controller version updated
|
||||
|
|
@ -204,7 +209,7 @@ func updateE2EDocs() {
|
|||
// The static deploy scripts use kustomize to generate them, this function ensures kustomize is installed
|
||||
func installKustomize() error {
|
||||
Info("Install Kustomize")
|
||||
var g0 = sh.RunCmd("go")
|
||||
g0 := sh.RunCmd("go")
|
||||
// somewhere in your main code
|
||||
err := g0("install", KUSTOMIZE_INSTALL_VERSION)
|
||||
if err != nil {
|
||||
|
|
@ -215,7 +220,7 @@ func installKustomize() error {
|
|||
|
||||
func updateStaticManifest() error {
|
||||
CheckIfError(installKustomize(), "error installing kustomize")
|
||||
//hack/generate-deploy-scripts.sh
|
||||
// hack/generate-deploy-scripts.sh
|
||||
err := sh.RunV("./hack/generate-deploy-scripts.sh")
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -270,28 +275,28 @@ func (Release) ReleaseNotes(newVersion string) error {
|
|||
}
|
||||
|
||||
func makeReleaseNotes(newVersion string) (*ReleaseNote, error) {
|
||||
var newReleaseNotes = ReleaseNote{}
|
||||
newReleaseNotes := ReleaseNote{}
|
||||
|
||||
newReleaseNotes.Version = newVersion
|
||||
allControllerTags := getAllControllerTags()
|
||||
|
||||
//new version
|
||||
// new version
|
||||
newReleaseNotes.NewControllerVersion = allControllerTags[0]
|
||||
newControllerVersion := fmt.Sprintf("controller-v%s", newVersion)
|
||||
|
||||
//the newControllerVersion should match the latest tag
|
||||
// the newControllerVersion should match the latest tag
|
||||
if newControllerVersion != allControllerTags[0] {
|
||||
return nil, errors.New(fmt.Sprintf("Generating release new version %s didnt match the current latest tag %s", newControllerVersion, allControllerTags[0]))
|
||||
}
|
||||
//previous version
|
||||
// previous version
|
||||
newReleaseNotes.PreviousControllerVersion = allControllerTags[1]
|
||||
|
||||
Info("New Version: %s Old Version: %s", newReleaseNotes.NewControllerVersion, newReleaseNotes.PreviousControllerVersion)
|
||||
|
||||
commits := commitsBetweenTags()
|
||||
|
||||
//dependency_updates
|
||||
//all_updates
|
||||
// dependency_updates
|
||||
// all_updates
|
||||
var allUpdates []string
|
||||
var depUpdates []string
|
||||
var helmUpdates []string
|
||||
|
|
@ -299,9 +304,9 @@ func makeReleaseNotes(newVersion string) (*ReleaseNote, error) {
|
|||
depBot := regexp.MustCompile("^(\\w){1,10} Bump ")
|
||||
helmRegex := regexp.MustCompile("helm|chart")
|
||||
for i, s := range commits {
|
||||
//matches on PR
|
||||
// matches on PR
|
||||
if prRegex.Match([]byte(s)) {
|
||||
//matches a dependant bot update
|
||||
// matches a dependant bot update
|
||||
if depBot.Match([]byte(s)) { //
|
||||
Debug("#%v DEPENDABOT %v", i, s)
|
||||
u := strings.SplitN(s, " ", 2)
|
||||
|
|
@ -311,13 +316,12 @@ func makeReleaseNotes(newVersion string) (*ReleaseNote, error) {
|
|||
u := strings.SplitN(s, " ", 2)
|
||||
allUpdates = append(allUpdates, u[1])
|
||||
|
||||
//helm chart updates
|
||||
// helm chart updates
|
||||
if helmRegex.Match([]byte(s)) {
|
||||
u := strings.SplitN(s, " ", 2)
|
||||
helmUpdates = append(helmUpdates, u[1])
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
helmUpdates = append(helmUpdates, fmt.Sprintf("Update Ingress-Nginx version %s", newReleaseNotes.NewControllerVersion))
|
||||
|
|
@ -326,7 +330,7 @@ func makeReleaseNotes(newVersion string) (*ReleaseNote, error) {
|
|||
newReleaseNotes.DepUpdates = depUpdates
|
||||
newReleaseNotes.HelmUpdates = helmUpdates
|
||||
|
||||
//controller_image_digests
|
||||
// controller_image_digests
|
||||
imagesYaml, err := downloadFile(IMAGES_YAML)
|
||||
if err != nil {
|
||||
ErrorF("Could not download file %s : %s", IMAGES_YAML, err)
|
||||
|
|
@ -342,7 +346,7 @@ func makeReleaseNotes(newVersion string) (*ReleaseNote, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
//controller
|
||||
// controller
|
||||
controllerDigest := findImageDigest(data, "controller", newVersion)
|
||||
if len(controllerDigest) == 0 {
|
||||
ErrorF("Controller Digest could not be found")
|
||||
|
|
@ -379,7 +383,7 @@ func makeReleaseNotes(newVersion string) (*ReleaseNote, error) {
|
|||
newReleaseNotes.printRelease()
|
||||
}
|
||||
|
||||
//write it all out to the changelog file
|
||||
// write it all out to the changelog file
|
||||
newReleaseNotes.template()
|
||||
|
||||
return &newReleaseNotes, nil
|
||||
|
|
|
|||
|
|
@ -20,11 +20,12 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
semver "github.com/blang/semver/v4"
|
||||
"github.com/magefile/mage/mg"
|
||||
"github.com/magefile/mage/sh"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Tag mg.Namespace
|
||||
|
|
@ -42,7 +43,7 @@ func getIngressNGINXVersion() (string, error) {
|
|||
dat, err := os.ReadFile("TAG")
|
||||
CheckIfError(err, "Could not read TAG file")
|
||||
datString := string(dat)
|
||||
//remove newline
|
||||
// remove newline
|
||||
datString = strings.Replace(datString, "\n", "", -1)
|
||||
return datString, nil
|
||||
}
|
||||
|
|
@ -88,14 +89,14 @@ func (Tag) BumpNginx(newTag string) {
|
|||
}
|
||||
|
||||
func bump(currentTag, newTag string) {
|
||||
//check if semver is valid
|
||||
// check if semver is valid
|
||||
if !checkSemVer(currentTag, newTag) {
|
||||
ErrorF("ERROR: Semver is not valid %v", newTag)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
Info("Updating Tag %v to %v", currentTag, newTag)
|
||||
err := os.WriteFile("TAG", []byte(newTag), 0666)
|
||||
err := os.WriteFile("TAG", []byte(newTag), 0o666)
|
||||
CheckIfError(err, "Error Writing New Tag File")
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue