Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
577 changes: 577 additions & 0 deletions pkg/certmanager/resources.go

Large diffs are not rendered by default.

141 changes: 141 additions & 0 deletions pkg/certmanager/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
// Package certmanager provides domain logic for interacting with cert-manager resources.
package certmanager

import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
)

// GVKs for cert-manager resources
var (
CertificateGVK = schema.GroupVersionKind{
Group: "cert-manager.io",
Version: "v1",
Kind: "Certificate",
}
CertificateRequestGVK = schema.GroupVersionKind{
Group: "cert-manager.io",
Version: "v1",
Kind: "CertificateRequest",
}
IssuerGVK = schema.GroupVersionKind{
Group: "cert-manager.io",
Version: "v1",
Kind: "Issuer",
}
ClusterIssuerGVK = schema.GroupVersionKind{
Group: "cert-manager.io",
Version: "v1",
Kind: "ClusterIssuer",
}
OrderGVK = schema.GroupVersionKind{
Group: "acme.cert-manager.io",
Version: "v1",
Kind: "Order",
}
ChallengeGVK = schema.GroupVersionKind{
Group: "acme.cert-manager.io",
Version: "v1",
Kind: "Challenge",
}
SecretGVK = schema.GroupVersionKind{
Group: "",
Version: "v1",
Kind: "Secret",
}
PodGVK = schema.GroupVersionKind{
Group: "",
Version: "v1",
Kind: "Pod",
}
)

// GVKs for cert-manager-operator resources
var (
CertManagerOperatorGVK = schema.GroupVersionKind{
Group: "operator.openshift.io",
Version: "v1alpha1",
Kind: "CertManager",
}
)

// Standard labels used by cert-manager for resource relationships
const (
// LabelCertificateName is the label cert-manager adds to CertificateRequests
LabelCertificateName = "cert-manager.io/certificate-name"
// LabelCertificateRevision is the label for the certificate revision
LabelCertificateRevision = "cert-manager.io/certificate-revision"
// LabelIssuerName is the label for the issuer name
LabelIssuerName = "cert-manager.io/issuer-name"
// LabelIssuerKind is the label for the issuer kind
LabelIssuerKind = "cert-manager.io/issuer-kind"
// LabelIssuerGroup is the label for the issuer group
LabelIssuerGroup = "cert-manager.io/issuer-group"
)

// Cert-manager component names and namespace
const (
CertManagerNamespace = "cert-manager"
CertManagerOperatorNamespace = "cert-manager-operator"
ControllerDeploymentName = "cert-manager"
WebhookDeploymentName = "cert-manager-webhook"
CAInjectorDeploymentName = "cert-manager-cainjector"
)

// Condition represents a Kubernetes-style condition
type Condition struct {
Type string
Status string
Reason string
Message string
LastTransitionTime string
}

// IssuerRef represents a reference to an Issuer or ClusterIssuer
type IssuerRef struct {
Name string
Kind string
Group string
}

// CertificateDetails contains a Certificate and all related resources
type CertificateDetails struct {
Certificate *unstructured.Unstructured
CertificateRequests []*unstructured.Unstructured
Issuer *unstructured.Unstructured
Orders []*unstructured.Unstructured
Challenges []*unstructured.Unstructured
Events []Event
}

// IssuerDetails contains an Issuer and related information
type IssuerDetails struct {
Issuer *unstructured.Unstructured
Events []Event
}

// Event represents a Kubernetes Event
type Event struct {
Type string
Reason string
Message string
Timestamp string
Count int32
}

// ComponentStatus represents the status of a cert-manager component
type ComponentStatus struct {
Name string
Ready bool
AvailableReplicas int32
DesiredReplicas int32
Message string
}

// OperatorStatus represents the overall status of cert-manager operator
type OperatorStatus struct {
Controller ComponentStatus
Webhook ComponentStatus
CAInjector ComponentStatus
Conditions []Condition
}
2 changes: 1 addition & 1 deletion pkg/kubernetes-mcp-server/cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func TestToolsets(t *testing.T) {
rootCmd := NewMCPServer(ioStreams)
rootCmd.SetArgs([]string{"--help"})
o, err := captureOutput(rootCmd.Execute) // --help doesn't use logger/klog, cobra prints directly to stdout
if !strings.Contains(o, "Comma-separated list of MCP toolsets to use (available toolsets: config, core, helm, kiali, kubevirt).") {
if !strings.Contains(o, "Comma-separated list of MCP toolsets to use (available toolsets: certmanager, config, core, helm, kiali, kubevirt).") {
t.Fatalf("Expected all available toolsets, got %s %v", o, err)
}
})
Expand Down
1 change: 1 addition & 0 deletions pkg/mcp/modules.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mcp

import (
_ "github.com/containers/kubernetes-mcp-server/pkg/toolsets/certmanager"
_ "github.com/containers/kubernetes-mcp-server/pkg/toolsets/config"
_ "github.com/containers/kubernetes-mcp-server/pkg/toolsets/core"
_ "github.com/containers/kubernetes-mcp-server/pkg/toolsets/helm"
Expand Down
Loading