diff --git a/.github/PULL_REQUEST_TEMPLATE.yml b/.github/PULL_REQUEST_TEMPLATE.yml deleted file mode 100644 index 5bcb8dce..00000000 --- a/.github/PULL_REQUEST_TEMPLATE.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Pull Request -description: Use this template when creating a pull request. - -body: - - type: markdown - attributes: - value: | - Thanks for taking the time to create this pull request. - - Please note that as per our contribution guidelines, unless the pull - request is for a simple typo correction or obvious bug fix, it's - recommended to initiate a discussion by first raising an issue. This - enables us to assess proposed changes and evaluate whether a change to - the core platform is really needed, or if there's a more effective - approach to achieve the desired outcome without making the changes. - - - type: textarea - id: change-summary - attributes: - label: Summary of the changes being made by this pull request - description: An overview of the changes you've made and why they are necessary. - validations: - required: true - - - type: textarea - id: related-issues - attributes: - label: Related issue(s) for this pull request - description: Link(s) to the GitHub issues this pull request is addressing. - validations: - required: false - - - type: textarea - id: additional-information - attributes: - label: Additional information - description: Add any other information related to the changes. - validations: - required: false diff --git a/carvel-packages/training-platform/bundle/config/00-schema.yaml b/carvel-packages/training-platform/bundle/config/00-schema.yaml index 0fac722d..e46642f2 100644 --- a/carvel-packages/training-platform/bundle/config/00-schema.yaml +++ b/carvel-packages/training-platform/bundle/config/00-schema.yaml @@ -60,7 +60,7 @@ clusterIngress: #! Ingress domain. DNS parent subdomain used for training portal and workshop #! ingresses. - domain: "educates-local-dev.xyz" + domain: "educates-local-dev.test" #! Ingress class. Required when multiple ingress controllers exist and it is #! necessary to use one which is not marked as the default. Note that any diff --git a/carvel-packages/training-platform/bundle/config/06-secrets.yaml b/carvel-packages/training-platform/bundle/config/06-secrets.yaml index bbb9384f..1c293ff8 100644 --- a/carvel-packages/training-platform/bundle/config/06-secrets.yaml +++ b/carvel-packages/training-platform/bundle/config/06-secrets.yaml @@ -15,7 +15,7 @@ metadata: annotations: kapp.k14s.io/versioned: "" kapp.k14s.io/num-versions: "5" -#@ if data.values.clusterIngress.domain == "educates-local-dev.xyz": +#@ if data.values.clusterIngress.domain == "educates-local-dev.test": stringData: values.yaml: #@ yaml.encode(data.values) kyverno-policies.yaml: #@ yaml.encode(kyverno_policies) diff --git a/client-programs/pkg/cmd/cluster_portal_create_cmd.go b/client-programs/pkg/cmd/cluster_portal_create_cmd.go index 826d617f..5103e2d7 100644 --- a/client-programs/pkg/cmd/cluster_portal_create_cmd.go +++ b/client-programs/pkg/cmd/cluster_portal_create_cmd.go @@ -79,7 +79,7 @@ func (p *ProjectInfo) NewClusterPortalCreateCmd() *cobra.Command { c.Flags().UintVar( &o.Capacity, "capacity", - 1, + 5, "maximum number of current sessions for the training portal", ) c.Flags().StringVar( diff --git a/client-programs/pkg/cmd/cluster_portal_open_cmd.go b/client-programs/pkg/cmd/cluster_portal_open_cmd.go index c6ab98fa..d09ba6e5 100644 --- a/client-programs/pkg/cmd/cluster_portal_open_cmd.go +++ b/client-programs/pkg/cmd/cluster_portal_open_cmd.go @@ -3,8 +3,12 @@ package cmd import ( "context" "fmt" + "io" + "net/http" + "net/url" "os/exec" "runtime" + "time" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -45,28 +49,59 @@ func (o *ClusterPortalOpenOptions) Run() error { return errors.New("no workshops deployed") } - url, found, _ := unstructured.NestedString(trainingPortal.Object, "status", "educates", "url") + targetUrl, found, _ := unstructured.NestedString(trainingPortal.Object, "status", "educates", "url") if !found { return errors.New("workshops not available") } + rootUrl := targetUrl + if o.Admin { - url = url + "/admin" + targetUrl = targetUrl + "/admin" + } else { + password, _, _ := unstructured.NestedString(trainingPortal.Object, "spec", "portal", "password") + + if password != "" { + values := url.Values{} + values.Add("redirect_url", "/") + values.Add("password", password) + + targetUrl = fmt.Sprintf("%s/workshops/access/?%s", targetUrl, values.Encode()) + } + } + + for i := 1; i < 300; i++ { + time.Sleep(time.Second) + + resp, err := http.Get(rootUrl) + + if err != nil || resp.StatusCode == 503 { + continue + } + + defer resp.Body.Close() + io.ReadAll(resp.Body) + + break } switch runtime.GOOS { case "linux": - err = exec.Command("xdg-open", url).Start() + err = exec.Command("xdg-open", targetUrl).Start() case "windows": - err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start() + err = exec.Command("rundll32", "url.dll,FileProtocolHandler", targetUrl).Start() case "darwin": - err = exec.Command("open", url).Start() + err = exec.Command("open", targetUrl).Start() default: err = fmt.Errorf("unsupported platform") } - return err + if err != nil { + return errors.Wrap(err, "unable to open web browser") + } + + return nil } func (p *ProjectInfo) NewClusterPortalOpenCmd() *cobra.Command { diff --git a/client-programs/pkg/cmd/cluster_workshop_deploy_cmd.go b/client-programs/pkg/cmd/cluster_workshop_deploy_cmd.go index 3e9524a8..00691c68 100644 --- a/client-programs/pkg/cmd/cluster_workshop_deploy_cmd.go +++ b/client-programs/pkg/cmd/cluster_workshop_deploy_cmd.go @@ -3,7 +3,13 @@ package cmd import ( "context" "encoding/json" + "fmt" + "io" "math/rand" + "net/http" + "net/url" + "os/exec" + "runtime" "strings" "time" @@ -36,6 +42,7 @@ type ClusterWorkshopDeployOptions struct { Environ []string WorkshopFile string WorkshopVersion string + OpenBrowser bool DataValuesFlags yttcmd.DataValuesFlags } @@ -86,7 +93,7 @@ func (o *ClusterWorkshopDeployOptions) Run() error { // Update the training portal, creating it if necessary. - err = deployWorkshopResource(dynamicClient, workshop, o.Portal, o.Capacity, o.Reserved, o.Initial, o.Expires, o.Overtime, o.Deadline, o.Orphaned, o.Overdue, o.Refresh, o.Repository, o.Environ) + err = deployWorkshopResource(dynamicClient, workshop, o.Portal, o.Capacity, o.Reserved, o.Initial, o.Expires, o.Overtime, o.Deadline, o.Orphaned, o.Overdue, o.Refresh, o.Repository, o.Environ, o.OpenBrowser) if err != nil { return err @@ -135,8 +142,8 @@ func (p *ProjectInfo) NewClusterWorkshopDeployCmd() *cobra.Command { c.Flags().UintVar( &o.Capacity, "capacity", - 1, - "maximum number of current sessions for the workshop", + 0, + "maximum number of concurrent sessions for this workshop", ) c.Flags().UintVar( &o.Reserved, @@ -215,6 +222,13 @@ func (p *ProjectInfo) NewClusterWorkshopDeployCmd() *cobra.Command { "the address of the image repository", ) + c.Flags().BoolVar( + &o.OpenBrowser, + "open-browser", + false, + "automatically launch browser on portal", + ) + c.Flags().StringArrayVar( &o.DataValuesFlags.EnvFromStrings, "data-values-env", @@ -258,7 +272,7 @@ func (p *ProjectInfo) NewClusterWorkshopDeployCmd() *cobra.Command { var trainingPortalResource = schema.GroupVersionResource{Group: "training.educates.dev", Version: "v1beta1", Resource: "trainingportals"} -func deployWorkshopResource(client dynamic.Interface, workshop *unstructured.Unstructured, portal string, capacity uint, reserved uint, initial uint, expires string, overtime string, deadline string, orphaned string, overdue string, refresh string, registry string, environ []string) error { +func deployWorkshopResource(client dynamic.Interface, workshop *unstructured.Unstructured, portal string, capacity uint, reserved uint, initial uint, expires string, overtime string, deadline string, orphaned string, overdue string, refresh string, registry string, environ []string, openBrowser bool) error { trainingPortalClient := client.Resource(trainingPortalResource) trainingPortal, err := trainingPortalClient.Get(context.TODO(), portal, metav1.GetOptions{}) @@ -292,7 +306,7 @@ func deployWorkshopResource(client dynamic.Interface, workshop *unstructured.Uns "sessions": struct { Maximum int64 `json:"maximum"` }{ - Maximum: 1, + Maximum: 5, }, "workshop": map[string]interface{}{ "defaults": struct { @@ -307,38 +321,6 @@ func deployWorkshopResource(client dynamic.Interface, workshop *unstructured.Uns }) } - var propertyExists bool - - var sessionsMaximum int64 = 1 - - if trainingPortalExists { - sessionsMaximum, propertyExists, err = unstructured.NestedInt64(trainingPortal.Object, "spec", "portal", "sessions", "maximum") - - if err == nil && propertyExists { - if sessionsMaximum >= 0 && uint(sessionsMaximum) < capacity { - capacity = uint(sessionsMaximum) - } - } - } else { - capacity = 1 - } - - if capacity != 0 { - if reserved > capacity { - reserved = capacity - } - if initial > capacity { - initial = capacity - } - } else if sessionsMaximum != 0 { - if reserved > uint(sessionsMaximum) { - reserved = uint(sessionsMaximum) - } - if initial > uint(sessionsMaximum) { - initial = uint(sessionsMaximum) - } - } - workshops, _, err := unstructured.NestedSlice(trainingPortal.Object, "spec", "workshops") if err != nil { @@ -516,6 +498,73 @@ func deployWorkshopResource(client dynamic.Interface, workshop *unstructured.Uns return errors.Wrapf(err, "unable to update training portal %q in cluster", portal) } + if openBrowser { + // Need to refetch training portal because if was just created the URL + // for access may not have been set yet. + + var targetUrl string + + for i := 1; i < 60; i++ { + time.Sleep(time.Second) + + trainingPortal, err = trainingPortalClient.Get(context.TODO(), portal, metav1.GetOptions{}) + + if err != nil { + return errors.Wrapf(err, "unable to fetch training portal %q in cluster", portal) + } + + var found bool + + targetUrl, found, _ = unstructured.NestedString(trainingPortal.Object, "status", "educates", "url") + + if found { + break + } + } + + rootUrl := targetUrl + + password, _, _ := unstructured.NestedString(trainingPortal.Object, "spec", "portal", "password") + + if password != "" { + values := url.Values{} + values.Add("redirect_url", "/") + values.Add("password", password) + + targetUrl = fmt.Sprintf("%s/workshops/access/?%s", targetUrl, values.Encode()) + } + + for i := 1; i < 300; i++ { + time.Sleep(time.Second) + + resp, err := http.Get(rootUrl) + + if err != nil || resp.StatusCode == 503 { + continue + } + + defer resp.Body.Close() + io.ReadAll(resp.Body) + + break + } + + switch runtime.GOOS { + case "linux": + err = exec.Command("xdg-open", targetUrl).Start() + case "windows": + err = exec.Command("rundll32", "url.dll,FileProtocolHandler", targetUrl).Start() + case "darwin": + err = exec.Command("open", targetUrl).Start() + default: + err = fmt.Errorf("unsupported platform") + } + + if err != nil { + return errors.Wrap(err, "unable to open web browser") + } + } + return nil } diff --git a/client-programs/pkg/cmd/cluster_workshop_request_cmd.go b/client-programs/pkg/cmd/cluster_workshop_request_cmd.go index 8bd4c5ea..d10e7bd7 100644 --- a/client-programs/pkg/cmd/cluster_workshop_request_cmd.go +++ b/client-programs/pkg/cmd/cluster_workshop_request_cmd.go @@ -478,7 +478,7 @@ func requestWorkshop(client dynamic.Interface, name string, portal string, param } if indexUrl == "" { - indexUrl = portalUrl + indexUrl = fmt.Sprintf("%s/accounts/logout/", portalUrl) } requestURL = fmt.Sprintf("%s/workshops/environment/%s/request/?index_url=%s", portalUrl, environmentName, url.QueryEscape(indexUrl)) diff --git a/client-programs/pkg/cmd/educates_cmd_group.go b/client-programs/pkg/cmd/educates_cmd_group.go index 540a8df6..0e4f6143 100644 --- a/client-programs/pkg/cmd/educates_cmd_group.go +++ b/client-programs/pkg/cmd/educates_cmd_group.go @@ -40,7 +40,6 @@ func (p *ProjectInfo) NewEducatesCmdGroup() *cobra.Command { overrideCommandName(p.NewClusterWorkshopDeployCmd(), "deploy-workshop"), overrideCommandName(p.NewClusterWorkshopListCmd(), "list-workshops"), overrideCommandName(p.NewClusterWorkshopServeCmd(), "serve-workshop"), - overrideCommandName(p.NewClusterWorkshopRequestCmd(), "request-workshop"), overrideCommandName(p.NewClusterWorkshopUpdateCmd(), "update-workshop"), overrideCommandName(p.NewClusterWorkshopDeleteCmd(), "delete-workshop"), diff --git a/docker-extension/Dockerfile b/docker-extension/Dockerfile index 08f7ab0b..d6811622 100644 --- a/docker-extension/Dockerfile +++ b/docker-extension/Dockerfile @@ -4,18 +4,6 @@ ARG TAG=latest FROM ${REPOSITORY}/${CLI_IMAGE_NAME}:${TAG} AS client-programs -# FROM golang:1.19-alpine AS builder -# ENV CGO_ENABLED=0 -# WORKDIR /backend -# COPY backend/go.* . -# RUN --mount=type=cache,target=/go/pkg/mod \ -# --mount=type=cache,target=/root/.cache/go-build \ -# go mod download -# COPY backend/. . -# RUN --mount=type=cache,target=/go/pkg/mod \ -# --mount=type=cache,target=/root/.cache/go-build \ -# go build -trimpath -ldflags="-s -w" -o bin/service - FROM --platform=$BUILDPLATFORM node:18.12-alpine3.16 AS client-builder WORKDIR /ui # cache packages in layer @@ -60,13 +48,9 @@ EOF COPY --from=client-programs educates-linux-${TARGETARCH} /educates -# COPY --from=builder /backend/bin/service / - COPY docker-compose.yaml . COPY metadata.json . COPY logo.svg . COPY --from=client-builder /ui/build ui -# CMD /service -socket /run/guest-services/backend.sock - CMD ["/educates", "docker", "extension", "backend", "--socket", "/run/guest-services/backend.sock"] diff --git a/docker-extension/backend/go.mod b/docker-extension/backend/go.mod deleted file mode 100644 index a71a76d5..00000000 --- a/docker-extension/backend/go.mod +++ /dev/null @@ -1,21 +0,0 @@ -module educates-docker-extension - -go 1.19 - -require ( - github.com/labstack/echo v3.3.10+incompatible - github.com/sirupsen/logrus v1.9.3 -) - -require ( - github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect - github.com/labstack/gommon v0.4.0 // indirect - github.com/mattn/go-colorable v0.1.11 // indirect - github.com/mattn/go-isatty v0.0.14 // indirect - github.com/valyala/bytebufferpool v1.0.0 // indirect - github.com/valyala/fasttemplate v1.2.2 // indirect - golang.org/x/crypto v0.12.0 // indirect - golang.org/x/net v0.10.0 // indirect - golang.org/x/sys v0.11.0 // indirect - golang.org/x/text v0.12.0 // indirect -) diff --git a/docker-extension/backend/go.sum b/docker-extension/backend/go.sum deleted file mode 100644 index 702217a0..00000000 --- a/docker-extension/backend/go.sum +++ /dev/null @@ -1,41 +0,0 @@ -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/labstack/echo v3.3.10+incompatible h1:pGRcYk231ExFAyoAjAfD85kQzRJCRI8bbnE7CX5OEgg= -github.com/labstack/echo v3.3.10+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= -github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8= -github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= -github.com/mattn/go-colorable v0.1.11 h1:nQ+aFkoE2TMGc0b68U2OKSexC+eq46+XwZzWXHRmPYs= -github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -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/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= -github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= -github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= -github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= -github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= -golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= -golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= -golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/docker-extension/backend/main.go b/docker-extension/backend/main.go deleted file mode 100644 index d5f95e68..00000000 --- a/docker-extension/backend/main.go +++ /dev/null @@ -1,92 +0,0 @@ -package main - -import ( - "flag" - "net" - "net/http" - "os" - "time" - - "github.com/labstack/echo/middleware" - - "github.com/labstack/echo" - "github.com/sirupsen/logrus" -) - -var logger = logrus.New() - -func main() { - var socketPath string - flag.StringVar(&socketPath, "socket", "/run/guest-services/backend.sock", "Unix domain socket to listen on") - flag.Parse() - - _ = os.RemoveAll(socketPath) - - logger.SetOutput(os.Stdout) - - logMiddleware := middleware.LoggerWithConfig(middleware.LoggerConfig{ - Skipper: middleware.DefaultSkipper, - Format: `{"time":"${time_rfc3339_nano}","id":"${id}",` + - `"method":"${method}","uri":"${uri}",` + - `"status":${status},"error":"${error}"` + - `}` + "\n", - CustomTimeFormat: "2006-01-02 15:04:05.00000", - Output: logger.Writer(), - }) - - logger.Infof("Starting listening on %s\n", socketPath) - router := echo.New() - router.HideBanner = true - router.Use(logMiddleware) - startURL := "" - - ln, err := listen(socketPath) - if err != nil { - logger.Fatal(err) - } - router.Listener = ln - - router.GET("/create", start) - router.GET("/destroy", stop) - - logger.Fatal(router.Start(startURL)) -} - -func listen(path string) (net.Listener, error) { - return net.Listen("unix", path) -} - -func start(ctx echo.Context) error { - time.Sleep(5 * time.Second) - url := ctx.QueryParam("url") - w := &Workshop{ - WorkshopDefinitionUrl: url, - Name: "lab-k8s-fundamentals", - Running: true, - Status: "running", - WorkshopUrl: "http://workshop.127-0-0-1.nip.io:10081/dashboard/", - } - return ctx.JSON(http.StatusOK, w) -} - -func stop(ctx echo.Context) error { - time.Sleep(3 * time.Second) - name := ctx.QueryParam("name") - w := &Workshop{ - WorkshopDefinitionUrl: "", - Name: name, - Running: false, - Status: "not_exist", - WorkshopUrl: "", - } - return ctx.JSON(http.StatusOK, w) -} - -type Workshop struct { - WorkshopDefinitionUrl string `json:"workshopDefinitionUrl"` - Name string `json:"name"` - Running bool `json:"running"` - Status string `json:"status"` - // Status can be starting, running, stopping and not_exist - WorkshopUrl string `json:"workshopUrl"` -} diff --git a/session-manager/handlers/operator_config.py b/session-manager/handlers/operator_config.py index a8c336a3..498f36d4 100644 --- a/session-manager/handlers/operator_config.py +++ b/session-manager/handlers/operator_config.py @@ -44,7 +44,7 @@ CLUSTER_DOMAIN = socket.getaddrinfo("kubernetes.default.svc", 0, flags=socket.AI_CANONNAME)[0][3] CLUSTER_DOMAIN = CLUSTER_DOMAIN.replace("kubernetes.default.svc.", "") -INGRESS_DOMAIN = xget(config_values, "clusterIngress.domain", "educates-local-dev.xyz") +INGRESS_DOMAIN = xget(config_values, "clusterIngress.domain", "educates-local-dev.test") INGRESS_CLASS = xget(config_values, "clusterIngress.class", "") INGRESS_SECRET = xget(config_values, "clusterIngress.tlsCertificateRef.name") diff --git a/training-portal/src/project/apps/workshops/views/access.py b/training-portal/src/project/apps/workshops/views/access.py index cd8f2db0..0cad1cdf 100644 --- a/training-portal/src/project/apps/workshops/views/access.py +++ b/training-portal/src/project/apps/workshops/views/access.py @@ -36,6 +36,12 @@ def access(request): if not redirect_url: return HttpResponseBadRequest("Need redirect URL for access check") + password = request.GET.get("password") + + if password and settings.PORTAL_PASSWORD == password: + request.session["is_allowed_access_to_event"] = True + return redirect(redirect_url) + data = {"redirect_url": redirect_url} form = AccessTokenForm(initial=data) diff --git a/training-portal/testing/start-training-portal b/training-portal/testing/start-training-portal index 3e2d54e0..df731b04 100755 --- a/training-portal/testing/start-training-portal +++ b/training-portal/testing/start-training-portal @@ -16,7 +16,7 @@ OPERATOR_API_GROUP=educates.dev OPERATOR_STATUS_KEY=educates OPERATOR_NAME_PREFIX=educates -INGRESS_DOMAIN=${INGRESS_DOMAIN:-educates-local-dev.xyz} +INGRESS_DOMAIN=${INGRESS_DOMAIN:-educates-local-dev.test} INGRESS_PROTOCOL=${INGRESS_PROTOCOL:-http} PORTAL_HOSTNAME=${PORTAL_HOSTNAME:-${TRAINING_PORTAL}-ui.${INGRESS_DOMAIN}:8080} diff --git a/tunnel-manager/main.py b/tunnel-manager/main.py index 9d82f466..40d38aeb 100644 --- a/tunnel-manager/main.py +++ b/tunnel-manager/main.py @@ -10,7 +10,7 @@ logger = logging.getLogger("educates") -ingress_domain = os.environ.get("INGRESS_DOMAIN", "educates-local-dev.xyz") +ingress_domain = os.environ.get("INGRESS_DOMAIN", "educates-local-dev.test") environment_name = os.environ.get("ENVIRONMENT_NAME", "") event_loop = None