generated from giantswarm/template-operator
-
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.
* add org CRD in helm chart * layout foundations for CRD with kubebuilder * remove useless files * update CRD names * add generated crd * applying suggestions * fix naming issues * update Dockerfile with copy command for the api package * update changelog * add symlink to crd in helm chart and updated crd * fix symlink * fix symlink * Update main.go Co-authored-by: Quentin Bisson <[email protected]> * add symlink back * add finalizer * Apply suggestions from code review Co-authored-by: Théo Brigitte <[email protected]> * regenerate crd * update sample * add crds template in chart * add authorizations for grafanaorganizations in operator rbac * Update api/v1alpha1/grafanaorganization_types.go Co-authored-by: Théo Brigitte <[email protected]> * go format * Update observability_v1alpha1_grafanaorganization.yaml Remove labels to make @TheoBrigitte happy --------- Co-authored-by: QuentinBisson <[email protected]> Co-authored-by: Théo Brigitte <[email protected]>
- Loading branch information
1 parent
b8fd26f
commit 3b383d7
Showing
14 changed files
with
538 additions
and
1 deletion.
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
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
Empty file.
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,105 @@ | ||
/* | ||
Copyright 2024. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
const ( | ||
// Finalizer needs to follow the format "domain name, a forward slash and the name of the finalizer" | ||
// See https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#finalizers | ||
GrafanaOrganizationFinalizer = "observability.giantswarm.io/grafanaorganization" | ||
) | ||
|
||
// GrafanaOrganizationSpec defines the desired state of GrafanaOrganization | ||
type GrafanaOrganizationSpec struct { | ||
// DisplayName is the name displayed when viewing the organization in Grafana. It can be different from the actual org's name. | ||
DisplayName string `json:"displayName"` | ||
|
||
// Access rules defines user permissions for interacting with the organization in Grafana. | ||
RBAC *RBAC `json:"rbac,omitempty"` | ||
} | ||
|
||
// RBAC defines the RoleBasedAccessControl configuration for the Grafana organization. | ||
// Each fields represents the mapping to a Grafana role: | ||
// | ||
// Admin: full access to the Grafana organization | ||
// Editor: edit resources in the Grafana organization | ||
// Viewer: read only access to the Grafana organization | ||
// | ||
// Each fields holds a list of string which represents values for a specific auth provider org attribute. | ||
// The org attribute is looked up using the `org_attribute_path` which is configured on your Grafana instance, see `https://<YOUR_GRAFANA_INSTANCE>/admin/settings`. | ||
// A user is granted a role when one of its org attribute value is contained within one of the role's values defined here. | ||
// More info on Grafana org attribute and role mapping at [Configure role mapping](https://grafana.com/docs/grafana/latest/setup-grafana/configure-security/configure-authentication/generic-oauth/#configure-role-mapping) | ||
type RBAC struct { | ||
// Admins is a list of user organizations that have admin access to the grafanaorganization. | ||
Admins []string `json:"admins"` | ||
|
||
// Editors is a list of user organizations that have editor access to the grafanaorganization. | ||
// +optional | ||
Editors []string `json:"editors"` | ||
|
||
// Viewers is a list of user organizations that have viewer access to the grafanaorganization. | ||
// +optional | ||
Viewers []string `json:"viewers"` | ||
} | ||
|
||
// GrafanaOrganizationStatus defines the observed state of GrafanaOrganization | ||
type GrafanaOrganizationStatus struct { | ||
// OrgID is the actual organisation ID in grafana. | ||
OrgID string `json:"orgID"` | ||
|
||
// DataSources is a list of grafana data sources that are available to the Grafana organization. | ||
DataSources []DataSources `json:"dataSources"` | ||
} | ||
|
||
// DataSource defines the name and id for data sources. | ||
type DataSources struct { | ||
// Name is the name of the data source. | ||
Name string `json:"name"` | ||
|
||
// ID is the unique id of the data source. | ||
ID string `json:"id"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:resource:scope=Cluster | ||
//+kubebuilder:subresource:status | ||
|
||
// GrafanaOrganization is the Schema describing a Grafana organization. Its lifecycle is managed by the observability-operator. | ||
type GrafanaOrganization struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec GrafanaOrganizationSpec `json:"spec,omitempty"` | ||
Status GrafanaOrganizationStatus `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:resource:scope=Cluster | ||
|
||
// GrafanaOrganizationList contains a list of GrafanaOrganization | ||
type GrafanaOrganizationList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []GrafanaOrganization `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&GrafanaOrganization{}, &GrafanaOrganizationList{}) | ||
} |
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,36 @@ | ||
/* | ||
Copyright 2024. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
// Package v1alpha1 contains API Schema definitions for the observability v1alpha1 API group | ||
// +kubebuilder:object:generate=true | ||
// +groupName=observability.giantswarm.io | ||
package v1alpha1 | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"sigs.k8s.io/controller-runtime/pkg/scheme" | ||
) | ||
|
||
var ( | ||
// GroupVersion is group version used to register these objects | ||
GroupVersion = schema.GroupVersion{Group: "observability.giantswarm.io", Version: "v1alpha1"} | ||
|
||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme | ||
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} | ||
|
||
// AddToScheme adds the types in this group-version to the given scheme. | ||
AddToScheme = SchemeBuilder.AddToScheme | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.