Skip to content

Conversation

@jglogan
Copy link
Contributor

@jglogan jglogan commented Sep 10, 2025

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

Consistent features and UX across managed resources.

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

- Closes apple#557.
- Breaking change: removes `.upToNextOption` for labels
  on volumes as this is not what is done for containers,
  and it forces the argument to precede the options if
  a label is supplied, which is non-intuitive.
Comment on lines +47 to +52
let container = try decoder.container(keyedBy: CodingKeys.self)

id = try container.decode(String.self, forKey: .id)
mode = try container.decode(NetworkMode.self, forKey: .mode)
subnet = try container.decodeIfPresent(String.self, forKey: .subnet)
labels = try container.decodeIfPresent([String: String].self, forKey: .labels) ?? [:]
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use the CodingKey enum to stay consistent with how ContainerConfiguration.swift handles labels?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

// using our configuration data, as the one from the helper doesn't include
// metadata.
guard case .running(_, let status) = try await client.state() else {
throw ContainerizationError(.exists, message: "network \(configuration.id) failed to start")
Copy link
Contributor

Choose a reason for hiding this comment

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

would .invalidState be better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, .exists is just wrong, I think it must've just autofilled and I didn't notice it

func run() async throws {
let config = NetworkConfiguration(id: self.name, mode: .nat)
let parsedLabels = Utility.parseKeyValuePairs(labels)
let config = NetworkConfiguration(id: self.name, mode: .nat, labels: parsedLabels)
Copy link
Contributor

Choose a reason for hiding this comment

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

should we have some sort of validation on the CLI level like containers or server level like volumes, for network name or labels?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, good call, I decided to make init() for NetworkConfiguration validate and throw

@jglogan jglogan merged commit a54be36 into apple:main Sep 15, 2025
2 checks passed
Mcrich23 added a commit to Mcrich23/container that referenced this pull request Sep 17, 2025
commit 449f1d2
Author: J Logan <[email protected]>
Date:   Tue Sep 16 13:37:55 2025 -0700

    Replace scattered defaults subcommands with `system property`. (apple#604)

    Common subcommands for all defaults.

    - Closes apple#384.
    - Replaces `registry default` and `system dns default` subcommands with
    `system property`.
    - Users can use `system property ls` to see details about each supported
    default value.
    - `system property set` implements reasonable validation for all
    properties.
    - NOTE: Probing of the registry for `registry default set` was removed,
    which means users will find out about a botched setting when pulling or
    pushing.
    - Updates docs.

    ## Type of Change
    - [ ] Bug fix
    - [x] New feature
    - [x] Breaking change
    - [x] Documentation update

    ## Motivation and Context
    See apple#384.

    ## Testing
    - [x] Tested locally
    - [x] Added/updated tests
    - [x] Added/updated docs

commit 386fd87
Author: Kathryn Baldauf <[email protected]>
Date:   Tue Sep 16 10:52:08 2025 -0700

    Enumerate using relative paths to avoid mismatch with symlink resolution of special paths like /tmp (apple#613)

    ## Type of Change
    - [x] Bug fix
    - [ ] New feature
    - [ ] Breaking change
    - [ ] Documentation update

    ## Motivation and Context
    Fixes apple#588. This PR changes the
    archiver compression file enumeration to use the
    [enumerator(atPath:)](https://developer.apple.com/documentation/foundation/filemanager/enumerator(atpath:))
    version. This version returns relative paths instead of full file paths
    from the filesystem. /tmp is symlinked to /private/tmp and some swift
    packages will handle that path differently. While a call to Foundation's
    `URL.resolvingSymlinksInPath()` will return "/tmp", a call to
    `FileManager.enumerator(at:)` will return "/private/tmp". This
    difference causes a container image build to fail when the user is using
    a path under /tmp or other special case paths as the context directory.

    ## Testing
    - [x] Tested locally
    - [x] Added/updated tests
    - [ ] Added/updated docs

    Signed-off-by: Kathryn Baldauf <[email protected]>

commit 79cc363
Author: J Logan <[email protected]>
Date:   Tue Sep 16 10:14:14 2025 -0700

    Relocates API server to Helpers, service to Services. (apple#616)

    - Closes apple#615.

    Improves project organization. Separates service so it can be tested and
    used separately from the executable target. No functional changes.

commit a54be36
Author: J Logan <[email protected]>
Date:   Mon Sep 15 11:27:51 2025 -0700

    Add `--labels` for networks. (apple#600)

    - Closes apple#557.
    - Breaking change: removes `.upToNextOption` for labels on volumes as
    this is not what is done for containers, and it forces the argument to
    precede the options if a label is supplied, which is non-intuitive.

    ## Type of Change
    - [ ] Bug fix
    - [x] New feature
    - [x] Breaking change
    - [x] Documentation update

    ## Motivation and Context
    Consistent features and UX across managed resources.

    ## Testing
    - [x] Tested locally
    - [x] Added/updated tests
    - [x] Added/updated docs
@jglogan jglogan deleted the users/jglogan/network-labels branch September 23, 2025 21:51
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.

[Request]: Add container network create --label option.

2 participants