func()

in app/registry/create.go [104:168]


func (a *App) createRegistryGet(ctx *gin.Context) (response router.Response, retErr error) {
	prjs, err := a.Services.Gerrit.GetProjects(context.Background())
	if err != nil {
		return nil, errors.Wrap(err, "unable to list gerrit projects")
	}
	prjs = a.filterProjects(prjs, a.Config.RegistryTemplateName)

	userCtx := router.ContextWithUserAccessToken(ctx)
	k8sService, err := a.Services.K8S.ServiceForContext(userCtx)
	if err != nil {
		return nil, errors.Wrap(err, "unable to init service for user context")
	}

	if err := a.checkCreateAccess(k8sService); err != nil {
		return nil, errors.Wrap(err, "error during create access check")
	}

	hwINITemplateContent, err := GetINITemplateContent(a.Config.HardwareINITemplatePath)
	if err != nil {
		return nil, errors.Wrap(err, "unable to get ini template data")
	}

	dnsManual, err := a.getDNSManualURL(ctx)
	if err != nil {
		return nil, errors.Wrap(err, "unable to get dns manual")
	}

	gerritBranches := formatGerritProjectBranches(prjs)

	keycloakHostname, err := LoadKeycloakDefaultHostname(ctx, a.KeycloakDefaultHostname, a.EDPComponent)
	if err != nil {
		return nil, fmt.Errorf("unable to load keycloak default hostname, %w", err)
	}

	keycloakHostnames, err := a.loadKeycloakHostnames()
	if err != nil {
		return nil, fmt.Errorf("unable to load keycloak hostnames, %w", err)
	}

	responseParams := gin.H{
		"dnsManual":            dnsManual,
		"page":                 "registry",
		"gerritProjects":       prjs,
		"gerritBranches":       gerritBranches,
		"model":                registry{KeyDeviceType: KeyDeviceTypeFile},
		"smtpConfig":           "{}",
		"action":               "create",
		"registryData":         "{}",
		"keycloakHostname":     keycloakHostname,
		"keycloakHostnames":    keycloakHostnames,
		"registryTemplateName": a.Config.RegistryTemplateName,
		"platformStatusType":   a.Config.CloudProvider,
		"registryVersion":      ctx.Request.URL.Query().Get("version"),
	}

	templateArgs, templateErr := json.Marshal(responseParams)
	if templateErr != nil {
		return nil, errors.Wrap(templateErr, "unable to encode template arguments")
	}

	responseParams["templateArgs"] = string(templateArgs)
	responseParams["hwINITemplateContent"] = hwINITemplateContent

	return router.MakeHTMLResponse(200, "registry/create.html", responseParams), nil
}