• 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/artifact_delete.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
        "github.com/mendersoftware/mender-cli/log"
24
)
25

26
var artifactDeleteCmd = &cobra.Command{
27
        Use:   "delete [flags] ARTIFACT_ID",
28
        Short: "Delete mender artifact from the Mender server.",
29
        Args:  cobra.ExactArgs(1),
UNCOV
30
        Run: func(c *cobra.Command, args []string) {
×
UNCOV
31
                cmd, err := NewArtifactDeleteCmd(c, args)
×
UNCOV
32
                CheckErr(err)
×
UNCOV
33
                CheckErr(cmd.Run())
×
UNCOV
34
        },
×
35
}
36

UNCOV
37
func init() {
×
UNCOV
38
}
×
39

40
type ArtifactDeleteCmd struct {
41
        server     string
42
        skipVerify bool
43
        artifactID string
44
        token      string
45
}
46

UNCOV
47
func NewArtifactDeleteCmd(cmd *cobra.Command, args []string) (*ArtifactDeleteCmd, error) {
×
UNCOV
48
        server := viper.GetString(argRootServer)
×
UNCOV
49
        if server == "" {
×
50
                return nil, errors.New("No server")
×
51
        }
×
52

UNCOV
53
        skipVerify, err := cmd.Flags().GetBool(argRootSkipVerify)
×
UNCOV
54
        if err != nil {
×
55
                return nil, err
×
56
        }
×
57

UNCOV
58
        token, err := getAuthToken(cmd)
×
UNCOV
59
        if err != nil {
×
60
                return nil, err
×
61
        }
×
62

UNCOV
63
        artifactID := ""
×
UNCOV
64
        if len(args) == 1 {
×
UNCOV
65
                artifactID = args[0]
×
UNCOV
66
        }
×
67

UNCOV
68
        return &ArtifactDeleteCmd{
×
UNCOV
69
                server:     server,
×
UNCOV
70
                artifactID: artifactID,
×
UNCOV
71
                token:      token,
×
UNCOV
72
                skipVerify: skipVerify,
×
UNCOV
73
        }, nil
×
74
}
75

UNCOV
76
func (c *ArtifactDeleteCmd) Run() error {
×
UNCOV
77

×
UNCOV
78
        client := deployments.NewClient(c.server, c.skipVerify)
×
UNCOV
79
        err := client.DeleteArtifact(c.artifactID, c.token)
×
UNCOV
80
        if err != nil {
×
81
                return err
×
82
        }
×
83

UNCOV
84
        log.Info("delete successful")
×
UNCOV
85

×
UNCOV
86
        return nil
×
87
}
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