Rework mage (#10417)
This commit is contained in:
parent
8f54b538d9
commit
9635ece4c0
18 changed files with 959 additions and 624 deletions
|
|
@ -1,19 +0,0 @@
|
|||
//go:build mage
|
||||
|
||||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
//go:build mage
|
||||
//go:build ignore
|
||||
|
||||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
|
@ -17,3 +17,11 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/magefile/mage/mage"
|
||||
)
|
||||
|
||||
func main() { os.Exit(mage.Main()) }
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
//go:build mage
|
||||
|
||||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
//import (
|
||||
// "github.com/magefile/mage/mg"
|
||||
// "github.com/mysteriumnetwork/go-ci/commands"
|
||||
//)
|
||||
//
|
||||
//type Go mg.Namespace
|
||||
//
|
||||
//// Checks for issues with go imports
|
||||
//func (Go) CheckGoImports() error {
|
||||
// return commands.GoImports("./...")
|
||||
//}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
module github.com/kubernetes/ingress-nginx/magefiles
|
||||
module k8s.io/ingress-nginx/magefiles
|
||||
|
||||
go 1.21.1
|
||||
|
||||
|
|
@ -6,27 +6,27 @@ require (
|
|||
github.com/blang/semver/v4 v4.0.0
|
||||
github.com/google/go-github/v48 v48.2.0
|
||||
github.com/helm/helm v2.17.0+incompatible
|
||||
github.com/magefile/mage v1.14.0
|
||||
github.com/magefile/mage v1.15.0
|
||||
github.com/vmware-labs/yaml-jsonpath v0.3.2
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be
|
||||
golang.org/x/oauth2 v0.12.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.2.1 // indirect
|
||||
github.com/BurntSushi/toml v1.3.2 // indirect
|
||||
github.com/Masterminds/semver v1.5.0 // indirect
|
||||
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
|
||||
github.com/dprotaso/go-yit v0.0.0-20191028211022-135eb7262960 // indirect
|
||||
github.com/ghodss/yaml v1.0.0 // indirect
|
||||
github.com/gobwas/glob v0.2.3 // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/google/go-querystring v1.1.0 // indirect
|
||||
github.com/stretchr/testify v1.8.1 // indirect
|
||||
golang.org/x/crypto v0.1.0 // indirect
|
||||
golang.org/x/net v0.7.0 // indirect
|
||||
github.com/rogpeppe/go-internal v1.11.0 // indirect
|
||||
golang.org/x/crypto v0.13.0 // indirect
|
||||
golang.org/x/net v0.15.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/protobuf v1.28.0 // indirect
|
||||
google.golang.org/protobuf v1.31.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
k8s.io/apimachinery v0.25.4 // indirect
|
||||
k8s.io/apimachinery v0.27.4 // indirect
|
||||
k8s.io/helm v2.17.0+incompatible // indirect
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
|
||||
github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
|
||||
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
|
||||
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
|
||||
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
|
||||
|
|
@ -19,8 +19,8 @@ github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJA
|
|||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
|
|
@ -34,65 +34,61 @@ github.com/helm/helm v2.17.0+incompatible/go.mod h1:ahXhuvluW4YnSL6W6hDVetZsVK8P
|
|||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo=
|
||||
github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg=
|
||||
github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.10.2 h1:uqH7bpe+ERSiDa34FDOF7RikN6RzXgduUF8yarlZp94=
|
||||
github.com/onsi/ginkgo v1.10.2/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/onsi/gomega v1.20.1 h1:PA/3qinGoukvymdIDV8pii6tiZgC8kbmJO6Z5+b002Q=
|
||||
github.com/onsi/gomega v1.20.1/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo=
|
||||
github.com/onsi/gomega v1.27.4 h1:Z2AnStgsdSayCMDiCU42qIz+HLqEPcgiOCXjAU/w+8E=
|
||||
github.com/onsi/gomega v1.27.4/go.mod h1:riYq/GJKh8hhoM01HN6Vmuy93AarCXCBGpvFDK3q3fQ=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
|
||||
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
|
||||
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
|
||||
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/vmware-labs/yaml-jsonpath v0.3.2 h1:/5QKeCBGdsInyDCyVNLbXyilb61MXGi9NP674f9Hobk=
|
||||
github.com/vmware-labs/yaml-jsonpath v0.3.2/go.mod h1:U6whw1z03QyqgWdgXxvVnQ90zN1BWz5V+51Ewf8k+rQ=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU=
|
||||
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
|
||||
golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck=
|
||||
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
|
||||
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
|
||||
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
||||
golang.org/x/oauth2 v0.12.0 h1:smVPGxink+n1ZI5pkQa8y6fZT0RW0MgCO5bFpepy4B4=
|
||||
golang.org/x/oauth2 v0.12.0/go.mod h1:A74bZ3aGXgCY0qaIC9Ahg6Lglin4AMAco8cIv9baba4=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
|
||||
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
|
||||
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
|
||||
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
|
|
@ -106,7 +102,7 @@ gopkg.in/yaml.v3 v3.0.0-20191026110619-0b21df46bc1d/go.mod h1:K4uyk7z7BCEPqu6E+C
|
|||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
k8s.io/apimachinery v0.25.4 h1:CtXsuaitMESSu339tfhVXhQrPET+EiWnIY1rcurKnAc=
|
||||
k8s.io/apimachinery v0.25.4/go.mod h1:jaF9C/iPNM1FuLl7Zuy5b9v+n35HGSh6AQ4HYRkCqwo=
|
||||
k8s.io/apimachinery v0.27.4 h1:CdxflD4AF61yewuid0fLl6bM4a3q04jWel0IlP+aYjs=
|
||||
k8s.io/apimachinery v0.27.4/go.mod h1:XNfZ6xklnMCOGGFNqXG7bUrQCoR04dh/E7FprV6pb+E=
|
||||
k8s.io/helm v2.17.0+incompatible h1:Bpn6o1wKLYqKM3+Osh8e+1/K2g/GsQJ4F4yNF2+deao=
|
||||
k8s.io/helm v2.17.0+incompatible/go.mod h1:LZzlS4LQBHfciFOurYBFkCMTaZ0D1l+p0teMg7TSULI=
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
//go:build ignore
|
||||
// +build ignore
|
||||
//go:build mage
|
||||
|
||||
/*
|
||||
Copyright 2021 The Kubernetes Authors.
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
@ -20,11 +19,6 @@ limitations under the License.
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/magefile/mage/mage"
|
||||
//mage:import
|
||||
_ "k8s.io/ingress-nginx/magefiles/steps"
|
||||
)
|
||||
|
||||
func main() {
|
||||
os.Exit(mage.Main())
|
||||
}
|
||||
|
|
|
|||
187
magefiles/steps/helm.go
Normal file
187
magefiles/steps/helm.go
Normal file
|
|
@ -0,0 +1,187 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package steps
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
semver "github.com/blang/semver/v4"
|
||||
"github.com/helm/helm/pkg/chartutil"
|
||||
"github.com/magefile/mage/mg"
|
||||
"github.com/magefile/mage/sh"
|
||||
yamlpath "github.com/vmware-labs/yaml-jsonpath/pkg/yamlpath"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
utils "k8s.io/ingress-nginx/magefiles/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
HelmChartPath = "charts/ingress-nginx/Chart.yaml"
|
||||
HelmChartValues = "charts/ingress-nginx/values.yaml"
|
||||
)
|
||||
|
||||
type Helm mg.Namespace
|
||||
|
||||
// UpdateVersion Update Helm Version of the Chart
|
||||
func (Helm) UpdateVersion(version string) {
|
||||
updateVersion(version)
|
||||
}
|
||||
|
||||
func currentChartVersion() string {
|
||||
chart, err := chartutil.LoadChartfile(HelmChartPath)
|
||||
utils.CheckIfError(err, "HELM Could not Load Chart")
|
||||
return chart.Version
|
||||
}
|
||||
|
||||
func updateVersion(version string) {
|
||||
utils.Info("HELM Reading File %v", HelmChartPath)
|
||||
|
||||
chart, err := chartutil.LoadChartfile(HelmChartPath)
|
||||
utils.CheckIfError(err, "HELM Could not Load Chart")
|
||||
|
||||
// Get the current tag
|
||||
// appVersionV, err := getIngressNGINXVersion()
|
||||
// utils.CheckIfError(err, "HELM Issue Retrieving the Current Ingress Nginx Version")
|
||||
|
||||
// remove the v from TAG
|
||||
appVersion := version
|
||||
|
||||
utils.Info("HELM Ingress-Nginx App Version: %s Chart AppVersion: %s", appVersion, chart.AppVersion)
|
||||
if appVersion == chart.AppVersion {
|
||||
utils.Warning("HELM Ingress NGINX Version didnt change Ingress-Nginx App Version: %s Chart AppVersion: %s", appVersion, chart.AppVersion)
|
||||
return
|
||||
}
|
||||
|
||||
controllerSemVer, err := semver.Parse(version)
|
||||
utils.CheckIfError(err, "error parsing semver of new app")
|
||||
isPreRelease := len(controllerSemVer.Pre) > 0
|
||||
oldControllerSemVer, err := semver.Parse(chart.AppVersion)
|
||||
utils.CheckIfError(err, "error parsing semver of old chart")
|
||||
isBreakingChange := controllerSemVer.Major > oldControllerSemVer.Major || controllerSemVer.Minor > oldControllerSemVer.Minor
|
||||
|
||||
// Update the helm chart
|
||||
chart.AppVersion = appVersion
|
||||
cTag, err := semver.Make(chart.Version)
|
||||
utils.CheckIfError(err, "HELM Creating Chart Version: %v", err)
|
||||
|
||||
incrFunc := cTag.IncrementPatch
|
||||
if isBreakingChange {
|
||||
cTag.Patch = 0
|
||||
incrFunc = cTag.IncrementMinor
|
||||
|
||||
}
|
||||
|
||||
if isPreRelease {
|
||||
chart.Annotations["artifacthub.io/prerelease"] = "true"
|
||||
cTag.Pre = controllerSemVer.Pre
|
||||
}
|
||||
|
||||
if err = incrFunc(); err != nil {
|
||||
utils.ErrorF("HELM Incrementing Chart Version: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
chart.Version = cTag.String()
|
||||
utils.Debug("HELM Updated Chart Version: %v", chart.Version)
|
||||
|
||||
err = chartutil.SaveChartfile(HelmChartPath, chart)
|
||||
utils.CheckIfError(err, "HELM Saving new Chart")
|
||||
}
|
||||
|
||||
func updateChartReleaseNotes(releasesNotes []string) {
|
||||
utils.Info("HELM Updating the Chart Release notes")
|
||||
chart, err := chartutil.LoadChartfile(HelmChartPath)
|
||||
utils.CheckIfError(err, "HELM Could not Load Chart to update release notes %s", HelmChartPath)
|
||||
var releaseNoteString string
|
||||
for i := range releasesNotes {
|
||||
releaseNoteString = fmt.Sprintf("%s - \"%s\"\n", releaseNoteString, releasesNotes[i])
|
||||
}
|
||||
utils.Info("HELM Release note string %s", releaseNoteString)
|
||||
chart.Annotations["artifacthub.io/changes"] = releaseNoteString
|
||||
err = chartutil.SaveChartfile(HelmChartPath, chart)
|
||||
utils.CheckIfError(err, "HELM Saving updated release notes for Chart")
|
||||
}
|
||||
|
||||
// UpdateChartValue Updates the Helm ChartValue
|
||||
func (Helm) UpdateChartValue(key, value string) {
|
||||
updateChartValue(key, value)
|
||||
}
|
||||
|
||||
func updateChartValue(key, value string) {
|
||||
utils.Info("HELM Updating Chart %s %s:%s", HelmChartValues, key, value)
|
||||
|
||||
// read current values.yaml
|
||||
data, err := os.ReadFile(HelmChartValues)
|
||||
utils.CheckIfError(err, "HELM Could not Load Helm Chart Values files %s", HelmChartValues)
|
||||
|
||||
// var valuesStruct IngressChartValue
|
||||
var n yaml.Node
|
||||
utils.CheckIfError(yaml.Unmarshal(data, &n), "HELM Could not Unmarshal %s", HelmChartValues)
|
||||
|
||||
// update value
|
||||
// keyParse := parsePath(key)
|
||||
p, err := yamlpath.NewPath(key)
|
||||
utils.CheckIfError(err, "HELM cannot create path")
|
||||
|
||||
q, err := p.Find(&n)
|
||||
utils.CheckIfError(err, "HELM unexpected error finding path")
|
||||
|
||||
for _, i := range q {
|
||||
utils.Info("HELM Found %s at %s", i.Value, key)
|
||||
i.Value = value
|
||||
utils.Info("HELM Updated %s at %s", i.Value, key)
|
||||
}
|
||||
|
||||
//// write to file
|
||||
var b bytes.Buffer
|
||||
yamlEncoder := yaml.NewEncoder(&b)
|
||||
yamlEncoder.SetIndent(2)
|
||||
err = yamlEncoder.Encode(&n)
|
||||
utils.CheckIfError(err, "HELM Could not Marshal new Values file")
|
||||
err = os.WriteFile(HelmChartValues, b.Bytes(), 0o644)
|
||||
utils.CheckIfError(err, "HELM Could not write new Values file to %s", HelmChartValues)
|
||||
|
||||
utils.Info("HELM Ingress Nginx Helm Chart update %s %s", key, value)
|
||||
}
|
||||
|
||||
func (Helm) Helmdocs() error {
|
||||
return runHelmDocs()
|
||||
}
|
||||
|
||||
func runHelmDocs() error {
|
||||
err := installHelmDocs()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = sh.RunV("helm-docs", "--chart-search-root=${PWD}/charts")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func installHelmDocs() error {
|
||||
utils.Info("HELM Install HelmDocs")
|
||||
g0 := sh.RunCmd("go")
|
||||
|
||||
err := g0("install", "github.com/norwoodj/helm-docs/cmd/helm-docs@v1.11.0")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
//go:build mage
|
||||
|
||||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
|
|
@ -16,26 +14,23 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
package steps
|
||||
|
||||
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"
|
||||
|
||||
utils "k8s.io/ingress-nginx/magefiles/utils"
|
||||
)
|
||||
|
||||
type Release mg.Namespace
|
||||
|
|
@ -62,55 +57,28 @@ const (
|
|||
CHANGELOG = "Changelog.md" // Name of the changelog
|
||||
)
|
||||
|
||||
// ControllerImage - struct with info about controllers
|
||||
type ControllerImage struct {
|
||||
Tag string
|
||||
Digest string
|
||||
Registry string
|
||||
Name string
|
||||
}
|
||||
|
||||
// IngressRelease All the information about an ingress-nginx release that gets updated
|
||||
type IngressRelease struct {
|
||||
ControllerVersion string
|
||||
ControllerImage ControllerImage
|
||||
ReleaseNote ReleaseNote
|
||||
Release *github.RepositoryRelease
|
||||
}
|
||||
|
||||
// ReleaseNote - All the pieces of information/documents that get updated during a release
|
||||
type ReleaseNote struct {
|
||||
Version string
|
||||
NewControllerVersion string
|
||||
PreviousControllerVersion string
|
||||
ControllerImages []ControllerImage
|
||||
DepUpdates []string
|
||||
Updates []string
|
||||
HelmUpdates []string
|
||||
NewHelmChartVersion string
|
||||
PreviousHelmChartVersion string
|
||||
}
|
||||
|
||||
// IMAGES_YAML returns this data structure
|
||||
type ImageYamls []ImageElement
|
||||
|
||||
// ImageElement - a specific image and it's data structure the dmap is a list of shas and container versions
|
||||
type ImageElement struct {
|
||||
Name string `json:"name"`
|
||||
Dmap map[string][]string `json:"dmap"`
|
||||
}
|
||||
|
||||
// init will set the GitHub token from the committers/releasers env var
|
||||
func init() {
|
||||
GITHUB_TOKEN = os.Getenv("GITHUB_TOKEN")
|
||||
}
|
||||
|
||||
// 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(version, "")
|
||||
}
|
||||
|
||||
func (Release) NewReleaseFromOld(version, oldversion string) {
|
||||
newRelease(version, oldversion)
|
||||
}
|
||||
|
||||
func (Release) E2EDocs() {
|
||||
e2edocs, err := utils.GenerateE2EDocs()
|
||||
utils.CheckIfError(err, "error on template")
|
||||
err = os.WriteFile("docs/e2e-tests.md", []byte(e2edocs), 644)
|
||||
utils.CheckIfError(err, "Could not write new e2e test file ")
|
||||
}
|
||||
|
||||
func newRelease(version, oldversion string) {
|
||||
// newRelease := Release{}
|
||||
|
||||
// update ingress-nginx version
|
||||
|
|
@ -119,12 +87,12 @@ func (Release) NewRelease(version string) {
|
|||
// mg.Deps(mg.F(Tag.BumpNginx, version))
|
||||
|
||||
tag, err := getIngressNGINXVersion()
|
||||
CheckIfError(err, "RELEASE Retrieving the current Ingress Nginx Version")
|
||||
utils.CheckIfError(err, "RELEASE Retrieving the current Ingress Nginx Version")
|
||||
|
||||
Info("RELEASE Checking Current Version %s to New Version %s", tag, version)
|
||||
utils.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 tag[1:] != version {
|
||||
Warning("RELEASE Ingress Nginx TAG %s and new version %s do not match", tag, version)
|
||||
utils.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)))
|
||||
}
|
||||
|
||||
|
|
@ -132,25 +100,25 @@ func (Release) NewRelease(version string) {
|
|||
mg.Deps(mg.F(Tag.NewControllerTag, version))
|
||||
|
||||
// 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)
|
||||
releaseNotes, err := makeReleaseNotes(version, oldversion)
|
||||
utils.CheckIfError(err, "RELEASE Creating Release Notes for version %s", version)
|
||||
utils.Info("RELEASE Release Notes %s completed", releaseNotes.Version)
|
||||
|
||||
// update chart values.yaml new controller tag and image digest
|
||||
releaseNotes.PreviousHelmChartVersion = currentChartVersion()
|
||||
|
||||
// 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)
|
||||
utils.Debug("releaseNotes.ControllerImages[0].Name %s", releaseNotes.ControllerImages[0].Name)
|
||||
utils.Debug("releaseNotes.ControllerImages[1].Name %s", releaseNotes.ControllerImages[1].Name)
|
||||
// controller digest
|
||||
if releaseNotes.ControllerImages[0].Name == "ingress-nginx/controller" {
|
||||
Debug("Updating Chart Value %s with %s", "controller.image.digest", releaseNotes.ControllerImages[0].Digest)
|
||||
utils.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
|
||||
if releaseNotes.ControllerImages[1].Name == "ingress-nginx/controller-chroot" {
|
||||
Debug("Updating Chart Value %s with %s", "controller.image.digestChroot", releaseNotes.ControllerImages[1].Digest)
|
||||
utils.Debug("Updating Chart Value %s with %s", "controller.image.digestChroot", releaseNotes.ControllerImages[1].Digest)
|
||||
updateChartValue("controller.image.digestChroot", releaseNotes.ControllerImages[1].Digest)
|
||||
}
|
||||
|
||||
|
|
@ -163,18 +131,18 @@ func (Release) NewRelease(version string) {
|
|||
updateChartReleaseNotes(releaseNotes.HelmUpdates)
|
||||
|
||||
// Run helm docs update
|
||||
CheckIfError(runHelmDocs(), "Error Updating Helm Docs ")
|
||||
utils.CheckIfError(runHelmDocs(), "Error Updating Helm Docs ")
|
||||
|
||||
releaseNotes.helmTemplate()
|
||||
releaseNotes.HelmTemplate()
|
||||
|
||||
// update static manifest
|
||||
CheckIfError(updateStaticManifest(), "Error Updating Static manifests")
|
||||
utils.CheckIfError(updateStaticManifest(), "Error Updating Static manifests")
|
||||
|
||||
////update e2e docs
|
||||
updateE2EDocs()
|
||||
mg.Deps(mg.F(Release.E2EDocs))
|
||||
|
||||
// update documentation with ingress-nginx version
|
||||
CheckIfError(updateIndexMD(releaseNotes.PreviousControllerVersion, releaseNotes.NewControllerVersion), "Error Updating %s", INDEX_DOCS)
|
||||
utils.CheckIfError(updateIndexMD(releaseNotes.PreviousControllerVersion, releaseNotes.NewControllerVersion), "Error Updating %s", INDEX_DOCS)
|
||||
|
||||
// keeping these manual for now
|
||||
// git commit TODO
|
||||
|
|
@ -185,30 +153,22 @@ func (Release) NewRelease(version string) {
|
|||
|
||||
// the index.md doc needs the controller version updated
|
||||
func updateIndexMD(old, new string) error {
|
||||
Info("Updating Deploy docs with new version")
|
||||
utils.Info("Updating Deploy docs with new version")
|
||||
data, err := os.ReadFile(INDEX_DOCS)
|
||||
CheckIfError(err, "Could not read INDEX_DOCS file %s", INDEX_DOCS)
|
||||
utils.CheckIfError(err, "Could not read INDEX_DOCS file %s", INDEX_DOCS)
|
||||
datString := string(data)
|
||||
datString = strings.Replace(datString, old, new, -1)
|
||||
err = os.WriteFile(INDEX_DOCS, []byte(datString), 644)
|
||||
if err != nil {
|
||||
ErrorF("Could not write new %s %s", INDEX_DOCS, err)
|
||||
utils.ErrorF("Could not write new %s %s", INDEX_DOCS, err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// runs the hack/generate-deploy-scripts.sh
|
||||
func updateE2EDocs() {
|
||||
updates, err := sh.Output("./hack/generate-e2e-suite-doc.sh")
|
||||
CheckIfError(err, "Could not run update hack script")
|
||||
err = os.WriteFile("docs/e2e-tests.md", []byte(updates), 644)
|
||||
CheckIfError(err, "Could not write new e2e test file ")
|
||||
}
|
||||
|
||||
// The static deploy scripts use kustomize to generate them, this function ensures kustomize is installed
|
||||
func installKustomize() error {
|
||||
Info("Install Kustomize")
|
||||
utils.Info("Install Kustomize")
|
||||
g0 := sh.RunCmd("go")
|
||||
// somewhere in your main code
|
||||
err := g0("install", KUSTOMIZE_INSTALL_VERSION)
|
||||
|
|
@ -219,7 +179,7 @@ func installKustomize() error {
|
|||
}
|
||||
|
||||
func updateStaticManifest() error {
|
||||
CheckIfError(installKustomize(), "error installing kustomize")
|
||||
utils.CheckIfError(installKustomize(), "error installing kustomize")
|
||||
// hack/generate-deploy-scripts.sh
|
||||
err := sh.RunV("./hack/generate-deploy-scripts.sh")
|
||||
if err != nil {
|
||||
|
|
@ -231,10 +191,10 @@ func updateStaticManifest() error {
|
|||
//// CreateRelease Creates a new GitHub Release
|
||||
//func (Release) CreateRelease(name string) {
|
||||
// releaser, err := gh_release.NewReleaser(INGRESS_ORG, INGRESS_REPO, GITHUB_TOKEN)
|
||||
// CheckIfError(err, "GitHub Release Client error")
|
||||
// utils.CheckIfError(err, "GitHub Release Client error")
|
||||
// newRelease, err := releaser.Create(fmt.Sprintf("controller-%s", name))
|
||||
// CheckIfError(err, "Create release error")
|
||||
// Info("New Release: Tag %v, ID: %v", newRelease.TagName, newRelease.ID)
|
||||
// utils.CheckIfError(err, "Create release error")
|
||||
// utils.Info("New Release: Tag %v, ID: %v", newRelease.TagName, newRelease.ID)
|
||||
//}
|
||||
|
||||
// Returns a GitHub client ready for use
|
||||
|
|
@ -248,34 +208,44 @@ func githubClient() *github.Client {
|
|||
|
||||
// LatestCommitLogs Retrieves the commit log between the latest two controller versions.
|
||||
func (Release) LatestCommitLogs() {
|
||||
commitLog := commitsBetweenTags()
|
||||
commitLog := commitsBetweenTags("", "")
|
||||
for i, s := range commitLog {
|
||||
Info("#%v Version %v", i, s)
|
||||
utils.Info("#%v Version %v", i, s)
|
||||
}
|
||||
}
|
||||
|
||||
func commitsBetweenTags() []string {
|
||||
func commitsBetweenTags(newversion, oldversion string) []string {
|
||||
|
||||
var newTag, oldTag string
|
||||
tags := getAllControllerTags()
|
||||
Info("Getting Commits between %v and %v", tags[0], tags[1])
|
||||
commitLog, err := git("log", "--full-history", "--pretty", "--oneline", fmt.Sprintf("%v..%v", tags[1], tags[0]))
|
||||
newTag, oldTag = tags[0], tags[1]
|
||||
if newversion != "" {
|
||||
newTag = newversion
|
||||
}
|
||||
if oldversion != "" {
|
||||
oldTag = oldversion
|
||||
}
|
||||
|
||||
utils.Info("Getting Commits between %v and %v", newTag, oldTag)
|
||||
commitLog, err := git("log", "--full-history", "--pretty", "--oneline", fmt.Sprintf("%v..%v", oldTag, newTag))
|
||||
|
||||
if commitLog == "" {
|
||||
Warning("All Controller Tags is empty")
|
||||
utils.Warning("All Controller Tags is empty")
|
||||
}
|
||||
CheckIfError(err, "Retrieving Commit log")
|
||||
utils.CheckIfError(err, "Retrieving Commit log")
|
||||
return strings.Split(commitLog, "\n")
|
||||
}
|
||||
|
||||
// Generate Release Notes
|
||||
func (Release) ReleaseNotes(newVersion string) error {
|
||||
notes, err := makeReleaseNotes(newVersion)
|
||||
CheckIfError(err, "Creating Release Notes for version %s", newVersion)
|
||||
Info("Release Notes %s completed", notes.Version)
|
||||
notes, err := makeReleaseNotes(newVersion, "")
|
||||
utils.CheckIfError(err, "Creating Release Notes for version %s", newVersion)
|
||||
utils.Info("Release Notes %s completed", notes.Version)
|
||||
return nil
|
||||
}
|
||||
|
||||
func makeReleaseNotes(newVersion string) (*ReleaseNote, error) {
|
||||
newReleaseNotes := ReleaseNote{}
|
||||
func makeReleaseNotes(newVersion, oldVersion string) (*utils.ReleaseNote, error) {
|
||||
newReleaseNotes := utils.ReleaseNote{}
|
||||
|
||||
newReleaseNotes.Version = newVersion
|
||||
allControllerTags := getAllControllerTags()
|
||||
|
|
@ -290,10 +260,13 @@ func makeReleaseNotes(newVersion string) (*ReleaseNote, error) {
|
|||
}
|
||||
// previous version
|
||||
newReleaseNotes.PreviousControllerVersion = allControllerTags[1]
|
||||
if oldVersion != "" {
|
||||
newReleaseNotes.PreviousControllerVersion = oldVersion
|
||||
}
|
||||
|
||||
Info("New Version: %s Old Version: %s", newReleaseNotes.NewControllerVersion, newReleaseNotes.PreviousControllerVersion)
|
||||
utils.Info("New Version: %s Old Version: %s", newReleaseNotes.NewControllerVersion, newReleaseNotes.PreviousControllerVersion)
|
||||
|
||||
commits := commitsBetweenTags()
|
||||
commits := commitsBetweenTags(newReleaseNotes.NewControllerVersion, newReleaseNotes.PreviousControllerVersion)
|
||||
|
||||
// dependency_updates
|
||||
// all_updates
|
||||
|
|
@ -308,11 +281,11 @@ func makeReleaseNotes(newVersion string) (*ReleaseNote, error) {
|
|||
if prRegex.Match([]byte(s)) {
|
||||
// matches a dependant bot update
|
||||
if depBot.Match([]byte(s)) { //
|
||||
Debug("#%v DEPENDABOT %v", i, s)
|
||||
utils.Debug("#%v DEPENDABOT %v", i, s)
|
||||
u := strings.SplitN(s, " ", 2)
|
||||
depUpdates = append(depUpdates, u[1])
|
||||
} else { // add it to the all updates slice
|
||||
Debug("#%v ALL UPDATES %v", i, s)
|
||||
utils.Debug("#%v ALL UPDATES %v", i, s)
|
||||
u := strings.SplitN(s, " ", 2)
|
||||
allUpdates = append(allUpdates, u[1])
|
||||
|
||||
|
|
@ -331,44 +304,44 @@ func makeReleaseNotes(newVersion string) (*ReleaseNote, error) {
|
|||
newReleaseNotes.HelmUpdates = helmUpdates
|
||||
|
||||
// controller_image_digests
|
||||
imagesYaml, err := downloadFile(IMAGES_YAML)
|
||||
imagesYaml, err := utils.DownloadFile(IMAGES_YAML)
|
||||
if err != nil {
|
||||
ErrorF("Could not download file %s : %s", IMAGES_YAML, err)
|
||||
utils.ErrorF("Could not download file %s : %s", IMAGES_YAML, err)
|
||||
return nil, err
|
||||
}
|
||||
Debug("%s", imagesYaml)
|
||||
utils.Debug("%s", imagesYaml)
|
||||
|
||||
data := ImageYamls{}
|
||||
data := utils.ImageYamls{}
|
||||
|
||||
err = yaml.Unmarshal([]byte(imagesYaml), &data)
|
||||
if err != nil {
|
||||
ErrorF("Could not unmarshal images yaml %s", err)
|
||||
utils.ErrorF("Could not unmarshal images yaml %s", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// controller
|
||||
controllerDigest := findImageDigest(data, "controller", newVersion)
|
||||
controllerDigest := utils.FindImageDigest(data, "controller", newVersion)
|
||||
if len(controllerDigest) == 0 {
|
||||
ErrorF("Controller Digest could not be found")
|
||||
utils.ErrorF("Controller Digest could not be found")
|
||||
return nil, errors.New("Controller digest could not be found")
|
||||
}
|
||||
|
||||
controllerChrootDigest := findImageDigest(data, "controller-chroot", newVersion)
|
||||
controllerChrootDigest := utils.FindImageDigest(data, "controller-chroot", newVersion)
|
||||
if len(controllerChrootDigest) == 0 {
|
||||
ErrorF("Controller Chroot Digest could not be found")
|
||||
utils.ErrorF("Controller Chroot Digest could not be found")
|
||||
return nil, errors.New("Controller Chroot digest could not be found")
|
||||
}
|
||||
|
||||
Debug("Latest Controller Digest %v", controllerDigest)
|
||||
Debug("Latest Controller Chroot Digest %v", controllerChrootDigest)
|
||||
c1 := ControllerImage{
|
||||
utils.Debug("Latest Controller Digest %v", controllerDigest)
|
||||
utils.Debug("Latest Controller Chroot Digest %v", controllerChrootDigest)
|
||||
c1 := utils.ControllerImage{
|
||||
Digest: controllerDigest,
|
||||
Registry: INGRESS_REGISTRY,
|
||||
Name: "ingress-nginx/controller",
|
||||
Tag: fmt.Sprintf("v%s", newReleaseNotes.Version),
|
||||
}
|
||||
|
||||
c2 := ControllerImage{
|
||||
c2 := utils.ControllerImage{
|
||||
Digest: controllerChrootDigest,
|
||||
Registry: INGRESS_REGISTRY,
|
||||
Name: "ingress-nginx/controller-chroot",
|
||||
|
|
@ -377,141 +350,37 @@ func makeReleaseNotes(newVersion string) (*ReleaseNote, error) {
|
|||
|
||||
newReleaseNotes.ControllerImages = append(newReleaseNotes.ControllerImages, c1)
|
||||
newReleaseNotes.ControllerImages = append(newReleaseNotes.ControllerImages, c2)
|
||||
Debug("New Release Controller Images %s %s", newReleaseNotes.ControllerImages[0].Digest, newReleaseNotes.ControllerImages[1].Digest)
|
||||
utils.Debug("New Release Controller Images %s %s", newReleaseNotes.ControllerImages[0].Digest, newReleaseNotes.ControllerImages[1].Digest)
|
||||
|
||||
if DEBUG {
|
||||
newReleaseNotes.printRelease()
|
||||
if utils.DEBUG {
|
||||
newReleaseNotes.PrintRelease()
|
||||
}
|
||||
|
||||
// write it all out to the changelog file
|
||||
newReleaseNotes.template()
|
||||
newReleaseNotes.Template()
|
||||
|
||||
return &newReleaseNotes, nil
|
||||
}
|
||||
|
||||
func (i ControllerImage) print() string {
|
||||
return fmt.Sprintf("%s/%s:%s@%s", i.Registry, i.Name, i.Tag, i.Digest)
|
||||
}
|
||||
|
||||
func (r ReleaseNote) template() {
|
||||
// Files are provided as a slice of strings.
|
||||
changelogTemplate, err := os.ReadFile("Changelog.md.gotmpl")
|
||||
if err != nil {
|
||||
ErrorF("Could not read changelog template file %s", err)
|
||||
}
|
||||
Debug("ChangeLog Templates %s", string(changelogTemplate))
|
||||
t := template.Must(template.New("changelog").Parse(string(changelogTemplate)))
|
||||
// create a new file
|
||||
file, err := os.Create(fmt.Sprintf("changelog/Changelog-%s.md", r.Version))
|
||||
if err != nil {
|
||||
ErrorF("Could not create changelog file %s", err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
err = t.Execute(file, r)
|
||||
if err != nil {
|
||||
ErrorF("executing template:", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (r ReleaseNote) helmTemplate() {
|
||||
// Files are provided as a slice of strings.
|
||||
changelogTemplate, err := os.ReadFile("charts/ingress-nginx/changelog.md.gotmpl")
|
||||
if err != nil {
|
||||
ErrorF("Could not read changelog template file %s", err)
|
||||
}
|
||||
Debug("ChangeLog Templates %s", string(changelogTemplate))
|
||||
t := template.Must(template.New("changelog").Parse(string(changelogTemplate)))
|
||||
// create a new file
|
||||
file, err := os.Create(fmt.Sprintf("charts/ingress-nginx/changelog/Changelog-%s.md", r.NewHelmChartVersion))
|
||||
if err != nil {
|
||||
ErrorF("Could not create changelog file %s", err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
err = t.Execute(file, r)
|
||||
if err != nil {
|
||||
ErrorF("executing template:", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (r ReleaseNote) printRelease() {
|
||||
Info("Release Version: %v", r.NewControllerVersion)
|
||||
Info("Previous Version: %v", r.PreviousControllerVersion)
|
||||
Info("Controller Image: %v", r.ControllerImages[0].print())
|
||||
Info("Controller Chroot Image: %v", r.ControllerImages[1].print())
|
||||
for i := range r.Updates {
|
||||
Info("Update #%v - %v", i, r.Updates[i])
|
||||
}
|
||||
for j := range r.DepUpdates {
|
||||
Info("Dependabot Update #%v - %v", j, r.DepUpdates[j])
|
||||
}
|
||||
}
|
||||
|
||||
func findImageDigest(yaml ImageYamls, image, version string) string {
|
||||
version = fmt.Sprintf("v%s", version)
|
||||
Info("Searching Digest for %s:%s", image, version)
|
||||
for i := range yaml {
|
||||
if yaml[i].Name == image {
|
||||
for k, v := range yaml[i].Dmap {
|
||||
if v[0] == version {
|
||||
return k
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func downloadFile(url string) (string, error) {
|
||||
client := &http.Client{
|
||||
Transport: &http.Transport{
|
||||
DialContext: (&net.Dialer{
|
||||
Timeout: 5 * time.Second,
|
||||
KeepAlive: 5 * time.Second,
|
||||
}).DialContext,
|
||||
TLSHandshakeTimeout: 5 * time.Second,
|
||||
ResponseHeaderTimeout: 5 * time.Second,
|
||||
ExpectContinueTimeout: 1 * time.Second,
|
||||
MaxIdleConnsPerHost: -1,
|
||||
},
|
||||
}
|
||||
resp, err := client.Get(url)
|
||||
if err != nil {
|
||||
return "", nil
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return "", errors.New(fmt.Sprintf("Could not retrieve file, response from server %s for file %s", resp.StatusCode, url))
|
||||
}
|
||||
bodyBytes, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return "", nil
|
||||
}
|
||||
return string(bodyBytes), nil
|
||||
}
|
||||
|
||||
// Latest returns latest Github Release
|
||||
func (Release) Latest() error {
|
||||
r, _, err := latestRelease()
|
||||
if err != nil {
|
||||
ErrorF("Latest Release error %s", err)
|
||||
utils.ErrorF("Latest Release error %s", err)
|
||||
return err
|
||||
}
|
||||
Info("Latest Release %v", r.String())
|
||||
utils.Info("Latest Release %v", r.String())
|
||||
return nil
|
||||
}
|
||||
|
||||
func (Release) ReleaseByTag(tag string) error {
|
||||
r, _, err := releaseByTag(tag)
|
||||
if err != nil {
|
||||
ErrorF("Release retrieve tag error %s", tag, err)
|
||||
utils.ErrorF("Release retrieve tag %s error %s", tag, err)
|
||||
return err
|
||||
}
|
||||
|
||||
Info("Latest Release %v", r.String())
|
||||
utils.Info("Latest Release %v", r.String())
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -525,31 +394,3 @@ func latestRelease() (*github.RepositoryRelease, *github.Response, error) {
|
|||
ghClient := githubClient()
|
||||
return ghClient.Repositories.GetLatestRelease(ctx, INGRESS_ORG, INGRESS_REPO)
|
||||
}
|
||||
|
||||
// Copy Test function to copy a release
|
||||
func (Release) Copy() error {
|
||||
ghClient := githubClient()
|
||||
kRelease, _, err := ghClient.Repositories.GetLatestRelease(ctx, "kubernetes", "ingress-nginx")
|
||||
if err != nil {
|
||||
ErrorF("Get Release from kubernetes %s", err)
|
||||
return err
|
||||
}
|
||||
|
||||
sRelease := &github.RepositoryRelease{
|
||||
TagName: kRelease.TagName,
|
||||
Name: kRelease.Name,
|
||||
Body: kRelease.Body,
|
||||
Draft: kRelease.Draft,
|
||||
Prerelease: kRelease.GenerateReleaseNotes,
|
||||
DiscussionCategoryName: kRelease.DiscussionCategoryName,
|
||||
GenerateReleaseNotes: kRelease.GenerateReleaseNotes,
|
||||
}
|
||||
|
||||
sRelease, _, err = ghClient.Repositories.CreateRelease(ctx, "strongjz", "ingress-nginx", sRelease)
|
||||
if err != nil {
|
||||
ErrorF("Creating Strongjz release %s", err)
|
||||
return err
|
||||
}
|
||||
Info("Copied over Kubernetes Release %v to Strongjz %v", &kRelease.Name, &sRelease.Name)
|
||||
return nil
|
||||
}
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
//go:build mage
|
||||
|
||||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
|
|
@ -16,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
package steps
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
|
@ -26,6 +24,8 @@ import (
|
|||
semver "github.com/blang/semver/v4"
|
||||
"github.com/magefile/mage/mg"
|
||||
"github.com/magefile/mage/sh"
|
||||
|
||||
utils "k8s.io/ingress-nginx/magefiles/utils"
|
||||
)
|
||||
|
||||
type Tag mg.Namespace
|
||||
|
|
@ -35,13 +35,13 @@ var git = sh.OutCmd("git")
|
|||
// Nginx returns the ingress-nginx current version
|
||||
func (Tag) Nginx() {
|
||||
tag, err := getIngressNGINXVersion()
|
||||
CheckIfError(err, "")
|
||||
utils.CheckIfError(err, "")
|
||||
fmt.Printf("%v", tag)
|
||||
}
|
||||
|
||||
func getIngressNGINXVersion() (string, error) {
|
||||
dat, err := os.ReadFile("TAG")
|
||||
CheckIfError(err, "Could not read TAG file")
|
||||
utils.CheckIfError(err, "Could not read TAG file")
|
||||
datString := string(dat)
|
||||
// remove newline
|
||||
datString = strings.Replace(datString, "\n", "", -1)
|
||||
|
|
@ -49,21 +49,21 @@ func getIngressNGINXVersion() (string, error) {
|
|||
}
|
||||
|
||||
func checkSemVer(currentVersion, newVersion string) bool {
|
||||
Info("Checking Sem Ver between current %s and new %s", currentVersion, newVersion)
|
||||
utils.Info("Checking Sem Ver between current %s and new %s", currentVersion, newVersion)
|
||||
cVersion, err := semver.Make(currentVersion[1:])
|
||||
if err != nil {
|
||||
ErrorF("TAG Error Current Tag %v Making Semver : %v", currentVersion[1:], err)
|
||||
utils.ErrorF("TAG Error Current Tag %v Making Semver : %v", currentVersion[1:], err)
|
||||
return false
|
||||
}
|
||||
nVersion, err := semver.Make(newVersion)
|
||||
if err != nil {
|
||||
ErrorF("TAG %v Error Making Semver %v \n", newVersion, err)
|
||||
utils.ErrorF("TAG %v Error Making Semver %v \n", newVersion, err)
|
||||
return false
|
||||
}
|
||||
|
||||
err = nVersion.Validate()
|
||||
if err != nil {
|
||||
ErrorF("TAG %v not a valid Semver %v \n", newVersion, err)
|
||||
utils.ErrorF("TAG %v not a valid Semver %v \n", newVersion, err)
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
@ -71,10 +71,10 @@ func checkSemVer(currentVersion, newVersion string) bool {
|
|||
//0 if newVersion == currentVersion
|
||||
//-1 if newVersion < currentVersion
|
||||
//+1 if newVersion > currentVersion.
|
||||
Info("TAG Comparing Old %s to New %s", cVersion.String(), nVersion.String())
|
||||
utils.Info("TAG Comparing Old %s to New %s", cVersion.String(), nVersion.String())
|
||||
comp := nVersion.Compare(cVersion)
|
||||
if comp <= 0 {
|
||||
Warning("SemVer:%v is not an update\n", newVersion)
|
||||
utils.Warning("SemVer:%v is not an update\n", newVersion)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
|
@ -82,29 +82,29 @@ func checkSemVer(currentVersion, newVersion string) bool {
|
|||
|
||||
// BumpNginx will update the nginx TAG
|
||||
func (Tag) BumpNginx(newTag string) {
|
||||
Info("TAG BumpNginx version %v", newTag)
|
||||
utils.Info("TAG BumpNginx version %v", newTag)
|
||||
currentTag, err := getIngressNGINXVersion()
|
||||
CheckIfError(err, "Getting Ingress-nginx Version")
|
||||
utils.CheckIfError(err, "Getting Ingress-nginx Version")
|
||||
bump(currentTag, newTag)
|
||||
}
|
||||
|
||||
func bump(currentTag, newTag string) {
|
||||
// check if semver is valid
|
||||
if !checkSemVer(currentTag, newTag) {
|
||||
ErrorF("ERROR: Semver is not valid %v", newTag)
|
||||
utils.ErrorF("ERROR: Semver is not valid %v", newTag)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
Info("Updating Tag %v to %v", currentTag, newTag)
|
||||
utils.Info("Updating Tag %v to %v", currentTag, newTag)
|
||||
err := os.WriteFile("TAG", []byte(newTag), 0o666)
|
||||
CheckIfError(err, "Error Writing New Tag File")
|
||||
utils.CheckIfError(err, "Error Writing New Tag File")
|
||||
}
|
||||
|
||||
// Git Returns the latest git tag
|
||||
func (Tag) Git() {
|
||||
tag, err := getGitTag()
|
||||
CheckIfError(err, "Retrieving Git Tag")
|
||||
Info("Git tag: %v", tag)
|
||||
utils.CheckIfError(err, "Retrieving Git Tag")
|
||||
utils.Info("Git tag: %v", tag)
|
||||
}
|
||||
|
||||
func getGitTag() (string, error) {
|
||||
|
|
@ -113,10 +113,10 @@ func getGitTag() (string, error) {
|
|||
|
||||
// ControllerTag Creates a new Git Tag for the ingress controller
|
||||
func (Tag) NewControllerTag(version string) {
|
||||
Info("Create Ingress Nginx Controller Tag v%s", version)
|
||||
utils.Info("Create Ingress Nginx Controller Tag v%s", version)
|
||||
tag, err := controllerTag(version)
|
||||
CheckIfError(err, "Creating git tag")
|
||||
Debug("Git Tag: %s", tag)
|
||||
utils.CheckIfError(err, "Creating git tag")
|
||||
utils.Debug("Git Tag: %s", tag)
|
||||
}
|
||||
|
||||
func controllerTag(version string) (string, error) {
|
||||
|
|
@ -126,22 +126,22 @@ func controllerTag(version string) (string, error) {
|
|||
func (Tag) AllControllerTags() {
|
||||
tags := getAllControllerTags()
|
||||
for i, s := range tags {
|
||||
Info("#%v Version %v", i, s)
|
||||
utils.Info("#%v Version %v", i, s)
|
||||
}
|
||||
}
|
||||
|
||||
func getAllControllerTags() []string {
|
||||
allControllerTags, err := git("tag", "-l", "--sort=-v:refname", "controller-v*")
|
||||
CheckIfError(err, "Retrieving git tags")
|
||||
utils.CheckIfError(err, "Retrieving git tags")
|
||||
if !sh.CmdRan(err) {
|
||||
Warning("Issue Running Command")
|
||||
utils.Warning("Issue Running Command")
|
||||
}
|
||||
if allControllerTags == "" {
|
||||
Warning("All Controller Tags is empty")
|
||||
utils.Warning("All Controller Tags is empty")
|
||||
}
|
||||
Debug("Controller Tags: %v", allControllerTags)
|
||||
utils.Debug("Controller Tags: %v", allControllerTags)
|
||||
|
||||
temp := strings.Split(allControllerTags, "\n")
|
||||
Debug("There are %v controller tags", len(temp))
|
||||
utils.Debug("There are %v controller tags", len(temp))
|
||||
return temp
|
||||
}
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
//go:build mage
|
||||
|
||||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
|
|
@ -16,10 +14,14 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
package utils
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
|
@ -80,3 +82,32 @@ func Debug(format string, args ...interface{}) {
|
|||
func ErrorF(format string, args ...interface{}) {
|
||||
fmt.Printf("\x1b[31;1m%s ERROR: %s\x1b[0m\n", timeStamp(), fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
func DownloadFile(url string) (string, error) {
|
||||
client := &http.Client{
|
||||
Transport: &http.Transport{
|
||||
DialContext: (&net.Dialer{
|
||||
Timeout: 5 * time.Second,
|
||||
KeepAlive: 5 * time.Second,
|
||||
}).DialContext,
|
||||
TLSHandshakeTimeout: 5 * time.Second,
|
||||
ResponseHeaderTimeout: 5 * time.Second,
|
||||
ExpectContinueTimeout: 1 * time.Second,
|
||||
MaxIdleConnsPerHost: -1,
|
||||
},
|
||||
}
|
||||
resp, err := client.Get(url)
|
||||
if err != nil {
|
||||
return "", nil
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return "", errors.New(fmt.Sprintf("could not retrieve file, response from server %d for file %s", resp.StatusCode, url))
|
||||
}
|
||||
bodyBytes, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return "", nil
|
||||
}
|
||||
return string(bodyBytes), nil
|
||||
}
|
||||
68
magefiles/utils/controller.go
Normal file
68
magefiles/utils/controller.go
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/google/go-github/v48/github"
|
||||
)
|
||||
|
||||
// ControllerImage - struct with info about controllers
|
||||
type ControllerImage struct {
|
||||
Tag string
|
||||
Digest string
|
||||
Registry string
|
||||
Name string
|
||||
}
|
||||
|
||||
// IngressRelease All the information about an ingress-nginx release that gets updated
|
||||
type IngressRelease struct {
|
||||
ControllerVersion string
|
||||
ControllerImage ControllerImage
|
||||
ReleaseNote ReleaseNote
|
||||
Release *github.RepositoryRelease
|
||||
}
|
||||
|
||||
// IMAGES_YAML returns this data structure
|
||||
type ImageYamls []ImageElement
|
||||
|
||||
// ImageElement - a specific image and it's data structure the dmap is a list of shas and container versions
|
||||
type ImageElement struct {
|
||||
Name string `json:"name"`
|
||||
Dmap map[string][]string `json:"dmap"`
|
||||
}
|
||||
|
||||
func (i ControllerImage) print() string {
|
||||
return fmt.Sprintf("%s/%s:%s@%s", i.Registry, i.Name, i.Tag, i.Digest)
|
||||
}
|
||||
|
||||
func FindImageDigest(yaml ImageYamls, image, version string) string {
|
||||
version = fmt.Sprintf("v%s", version)
|
||||
Info("Searching Digest for %s:%s", image, version)
|
||||
for i := range yaml {
|
||||
if yaml[i].Name == image {
|
||||
for k, v := range yaml[i].Dmap {
|
||||
if v[0] == version {
|
||||
return k
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
140
magefiles/utils/e2edocs.go
Normal file
140
magefiles/utils/e2edocs.go
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"embed"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"slices"
|
||||
)
|
||||
|
||||
//go:embed templates/e2edocs.tpl
|
||||
var tplContent embed.FS
|
||||
|
||||
var (
|
||||
skipFiles = []string{
|
||||
"test/e2e/framework/framework.go",
|
||||
"test/e2e/e2e.go",
|
||||
"test/e2e/e2e_test.go",
|
||||
}
|
||||
)
|
||||
|
||||
const (
|
||||
testDir = "test/e2e"
|
||||
describe = "Describe"
|
||||
URL = "https://github.com/kubernetes/ingress-nginx/tree/main/"
|
||||
)
|
||||
|
||||
var (
|
||||
betweenquotes = regexp.MustCompile(`("|\')(?P<TestDescription>.*)("|\')`)
|
||||
)
|
||||
|
||||
type E2ETemplate struct {
|
||||
URL string
|
||||
Tests []string
|
||||
}
|
||||
|
||||
func getDescription(linetext, path, url string, lineN int, isDescription bool) string {
|
||||
var descriptionLine string
|
||||
prefix := "-"
|
||||
if isDescription {
|
||||
prefix = "###"
|
||||
}
|
||||
|
||||
matches := betweenquotes.FindStringSubmatch(linetext)
|
||||
contentIndex := betweenquotes.SubexpIndex("TestDescription")
|
||||
if len(matches) < 2 || contentIndex == -1 {
|
||||
return ""
|
||||
}
|
||||
|
||||
fileName := fmt.Sprintf("%s/%s", url, path)
|
||||
descriptionLine = fmt.Sprintf("%s [%s](%s#L%d)", prefix, matches[contentIndex], fileName, lineN)
|
||||
|
||||
return descriptionLine
|
||||
}
|
||||
|
||||
func containsGinkgoTest(line string) bool {
|
||||
if !strings.Contains(line, describe) && !strings.Contains(line, "It") {
|
||||
return false
|
||||
}
|
||||
return strings.Contains(line, "func() {")
|
||||
}
|
||||
|
||||
func (t *E2ETemplate) walkE2eDir(path string, d fs.DirEntry, errAggregated error) error {
|
||||
if errAggregated != nil {
|
||||
return errAggregated
|
||||
}
|
||||
// Remove ignored files or non .go files
|
||||
if d.IsDir() || slices.Contains(skipFiles, path) || !strings.HasSuffix(path, ".go") {
|
||||
return nil
|
||||
}
|
||||
|
||||
content, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fileScanner := bufio.NewScanner(bytes.NewReader(content))
|
||||
|
||||
fileScanner.Split(bufio.ScanLines)
|
||||
|
||||
tests := make([]string, 0)
|
||||
var lineN = 0
|
||||
for fileScanner.Scan() {
|
||||
lineN = lineN + 1
|
||||
if !containsGinkgoTest(fileScanner.Text()) {
|
||||
continue
|
||||
}
|
||||
|
||||
line := getDescription(fileScanner.Text(), path, t.URL, lineN, strings.Contains(fileScanner.Text(), describe))
|
||||
if line != "" {
|
||||
tests = append(tests, line)
|
||||
}
|
||||
}
|
||||
t.Tests = append(t.Tests, tests...)
|
||||
return nil
|
||||
}
|
||||
|
||||
func GenerateE2EDocs() (string, error) {
|
||||
e2etpl := &E2ETemplate{URL: URL}
|
||||
err := filepath.WalkDir(testDir, e2etpl.walkE2eDir)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
tmpl, err := template.New("e2edocs.tpl").ParseFS(tplContent, "templates/e2edocs.tpl")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error parsing the template file: %s", err)
|
||||
}
|
||||
|
||||
tplBuff := new(bytes.Buffer)
|
||||
err = tmpl.Execute(tplBuff, e2etpl)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return tplBuff.String(), nil
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
//go:build mage
|
||||
|
||||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
|
|
@ -16,178 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
semver "github.com/blang/semver/v4"
|
||||
"github.com/helm/helm/pkg/chartutil"
|
||||
"github.com/magefile/mage/mg"
|
||||
"github.com/magefile/mage/sh"
|
||||
yamlpath "github.com/vmware-labs/yaml-jsonpath/pkg/yamlpath"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
const (
|
||||
HelmChartPath = "charts/ingress-nginx/Chart.yaml"
|
||||
HelmChartValues = "charts/ingress-nginx/values.yaml"
|
||||
)
|
||||
|
||||
type Helm mg.Namespace
|
||||
|
||||
// UpdateAppVersion Updates the Helm App Version of Ingress Nginx Controller
|
||||
func (Helm) UpdateAppVersion() {
|
||||
updateAppVersion()
|
||||
}
|
||||
|
||||
func updateAppVersion() {
|
||||
}
|
||||
|
||||
// UpdateVersion Update Helm Version of the Chart
|
||||
func (Helm) UpdateVersion(version string) {
|
||||
updateVersion(version)
|
||||
}
|
||||
|
||||
func currentChartVersion() string {
|
||||
chart, err := chartutil.LoadChartfile(HelmChartPath)
|
||||
CheckIfError(err, "HELM Could not Load Chart")
|
||||
return chart.Version
|
||||
}
|
||||
|
||||
func currentChartAppVersion() string {
|
||||
chart, err := chartutil.LoadChartfile(HelmChartPath)
|
||||
CheckIfError(err, "HELM Could not Load Chart")
|
||||
return chart.AppVersion
|
||||
}
|
||||
|
||||
func updateVersion(version string) {
|
||||
Info("HELM Reading File %v", HelmChartPath)
|
||||
|
||||
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")
|
||||
|
||||
// remove the v from TAG
|
||||
appVersion := version
|
||||
|
||||
Info("HELM Ingress-Nginx App Version: %s Chart AppVersion: %s", appVersion, chart.AppVersion)
|
||||
if appVersion == chart.AppVersion {
|
||||
Warning("HELM Ingress NGINX Version didnt change Ingress-Nginx App Version: %s Chart AppVersion: %s", appVersion, chart.AppVersion)
|
||||
return
|
||||
}
|
||||
|
||||
// Update the helm chart
|
||||
chart.AppVersion = appVersion
|
||||
cTag, err := semver.Make(chart.Version)
|
||||
CheckIfError(err, "HELM Creating Chart Version: %v", err)
|
||||
|
||||
if err = cTag.IncrementPatch(); err != nil {
|
||||
ErrorF("HELM Incrementing Chart Version: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
chart.Version = cTag.String()
|
||||
Debug("HELM Updated Chart Version: %v", chart.Version)
|
||||
|
||||
err = chartutil.SaveChartfile(HelmChartPath, chart)
|
||||
CheckIfError(err, "HELM Saving new Chart")
|
||||
}
|
||||
|
||||
func updateChartReleaseNotes(releasesNotes []string) {
|
||||
Info("HELM Updating the Chart Release notes")
|
||||
chart, err := chartutil.LoadChartfile(HelmChartPath)
|
||||
CheckIfError(err, "HELM Could not Load Chart to update release notes %s", HelmChartPath)
|
||||
var releaseNoteString string
|
||||
for i := range releasesNotes {
|
||||
releaseNoteString = fmt.Sprintf("%s - \"%s\"\n", releaseNoteString, releasesNotes[i])
|
||||
}
|
||||
Info("HELM Release note string %s", releaseNoteString)
|
||||
chart.Annotations["artifacthub.io/changes"] = releaseNoteString
|
||||
err = chartutil.SaveChartfile(HelmChartPath, chart)
|
||||
CheckIfError(err, "HELM Saving updated release notes for Chart")
|
||||
}
|
||||
|
||||
func UpdateChartChangelog() {
|
||||
}
|
||||
|
||||
// UpdateChartValue Updates the Helm ChartValue
|
||||
func (Helm) UpdateChartValue(key, value string) {
|
||||
updateChartValue(key, value)
|
||||
}
|
||||
|
||||
func updateChartValue(key, value string) {
|
||||
Info("HELM Updating Chart %s %s:%s", HelmChartValues, key, value)
|
||||
|
||||
// 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 n yaml.Node
|
||||
CheckIfError(yaml.Unmarshal(data, &n), "HELM Could not Unmarshal %s", HelmChartValues)
|
||||
|
||||
// update value
|
||||
// keyParse := parsePath(key)
|
||||
p, err := yamlpath.NewPath(key)
|
||||
CheckIfError(err, "HELM cannot create path")
|
||||
|
||||
q, err := p.Find(&n)
|
||||
CheckIfError(err, "HELM unexpected error finding path")
|
||||
|
||||
for _, i := range q {
|
||||
Info("HELM Found %s at %s", i.Value, key)
|
||||
i.Value = value
|
||||
Info("HELM Updated %s at %s", i.Value, key)
|
||||
}
|
||||
|
||||
//// write to file
|
||||
var b bytes.Buffer
|
||||
yamlEncoder := yaml.NewEncoder(&b)
|
||||
yamlEncoder.SetIndent(2)
|
||||
err = yamlEncoder.Encode(&n)
|
||||
CheckIfError(err, "HELM Could not Marshal new Values file")
|
||||
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)
|
||||
}
|
||||
|
||||
func (Helm) Helmdocs() error {
|
||||
return runHelmDocs()
|
||||
}
|
||||
|
||||
func runHelmDocs() error {
|
||||
err := installHelmDocs()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = sh.RunV("helm-docs", "--chart-search-root=${PWD}/charts")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func installHelmDocs() error {
|
||||
Info("HELM Install HelmDocs")
|
||||
g0 := sh.RunCmd("go")
|
||||
|
||||
err := g0("install", "github.com/norwoodj/helm-docs/cmd/helm-docs@v1.11.0")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func parsePath(key string) []string { return strings.Split(key, ".") }
|
||||
|
||||
func updateHelmDocs() {
|
||||
}
|
||||
package utils
|
||||
|
||||
type IngressChartValue struct {
|
||||
CommonLabels struct{} `yaml:"commonLabels"`
|
||||
91
magefiles/utils/releasenote.go
Normal file
91
magefiles/utils/releasenote.go
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
// ReleaseNote - All the pieces of information/documents that get updated during a release
|
||||
type ReleaseNote struct {
|
||||
Version string
|
||||
NewControllerVersion string
|
||||
PreviousControllerVersion string
|
||||
ControllerImages []ControllerImage
|
||||
DepUpdates []string
|
||||
Updates []string
|
||||
HelmUpdates []string
|
||||
NewHelmChartVersion string
|
||||
PreviousHelmChartVersion string
|
||||
}
|
||||
|
||||
func (r ReleaseNote) Template() {
|
||||
// Files are provided as a slice of strings.
|
||||
changelogTemplate, err := os.ReadFile("Changelog.md.gotmpl")
|
||||
if err != nil {
|
||||
ErrorF("Could not read changelog template file %s", err)
|
||||
}
|
||||
Debug("ChangeLog Templates %s", string(changelogTemplate))
|
||||
t := template.Must(template.New("changelog").Parse(string(changelogTemplate)))
|
||||
// create a new file
|
||||
file, err := os.Create(fmt.Sprintf("changelog/Changelog-%s.md", r.Version))
|
||||
if err != nil {
|
||||
ErrorF("Could not create changelog file %s", err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
err = t.Execute(file, r)
|
||||
if err != nil {
|
||||
ErrorF("executing template: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (r ReleaseNote) HelmTemplate() {
|
||||
// Files are provided as a slice of strings.
|
||||
changelogTemplate, err := os.ReadFile("charts/ingress-nginx/changelog.md.gotmpl")
|
||||
if err != nil {
|
||||
ErrorF("Could not read changelog template file %s", err)
|
||||
}
|
||||
Debug("ChangeLog Templates %s", string(changelogTemplate))
|
||||
t := template.Must(template.New("changelog").Parse(string(changelogTemplate)))
|
||||
// create a new file
|
||||
file, err := os.Create(fmt.Sprintf("charts/ingress-nginx/changelog/Changelog-%s.md", r.NewHelmChartVersion))
|
||||
if err != nil {
|
||||
ErrorF("Could not create changelog file %s", err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
err = t.Execute(file, r)
|
||||
if err != nil {
|
||||
ErrorF("executing template: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (r ReleaseNote) PrintRelease() {
|
||||
Info("Release Version: %v", r.NewControllerVersion)
|
||||
Info("Previous Version: %v", r.PreviousControllerVersion)
|
||||
Info("Controller Image: %v", r.ControllerImages[0].print())
|
||||
Info("Controller Chroot Image: %v", r.ControllerImages[1].print())
|
||||
for i := range r.Updates {
|
||||
Info("Update #%v - %v", i, r.Updates[i])
|
||||
}
|
||||
for j := range r.DepUpdates {
|
||||
Info("Dependabot Update #%v - %v", j, r.DepUpdates[j])
|
||||
}
|
||||
}
|
||||
10
magefiles/utils/templates/e2edocs.tpl
Normal file
10
magefiles/utils/templates/e2edocs.tpl
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<!---
|
||||
This file is autogenerated!
|
||||
Do not try to edit it manually.
|
||||
-->
|
||||
|
||||
# e2e test suite for [Ingress NGINX Controller]({{.URL}})
|
||||
|
||||
{{ range $test := .Tests }}
|
||||
{{ $test }}
|
||||
{{- end }}
|
||||
Loading…
Add table
Add a link
Reference in a new issue