-
Notifications
You must be signed in to change notification settings - Fork 33
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
Adds HumioUsers CRD #711
Draft
schofield
wants to merge
10
commits into
master
Choose a base branch
from
grant/issue-635
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Adds HumioUsers CRD #711
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8b9bf0e
Adds HumioUsers CRD
cs-gschofield 3c39826
Update pkg/humio/client.go
schofield 8698e7c
Update pkg/humio/client.go
schofield 943eb9d
Update pkg/humio/client.go
schofield 5d79a2c
Update pkg/humio/client.go
schofield 34eff0d
Update pkg/humio/client_mock.go
schofield 052a795
Merge branch 'master' into grant/issue-635
SaaldjorMike 3691433
satisfy staticcheck
SaaldjorMike 06d4a09
fix example
SaaldjorMike 216de7f
Merge branch 'master' into grant/issue-635
SaaldjorMike File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
Copyright 2020 Humio https://humio.com | ||
|
||
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 ( | ||
// HumioUserStateUnknown is the Unknown state of the user | ||
HumioUserStateUnknown = "Unknown" | ||
// HumioUserStateExists is the Exists state of the user | ||
HumioUserStateExists = "Exists" | ||
// HumioUserStateNotFound is the NotFound state of the user | ||
HumioUserStateNotFound = "NotFound" | ||
// HumioUserStateConfigError is the state of the user when user-provided specification results in configuration error, such as non-existent humio cluster | ||
HumioUserStateConfigError = "ConfigError" | ||
) | ||
|
||
// HumioUserSpec defines the desired state of HumioUser | ||
type HumioUserSpec struct { | ||
// ManagedClusterName refers to an object of type HumioCluster that is managed by the operator where the Humio | ||
// resources should be created. | ||
// This conflicts with ExternalClusterName. | ||
ManagedClusterName string `json:"managedClusterName,omitempty"` | ||
// ExternalClusterName refers to an object of type HumioExternalCluster where the Humio resources should be created. | ||
// This conflicts with ManagedClusterName. | ||
ExternalClusterName string `json:"externalClusterName,omitempty"` | ||
// Username of the user in humio | ||
Username string `json:"username,omitempty"` | ||
// User ID of the user in humio | ||
ID string `json:"id,omitempty"` | ||
// FullName is the full name of the user | ||
FullName string `json:"fullName,omitempty"` | ||
// Email is the email of the user | ||
Email string `json:"email,omitempty"` | ||
// Company is the compnay of the user | ||
Company string `json:"company,omitempty"` | ||
// CountryCode is the compnay of the user | ||
CountryCode string `json:"countryCode,omitempty"` | ||
// Picture is the url to the user's profile picture | ||
Picture string `json:"picture,omitempty"` | ||
// IsRoot is the root setting for the user | ||
IsRoot bool `json:"isRoot,omitempty"` | ||
// CreatedAt is date when the user was created | ||
CreatedAt string `json:"createdAt,omitempty"` | ||
} | ||
|
||
// HumioUserStatus defines the observed state of HumioUser | ||
type HumioUserStatus struct { | ||
// State reflects the current state of the HumioUser | ||
State string `json:"state,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:subresource:status | ||
//+kubebuilder:resource:path=humiousers,scope=Namespaced | ||
//+kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.state",description="The state of the user" | ||
//+operator-sdk:gen-csv:customresourcedefinitions.displayName="Humio User" | ||
|
||
// HumioUser is the Schema for the humiousers API | ||
type HumioUser struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec HumioUserSpec `json:"spec,omitempty"` | ||
Status HumioUserStatus `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// HumioUserList contains a list of HumioUser | ||
type HumioUserList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []HumioUser `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&HumioUser{}, &HumioUserList{}) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
105 changes: 105 additions & 0 deletions
105
charts/humio-operator/crds/core.humio.com_humiousers.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,105 @@ | ||
|
||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.6.2 | ||
creationTimestamp: null | ||
name: humiousers.core.humio.com | ||
labels: | ||
app: 'humio-operator' | ||
app.kubernetes.io/name: 'humio-operator' | ||
app.kubernetes.io/instance: 'humio-operator' | ||
app.kubernetes.io/managed-by: 'Helm' | ||
helm.sh/chart: 'humio-operator-0.19.0' | ||
spec: | ||
group: core.humio.com | ||
names: | ||
kind: HumioUser | ||
listKind: HumioUserList | ||
plural: humiousers | ||
singular: humiouser | ||
scope: Namespaced | ||
versions: | ||
- additionalPrinterColumns: | ||
- description: The state of the user | ||
jsonPath: .status.state | ||
name: State | ||
type: string | ||
name: v1alpha1 | ||
schema: | ||
openAPIV3Schema: | ||
description: HumioUser is the Schema for the humiousers API | ||
properties: | ||
apiVersion: | ||
description: 'APIVersion defines the versioned schema of this representation | ||
of an object. Servers should convert recognized schemas to the latest | ||
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' | ||
type: string | ||
kind: | ||
description: 'Kind is a string value representing the REST resource this | ||
object represents. Servers may infer this from the endpoint the client | ||
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' | ||
type: string | ||
metadata: | ||
type: object | ||
spec: | ||
description: HumioUserSpec defines the desired state of HumioUser | ||
properties: | ||
company: | ||
description: Company is the compnay of the user | ||
type: string | ||
countryCode: | ||
description: CountryCode is the compnay of the user | ||
type: string | ||
createdAt: | ||
description: CreatedAt is date when the user was created | ||
type: string | ||
email: | ||
description: Email is the email of the user | ||
type: string | ||
externalClusterName: | ||
description: ExternalClusterName refers to an object of type HumioExternalCluster | ||
where the Humio resources should be created. This conflicts with | ||
ManagedClusterName. | ||
type: string | ||
fullName: | ||
description: FullName is the full name of the user | ||
type: string | ||
id: | ||
description: User ID of the user in humio | ||
type: string | ||
isRoot: | ||
description: IsRoot is the root setting for the user | ||
type: boolean | ||
managedClusterName: | ||
description: ManagedClusterName refers to an object of type HumioCluster | ||
that is managed by the operator where the Humio resources should | ||
be created. This conflicts with ExternalClusterName. | ||
type: string | ||
picture: | ||
description: Picture is the url to the user's profile picture | ||
type: string | ||
username: | ||
description: Username of the user in humio | ||
type: string | ||
type: object | ||
status: | ||
description: HumioUserStatus defines the observed state of HumioUser | ||
properties: | ||
state: | ||
description: State reflects the current state of the HumioUser | ||
type: string | ||
type: object | ||
type: object | ||
served: true | ||
storage: true | ||
subresources: | ||
status: {} | ||
status: | ||
acceptedNames: | ||
kind: "" | ||
plural: "" | ||
conditions: [] | ||
storedVersions: [] |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this as part of the spec? I can't think of a reason one would want to set this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have seen people use it and it is configurable so I think it should be in the spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What controls will there be around the
IsRoot
field? Could anyone push a YAML doc to the API server and give themselves root privileges?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that
CreatedAt
does seem very strange to add (at least to the Spec of the CRD). The go client involved usingUsers().Add(...)
doesn't use it (same forUsers().Update(...)
. The only use of it that I see is to reflect back theCreatedAt
timestamp for a user as for when it was created. This does not make sense in HumioUsers.Spec though. If we really want to ensure our k8s CR's store that data, then we can store it in HumioUsers.Status if we really have to, but I'm not sure we really need it. It definitely doesn't belong in the Spec though, since users cannot specify that themselves, but is given by the user upon user-creation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, I'll remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any user that has the ability to create the resource could change the attribute yes but they could also change the cluster resource and change the authentication.