From c50c1af145959cae7f1af77bde4e98ce3c3115d2 Mon Sep 17 00:00:00 2001 From: gbenhaim Date: Thu, 5 Sep 2024 10:29:30 +0300 Subject: [PATCH] Move Signup* types to their own package Needed in order to import them from several modules. Signed-off-by: gbenhaim --- Dockerfile | 1 + cmd/main.go | 21 +++++---------------- pkg/api/v1alpha1/usersignup_types.go | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 16 deletions(-) create mode 100644 pkg/api/v1alpha1/usersignup_types.go diff --git a/Dockerfile b/Dockerfile index 5ab34e2..a437d6c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,7 @@ RUN go mod download # Copy the go source COPY cmd/main.go cmd/main.go +COPY pkg pkg # Build RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager cmd/main.go diff --git a/cmd/main.go b/cmd/main.go index 25333c6..3eaab89 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -22,20 +22,9 @@ import ( crt "github.com/codeready-toolchain/api/api/v1alpha1" "k8s.io/client-go/kubernetes" -) - -type SignupStatusReason = string -var SignedUp SignupStatusReason = "SignedUp" - -type SignupStatus struct { - Ready bool `json:"ready"` - Reason SignupStatusReason `json:"reason"` -} - -type Signup struct { - SignupStatus SignupStatus `json:"status"` -} + "github.com/konflux-ci/workspace-manager/pkg/api/v1alpha1" +) var ( scheme = runtime.NewScheme() @@ -215,10 +204,10 @@ func main() { }) e.GET("/api/v1/signup", func(c echo.Context) error { - resp := &Signup{ - SignupStatus: SignupStatus{ + resp := &v1alpha1.Signup{ + SignupStatus: v1alpha1.SignupStatus{ Ready: true, - Reason: SignedUp, + Reason: v1alpha1.SignedUp, }, } return c.JSON(http.StatusOK, resp) diff --git a/pkg/api/v1alpha1/usersignup_types.go b/pkg/api/v1alpha1/usersignup_types.go new file mode 100644 index 0000000..a940eef --- /dev/null +++ b/pkg/api/v1alpha1/usersignup_types.go @@ -0,0 +1,14 @@ +package v1alpha1 + +type SignupStatusReason = string + +var SignedUp SignupStatusReason = "SignedUp" + +type SignupStatus struct { + Ready bool `json:"ready"` + Reason SignupStatusReason `json:"reason"` +} + +type Signup struct { + SignupStatus SignupStatus `json:"status"` +}