Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add constants crate #1709

Merged
merged 3 commits into from
Aug 18, 2021
Merged

Conversation

arnaldo2792
Copy link
Contributor

@arnaldo2792 arnaldo2792 commented Aug 11, 2021

Issue number:
#123

Description of changes:

7c3cdbe5 sources: use shared constants crate in crates
5b17ca46 sources: add constants crate
56e97663 sources: remove unused struct from apiserver mod

This change adds the constants crate and updates the following crates to use it:

  • apiclient
  • bootstrap-containers
  • certdog
  • corndog
  • early-boot-config
  • ecs-settings-applier
  • host-containers
  • pluto
  • schnauzer
  • service-dog
  • settings-commiter
  • static-pods
  • storewolf
  • sundog
  • thar-be-settings
  • thar-be-updates

As part of this PR, I included a small nit to removed an unused struct imported in sources/api/apiserver/src/server/mod.rs.

Testing done:

aws-k8s-1.21, aws-k8s-1.19, aws-ecs-1:

  • I ran an nginx pod/task and called curl http://localhost from within the pod/task
  • systemctl status didn't show any failures
  • I let the workloads run for +1 hour and journalctl -p notice didn't show any alarming message

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

This commit removes the `BaseHttpResponse` struct from the apiserver's
mod.rs file

Signed-off-by: Arnaldo Garcia Rincon <[email protected]>
@arnaldo2792
Copy link
Contributor Author

Forced push includes:

  • Rename bottlerocket-constants to constants

@webern
Copy link
Contributor

webern commented Aug 12, 2021

  • Rename bottlerocket-constants to constants

I was going to suggest that change. 😎

@@ -87,21 +87,15 @@ use std::fs;
use std::path::Path;
use std::process::{self, Command};
use std::str::FromStr;
use constants;
Copy link
Contributor

@webern webern Aug 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably import the constant names instead of qualifying them everywhere. (Same in all places...)

Suggested change
use constants;
use constants::{API_SOCKET, HOST_CTR_BIN, SYSTEMCTL_BIN};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a case where the opposite is justifiable - qualified constants make it clear that they're not crate-specific, where unqualified ones look like "standard" constants you'd expect in the same file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qualified constants make it clear that they're not crate-specific, where unqualified ones look like "standard" constants you'd expect in the same file.

I guess I don't have the expectation that constants are in the same file. To me they're like all other symbols. That is, I have to jump to definition to know where they are. Not a big deal though.

Copy link
Contributor

@zmrow zmrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one nit - thanks for doing this!


Current version: 0.1.0

This crate contains constants shared accross multiple bottlerocket's crates
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Across is misspelled :)

I think this should probably read shared across multiple Bottlerocket crates

This commit adds the constants crate, which is shared accross different
crates

Signed-off-by: Arnaldo Garcia Rincon <[email protected]>
This commit updates the following crates to use the shared constants
crate:

- apiclient
- bootstrap-containers
- certdog
- corndog
- early-boot-config
- ecs-settings-applier
- host-containers
- pluto
- schnauzer
- service-dog
- settings-commiter
- static-pods
- storewolf
- sundog
- thar-be-settings
- thar-be-updates

Signed-off-by: Arnaldo Garcia Rincon <[email protected]>
@arnaldo2792
Copy link
Contributor Author

arnaldo2792 commented Aug 17, 2021

Forced push includes fix in crate's doc string

@@ -24,16 +24,11 @@ use std::env;
use std::ffi::OsStr;
use std::process::{self, Command};
use std::str::FromStr;
use constants;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$1.00 if we delete servicedog since we haven't used it for anything in over a year 😀

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will owe me $2 dollars 🤑

@arnaldo2792 arnaldo2792 merged commit b9c8747 into bottlerocket-os:develop Aug 18, 2021
@arnaldo2792 arnaldo2792 deleted the constants branch November 29, 2021 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stop hardcoding API constants across several programs
5 participants