Skip to content

Commit d253cb3

Browse files
committed
implement createOrUpdate path of mcp controller
1 parent 2f0086d commit d253cb3

File tree

11 files changed

+495
-7
lines changed

11 files changed

+495
-7
lines changed

api/clusters/v1alpha1/constants.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,13 @@ const (
8484
// SecretKeyCreationTimestamp is the name of the key in the AccessRequest secret that contains the creation timestamp.
8585
// This value is optional and must not be set for non-expiring authentication methods.
8686
SecretKeyCreationTimestamp = "creationTimestamp"
87+
// SecretKeyHost is the name of the key in the AccessRequest secret that contains the host of the cluster.
88+
// This value is optional.
89+
SecretKeyHost = "host"
90+
// SecretKeyCA is the name of the key in the AccessRequest secret that contains the CA certificate of the cluster.
91+
// This value is optional.
92+
SecretKeyCA = "ca.crt"
93+
// SecretKeyToken is the name of the key in the AccessRequest secret that contains the token.
94+
// This value is optional.
95+
SecretKeyToken = "token"
8796
)

api/clusters/v1alpha1/constants/reasons.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@ const (
1111
ReasonConfigurationProblem = "ConfigurationProblem"
1212
// ReasonInternalError indicates that something went wrong internally.
1313
ReasonInternalError = "InternalError"
14+
// ReasonWaitingForClusterRequest indicates that something is waiting for a ClusterRequest to become ready.
15+
ReasonWaitingForClusterRequest = "WaitingForClusterRequest"
16+
// ReasonWaitingForAccessRequest indicates that something is waiting for an AccessRequest to become ready.
17+
ReasonWaitingForAccessRequest = "WaitingForAccessRequest"
1418
)

api/core/v2alpha1/constants.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,14 @@ const (
44
// DefaultOIDCProviderName is the identifier for the default OIDC provider.
55
DefaultOIDCProviderName = "default"
66
)
7+
8+
const (
9+
MCPLabel = GroupName + "/mcp"
10+
OIDCProviderLabel = GroupName + "/oidc-provider"
11+
)
12+
13+
const (
14+
ConditionClusterRequestReady = "ClusterRequestReady"
15+
ConditionPrefixOIDCAccessReady = "OIDCAccessReady_"
16+
ConditionAllAccessReady = "AllAccessReady"
17+
)

api/core/v2alpha1/groupversion_info.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import (
77
"sigs.k8s.io/controller-runtime/pkg/scheme"
88
)
99

10+
const GroupName = "core.openmcp.cloud"
11+
1012
var (
1113
// GroupVersion is group version used to register these objects
12-
GroupVersion = schema.GroupVersion{Group: "core.openmcp.cloud", Version: "v2alpha1"}
14+
GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v2alpha1"}
1315

1416
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
1517
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ require (
1010
dario.cat/mergo v1.0.2
1111
github.com/onsi/ginkgo/v2 v2.23.4
1212
github.com/onsi/gomega v1.37.0
13-
github.com/openmcp-project/controller-utils v0.13.1
13+
github.com/openmcp-project/controller-utils v0.14.0
1414
github.com/openmcp-project/openmcp-operator/api v0.9.1
15+
github.com/openmcp-project/openmcp-operator/lib v0.9.1
1516
github.com/spf13/cobra v1.9.1
1617
k8s.io/api v0.33.3
1718
k8s.io/apimachinery v0.33.3

go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,10 @@ github.com/onsi/ginkgo/v2 v2.23.4 h1:ktYTpKJAVZnDT4VjxSbiBenUjmlL/5QkBEocaWXiQus
9999
github.com/onsi/ginkgo/v2 v2.23.4/go.mod h1:Bt66ApGPBFzHyR+JO10Zbt0Gsp4uWxu5mIOTusL46e8=
100100
github.com/onsi/gomega v1.37.0 h1:CdEG8g0S133B4OswTDC/5XPSzE1OeP29QOioj2PID2Y=
101101
github.com/onsi/gomega v1.37.0/go.mod h1:8D9+Txp43QWKhM24yyOBEdpkzN8FvJyAwecBgsU4KU0=
102-
github.com/openmcp-project/controller-utils v0.13.1 h1:+06c0bs1BIO+hBsTcuiEK5y8vpDFoZPml59WNm8fagM=
103-
github.com/openmcp-project/controller-utils v0.13.1/go.mod h1:Z1ytVshYcgJq3VQVGqkuZsjO/BCr4UYAaVpHl6JSIMI=
102+
github.com/openmcp-project/controller-utils v0.14.0 h1:semDlO6fmEmTp7mT1j2ZmT1cCG3TtNujrMyKBU5Tzic=
103+
github.com/openmcp-project/controller-utils v0.14.0/go.mod h1:BA5sey3z1ISAqOP5CzgWGVcPeA906XgXEq4uBOpNfg4=
104+
github.com/openmcp-project/openmcp-operator/lib v0.9.1 h1:zp/1L/2ySLajx7z1NSGDzvaHZBy0NyCqBUtZMRybfLA=
105+
github.com/openmcp-project/openmcp-operator/lib v0.9.1/go.mod h1:DvL3Dl1sbqQTs6tfX2Bd4UxYt1hW+zBX2vRyoOdmgmI=
104106
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
105107
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
106108
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=

internal/config/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ type Config struct {
2929

3030
// AccessRequest is the configuration for the access request controller.
3131
AccessRequest *AccessRequestConfig `json:"accessRequest,omitempty"`
32+
33+
// ManagedControlPlane is the configuration for the MCP controller.
34+
ManagedControlPlane *ManagedControlPlaneConfig `json:"managedControlPlane,omitempty"`
3235
}
3336

3437
// Dump is used for logging and debugging purposes.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package config
2+
3+
import (
4+
"k8s.io/apimachinery/pkg/util/validation/field"
5+
6+
commonapi "github.com/openmcp-project/openmcp-operator/api/common"
7+
)
8+
9+
type ManagedControlPlaneConfig struct {
10+
// MCPClusterPurpose is the purpose that is used for ClusterRequests created for ManagedControlPlane resources.
11+
MCPClusterPurpose string `json:"mcpClusterPurpose"`
12+
13+
// StandardOIDCProvider is the standard OIDC provider that is enabled for all ManagedControlPlane resources, unless explicitly disabled.
14+
// If nil, no standard OIDC provider will be used.
15+
StandardOIDCProvider *commonapi.OIDCProviderConfig `json:"standardOIDCProvider,omitempty"`
16+
17+
// ReconcileMCPEveryXDays specifies after how many days an MCP should be reconciled.
18+
// This is useful if the AccessRequests created by the MCP use an expiring authentication method and the MCP needs to refresh the access regularly.
19+
// A value of 0 disables the periodic reconciliation.
20+
// +optional
21+
ReconcileMCPEveryXDays int `json:"reconcileMCPEveryXDays,omitempty"`
22+
}
23+
24+
func (c *ManagedControlPlaneConfig) Default(_ *field.Path) error {
25+
return nil
26+
}
27+
28+
func (c *ManagedControlPlaneConfig) Validate(fldPath *field.Path) error {
29+
errs := field.ErrorList{}
30+
31+
if c.MCPClusterPurpose == "" {
32+
errs = append(errs, field.Required(fldPath.Child("mcpClusterPurpose"), "MCP cluster purpose must be set"))
33+
}
34+
35+
return errs.ToAggregate()
36+
}

0 commit comments

Comments
 (0)