-
Notifications
You must be signed in to change notification settings - Fork 202
/
configurations.go
49 lines (43 loc) · 1.47 KB
/
configurations.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
package kubernetes
import (
"github.com/dapr/cli/pkg/age"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// ComponentsOutput represent a Dapr component.
type ConfigurtionsOutput struct {
Name string `csv:"Name"`
TracingEnabled bool `csv:"TRACING-ENABLED"`
MTLSEnabled bool `csv:"MTLS-ENABLED"`
WorkloadCertTTL string `csv:"MTLS-WORKLOAD-TTL"`
ClockSkew string `csv:"MTLS-CLOCK-SKEW"`
Age string `csv:"AGE"`
Created string `csv:"CREATED"`
}
// List outputs all Dapr configurations.
func Configurations() ([]ConfigurtionsOutput, error) {
client, err := DaprClient()
if err != nil {
return nil, err
}
confs, err := client.ConfigurationV1alpha1().Configurations(meta_v1.NamespaceAll).List(meta_v1.ListOptions{})
if err != nil {
return nil, err
}
co := []ConfigurtionsOutput{}
for _, c := range confs.Items {
co = append(co, ConfigurtionsOutput{
Name: c.GetName(),
TracingEnabled: c.Spec.TracingSpec.Enabled,
MTLSEnabled: c.Spec.MTLSSpec.Enabled,
WorkloadCertTTL: c.Spec.MTLSSpec.WorkloadCertTTL,
ClockSkew: c.Spec.MTLSSpec.AllowedClockSkew,
Created: c.CreationTimestamp.Format("2006-01-02 15:04.05"),
Age: age.GetAge(c.CreationTimestamp.Time),
})
}
return co, nil
}