Skip to content

Commit

Permalink
Merge pull request #3 from robertoeguia/add_folder_sync_feature
Browse files Browse the repository at this point in the history
Add folder sync feature
  • Loading branch information
robertoeguia authored Aug 24, 2024
2 parents 42f14ca + 0962db1 commit cb5beba
Show file tree
Hide file tree
Showing 22 changed files with 768 additions and 21 deletions.
13 changes: 12 additions & 1 deletion PROJECT
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Code generated by tool. DO NOT EDIT.
# This file is used to track the info used to scaffold your project
# and allow the plugins properly work.
# More info: https://book.kubebuilder.io/reference/project-config.html
domain: edgelevel.com
layout:
- go.kubebuilder.io/v4
Expand All @@ -12,8 +16,15 @@ resources:
namespaced: true
controller: true
domain: edgelevel.com
group: edgelevel.com
kind: LastPass
path: github.com/edgelevel/lastpass-operator/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: edgelevel.com
kind: LastPassGroup
path: github.com/edgelevel/lastpass-operator/api/v1alpha1
version: v1alpha1
version: "3"
7 changes: 0 additions & 7 deletions api/v1alpha1/lastpass_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ limitations under the License.
package v1alpha1

import (
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -45,11 +43,6 @@ type SecretRef struct {
WithNote bool `json:"withNote,omitempty"`
}

type SyncPolicy struct {
Enabled bool `json:"enabled,required"`
Refresh time.Duration `json:"refresh,required"`
}

// LastPassStatus defines the observed state of LastPass
// +k8s:openapi-gen=true
type LastPassStatus struct {
Expand Down
56 changes: 56 additions & 0 deletions api/v1alpha1/lastpassgroup_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// LastPassGroupSpec defines the desired state of LastPassGroup
type LastPassGroupSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

GroupRef GroupRef `json:"groupRef,required"`
SyncPolicy SyncPolicy `json:"syncPolicy,omitempty"`
}

type GroupRef struct {
Group string `json:"group,omitempty"`
WithUsername bool `json:"withUsername,omitempty"`
WithPassword bool `json:"withPassword,omitempty"`
WithUrl bool `json:"withUrl,omitempty"`
WithNote bool `json:"withNote,omitempty"`
}

// LastPassGroupStatus defines the observed state of LastPassGroup
type LastPassGroupStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// LastPassGroup is the Schema for the lastpassgroups API
type LastPassGroup struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec LastPassGroupSpec `json:"spec,omitempty"`
Status LastPassGroupStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// LastPassGroupList contains a list of LastPassGroup
type LastPassGroupList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []LastPassGroup `json:"items"`
}

func init() {
SchemeBuilder.Register(&LastPassGroup{}, &LastPassGroupList{})
}
8 changes: 8 additions & 0 deletions api/v1alpha1/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package v1alpha1

import "time"

type SyncPolicy struct {
Enabled bool `json:"enabled,required"`
Refresh time.Duration `json:"refresh,required"`
}
106 changes: 106 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

9 changes: 9 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "LastPass")
os.Exit(1)
}
if err = (&controller.LastPassGroupReconciler{
Client: mgr.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("LastPass"),
Scheme: mgr.GetScheme(),
SecretNameTemplate: secretNameTemplate,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "LastPassGroup")
os.Exit(1)
}
// +kubebuilder:scaffold:builder

setupLog.Info("starting manager")
Expand Down
80 changes: 80 additions & 0 deletions config/crd/bases/edgelevel.com_lastpassgroups.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
name: lastpassgroups.edgelevel.com
spec:
group: edgelevel.com
names:
kind: LastPassGroup
listKind: LastPassGroupList
plural: lastpassgroups
singular: lastpassgroup
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: LastPassGroup is the Schema for the lastpassgroups 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: LastPassGroupSpec defines the desired state of LastPassGroup
properties:
groupRef:
properties:
group:
type: string
withNote:
type: boolean
withPassword:
type: boolean
withUrl:
type: boolean
withUsername:
type: boolean
type: object
syncPolicy:
properties:
enabled:
type: boolean
refresh:
description: |-
A Duration represents the elapsed time between two instants
as an int64 nanosecond count. The representation limits the
largest representable duration to approximately 290 years.
format: int64
type: integer
required:
- enabled
- refresh
type: object
required:
- groupRef
type: object
status:
description: LastPassGroupStatus defines the observed state of LastPassGroup
type: object
type: object
served: true
storage: true
subresources:
status: {}
2 changes: 2 additions & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# It should be run by config/default
resources:
- bases/edgelevel.com_lastpasses.yaml
- bases/edgelevel.com_lastpassgroups.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patches:
Expand All @@ -13,6 +14,7 @@ patches:
# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
# patches here are for enabling the CA injection for each CRD
#- path: patches/cainjection_in_lastpasses.yaml
#- path: patches/cainjection_in_lastpassgroups.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

# [WEBHOOK] To enable webhook, uncomment the following section
Expand Down
2 changes: 2 additions & 0 deletions config/rbac/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ resources:
# default, aiding admins in cluster management. Those roles are
# not used by the Project itself. You can comment the following lines
# if you do not want those helpers be installed with your Project.
# - lastpassgroup_editor_role.yaml
# - lastpassgroup_viewer_role.yaml
# - lastpass_editor_role.yaml
# - lastpass_viewer_role.yaml
27 changes: 27 additions & 0 deletions config/rbac/lastpassgroup_editor_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# permissions for end users to edit lastpassgroups.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/name: lastpass-operator
app.kubernetes.io/managed-by: kustomize
name: lastpassgroup-editor-role
rules:
- apiGroups:
- edgelevel.com
resources:
- lastpassgroups
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- edgelevel.com
resources:
- lastpassgroups/status
verbs:
- get
Loading

0 comments on commit cb5beba

Please sign in to comment.