Skip to content

Commit 77e3943

Browse files
authored
al support cloud storage (#290)
New feature - Support configure rotation policy and cloud storage for audit log with `ticloud serverless audit-log config update` command. Break change - The command `ticloud serverless audit-log config` is replaced by `ticloud serverless audit-log config update`. - The command `ticloud serverless audit-log describe` is replaced by `ticloud serverless audit-log config describe`
1 parent b83e0af commit 77e3943

84 files changed

Lines changed: 10988 additions & 3375 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

internal/cli/serverless/auditlog/auditlog.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package auditlog
1717
import (
1818
"github.com/spf13/cobra"
1919
"github.com/tidbcloud/tidbcloud-cli/internal"
20+
"github.com/tidbcloud/tidbcloud-cli/internal/cli/serverless/auditlog/config"
2021
"github.com/tidbcloud/tidbcloud-cli/internal/cli/serverless/auditlog/filter"
2122
)
2223

@@ -28,8 +29,7 @@ func AuditLoggingCmd(h *internal.Helper) *cobra.Command {
2829
}
2930

3031
auditLoggingCmd.AddCommand(DownloadCmd(h))
31-
auditLoggingCmd.AddCommand(DescribeCmd(h))
32-
auditLoggingCmd.AddCommand(ConfigCmd(h))
32+
auditLoggingCmd.AddCommand(config.ConfigCmd(h))
3333
auditLoggingCmd.AddCommand(filter.FilterRuleCmd(h))
3434

3535
return auditLoggingCmd

internal/cli/serverless/auditlog/config.go

Lines changed: 0 additions & 216 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2025 PingCAP, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package config
16+
17+
import (
18+
"github.com/spf13/cobra"
19+
"github.com/tidbcloud/tidbcloud-cli/internal"
20+
)
21+
22+
func ConfigCmd(h *internal.Helper) *cobra.Command {
23+
var configCmd = &cobra.Command{
24+
Use: "config",
25+
Short: "Manage TiDB Cloud Serverless database audit logging configuration",
26+
}
27+
28+
configCmd.AddCommand(DescribeCmd(h))
29+
configCmd.AddCommand(UpdateCmd(h))
30+
31+
return configCmd
32+
}

internal/cli/serverless/auditlog/describe.go renamed to internal/cli/serverless/auditlog/config/describe.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package auditlog
15+
package config
1616

1717
import (
1818
"fmt"
@@ -24,7 +24,6 @@ import (
2424
"github.com/tidbcloud/tidbcloud-cli/internal/flag"
2525
"github.com/tidbcloud/tidbcloud-cli/internal/output"
2626
"github.com/tidbcloud/tidbcloud-cli/internal/service/cloud"
27-
"github.com/tidbcloud/tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/cluster"
2827
)
2928

3029
type DescribeOpts struct {
@@ -69,10 +68,10 @@ func DescribeCmd(h *internal.Helper) *cobra.Command {
6968
Aliases: []string{"get"},
7069
Args: cobra.NoArgs,
7170
Example: fmt.Sprintf(` Get the database audit logging configuration in interactive mode:
72-
$ %[1]s serverless audit-log describe
71+
$ %[1]s serverless audit-log config describe
7372
7473
Get the database audit logging configuration in non-interactive mode:
75-
$ %[1]s serverless audit-log describe -c <cluster-id> `, config.CliName),
74+
$ %[1]s serverless audit-log config describe -c <cluster-id> `, config.CliName),
7675
PreRunE: func(cmd *cobra.Command, args []string) error {
7776
return opts.MarkInteractive(cmd)
7877
},
@@ -104,12 +103,12 @@ func DescribeCmd(h *internal.Helper) *cobra.Command {
104103
}
105104
}
106105

107-
cluster, err := d.GetCluster(ctx, clusterID, cluster.SERVERLESSSERVICEGETCLUSTERVIEWPARAMETER_BASIC)
106+
auditlogConfig, err := d.GetAuditLogConfig(ctx, clusterID)
108107
if err != nil {
109108
return errors.Trace(err)
110109
}
111110

112-
err = output.PrintJson(h.IOStreams.Out, cluster.AuditLogConfig)
111+
err = output.PrintJson(h.IOStreams.Out, auditlogConfig)
113112
return errors.Trace(err)
114113
},
115114
}

0 commit comments

Comments
 (0)