Skip to content

Commit

Permalink
Describing tf resourece
Browse files Browse the repository at this point in the history
  • Loading branch information
laszlocph committed Oct 17, 2024
1 parent 983556f commit 862aff4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 8 deletions.
47 changes: 41 additions & 6 deletions cmd/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/sirupsen/logrus"
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/meta"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -463,17 +463,52 @@ func describeResource(
gimletHost string,
agentKey string,
) {
var gk schema.GroupKind
var gvr schema.GroupVersionResource
var gvk schema.GroupVersionKind
switch resource {
case "Deployment":
gk = schema.GroupKind{Group: appsv1.GroupName, Kind: "Deployment"}
gvr = schema.GroupVersionResource{
Group: "apps",
Version: "v1",
Resource: "deployments",
}
gvk = schema.GroupVersionKind{
Group: "apps",
Version: "v1",
Kind: "Deployment",
}
case "Pod":
gk = schema.GroupKind{Group: v1.GroupName, Kind: "Pod"}
gvr = schema.GroupVersionResource{
Group: "",
Version: "v1",
Resource: "pods",
}
gvk = schema.GroupVersionKind{
Group: "",
Version: "v1",
Kind: "Pod",
}
case "Terraform":
gk = schema.GroupKind{Group: "infra.contrib.fluxcd.io", Kind: "Terraform"}
gvr = schema.GroupVersionResource{
Group: "infra.contrib.fluxcd.io",
Version: "v1alpha2",
Resource: "terraforms",
}
gvk = schema.GroupVersionKind{
Group: "infra.contrib.fluxcd.io",
Version: "v1alpha2",
Kind: "Terraform",
}
}

describer, ok := describe.DescriberFor(gk, kubeEnv.Config)
describer, ok := describe.GenericDescriberFor(
&meta.RESTMapping{
Resource: gvr,
GroupVersionKind: gvk,
Scope: meta.RESTScopeNamespace,
},
kubeEnv.Config,
)
if !ok {
logrus.Errorf("could not get describer for %s", resource)
return
Expand Down
4 changes: 2 additions & 2 deletions web/src/views/footer/capacitor/Describe.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ export function Describe(props) {
setSelected={setSelected}
/>}
>
<code key={selected} className='flex whitespace-pre items-center font-mono text-xs p-2 text-yellow-100 rounded'>
<code key={selected} className='text-left flex whitespace-pre font-mono text-xs p-2 text-yellow-100 rounded'>
{content ?? <SkeletonLoader />}
</code>
</Modal>
}
<button onClick={() => {
setShowModal(true);
}}
className="transparentBtn">
className="transparentBtn w-24">
Describe
</button>
</>
Expand Down

0 comments on commit 862aff4

Please sign in to comment.