-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add dependencies override and ability to rm rbacs by component (#527)
* add dependencies override and ability to rm rbacs by component
- Loading branch information
1 parent
0529b95
commit 0c9f570
Showing
5 changed files
with
166 additions
and
17 deletions.
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
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
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,33 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2016-present Datadog, Inc. | ||
|
||
package override | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/util/errors" | ||
|
||
"github.com/DataDog/datadog-operator/apis/datadoghq/v2alpha1" | ||
apiutils "github.com/DataDog/datadog-operator/apis/utils" | ||
"github.com/DataDog/datadog-operator/controllers/datadogagent/feature" | ||
) | ||
|
||
// Dependencies is used to override any resource/dependency settings with a v2alpha1.DatadogAgentComponentOverride. | ||
func Dependencies(manager feature.ResourceManagers, overrides map[v2alpha1.ComponentName]*v2alpha1.DatadogAgentComponentOverride, namespace string) (errs []error) { | ||
for component, override := range overrides { | ||
errs = append(errs, overrideComponentDependencies(manager, override, component, namespace)) | ||
} | ||
return errs | ||
} | ||
|
||
func overrideComponentDependencies(manager feature.ResourceManagers, override *v2alpha1.DatadogAgentComponentOverride, component v2alpha1.ComponentName, namespace string) error { | ||
var errs []error | ||
if !apiutils.BoolValue(override.CreateRbac) { | ||
rbacManager := manager.RBACManager() | ||
errs = append(errs, rbacManager.DeleteServiceAccountByComponent(string(component), namespace)) | ||
errs = append(errs, rbacManager.DeleteRoleByComponent(string(component), namespace)) | ||
errs = append(errs, rbacManager.DeleteClusterRoleByComponent(string(component), namespace)) | ||
} | ||
return errors.NewAggregate(errs) | ||
} |