-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
2,771 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,52 @@ | ||
.PHONY: pre | ||
pre: | ||
@go install sigs.k8s.io/controller-tools/cmd/[email protected] | ||
|
||
.PHONY: gen-crd | ||
gen-crd: SHELL:=C:\Windows\System32\bash.exe | ||
gen-crd: | ||
@bash `go list -f '{{ .Dir }}' -m k8s.io/[email protected]`/generate-groups.sh "deepcopy,client,informer,lister" github.com/LilithGames/spiracle/pkg/generated github.com/LilithGames/spiracle/pkg/apis "samplecontroller:v1alpha1" --output-base github.com/LilithGames/spiracle --go-header-file doc/boilerplate.go.txt | ||
|
||
.PHONY: crd | ||
crd: crd-object crd-manifests | ||
|
||
.PHONY: crd-manifests | ||
crd-manifests: | ||
@controller-gen crd:trivialVersions=true,preserveUnknownFields=false rbac:roleName=spiracle-role webhook paths=./... output:crd:artifacts:config=deploy/crd output:rbac:artifacts:config=deploy/rbac output:webhook:artifacts:config=deploy/webhook | ||
|
||
.PHONY: crd-object | ||
crd-object: | ||
@@controller-gen object:headerFile="doc/boilerplate.go.txt" paths="./..." | ||
|
||
.PHONY: build | ||
build: | ||
@GOOS=linux go build -o bin/ github.com/LilithGames/spiracle/... | ||
|
||
.PHONY: run | ||
run: build | ||
@wsl -e bin/spiracle | ||
|
||
.PHONY: image | ||
image: build | ||
@docker-compose -f deploy/build/docker-compose.yaml build | ||
|
||
.PHONY: install | ||
install: | ||
@kubectl apply -k deploy | ||
@kubectl rollout restart deployment.apps/spiracle | ||
@kubectl rollout status deployment.apps/spiracle | ||
|
||
.PHONY: deploy | ||
deploy: image install | ||
|
||
.PHONY: clean | ||
clean: | ||
@kubectl delete -k deploy | ||
|
||
.PHONY: install-sample | ||
install-sample: | ||
@kubectl apply -f deploy/samples/roomingress1.yaml | ||
|
||
.PHONY: clean-sample | ||
clean-sample: | ||
@kubectl delete -f deploy/samples/roomingress1.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package v1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
//+kubebuilder:rbac:groups=projectdavinci.com,resources=roomingresses,verbs=get;list;watch;create;update;patch;delete | ||
//+kubebuilder:rbac:groups=projectdavinci.com,resources=roomingresses/status,verbs=get;update;patch | ||
//+kubebuilder:rbac:groups=projectdavinci.com,resources=roomingresses/finalizers,verbs=update | ||
//+kubebuilder:webhook:path=/mutate,mutating=true,failurePolicy=fail,groups=projectdavinci.com,resources=roomingresses,verbs=create;update;patch;delete,versions=v1,name=roomingress-webhook.projectdavinci.com,sideEffects=None,admissionReviewVersions=v1 | ||
|
||
func init() { | ||
SchemeBuilder.Register(&RoomIngress{}, &RoomIngressList{}) | ||
} | ||
|
||
type RoomIngressPlayer struct { | ||
//+kubebuilder:validation:MinLength=1 | ||
Id string `json:"id"` | ||
//+kubebuilder:validation:Minimum=1 | ||
//+kubebuilder:validation:Maximum=4294967295 | ||
Token int64 `json:"token"` | ||
} | ||
|
||
type RoomIngressRoom struct { | ||
//+kubebuilder:validation:MinLength=1 | ||
Id string `json:"id,omitempty"` | ||
//+kubebuilder:validation:MinLength=1 | ||
Server string `json:"server,omitempty"` | ||
//+kubebuilder:validation:MinLength=1 | ||
Upstream string `json:"upstream,omitempty"` | ||
//+kubebuilder:validation:UniqueItems=true | ||
Players []RoomIngressPlayer `json:"players"` | ||
} | ||
|
||
type RoomIngressSpec struct { | ||
//+kubebuilder:validation:MinItems=1 | ||
//+kubebuilder:validation:UniqueItems=true | ||
Rooms []RoomIngressRoom `json:"rooms,omitempty"` | ||
} | ||
|
||
type RoomIngressPlayerStatus struct { | ||
Id string `json:"id"` | ||
//+kubebuilder:validation:Minimum=1 | ||
//+kubebuilder:validation:Maximum=4294967295 | ||
Token int64 `json:"token"` | ||
} | ||
|
||
type RoomIngressRoomStatus struct { | ||
Id string `json:"id,omitempty"` | ||
Server string `json:"server,omitempty"` | ||
Upstream string `json:"upstream,omitempty"` | ||
Players []RoomIngressPlayerStatus `json:"players,omitempty"` | ||
} | ||
|
||
type RoomIngressStatus struct { | ||
Rooms []RoomIngressRoomStatus `json:"rooms,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:subresource:status | ||
//+kubebuilder:printcolumn:name="Server",type=string,JSONPath=`.spec.rules[0].server` | ||
//+kubebuilder:resource:shortName="ring" | ||
type RoomIngress struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec RoomIngressSpec `json:"spec,omitempty"` | ||
Status RoomIngressStatus `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
type RoomIngressList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []RoomIngress `json:"items"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//+kubebuilder:object:generate=true | ||
//+groupName=projectdavinci.com | ||
package v1 | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"sigs.k8s.io/controller-runtime/pkg/scheme" | ||
) | ||
|
||
var ( | ||
GroupVersion = schema.GroupVersion{Group: "projectdavinci.com", Version: "v1"} | ||
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} | ||
AddToScheme = SchemeBuilder.AddToScheme | ||
) | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Oops, something went wrong.