Skip to content

Commit

Permalink
feat: implement enum generator for proto files
Browse files Browse the repository at this point in the history
`structprotogen` now supports generating enums directly instead of using predeclared file and hardcoded types. To use this functionality, simply put `structprotogen:gen_enum` in the comment above const block, you want to have the proto definitions for.

Closes #6215

Signed-off-by: Dmitriy Matrenichev <dmitry.matrenichev@siderolabs.com>
  • Loading branch information
DmitriyMV committed Jan 11, 2023
1 parent 771b0dc commit 8e9fc13
Show file tree
Hide file tree
Showing 33 changed files with 1,797 additions and 1,136 deletions.
Binary file modified api/api.descriptors
Binary file not shown.
202 changes: 116 additions & 86 deletions api/resource/definitions/enums/enums.proto
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -19,42 +19,21 @@ enum MachineType {
TYPE_WORKER = 3;
}

// KubespanPeerState is KubeSpan peer current state.
enum KubespanPeerState {
PEER_STATE_UNKNOWN = 0;
PEER_STATE_UP = 1;
PEER_STATE_DOWN = 2;
}

// NetworkConfigLayer describes network configuration layers, with lowest priority first.
enum NetworkConfigLayer {
CONFIG_DEFAULT = 0;
CONFIG_CMDLINE = 1;
CONFIG_PLATFORM = 2;
CONFIG_OPERATOR = 3;
CONFIG_MACHINE_CONFIGURATION = 4;
}

// NetworkOperator enumerates Talos network operators.
enum NetworkOperator {
OPERATOR_DHCP_4 = 0;
OPERATOR_DHCP_6 = 1;
OPERATOR_VIP = 2;
}

// NethelpersFamily is a network family.
enum NethelpersFamily {
FAMILY_INET_4 = 0;
FAMILY_INET_6 = 1;
}

