• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nats-io / nsc / 14765656943

30 Apr 2025 10:34PM UTC coverage: 69.949% (-4.2%) from 74.148%
14765656943

Pull #691

github

web-flow
Merge b4ee16f94 into a9c0df586
Pull Request #691: Generate docs

1 of 1 new or added line in 1 file covered. (100.0%)

3680 existing lines in 93 files now uncovered.

12325 of 17620 relevant lines covered (69.95%)

1.66 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.45
/cmd/describeoperator.go
1
// Copyright 2018-2025 The NATS Authors
2
// Licensed under the Apache License, Version 2.0 (the "License");
3
// you may not use this file except in compliance with the License.
4
// You may obtain a copy of the License at
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software
9
// distributed under the License is distributed on an "AS IS" BASIS,
10
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
// See the License for the specific language governing permissions and
12
// limitations under the License.
13

14
package cmd
15

16
import (
17
        "errors"
18
        "fmt"
19
        "github.com/nats-io/nsc/v2/cmd/store"
20

21
        "github.com/spf13/cobra"
22
)
23

24
func createDescribeOperatorCmd() *cobra.Command {
25
        var params DescribeOperatorParams
26
        cmd := &cobra.Command{
27
                Use:          "operator",
2✔
28
                Short:        "Describes the operator",
2✔
29
                Args:         cobra.MaximumNArgs(1),
2✔
30
                SilenceUsage: true,
2✔
31
                RunE: func(cmd *cobra.Command, args []string) error {
2✔
32
                        return RunMaybeStorelessAction(cmd, args, &params)
2✔
33
                },
2✔
34
        }
4✔
35
        cmd.Flags().StringVarP(&params.outputFile, "output-file", "o", "--", "output file, '--' is stdout")
2✔
36
        cmd.Flags().StringVarP(&params.name, "name", "n", "", "operator name")
2✔
37

38
        return cmd
2✔
39
}
2✔
40

2✔
41
func init() {
2✔
42
        describeCmd.AddCommand(createDescribeOperatorCmd())
43
}
44

2✔
45
type DescribeOperatorParams struct {
2✔
46
        name string
2✔
47
        BaseDescribe
48
}
49

50
func (p *DescribeOperatorParams) SetDefaults(ctx ActionCtx) error {
51
        p.name = NameFlagOrArgument(p.name, ctx)
52
        if p.name != "" {
53
                actx, ok := ctx.(*Actx)
54
                if !ok {
55
                        return errors.New("unable to cast to actx")
2✔
56
                }
2✔
57
                s, err := GetStoreForOperator(p.name)
4✔
58
                if err != nil {
2✔
59
                        return err
2✔
UNCOV
60
                }
×
UNCOV
61
                cc, err := s.GetContext()
×
62
                if err != nil {
2✔
63
                        return err
4✔
64
                }
2✔
65
                actx.ctx.Store = s
2✔
66
                actx.ctx = cc
2✔
67
        } else if ctx.StoreCtx().Store == nil {
2✔
68
                return fmt.Errorf("set an operator")
×
69

×
70
        }
2✔
71
        return nil
2✔
72
}
2✔
UNCOV
73

×
UNCOV
74
func (p *DescribeOperatorParams) Load(ctx ActionCtx) error {
×
UNCOV
75
        var err error
×
76
        p.raw, err = ctx.StoreCtx().Store.ReadRawOperatorClaim()
2✔
77
        if err != nil {
78
                return err
79
        }
×
UNCOV
80
        return p.Init()
×
UNCOV
81
}
×
82

83
func (p *DescribeOperatorParams) PreInteractive(_ ActionCtx) error {
2✔
84
        return nil
2✔
85
}
4✔
86

2✔
87
func (p *DescribeOperatorParams) Validate(_ ActionCtx) error {
2✔
UNCOV
88
        return nil
×
UNCOV
89
}
×
90

4✔
91
func (p *DescribeOperatorParams) PostInteractive(_ ActionCtx) error {
2✔
92
        return nil
2✔
93
}
×
UNCOV
94

×
95
func (p *DescribeOperatorParams) Run(ctx ActionCtx) (store.Status, error) {
96
        return p.Describe(ctx)
4✔
97
}
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc