Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uro3 #71

Merged
merged 6 commits into from
Mar 25, 2024
Merged

Uro3 #71

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest

## Tool Versions
KUSTOMIZE_VERSION ?= v4.5.7
CONTROLLER_TOOLS_VERSION ?= v0.9.0
CONTROLLER_TOOLS_VERSION ?= v0.14.0

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
Expand Down
2 changes: 2 additions & 0 deletions api/v1alpha1/stardoginstance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ type StardogInstanceSpec struct {
// This is used by the Operator to make changes in the roles, permissions and users.
// +kubebuilder:validation:Required
AdminCredentials StardogUserCredentialsSpec `json:"adminCredentials,omitempty"`
// Disabled whether this instance is disabled or enabled for operator to recycle resources
Disabled bool `json:"disabled,omitempty"`
}

// StardogInstanceStatus defines the observed state of StardogInstance
Expand Down
1 change: 0 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions api/v1beta1/database_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ type DatabaseSpec struct {
// DatabaseName the database name that has to be created in the Stardog server
DatabaseName string `json:"databaseName,omitempty"`

//+kubebuilder:validation:optional
// AddUserForNonHiddenGraphs a dynamically managed user of this db with custom permissions
// Mainly used to not have access to hidden graphs
AddUserForNonHiddenGraphs string `json:"addUserForNonHiddenGraphs,omitempty"`

//+kubebuilder:validation:optional
// Options is the Stardog configuration options for this database. Only json input is valid.
Options string `json:"options,omitempty"`
Expand All @@ -35,11 +40,12 @@ type DatabaseSpec struct {

// DatabaseStatus defines the observed state of the Database
type DatabaseStatus struct {
DatabaseName string `json:"databaseName,omitempty"`
NamedGraphPrefix string `json:"namedGraphPrefix,omitempty"`
Options string `json:"options,omitempty"`
StardogInstanceRefs []StardogInstanceRef `json:"stardogInstanceRef,omitempty"`
Conditions []v1alpha1.StardogCondition `json:"conditions,omitempty"`
DatabaseName string `json:"databaseName,omitempty"`
AddUserForNonHiddenGraphs string `json:"addUserForNonHiddenGraphs,omitempty"`
NamedGraphPrefix string `json:"namedGraphPrefix,omitempty"`
Options string `json:"options,omitempty"`
StardogInstanceRefs []StardogInstanceRef `json:"stardogInstanceRef,omitempty"`
Conditions []v1alpha1.StardogCondition `json:"conditions,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
53 changes: 47 additions & 6 deletions api/v1beta1/organization_types.go
Original file line number Diff line number Diff line change
@@ -1,36 +1,49 @@
package v1beta1

import (
"fmt"
"github.com/vshn/stardog-userrole-operator/api/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// OrganizationSpec defines the desired state of an Organization
type OrganizationSpec struct {
//+kubebuilder:validation:required
// +kubebuilder:validation:required
// Name is the short name of an organization
Name string `json:"name,omitempty"`

//+kubebuilder:validation:required
// +kubebuilder:validation:required
// DisplayName is the long name of an organization
DisplayName string `json:"displayName,omitempty"`

//+kubebuilder:validation:required
// +kubebuilder:validation:required
// DatabaseRef is the name of the Database this Organization is assigned to
DatabaseRef string `json:"databaseRef,omitempty"`

//+kubebuilder:validation:required
// +kubebuilder:validation:required
// NamedGraphs are the suffix graph names for this organization. The prefix can be found in the Database resource.
// The final graphs is defined as prefix + "/" + orgName + "/" suffix
NamedGraphs []string `json:"namedGraphs,omitempty"`
NamedGraphs []NamedGraph `json:"namedGraphs,omitempty"`
}

// NamedGraph defines the name and if necessary add another hidden named graph for this named graph
type NamedGraph struct {
// +kubebuilder:validation:required
// The name of the Named Graph
Name string `json:"name,omitempty"`

// +kubebuilder:validation:optional
// +kubebuilder:default=false
// AddHidden adds another graph with the same name but with a prefix "<named-graph-name/hidden>"
AddHidden bool `json:"addHidden"`
}

// OrganizationStatus defines the observed state of the Organization
type OrganizationStatus struct {
Name string `json:"name,omitempty"`
DisplayName string `json:"displayName,omitempty"`
DatabaseRef string `json:"databaseRef,omitempty"`
NamedGraphs []string `json:"namedGraphs,omitempty"`
NamedGraphs []NamedGraph `json:"namedGraphs,omitempty"`
StardogInstanceRefs []StardogInstanceRef `json:"stardogInstanceRefs,omitempty"`
Conditions []v1alpha1.StardogCondition `json:"conditions,omitempty"`
}
Expand Down Expand Up @@ -60,3 +73,31 @@ type OrganizationList struct {
func init() {
SchemeBuilder.Register(&Organization{}, &OrganizationList{})
}

func GetNamedGraphNames(namedGraphs []NamedGraph) []string {
names := make([]string, len(namedGraphs))
for _, graph := range namedGraphs {
names = append(names, graph.Name)
}
return names
}

func GetHiddenNamedGraphNames(namedGraphs []NamedGraph) []string {
names := make([]string, len(namedGraphs))
for _, graph := range namedGraphs {
if graph.AddHidden {
names = append(names, graph.Name)
}
}
return names
}

// FindNamedGraphByName finds the NamedGraph by name from a slice of NamedGraphs
func FindNamedGraphByName(graphs []NamedGraph, name string) (NamedGraph, error) {
for _, g := range graphs {
if g.Name == name {
return g, nil
}
}
return NamedGraph{}, fmt.Errorf("cannot find graph from name %s", name)
}
20 changes: 17 additions & 3 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

109 changes: 0 additions & 109 deletions config/crd/bases/stardog.vshn.ch_databases.yaml

This file was deleted.

Loading
Loading