ci: fix misc and refactorings (#4994)

* ci: fix misc and refactorings

* ci: additional fix
pull/4995/head
James Elliott 2023-02-26 13:22:22 +11:00 committed by GitHub
parent 024004f5a1
commit ac72ee494c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 96 additions and 133 deletions

View File

@ -5,5 +5,7 @@
"RememberMe":"{{ .RememberMe }}", "RememberMe":"{{ .RememberMe }}",
"ResetPassword":"{{ .ResetPassword }}", "ResetPassword":"{{ .ResetPassword }}",
"ResetPasswordCustomURL":"{{ .ResetPasswordCustomURL }}", "ResetPasswordCustomURL":"{{ .ResetPasswordCustomURL }}",
"PrivacyPolicyURL":"{{ .PrivacyPolicyURL }}",
"PrivacyPolicyAccept":"{{ .PrivacyPolicyAccept }}",
"Theme":"{{ .Theme }}" "Theme":"{{ .Theme }}"
} }

View File

@ -83,8 +83,8 @@ const (
) )
const ( const (
envFileProd = "./web/.env.production" envFileProd = "/web/.env.production"
envFileDev = "./web/.env.development" envFileDev = "/web/.env.development"
namespaceAuthelia = "authelia" namespaceAuthelia = "authelia"
namespaceDashboard = "kubernetes-dashboard" namespaceDashboard = "kubernetes-dashboard"
namespaceKube = "kube-system" namespaceKube = "kube-system"

View File

@ -19,14 +19,12 @@ func init() {
"internal/suites/example/compose/samba/docker-compose.yml", "internal/suites/example/compose/samba/docker-compose.yml",
}) })
setup := func(suitePath string) error { setup := func(suitePath string) (err error) {
err := dockerEnvironment.Up() if err = dockerEnvironment.Up(); err != nil {
if err != nil {
return err return err
} }
err = waitUntilAutheliaIsReady(dockerEnvironment, activedirectorySuiteName) if err = waitUntilAutheliaIsReady(dockerEnvironment, activedirectorySuiteName); err != nil {
if err != nil {
return err return err
} }

View File

@ -19,14 +19,12 @@ func init() {
"internal/suites/example/compose/smtp/docker-compose.yml", "internal/suites/example/compose/smtp/docker-compose.yml",
}) })
setup := func(suitePath string) error { setup := func(suitePath string) (err error) {
err := dockerEnvironment.Up() if err = dockerEnvironment.Up(); err != nil {
if err != nil {
return err return err
} }
err = waitUntilAutheliaIsReady(dockerEnvironment, bypassAllSuiteName) if err = waitUntilAutheliaIsReady(dockerEnvironment, bypassAllSuiteName); err != nil {
if err != nil {
return err return err
} }

View File

@ -32,14 +32,12 @@ func init() {
}) })
} }
setup := func(suitePath string) error { setup := func(suitePath string) (err error) {
err := dockerEnvironment.Up() if err = dockerEnvironment.Up(); err != nil {
if err != nil {
return err return err
} }
err = waitUntilAutheliaIsReady(dockerEnvironment, caddySuiteName) if err = waitUntilAutheliaIsReady(dockerEnvironment, caddySuiteName); err != nil {
if err != nil {
return err return err
} }

View File

@ -15,8 +15,8 @@ func init() {
"internal/suites/example/compose/authelia/docker-compose.backend.{}.yml", "internal/suites/example/compose/authelia/docker-compose.backend.{}.yml",
}) })
setup := func(suitePath string) error { setup := func(suitePath string) (err error) {
if err := dockerEnvironment.Up(); err != nil { if err = dockerEnvironment.Up(); err != nil {
return err return err
} }

View File

@ -18,14 +18,12 @@ func init() {
"internal/suites/example/compose/smtp/docker-compose.yml", "internal/suites/example/compose/smtp/docker-compose.yml",
}) })
setup := func(suitePath string) error { setup := func(suitePath string) (err error) {
err := dockerEnvironment.Up() if err = dockerEnvironment.Up(); err != nil {
if err != nil {
return err return err
} }
err = waitUntilAutheliaIsReady(dockerEnvironment, dockerSuiteName) if err = waitUntilAutheliaIsReady(dockerEnvironment, dockerSuiteName); err != nil {
if err != nil {
return err return err
} }

View File

@ -19,14 +19,12 @@ func init() {
"internal/suites/example/compose/duo-api/docker-compose.yml", "internal/suites/example/compose/duo-api/docker-compose.yml",
}) })
setup := func(suitePath string) error { setup := func(suitePath string) (err error) {
err := dockerEnvironment.Up() if err = dockerEnvironment.Up(); err != nil {
if err != nil {
return err return err
} }
err = waitUntilAutheliaIsReady(dockerEnvironment, duoPushSuiteName) if err = waitUntilAutheliaIsReady(dockerEnvironment, duoPushSuiteName); err != nil {
if err != nil {
return err return err
} }

View File

@ -32,14 +32,12 @@ func init() {
}) })
} }
setup := func(suitePath string) error { setup := func(suitePath string) (err error) {
err := dockerEnvironment.Up() if err = dockerEnvironment.Up(); err != nil {
if err != nil {
return err return err
} }
err = waitUntilAutheliaIsReady(dockerEnvironment, envoySuiteName) if err = waitUntilAutheliaIsReady(dockerEnvironment, envoySuiteName); err != nil {
if err != nil {
return err return err
} }

View File

@ -32,14 +32,12 @@ func init() {
}) })
} }
setup := func(suitePath string) error { setup := func(suitePath string) (err error) {
err := dockerEnvironment.Up() if err = dockerEnvironment.Up(); err != nil {
if err != nil {
return err return err
} }
err = waitUntilAutheliaIsReady(dockerEnvironment, haproxySuiteName) if err = waitUntilAutheliaIsReady(dockerEnvironment, haproxySuiteName); err != nil {
if err != nil {
return err return err
} }

View File

@ -23,14 +23,12 @@ var haDockerEnvironment = NewDockerEnvironment([]string{
}) })
func init() { func init() {
setup := func(suitePath string) error { setup := func(suitePath string) (err error) {
err := haDockerEnvironment.Up() if err = haDockerEnvironment.Up(); err != nil {
if err != nil {
return err return err
} }
err = waitUntilAutheliaIsReady(haDockerEnvironment, highAvailabilitySuiteName) if err = waitUntilAutheliaIsReady(haDockerEnvironment, highAvailabilitySuiteName); err != nil {
if err != nil {
return err return err
} }

View File

@ -20,14 +20,12 @@ func init() {
"internal/suites/example/compose/ldap/docker-compose.admin.yml", "internal/suites/example/compose/ldap/docker-compose.admin.yml",
}) })
setup := func(suitePath string) error { setup := func(suitePath string) (err error) {
err := dockerEnvironment.Up() if err = dockerEnvironment.Up(); err != nil {
if err != nil {
return err return err
} }
err = waitUntilAutheliaIsReady(dockerEnvironment, ldapSuiteName) if err = waitUntilAutheliaIsReady(dockerEnvironment, ldapSuiteName); err != nil {
if err != nil {
return err return err
} }

View File

@ -20,14 +20,12 @@ func init() {
"internal/suites/example/compose/ldap/docker-compose.yml", "internal/suites/example/compose/ldap/docker-compose.yml",
}) })
setup := func(suitePath string) error { setup := func(suitePath string) (err error) {
err := dockerEnvironment.Up() if err = dockerEnvironment.Up(); err != nil {
if err != nil {
return err return err
} }
err = waitUntilAutheliaIsReady(dockerEnvironment, mariadbSuiteName) if err = waitUntilAutheliaIsReady(dockerEnvironment, mariadbSuiteName); err != nil {
if err != nil {
return err return err
} }

View File

@ -18,13 +18,16 @@ var multiCookieDomainDockerEnvironment = NewDockerEnvironment([]string{
}) })
func init() { func init() {
setup := func(suitePath string) error { setup := func(suitePath string) (err error) {
err := multiCookieDomainDockerEnvironment.Up() if err = multiCookieDomainDockerEnvironment.Up(); err != nil {
if err != nil {
return err return err
} }
return waitUntilAutheliaIsReady(multiCookieDomainDockerEnvironment, multiCookieDomainSuiteName) if err = waitUntilAutheliaIsReady(multiCookieDomainDockerEnvironment, multiCookieDomainSuiteName); err != nil {
return err
}
return updateDevEnvFileForDomain(BaseDomain, true)
} }
displayAutheliaLogs := func() error { displayAutheliaLogs := func() error {

View File

@ -20,14 +20,12 @@ func init() {
"internal/suites/example/compose/ldap/docker-compose.yml", "internal/suites/example/compose/ldap/docker-compose.yml",
}) })
setup := func(suitePath string) error { setup := func(suitePath string) (err error) {
err := dockerEnvironment.Up() if err = dockerEnvironment.Up(); err != nil {
if err != nil {
return err return err
} }
err = waitUntilAutheliaIsReady(dockerEnvironment, mysqlSuiteName) if err = waitUntilAutheliaIsReady(dockerEnvironment, mysqlSuiteName); err != nil {
if err != nil {
return err return err
} }

View File

@ -21,14 +21,12 @@ func init() {
"internal/suites/example/compose/httpbin/docker-compose.yml", "internal/suites/example/compose/httpbin/docker-compose.yml",
}) })
setup := func(suitePath string) error { setup := func(suitePath string) (err error) {
err := dockerEnvironment.Up() if err = dockerEnvironment.Up(); err != nil {
if err != nil {
return err return err
} }
err = waitUntilAutheliaIsReady(dockerEnvironment, networkACLSuiteName) if err = waitUntilAutheliaIsReady(dockerEnvironment, networkACLSuiteName); err != nil {
if err != nil {
return err return err
} }

View File

@ -20,21 +20,18 @@ func init() {
"internal/suites/example/compose/redis/docker-compose.yml", "internal/suites/example/compose/redis/docker-compose.yml",
}) })
setup := func(suitePath string) error { setup := func(suitePath string) (err error) {
// TODO(c.michaud): use version in tags for oidc-client but in the meantime we pull the image to make sure it's // TODO(c.michaud): use version in tags for oidc-client but in the meantime we pull the image to make sure it's
// up to date. // up to date.
err := dockerEnvironment.Pull("oidc-client") if err = dockerEnvironment.Pull("oidc-client"); err != nil {
if err != nil {
return err return err
} }
err = dockerEnvironment.Up() if err = dockerEnvironment.Up(); err != nil {
if err != nil {
return err return err
} }
err = waitUntilAutheliaIsReady(dockerEnvironment, oidcSuiteName) if err = waitUntilAutheliaIsReady(dockerEnvironment, oidcSuiteName); err != nil {
if err != nil {
return err return err
} }

View File

@ -34,21 +34,18 @@ func init() {
}) })
} }
setup := func(suitePath string) error { setup := func(suitePath string) (err error) {
// TODO(c.michaud): use version in tags for oidc-client but in the meantime we pull the image to make sure it's // TODO(c.michaud): use version in tags for oidc-client but in the meantime we pull the image to make sure it's
// up to date. // up to date.
err := dockerEnvironment.Pull("oidc-client") if err = dockerEnvironment.Pull("oidc-client"); err != nil {
if err != nil {
return err return err
} }
err = dockerEnvironment.Up() if err = dockerEnvironment.Up(); err != nil {
if err != nil {
return err return err
} }
err = waitUntilAutheliaIsReady(dockerEnvironment, oidcTraefikSuiteName) if err = waitUntilAutheliaIsReady(dockerEnvironment, oidcTraefikSuiteName); err != nil {
if err != nil {
return err return err
} }

View File

@ -17,14 +17,12 @@ func init() {
"internal/suites/example/compose/nginx/portal/docker-compose.yml", "internal/suites/example/compose/nginx/portal/docker-compose.yml",
}) })
setup := func(suitePath string) error { setup := func(suitePath string) (err error) {
err := dockerEnvironment.Up() if err = dockerEnvironment.Up(); err != nil {
if err != nil {
return err return err
} }
err = waitUntilAutheliaIsReady(dockerEnvironment, oneFactorOnlySuiteName) if err = waitUntilAutheliaIsReady(dockerEnvironment, oneFactorOnlySuiteName); err != nil {
if err != nil {
return err return err
} }

View File

@ -32,14 +32,12 @@ func init() {
}) })
} }
setup := func(suitePath string) error { setup := func(suitePath string) (err error) {
err := dockerEnvironment.Up() if err = dockerEnvironment.Up(); err != nil {
if err != nil {
return err return err
} }
err = waitUntilAutheliaIsReady(dockerEnvironment, pathPrefixSuiteName) if err = waitUntilAutheliaIsReady(dockerEnvironment, pathPrefixSuiteName); err != nil {
if err != nil {
return err return err
} }

View File

@ -20,14 +20,12 @@ func init() {
"internal/suites/example/compose/ldap/docker-compose.yml", "internal/suites/example/compose/ldap/docker-compose.yml",
}) })
setup := func(suitePath string) error { setup := func(suitePath string) (err error) {
err := dockerEnvironment.Up() if err = dockerEnvironment.Up(); err != nil {
if err != nil {
return err return err
} }
err = waitUntilAutheliaIsReady(dockerEnvironment, postgresSuiteName) if err = waitUntilAutheliaIsReady(dockerEnvironment, postgresSuiteName); err != nil {
if err != nil {
return err return err
} }

View File

@ -18,14 +18,12 @@ func init() {
"internal/suites/example/compose/smtp/docker-compose.yml", "internal/suites/example/compose/smtp/docker-compose.yml",
}) })
setup := func(suitePath string) error { setup := func(suitePath string) (err error) {
err := dockerEnvironment.Up() if err = dockerEnvironment.Up(); err != nil {
if err != nil {
return err return err
} }
err = waitUntilAutheliaIsReady(dockerEnvironment, shortTimeoutsSuiteName) if err = waitUntilAutheliaIsReady(dockerEnvironment, shortTimeoutsSuiteName); err != nil {
if err != nil {
return err return err
} }

View File

@ -23,14 +23,12 @@ func init() {
"internal/suites/example/compose/smtp/docker-compose.yml", "internal/suites/example/compose/smtp/docker-compose.yml",
}) })
setup := func(suitePath string) error { setup := func(suitePath string) (err error) {
err := dockerEnvironment.Up() if err = dockerEnvironment.Up(); err != nil {
if err != nil {
return err return err
} }
err = waitUntilAutheliaIsReady(dockerEnvironment, standaloneSuiteName) if err = waitUntilAutheliaIsReady(dockerEnvironment, standaloneSuiteName); err != nil {
if err != nil {
return err return err
} }

View File

@ -32,14 +32,12 @@ func init() {
}) })
} }
setup := func(suitePath string) error { setup := func(suitePath string) (err error) {
err := dockerEnvironment.Up() if err = dockerEnvironment.Up(); err != nil {
if err != nil {
return err return err
} }
err = waitUntilAutheliaIsReady(dockerEnvironment, traefikSuiteName) if err = waitUntilAutheliaIsReady(dockerEnvironment, traefikSuiteName); err != nil {
if err != nil {
return err return err
} }

View File

@ -34,14 +34,12 @@ func init() {
}) })
} }
setup := func(suitePath string) error { setup := func(suitePath string) (err error) {
err := traefik2DockerEnvironment.Up() if err = traefik2DockerEnvironment.Up(); err != nil {
if err != nil {
return err return err
} }
err = waitUntilAutheliaIsReady(traefik2DockerEnvironment, traefik2SuiteName) if err = waitUntilAutheliaIsReady(traefik2DockerEnvironment, traefik2SuiteName); err != nil {
if err != nil {
return err return err
} }

View File

@ -241,8 +241,8 @@ func fixCoveragePath(path string, file os.FileInfo, err error) error {
// getEnvInfoFromURL gets environments variables for specified cookie domain // getEnvInfoFromURL gets environments variables for specified cookie domain
// this func makes a http call to https://login.<domain>/devworkflow and is only useful for suite tests. // this func makes a http call to https://login.<domain>/devworkflow and is only useful for suite tests.
func getDomainEnvInfo(domain string) (map[string]string, error) { func getDomainEnvInfo(domain string) (info map[string]string, err error) {
info := make(map[string]string) info = make(map[string]string)
client := &http.Client{ client := &http.Client{
Transport: &http.Transport{ Transport: &http.Transport{
@ -256,7 +256,6 @@ func getDomainEnvInfo(domain string) (map[string]string, error) {
req *http.Request req *http.Request
resp *http.Response resp *http.Response
body []byte body []byte
err error
) )
targetURL := LoginBaseURLFmt(domain) + "/devworkflow" targetURL := LoginBaseURLFmt(domain) + "/devworkflow"
@ -285,16 +284,20 @@ func getDomainEnvInfo(domain string) (map[string]string, error) {
} }
// generateDevEnvFile generates web/.env.development based on opts. // generateDevEnvFile generates web/.env.development based on opts.
func generateDevEnvFile(opts map[string]string) error { func generateDevEnvFile(info map[string]string) (err error) {
tmpl, err := template.ParseFiles(envFileProd) base, _ := os.Getwd()
if err != nil { base = strings.TrimSuffix(base, "/internal/suites")
var tmpl *template.Template
if tmpl, err = template.ParseFiles(base + envFileProd); err != nil {
return err return err
} }
file, _ := os.Create(envFileDev) file, _ := os.Create(base + envFileDev)
defer file.Close() defer file.Close()
if err := tmpl.Execute(file, opts); err != nil { if err = tmpl.Execute(file, info); err != nil {
return err return err
} }
@ -303,29 +306,28 @@ func generateDevEnvFile(opts map[string]string) error {
// updateDevEnvFileForDomain updates web/.env.development. // updateDevEnvFileForDomain updates web/.env.development.
// this function only affects local dev environments. // this function only affects local dev environments.
func updateDevEnvFileForDomain(domain string, setup bool) error { func updateDevEnvFileForDomain(domain string, setup bool) (err error) {
if os.Getenv("CI") == t { if os.Getenv("CI") == t {
return nil return nil
} }
if _, err := os.Stat(envFileDev); err != nil && os.IsNotExist(err) { if _, err = os.Stat(envFileDev); err != nil && os.IsNotExist(err) {
file, _ := os.Create(envFileDev) file, _ := os.Create(envFileDev)
file.Close() file.Close()
} }
info, err := getDomainEnvInfo(domain) var info map[string]string
if err != nil {
if info, err = getDomainEnvInfo(domain); err != nil {
return err return err
} }
err = generateDevEnvFile(info) if err = generateDevEnvFile(info); err != nil {
if err != nil {
return err return err
} }
if !setup { if !setup {
err = waitUntilAutheliaFrontendIsReady(multiCookieDomainDockerEnvironment) if err = waitUntilAutheliaFrontendIsReady(multiCookieDomainDockerEnvironment); err != nil {
if err != nil {
return err return err
} }
} }