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

mendersoftware / mender-cli / 1779286128

22 Apr 2025 08:09AM UTC coverage: 1.737% (-30.1%) from 31.802%
1779286128

Pull #277

gitlab-ci

alfrunes
chore: Improve dockerfile by pinning versions and pruning dependencies

Changed the builder image to the debian (official) golang image and
upgraded to the latest version.

Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
Pull Request #277: 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/artifact_download.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
        "github.com/pkg/errors"
18

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

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

26
const (
27
        argDestinationPath = "destination-path"
28
)
29

30
var artifactDownloadCmd = &cobra.Command{
31
        Use:   "download [flags] ARTIFACT",
32
        Short: "Download mender artifact from the Mender server.",
UNCOV
33
        Run: func(c *cobra.Command, args []string) {
×
UNCOV
34
                cmd, err := NewArtifactDownloadCmd(c, args)
×
UNCOV
35
                CheckErr(err)
×
UNCOV
36
                CheckErr(cmd.Run())
×
UNCOV
37
        },
×
38
}
39

UNCOV
40
func init() {
×
UNCOV
41
        artifactDownloadCmd.Flags().StringP(argDestinationPath, "", "",
×
UNCOV
42
                "destination path to download to")
×
UNCOV
43
        artifactDownloadCmd.Flags().BoolP(argWithoutProgress, "", false,
×
UNCOV
44
                "disable progress bar")
×
UNCOV
45
}
×
46

47
type ArtifactDownloadCmd struct {
48
        server          string
49
        skipVerify      bool
50
        destinationPath string
51
        artifactID      string
52
        token           string
53
        withoutProgress bool
54
}
55

UNCOV
56
func NewArtifactDownloadCmd(cmd *cobra.Command, args []string) (*ArtifactDownloadCmd, error) {
×
UNCOV
57
        server := viper.GetString(argRootServer)
×
UNCOV
58
        if server == "" {
×
59
                return nil, errors.New("No server")
×
60
        }
×
61

UNCOV
62
        skipVerify, err := cmd.Flags().GetBool(argRootSkipVerify)
×
UNCOV
63
        if err != nil {
×
64
                return nil, err
×
65
        }
×
66

UNCOV
67
        withoutProgress, err := cmd.Flags().GetBool(argWithoutProgress)
×
UNCOV
68
        if err != nil {
×
69
                return nil, err
×
70
        }
×
71

UNCOV
72
        destinationPath, err := cmd.Flags().GetString(argDestinationPath)
×
UNCOV
73
        if err != nil {
×
74
                return nil, err
×
75
        }
×
76

UNCOV
77
        artifactID := ""
×
UNCOV
78
        if len(args) == 1 {
×
UNCOV
79
                artifactID = args[0]
×
UNCOV
80
        }
×
81

UNCOV
82
        token, err := getAuthToken(cmd)
×
UNCOV
83
        if err != nil {
×
84
                return nil, err
×
85
        }
×
86

UNCOV
87
        return &ArtifactDownloadCmd{
×
UNCOV
88
                server:          server,
×
UNCOV
89
                destinationPath: destinationPath,
×
UNCOV
90
                artifactID:      artifactID,
×
UNCOV
91
                token:           token,
×
UNCOV
92
                skipVerify:      skipVerify,
×
UNCOV
93
                withoutProgress: withoutProgress,
×
UNCOV
94
        }, nil
×
95
}
96

UNCOV
97
func (c *ArtifactDownloadCmd) Run() error {
×
UNCOV
98
        client := deployments.NewClient(c.server, c.skipVerify)
×
UNCOV
99
        err := client.DownloadArtifact(c.destinationPath, c.artifactID, c.token, c.withoutProgress)
×
UNCOV
100
        if err != nil {
×
101
                return err
×
102
        }
×
103

UNCOV
104
        log.Info("download successful")
×
UNCOV
105

×
UNCOV
106
        return nil
×
107
}
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