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

mendersoftware / workflows / 1565759653

29 Nov 2024 07:56AM UTC coverage: 67.786% (-14.5%) from 82.255%
1565759653

push

gitlab-ci

web-flow
Merge pull request #336 from alfrunes/2.6.x

chore(deps): Update golang builder images to latest

1050 of 1549 relevant lines covered (67.79%)

5.01 hits per line

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

0.0
/config/config.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 config
16

17
import (
18
        "github.com/mendersoftware/go-lib-micro/config"
19
        "github.com/pkg/errors"
20

21
        "github.com/mendersoftware/workflows/client/nats"
22
)
23

24
const (
25
        // SettingListen is the config key for the listen address
26
        SettingListen = "listen"
27
        // SettingListenDefault is the default value for the listen address
28
        SettingListenDefault = ":8080"
29

30
        // SettingNatsURI is the config key for the nats uri
31
        SettingNatsURI = "nats_uri"
32
        // SettingNatsURIDefault is the default value for the nats uri
33
        SettingNatsURIDefault = "nats://mender-nats:4222"
34

35
        // SettingNatsStreamName is the config key for the nats streaem name
36
        SettingNatsStreamName = "nats_stream_name"
37
        // SettingNatsStreamNameDefault is the default value for the nats stream name
38
        SettingNatsStreamNameDefault = "WORKFLOWS"
39

40
        // SettingNatsSubscriberTopic is the config key for the nats subscriber topic name
41
        SettingNatsSubscriberTopic = "nats_subscriber_topic"
42
        // SettingNatsSubscriberTopicDefault is the default value for the nats subscriber topic name
43
        SettingNatsSubscriberTopicDefault = "default"
44

45
        // SettingNatsSubscriberDurable is the config key for the nats subscriber durable name
46
        SettingNatsSubscriberDurable = "nats_subscriber_durable"
47
        // SettingNatsSubscriberDurableDefault is the default value for the nats subscriber durable name
48
        SettingNatsSubscriberDurableDefault = "workflows-worker"
49

50
        SettingsNats = "nats"
51

52
        SettingNatsConsumer                  = SettingsNats + ".consumer"
53
        SettingNatsConsumerAckWait           = SettingNatsConsumer + ".ack_wait"
54
        SettingNatsConsumerAckWaitDefault    = "30s"
55
        SettingNatsConsumerMaxDeliver        = SettingNatsConsumer + ".max_deliver"
56
        SettingNatsConsumerMaxDeliverDefault = 3
57
        SettingNatsConsumerMaxPending        = SettingNatsConsumer + ".max_pending"
58
        SettingNatsConsumerMaxPendingDefault = 1000
59

60
        // SettingMongo is the config key for the mongo URL
61
        SettingMongo = "mongo-url"
62
        // SettingMongoDefault is the default value for the mongo URL
63
        SettingMongoDefault = "mongodb://mender-mongo:27017"
64

65
        // SettingDbName is the config key for the mongo database name
66
        SettingDbName = "mongo-dbname"
67
        // SettingDbNameDefault is the default value for the mongo database name
68
        SettingDbNameDefault = "workflows"
69

70
        // SettingDbSSL is the config key for the mongo SSL setting
71
        SettingDbSSL = "mongo_ssl"
72
        // SettingDbSSLDefault is the default value for the mongo SSL setting
73
        SettingDbSSLDefault = false
74

75
        // SettingDbSSLSkipVerify is the config key for the mongo SSL skip verify setting
76
        SettingDbSSLSkipVerify = "mongo_ssl_skipverify"
77
        // SettingDbSSLSkipVerifyDefault is the default value for the mongo SSL skip verify setting
78
        SettingDbSSLSkipVerifyDefault = false
79

80
        // SettingDbUsername is the config key for the mongo username
81
        SettingDbUsername = "mongo_username"
82

83
        // SettingDbPassword is the config key for the mongo password
84
        SettingDbPassword = "mongo_password"
85

86
        // SettingSMTPHost is the config key for the SMTP host
87
        SettingSMTPHost = "smtp_host"
88
        // SettingSMTPHostDefault is the default value for the SMTP host
89
        SettingSMTPHostDefault = "localhost:25"
90

91
        // SettingSMTPAuthMechanism is the config key for the SMTP auth mechanism
92
        SettingSMTPAuthMechanism = "smtp_auth_mechanism"
93
        // SettingSMTPAuthMechanismDefault is the default value for the SMTP auth mechanism
94
        SettingSMTPAuthMechanismDefault = "PLAIN"
95

96
        // SettingSMTPUsername is the config key for the SMTP username
97
        SettingSMTPUsername = "smtp_username"
98

99
        // SettingSMTPPassword is the config key for the SMTP password
100
        SettingSMTPPassword = "smtp_password"
101

102
        // SettingWorkflowsPath is the config key for the workflows path
103
        SettingWorkflowsPath = "workflows_path"
104

105
        // SettingConcurrency is the config key for the concurrency limit
106
        SettingConcurrency = "concurrency"
107
        // SettingConcurrencyDefault is the default value for the concurrency limit
108
        SettingConcurrencyDefault = 10
109

110
        // SettingDebugLog is the config key for the truning on the debug log
111
        SettingDebugLog = "debug_log"
112
        // SettingDebugLogDefault is the default value for the debug log enabling
113
        SettingDebugLogDefault = false
114
)
115

