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

mendersoftware / mender-cli / 1779499080

22 Apr 2025 10:11AM UTC coverage: 1.737% (-30.1%) from 31.802%
1779499080

push

gitlab-ci

web-flow
Merge pull request #277 from alfrunes/MEN-7794

MEN-7794: Add support for pagination when listing devices

28 of 82 new or added lines in 4 files covered. (34.15%)

770 existing lines in 17 files now uncovered.

45 of 2590 relevant lines covered (1.74%)

0.04 hits per line

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

0.0
/cmd/artifacts_list.go
1
// Copyright 2023 Northern.tech AS
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
package cmd
15

16
import (
17
        "errors"
18

19
        "github.com/spf13/cobra"
20
        "github.com/spf13/viper"
21

22
        "github.com/mendersoftware/mender-cli/client/deployments"
23
)
24

25
const (
26
        argDetailLevel = "detail"
27
)
28

29
var artifactsListCmd = &cobra.Command{
30
        Use:   "list",
31
        Short: "Get a list of artifacts from the Mender server.",
UNCOV
32
        Run: func(c *cobra.Command, args []string) {
×
UNCOV
33
                cmd, err := NewArtifactsListCmd(c, args)
×
UNCOV
34
                CheckErr(err)
×
UNCOV
35
                CheckErr(cmd.Run())
×
UNCOV
36
        },
×
37
}
38

UNCOV
39
func init() {
×
UNCOV
40
        artifactsListCmd.Flags().IntP(argDetailLevel, "d", 0, "artifacts list detail level [0..3]")
×
UNCOV
41
}
×
42

43
type ArtifactsListCmd struct {
44
        server      string
45
        skipVerify  bool
46
        token       string
47
        detailLevel int
48
}
49

UNCOV
50
func NewArtifactsListCmd(cmd *cobra.Command, args []string) (*ArtifactsListCmd, error) {
×
UNCOV
51
        server := viper.GetString(argRootServer)
×
UNCOV
52
        if server == "" {
×
53
                return nil, errors.New("No server")
×
54
        }
×
55

UNCOV
56
        skipVerify, err := cmd.Flags().GetBool(argRootSkipVerify)
×
UNCOV
57
        if err != nil {
×
58
                return nil, err
×
59
        }
×
60

UNCOV
61
        detailLevel, err := cmd.Flags().GetInt(argDetailLevel)
×
UNCOV
62
        if err != nil {
×
63
                return nil, err
×
64
        }
×
65

UNCOV
66
        token, err := getAuthToken(cmd)
×
UNCOV
67
        if err != nil {
×
68
                return nil, err
×
69
        }
×
70

UNCOV
71
        return &ArtifactsListCmd{
×
UNCOV
72
                server:      server,
×
UNCOV
73
                token:       token,
×
UNCOV
74
                skipVerify:  skipVerify,
×
UNCOV
75
                detailLevel: detailLevel,
×
UNCOV
76
        }, nil
×
77
}
78

UNCOV
79
func (c *ArtifactsListCmd) Run() error {
×
UNCOV
80

×
UNCOV
81
        client := deployments.NewClient(c.server, c.skipVerify)
×
UNCOV
82
        return client.ListArtifacts(c.token, c.detailLevel)
×
UNCOV
83
}
×
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