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

mendersoftware / deployments / 1197570064

01 Mar 2024 06:24PM UTC coverage: 52.222% (-28.4%) from 80.645%
1197570064

Pull #998

gitlab-ci

web-flow
chore: bump github.com/Azure/azure-sdk-for-go/sdk/azcore

Bumps [github.com/Azure/azure-sdk-for-go/sdk/azcore](https://github.com/Azure/azure-sdk-for-go) from 1.9.1 to 1.10.0.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/release.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/azcore/v1.9.1...sdk/azcore/v1.10.0)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/azcore
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #998: chore: bump github.com/Azure/azure-sdk-for-go/sdk/azcore from 1.9.1 to 1.10.0

5218 of 9992 relevant lines covered (52.22%)

0.55 hits per line

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

54.17
/app/app_os.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

15
package app
16

17
import (
18
        "context"
19

20
        "github.com/pkg/errors"
21

22
        "github.com/mendersoftware/go-lib-micro/log"
23

24
        "github.com/mendersoftware/deployments/model"
25
)
26

27
func (d *Deployments) isAlreadyInstalled(
28
        request *model.DeploymentNextRequest,
29
        deviceDeployment *model.DeviceDeployment,
30
) bool {
1✔
31
        if request == nil ||
1✔
32
                request.DeviceProvides == nil ||
1✔
33
                deviceDeployment == nil ||
1✔
34
                deviceDeployment.Image == nil ||
1✔
35
                deviceDeployment.Image.ArtifactMeta == nil {
1✔
36
                return false
×
37
        }
×
38

39
        // check if the device reported same artifact name as the one
40
        // in the artifact selected for a given device deployment
41
        return request.DeviceProvides.ArtifactName == deviceDeployment.Image.ArtifactMeta.Name
1✔
42
}
43

44
func (d *Deployments) handleAlreadyInstalled(
45
        ctx context.Context,
46
        deviceDeployment *model.DeviceDeployment,
47
) error {
1✔
48
        l := log.FromContext(ctx)
1✔
49
        if err := d.UpdateDeviceDeploymentStatus(
1✔
50
                ctx,
1✔
51
                deviceDeployment.DeploymentId,
1✔
52
                deviceDeployment.DeviceId,
1✔
53
                model.DeviceDeploymentState{
1✔
54
                        Status: model.DeviceDeploymentStatusAlreadyInst,
1✔
55
                }); err != nil {
1✔
56
                return errors.Wrap(err, "Failed to update deployment status")
×
57
        }
×
58
        if err := d.reindexDevice(ctx, deviceDeployment.DeviceId); err != nil {
1✔
59
                l.Warn(errors.Wrap(err, "failed to trigger a device reindex"))
×
60
        }
×
61
        if err := d.reindexDeployment(ctx, deviceDeployment.DeviceId,
1✔
62
                deviceDeployment.DeploymentId, deviceDeployment.Id); err != nil {
1✔
63
                l.Warn(errors.Wrap(err, "failed to trigger a device reindex"))
×
64
        }
×
65

66
        return nil
1✔
67
}
68

69
// assignArtifact assigns artifact to the device deployment
70
func (d *Deployments) assignArtifact(
71
        ctx context.Context,
72
        deployment *model.Deployment,
73
        deviceDeployment *model.DeviceDeployment,
74
        installed *model.InstalledDeviceDeployment) error {
1✔
75

1✔
76
        // Assign artifact to the device deployment.
1✔
77
        var artifact *model.Image
1✔
78
        var err error
1✔
79

1✔
80
        if err = installed.Validate(); err != nil {
1✔
81
                return err
×
82
        }
×
83

84
        if deviceDeployment.DeploymentId == "" || deviceDeployment.DeviceId == "" {
1✔
85
                return ErrModelInternal
×
86
        }
×
87

88
        // Clear device deployment image
89
        // New artifact will be selected for the device deployment
90
        deviceDeployment.Image = nil
1✔
91

1✔
92
        // First case is for backward compatibility.
1✔
93
        // It is possible that there is old deployment structure in the system.
1✔
94
        // In such case we need to select artifact using name and device type.
1✔
95
        if deployment.Artifacts == nil || len(deployment.Artifacts) == 0 {
1✔
96
                artifact, err = d.db.ImageByNameAndDeviceType(
×
97
                        ctx,
×
98
                        installed.ArtifactName,
×
99
                        installed.DeviceType,
×
100
                )
×
101
                if err != nil {
×
102
                        return errors.Wrap(err, "assigning artifact to device deployment")
×
103
                }
×
104
        } else {
1✔
105
                // Select artifact for the device deployment from artifacts assigned to the deployment.
1✔
106
                artifact, err = d.db.ImageByIdsAndDeviceType(
1✔
107
                        ctx,
1✔
108
                        deployment.Artifacts,
1✔
109
                        installed.DeviceType,
1✔
110
                )
1✔
111
                if err != nil {
1✔
112
                        return errors.Wrap(err, "assigning artifact to device deployment")
×
113
                }
×
114
        }
115

116
        // If not having appropriate image, set noartifact status
117
        if artifact == nil {
1✔
118
                return d.assignNoArtifact(ctx, deviceDeployment)
×
119
        }
×
120

121
        if err := d.db.AssignArtifact(
1✔
122
                ctx,
1✔
123
                deviceDeployment.DeviceId,
1✔
124
                deviceDeployment.DeploymentId,
1✔
125
                artifact,
1✔
126
        ); err != nil {
1✔
127
                return errors.Wrap(err, "Assigning artifact to the device deployment")
×
128
        }
×
129

130
        deviceDeployment.Image = artifact
1✔
131

1✔
132
        return nil
1✔
133
}
134

135
func (d *Deployments) assignNoArtifact(
136
        ctx context.Context,
137
        deviceDeployment *model.DeviceDeployment,
138
) error {
×
139
        l := log.FromContext(ctx)
×
140
        if err := d.UpdateDeviceDeploymentStatus(ctx, deviceDeployment.DeploymentId,
×
141
                deviceDeployment.DeviceId,
×
142
                model.DeviceDeploymentState{
×
143
                        Status: model.DeviceDeploymentStatusNoArtifact,
×
144
                }); err != nil {
×
145
                return errors.Wrap(err, "Failed to update deployment status")
×
146
        }
×
147
        if err := d.reindexDevice(ctx, deviceDeployment.DeviceId); err != nil {
×
148
                l.Warn(errors.Wrap(err, "failed to trigger a device reindex"))
×
149
        }
×
150
        if err := d.reindexDeployment(ctx, deviceDeployment.DeviceId,
×
151
                deviceDeployment.DeploymentId, deviceDeployment.Id); err != nil {
×
152
                l := log.FromContext(ctx)
×
153
                l.Warn(errors.Wrap(err, "failed to trigger a device reindex"))
×
154
        }
×
155
        return nil
×
156
}
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