116
var (
117
        // Defaults are the default configuration settings
118
        Defaults = []config.Default{
119
                {Key: SettingListen, Value: SettingListenDefault},
120
                {Key: SettingNatsURI, Value: SettingNatsURIDefault},
121
                {Key: SettingNatsStreamName, Value: SettingNatsStreamNameDefault},
122
                {Key: SettingNatsSubscriberTopic, Value: SettingNatsSubscriberTopicDefault},
123
                {Key: SettingNatsSubscriberDurable, Value: SettingNatsSubscriberDurableDefault},
124
                {Key: SettingMongo, Value: SettingMongoDefault},
125
                {Key: SettingDbName, Value: SettingDbNameDefault},
126
                {Key: SettingDbSSL, Value: SettingDbSSLDefault},
127
                {Key: SettingDbSSLSkipVerify, Value: SettingDbSSLSkipVerifyDefault},
128
                {Key: SettingSMTPHost, Value: SettingSMTPHostDefault},
129
                {Key: SettingSMTPAuthMechanism, Value: SettingSMTPAuthMechanismDefault},
130
                {Key: SettingConcurrency, Value: SettingConcurrencyDefault},
131
                {Key: SettingDebugLog, Value: SettingDebugLogDefault},
132
                {Key: SettingNatsConsumerAckWait, Value: SettingNatsConsumerAckWaitDefault},
133
                {Key: SettingNatsConsumerMaxDeliver, Value: SettingNatsConsumerMaxDeliverDefault},
134
                {Key: SettingNatsConsumerMaxPending, Value: SettingNatsConsumerMaxPendingDefault},
135
        }
136
)
137

138
func GetNatsConsumerConfig(c config.Reader) (consumer nats.ConsumerConfig, err error) {
×
139
        streamName := c.GetString(SettingNatsStreamName)
×
140
        consumer.Filter = streamName + "." + c.GetString(SettingNatsSubscriberTopic)
×
141
        consumer.AckWait = c.GetDuration(SettingNatsConsumerAckWait)
×
142
        consumer.MaxDeliver = c.GetInt(SettingNatsConsumerMaxDeliver)
×
143
        consumer.MaxPending = c.GetInt(SettingNatsConsumerMaxPending)
×
144
        return consumer, errors.WithMessage(
×
145
                consumer.Validate(),
×
146
                `invalid settings "nats.consumer"`,
×
147
        )
×
148
}
×
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