diff --git a/pkg/kopia/cli/internal/kopia_test.go b/pkg/kopia/cli/internal/kopia_test.go index de2217bbbb..671f2af8d5 100644 --- a/pkg/kopia/cli/internal/kopia_test.go +++ b/pkg/kopia/cli/internal/kopia_test.go @@ -1,3 +1,17 @@ +// Copyright 2024 The Kanister Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package internal_test import ( diff --git a/pkg/kopia/cli/internal/test/command_suite.go b/pkg/kopia/cli/internal/test/command_suite.go index 0eebf793ff..8ce690be20 100644 --- a/pkg/kopia/cli/internal/test/command_suite.go +++ b/pkg/kopia/cli/internal/test/command_suite.go @@ -1,3 +1,17 @@ +// Copyright 2024 The Kanister Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package test import ( diff --git a/pkg/kopia/cli/repository/data_test.go b/pkg/kopia/cli/repository/data_test.go index 0b6ef70b29..6ad10df1a3 100644 --- a/pkg/kopia/cli/repository/data_test.go +++ b/pkg/kopia/cli/repository/data_test.go @@ -1,3 +1,17 @@ +// Copyright 2024 The Kanister Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package repository import ( diff --git a/pkg/kopia/cli/repository/opts.go b/pkg/kopia/cli/repository/opts.go index 919a322208..31c92ab0e5 100644 --- a/pkg/kopia/cli/repository/opts.go +++ b/pkg/kopia/cli/repository/opts.go @@ -38,6 +38,7 @@ var ( subcmdConnect = command.NewArgument("connect") subcmdServer = command.NewArgument("server") subcmdSetParameters = command.NewArgument("set-parameters") + subcmdStatus = command.NewArgument("status") ) // optHostname creates a new option for the hostname of the repository. diff --git a/pkg/kopia/cli/repository/repository_connect_server_test.go b/pkg/kopia/cli/repository/repository_connect_server_test.go index 43a188637e..b50a03b0f6 100644 --- a/pkg/kopia/cli/repository/repository_connect_server_test.go +++ b/pkg/kopia/cli/repository/repository_connect_server_test.go @@ -1,3 +1,17 @@ +// Copyright 2024 The Kanister Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package repository import ( diff --git a/pkg/kopia/cli/repository/repository_connect_test.go b/pkg/kopia/cli/repository/repository_connect_test.go index d3f8f338ea..9f8f0d7067 100644 --- a/pkg/kopia/cli/repository/repository_connect_test.go +++ b/pkg/kopia/cli/repository/repository_connect_test.go @@ -1,3 +1,17 @@ +// Copyright 2024 The Kanister Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package repository import ( diff --git a/pkg/kopia/cli/repository/repository_set_parameters_test.go b/pkg/kopia/cli/repository/repository_set_parameters_test.go index bf9d460e61..5f7fe01a08 100644 --- a/pkg/kopia/cli/repository/repository_set_parameters_test.go +++ b/pkg/kopia/cli/repository/repository_set_parameters_test.go @@ -1,3 +1,17 @@ +// Copyright 2024 The Kanister Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package repository import ( diff --git a/pkg/kopia/cli/repository/repository_status.go b/pkg/kopia/cli/repository/repository_status.go new file mode 100644 index 0000000000..c13dfd37ad --- /dev/null +++ b/pkg/kopia/cli/repository/repository_status.go @@ -0,0 +1,42 @@ +// Copyright 2024 The Kanister Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package repository + +import ( + "github.com/kanisterio/safecli" + + "github.com/kanisterio/kanister/pkg/kopia/cli/args" + "github.com/kanisterio/kanister/pkg/kopia/cli/internal" + "github.com/kanisterio/kanister/pkg/kopia/cli/internal/opts" + "github.com/kanisterio/kanister/pkg/log" +) + +// StatusArgs defines the arguments for the `kopia repository status ...` command. +type StatusArgs struct { + args.Common // embed common arguments + + JSONOutput bool // shows the output in JSON format + + Logger log.Logger +} + +// Status creates a new `kopia repository status ...` command. +func Status(args StatusArgs) (*safecli.Builder, error) { + return internal.NewKopiaCommand( + opts.Common(args.Common), + cmdRepository, subcmdStatus, + opts.JSON(args.JSONOutput), + ) +} diff --git a/pkg/kopia/cli/repository/repository_status_test.go b/pkg/kopia/cli/repository/repository_status_test.go new file mode 100644 index 0000000000..68a11cfdd4 --- /dev/null +++ b/pkg/kopia/cli/repository/repository_status_test.go @@ -0,0 +1,66 @@ +// Copyright 2024 The Kanister Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package repository + +import ( + "testing" + + "github.com/kanisterio/safecli" + "gopkg.in/check.v1" + + "github.com/kanisterio/kanister/pkg/kopia/cli/internal/test" +) + +func TestRepositoryStatusCommand(t *testing.T) { check.TestingT(t) } + +// Test Repository Status command +var _ = check.Suite(test.NewCommandSuite([]test.CommandTest{ + { + Name: "repository status with default args", + Command: func() (*safecli.Builder, error) { + args := StatusArgs{ + Common: common, + } + return Status(args) + }, + ExpectedCLI: []string{"kopia", + "--config-file=path/kopia.config", + "--log-dir=cache/log", + "--log-level=error", + "--password=encr-key", + "repository", + "status", + }, + }, + { + Name: "repository status with JSON output", + Command: func() (*safecli.Builder, error) { + args := StatusArgs{ + Common: common, + JSONOutput: true, + } + return Status(args) + }, + ExpectedCLI: []string{"kopia", + "--config-file=path/kopia.config", + "--log-dir=cache/log", + "--log-level=error", + "--password=encr-key", + "repository", + "status", + "--json", + }, + }, +}))