Skip to content

Commit

Permalink
doc(expand CRDs): Clean comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoMori8 committed Feb 11, 2025
1 parent 8ecc71c commit e9a5a92
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 14 deletions.
1 change: 0 additions & 1 deletion pkg/apis/vaultwebhook.uswitch.com/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type DatabaseCredentialBindingSpec struct {
OutputFile string `json:"outputFile"`
ServiceAccount string `json:"serviceAccount"`
Container Container `json:"container,omitempty"`
// InitContainer Container `json:"initcontainer,omitempty"` // TODO: Fix support for initcontainer's Lifecycle hooks ( Go dep to be updated )
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down
9 changes: 0 additions & 9 deletions vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func addVault(pod *corev1.Pod, namespace string, databases []database) (patch []
for _, databaseInfo := range databases {

vaultContainerSpec := databaseInfo.vaultContainer
//initVaultContainerSpec := databaseInfo.initVaultContainer // TODO: Fix support for initcontainer's Lifecycle hooks ( Go dep to be updated )

database := databaseInfo.database
role := databaseInfo.role
Expand Down Expand Up @@ -109,7 +108,6 @@ func addVault(pod *corev1.Pod, namespace string, databases []database) (patch []
initContainer := vaultContainer

// Configure Lifecycle Hooks if spec exists
// initContainer = addLifecycleHook(initContainer, initVaultContainerSpec) // TODO: Fix support for initcontainer's Lifecycle hooks ( Go dep to be updated )
vaultContainer = addLifecycleHook(vaultContainer, vaultContainerSpec)

jobLikeOwnerReferencesKinds := map[string]bool{"Job": true, "Workflow": true}
Expand Down Expand Up @@ -220,12 +218,5 @@ func addLifecycleHook(container corev1.Container, containerSpec v1alpha1.Contain
}

}
// TODO: Fix support for initcontainer's Lifecycle hooks ( Go dep to be updated )
// Init containers must have RestartPolicy=Always to be able to support Lifecycle hooks
// if isInit {
// restartPolicy := corev1.ContainerRestartPolicyAlways
// container.RestartPolicy = &restartPolicy
// }
//}
return container
}
5 changes: 1 addition & 4 deletions webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ type database struct {
outputPath string
outputFile string
vaultContainer v1alpha1.Container
// initVaultContainer v1alpha1.Container // TODO: Fix support for initcontainer's Lifecycle hooks ( Go dep to be updated )
}

func (srv webHookServer) serve(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -199,15 +198,13 @@ func matchBindings(bindings []v1alpha1.DatabaseCredentialBinding, serviceAccount
output = "/etc/database"
}
log.Infof("[matchBindings] Printing content of Container: %+v", binding.Spec.Container)
//log.Infof("[matchBindings] Printing content of InitContainer: %+v", binding.Spec.InitContainer)

matchedBindings = appendIfMissing(matchedBindings, database{
role: binding.Spec.Role,
database: binding.Spec.Database,
outputPath: output,
outputFile: binding.Spec.OutputFile,
vaultContainer: binding.Spec.Container,
//initVaultContainer: binding.Spec.InitContainer, // TODO: Fix support for initcontainer's Lifecycle hooks ( Go dep to be updated )
})
}
}
Expand All @@ -216,7 +213,7 @@ func matchBindings(bindings []v1alpha1.DatabaseCredentialBinding, serviceAccount

func appendIfMissing(slice []database, d database) []database {
for _, ele := range slice {
// No need to compare the Container and InitContainer fields.
// No need to compare Container fields.
if ele.role == d.role &&
ele.database == d.database &&
ele.outputPath == d.outputPath &&
Expand Down

0 comments on commit e9a5a92

Please sign in to comment.