// NethelpersScope is an address scope.
enum NethelpersScope {
SCOPE_GLOBAL = 0;
SCOPE_SITE = 200;
SCOPE_LINK = 253;
SCOPE_HOST = 254;
SCOPE_NOWHERE = 255;
// NethelpersAddressFlag wraps IFF_* constants.
enum NethelpersAddressFlag {
NETHELPERS_ADDRESSFLAG_UNSPECIFIED = 0;
ADDRESS_TEMPORARY = 1;
ADDRESS_NO_DAD = 2;
ADDRESS_OPTIMISTIC = 4;
ADDRESS_DAD_FAILED = 8;
ADDRESS_HOME = 16;
ADDRESS_DEPRECATED = 32;
ADDRESS_TENTATIVE = 64;
ADDRESS_PERMANENT = 128;
ADDRESS_MANAGEMENT_TEMP = 256;
ADDRESS_NO_PREFIX_ROUTE = 512;
ADDRESS_MC_AUTO_JOIN = 1024;
ADDRESS_STABLE_PRIVACY = 2048;
}

// NethelpersADSelect is ADSelect.
Expand All @@ -78,53 +57,56 @@ enum NethelpersARPValidate {
ARP_VALIDATE_ALL = 3;
}

// NethelpersFailOverMAC is a MAC failover mode.
enum NethelpersFailOverMAC {
FAIL_OVER_MAC_NONE = 0;
FAIL_OVER_MAC_ACTIVE = 1;
FAIL_OVER_MAC_FOLLOW = 2;
// NethelpersBondMode is a bond mode.
enum NethelpersBondMode {
BOND_MODE_ROUNDROBIN = 0;
BOND_MODE_ACTIVE_BACKUP = 1;
BOND_MODE_XOR = 2;
BOND_MODE_BROADCAST = 3;
BOND_MODE8023_AD = 4;
BOND_MODE_TLB = 5;
BOND_MODE_ALB = 6;
}

// NethelpersBondXmitHashPolicy is a bond hash policy.
enum NethelpersBondXmitHashPolicy {
// layer2
BOND_XMIT_POLICY_LAYER2 = 0;
// layer3+4
BOND_XMIT_POLICY_LAYER34 = 1;
// layer2+3
BOND_XMIT_POLICY_LAYER23 = 2;
// encap2+3
BOND_XMIT_POLICY_ENCAP23 = 3;
// encap3+4
BOND_XMIT_POLICY_ENCAP34 = 4;
}

// NethelpersLACPRate is a LACP rate.
enum NethelpersLACPRate {
LACP_RATE_SLOW = 0;
LACP_RATE_FAST = 1;
// NethelpersDuplex wraps ethtool.Duplex for YAML marshaling.
enum NethelpersDuplex {
HALF = 0;
FULL = 1;
UNKNOWN = 255;
}

// NethelpersBondMode is a bond mode.
enum NethelpersBondMode {
BOND_MODE_ROUNDROBIN = 0;
BOND_MODE_ACTIVE_BACKUP = 1;
BOND_MODE_XOR = 2;
BOND_MODE_BROADCAST = 3;
BOND_MODE8023_AD = 4;
BOND_MODE_TLB = 5;
BOND_MODE_ALB = 6;
// NethelpersFailOverMAC is a MAC failover mode.
enum NethelpersFailOverMAC {
FAIL_OVER_MAC_NONE = 0;
FAIL_OVER_MAC_ACTIVE = 1;
FAIL_OVER_MAC_FOLLOW = 2;
}

// NethelpersPrimaryReselect is an ARP targets mode.
enum NethelpersPrimaryReselect {
PRIMARY_RESELECT_ALWAYS = 0;
PRIMARY_RESELECT_BETTER = 1;
PRIMARY_RESELECT_FAILURE = 2;
// NethelpersFamily is a network family.
enum NethelpersFamily {
NETHELPERS_FAMILY_UNSPECIFIED = 0;
FAMILY_INET4 = 2;
FAMILY_INET6 = 10;
}

// NethelpersLACPRate is a LACP rate.
enum NethelpersLACPRate {
LACP_RATE_SLOW = 0;
LACP_RATE_FAST = 1;
}

// NethelpersLinkType is a link type.
enum NethelpersLinkType {
option allow_alias = true;
LINK_NETROM = 0;
LINK_ETHER = 1;
LINK_EETHER = 2;
Expand All @@ -151,7 +133,8 @@ enum NethelpersLinkType {
LINK_HWX25 = 272;
LINK_CAN = 280;
LINK_PPP = 512;
LINK_CISCO_HDLC = 513;
LINK_CISCO = 513;
LINK_HDLC = 513;
LINK_LAPB = 516;
LINK_DDCMP = 517;
LINK_RAWHDLC = 518;
Expand Down Expand Up @@ -187,29 +170,22 @@ enum NethelpersLinkType {
LINK_FCFABRIC10 = 797;
LINK_FCFABRIC11 = 798;
LINK_FCFABRIC12 = 799;
LINK_IEE802_TR = 800;
LINK_IEE802TR = 800;
LINK_IEE80211 = 801;
LINK_IEE80211_PRISM = 802;
LINK_IEE80211PRISM = 802;
LINK_IEE80211_RADIOTAP = 803;
LINK_IEE8021154 = 804;
LINK_IEE8021154_MONITOR = 805;
LINK_IEE8021154MONITOR = 805;
LINK_PHONET = 820;
LINK_PHONETPIPE = 821;
LINK_CAIF = 822;
LINK_IP6_GRE = 823;
LINK_IP6GRE = 823;
LINK_NETLINK = 824;
LINK6_LOWPAN = 825;
LINK_VOID = 65535;
LINK_NONE = 65534;
}

// NethelpersDuplex wraps ethtool.Duplex for YAML marshaling.
enum NethelpersDuplex {
HALF = 0;
FULL = 1;
UNKNOWN = 255;
}

// NethelpersOperationalState wraps rtnetlink.OperationalState for YAML marshaling.
enum NethelpersOperationalState {
OPER_STATE_UNKNOWN = 0;
Expand All @@ -233,6 +209,26 @@ enum NethelpersPort {
OTHER = 255;
}

// NethelpersPrimaryReselect is an ARP targets mode.
enum NethelpersPrimaryReselect {
PRIMARY_RESELECT_ALWAYS = 0;
PRIMARY_RESELECT_BETTER = 1;
PRIMARY_RESELECT_FAILURE = 2;
}

// NethelpersRouteFlag wraps RTM_F_* constants.
enum NethelpersRouteFlag {
NETHELPERS_ROUTEFLAG_UNSPECIFIED = 0;
ROUTE_NOTIFY = 256;
ROUTE_CLONED = 512;
ROUTE_EQUALIZE = 1024;
ROUTE_PREFIX = 2048;
ROUTE_LOOKUP_TABLE = 4096;
ROUTE_FIB_MATCH = 8192;
ROUTE_OFFLOAD = 16384;
ROUTE_TRAP = 32768;
}

// NethelpersRouteProtocol is a routing protocol.
enum NethelpersRouteProtocol {
PROTOCOL_UNSPEC = 0;
Expand All @@ -259,14 +255,6 @@ enum NethelpersRouteProtocol {
PROTOCOL_EIGRP = 192;
}

// NethelpersRoutingTable is a routing table ID.
enum NethelpersRoutingTable {
TABLE_UNSPEC = 0;
TABLE_DEFAULT = 253;
TABLE_MAIN = 254;
TABLE_LOCAL = 255;
}

// NethelpersRouteType is a route type.
enum NethelpersRouteType {
TYPE_UNSPEC = 0;
Expand All @@ -283,10 +271,51 @@ enum NethelpersRouteType {
TYPE_X_RESOLVE = 11;
}

// NethelpersRoutingTable is a routing table ID.
enum NethelpersRoutingTable {
TABLE_UNSPEC = 0;
TABLE_DEFAULT = 253;
TABLE_MAIN = 254;
TABLE_LOCAL = 255;
}

// NethelpersScope is an address scope.
enum NethelpersScope {
SCOPE_GLOBAL = 0;
SCOPE_SITE = 200;
SCOPE_LINK = 253;
SCOPE_HOST = 254;
SCOPE_NOWHERE = 255;
}

// NethelpersVLANProtocol is a VLAN protocol.
enum NethelpersVLANProtocol {
VLAN_PROTOCOL8021_Q = 0;
VLAN_PROTOCOL8021_AD = 1;
NETHELPERS_VLANPROTOCOL_UNSPECIFIED = 0;
VLAN_PROTOCOL8021_Q = 33024;
VLAN_PROTOCOL8021_AD = 34984;
}

// KubespanPeerState is KubeSpan peer current state.
enum KubespanPeerState {
PEER_STATE_UNKNOWN = 0;
PEER_STATE_UP = 1;
PEER_STATE_DOWN = 2;
}

// NetworkConfigLayer describes network configuration layers, with lowest priority first.
enum NetworkConfigLayer {
CONFIG_DEFAULT = 0;
CONFIG_CMDLINE = 1;
CONFIG_PLATFORM = 2;
CONFIG_OPERATOR = 3;
CONFIG_MACHINE_CONFIGURATION = 4;
}

// NetworkOperator enumerates Talos network operators.
enum NetworkOperator {
OPERATOR_DHCP4 = 0;
OPERATOR_DHCP6 = 1;
OPERATOR_VIP = 2;
}

// RuntimeMachineStage describes the stage of the machine boot/run process.
Expand All @@ -301,3 +330,4 @@ enum RuntimeMachineStage {
MACHINE_STAGE_RESETTING = 7;
MACHINE_STAGE_UPGRADING = 8;
}

Loading

0 comments on commit 8e9fc13

Please sign in to comment.