Skip to content

Commit

Permalink
feat(config): var to disable a service (#88)
Browse files Browse the repository at this point in the history
active: false
  • Loading branch information
JosephKav authored Jun 15, 2022
1 parent a24e194 commit 8606bbf
Show file tree
Hide file tree
Showing 19 changed files with 41 additions and 24 deletions.
5 changes: 5 additions & 0 deletions service/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ func (s *Service) GetAccessToken() string {
return utils.DefaultIfNil(utils.GetFirstNonNilPtr(s.AccessToken, s.Defaults.AccessToken, s.HardDefaults.AccessToken))
}

// GetActive will return whether the Service is Active or not (default = true)
func (s *Service) GetActive() bool {
return utils.EvalBoolPtr(s.Active, true)
}

// GetAllowInvalidCerts returns whether invalid HTTPS certs are allowed.
func (s *Service) GetAllowInvalidCerts() bool {
return *utils.GetFirstNonNilPtr(s.AllowInvalidCerts, s.Defaults.AllowInvalidCerts, s.HardDefaults.AllowInvalidCerts)
Expand Down
6 changes: 6 additions & 0 deletions service/track.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ import (
// Track will call Track on all Services in this Slice.
func (s *Slice) Track(ordering *[]string) {
for _, key := range *ordering {
// Skip disabled Services
if !(*s)[key].GetActive() {
continue
}
(*s)[key].Active = nil

jLog.Verbose(
fmt.Sprintf("Tracking %s at %s every %s", *(*s)[key].ID, (*s)[key].GetServiceURL(true), (*s)[key].GetInterval()),
utils.LogFrom{Primary: *(*s)[key].ID},
Expand Down
1 change: 1 addition & 0 deletions service/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type Slice map[string]*Service
// the latest version from the URL provided.
type Service struct {
ID *string `yaml:"-"` // service_name.
Active *bool `yaml:"active,omitempty"` // Disable the service
Type *string `yaml:"type,omitempty"` // "github"/"URL"
URL *string `yaml:"url,omitempty"` // type:URL - "https://example.com", type:github - "owner/repo" or "https://github.com/owner/repo".
AllowInvalidCerts *bool `yaml:"allow_invalid_certs,omitempty"` // default - false = Disallows invalid HTTPS certificates.
Expand Down
2 changes: 2 additions & 0 deletions web/api/types/argus.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

// ServiceSummary is the Summary of a Service.
type ServiceSummary struct {
Active *bool `json:"active,omitempty"` // Active Service?
ID *string `json:"id"`
Type *string `json:"type,omitempty"` // "github"/"URL"
URL *string `json:"url,omitempty"` // type:URL - "https://example.com", type:github - "owner/repo" or "https://github.com/owner/repo".
Expand Down Expand Up @@ -240,6 +241,7 @@ type ServiceSlice map[string]*Service
// Service is a source to be serviceed and provides everything needed to extract
// the latest version from the URL provided.
type Service struct {
Active *bool `json:"active,omitempty"` // Active Service?
Type *string `json:"type,omitempty"` // "github"/"URL"
URL *string `json:"url,omitempty"` // type:URL - "https://example.com", type:github - "owner/repo" or "https://github.com/owner/repo".
WebURL *string `json:"web_url,omitempty"` // URL to provide on the Web UI
Expand Down
2 changes: 2 additions & 0 deletions web/api/v1/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func (api *API) wsService(client *Client) {
hasDeployedVersionLookup := service.DeployedVersionLookup != nil

serviceSummary := api_types.ServiceSummary{
Active: service.Active,
ID: service.ID,
Type: service.Type,
URL: &url,
Expand Down Expand Up @@ -510,6 +511,7 @@ func (api *API) wsConfigService(client *Client) {
service := api.Config.Service[key]

serviceConfig[key] = &api_types.Service{
Active: service.Active,
Type: service.Type,
URL: service.URL,
WebURL: service.WebURL,
Expand Down
2 changes: 1 addition & 1 deletion web/ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions web/ui/react-app/src/components/approvals/service-info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ export const ServiceInfo = ({

// If version hasn't been found or a new version has been found
const serviceWarning =
service?.status?.deployed_version === undefined ||
service?.status?.deployed_version === "" ||
(updateAvailable && !updateSkipped);
service.active !== false &&
(service?.status?.deployed_version === undefined ||
service?.status?.deployed_version === "" ||
(updateAvailable && !updateSkipped));

const IconDeployedVersionIndicator = forwardRef((props, ref) =>
service.has_deployed_version ? (
Expand Down Expand Up @@ -262,14 +263,16 @@ export const ServiceInfo = ({
>
{service?.status?.last_queried ? (
<>
Queried{" "}
queried{" "}
{formatRelative(
new Date(service.status.last_queried),
new Date()
)}
</>
) : service.loading ? (
"loading"
) : service.active === false ? (
"disabled"
) : (
"no successful queries"
)}
Expand Down
6 changes: 1 addition & 5 deletions web/ui/react-app/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,6 @@ body {
.same-color-as-background {
color: var(--background);
}
.same-background-color {
color: var(--dark-text);
background-color: var(--background);
}

.card-footer {
border-top: none;
Expand All @@ -340,7 +336,7 @@ body {
}

.list-group-item-secondary {
background-color: var(--background);
background-color: transparent;
color: var(--dark-text);
}
.list-group-item-warning {
Expand Down
1 change: 1 addition & 0 deletions web/ui/react-app/src/types/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export interface ServiceListType {
}

export interface ServiceType {
active?: boolean;
type: string;
url?: string;
allow_invalid_certs?: boolean;
Expand Down
1 change: 1 addition & 0 deletions web/ui/react-app/src/types/summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface ServiceSummaryListType {
}

export interface ServiceSummaryType {
active?: boolean;
id: string;
loading: boolean;
type?: string;
Expand Down
12 changes: 6 additions & 6 deletions web/ui/static/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"files": {
"main.css": "./static/css/main.93d93d0c.css",
"main.js": "./static/js/main.7137ee59.js",
"main.css": "./static/css/main.f180f0e2.css",
"main.js": "./static/js/main.5bdafa73.js",
"index.html": "./index.html",
"main.93d93d0c.css.map": "./static/css/main.93d93d0c.css.map",
"main.7137ee59.js.map": "./static/js/main.7137ee59.js.map"
"main.f180f0e2.css.map": "./static/css/main.f180f0e2.css.map",
"main.5bdafa73.js.map": "./static/js/main.5bdafa73.js.map"
},
"entrypoints": [
"static/css/main.93d93d0c.css",
"static/js/main.7137ee59.js"
"static/css/main.f180f0e2.css",
"static/js/main.5bdafa73.js"
]
}
2 changes: 1 addition & 1 deletion web/ui/static/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="./favicon.svg" type="image/svg+xml"/><link rel="apple-touch-icon" href="./apple-touch-icon.png"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="Argus" content="Monitor new releases"/><link rel="apple-touch-icon" href="./favicon.png"/><link rel="manifest" href="./manifest.json"/><title>Argus</title><script defer="defer" src="./static/js/main.7137ee59.js"></script><link href="./static/css/main.93d93d0c.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="./favicon.svg" type="image/svg+xml"/><link rel="apple-touch-icon" href="./apple-touch-icon.png"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="Argus" content="Monitor new releases"/><link rel="apple-touch-icon" href="./favicon.png"/><link rel="manifest" href="./manifest.json"/><title>Argus</title><script defer="defer" src="./static/js/main.5bdafa73.js"></script><link href="./static/css/main.f180f0e2.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
1 change: 0 additions & 1 deletion web/ui/static/static/css/main.93d93d0c.css.map

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions web/ui/static/static/css/main.f180f0e2.css.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions web/ui/static/static/js/main.5bdafa73.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion web/ui/static/static/js/main.7137ee59.js.map

This file was deleted.

0 comments on commit 8606bbf

Please sign in to comment.