Skip to content

Commit

Permalink
add ip address metadata types
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Siwiec <rizzza@users.noreply.github.com>
  • Loading branch information
rizzza committed Nov 30, 2023
1 parent 3d091d9 commit b0fe1cc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 131 deletions.
11 changes: 0 additions & 11 deletions pkg/metadata/errors.go

This file was deleted.

36 changes: 3 additions & 33 deletions pkg/metadata/metadata.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
package metadata

import (
"encoding/json"
"fmt"

"go.infratographer.com/x/gidx"

"go.infratographer.com/load-balancer-api/pkg/client"
)

// LoadBalancerState state of a load balancer
type LoadBalancerState string

Expand All @@ -19,28 +10,7 @@ const (
LoadBalancerStateActive LoadBalancerState = "active"
LoadBalancerStateDeleted LoadBalancerState = "deleted"
LoadBalancerStateUpdating LoadBalancerState = "updating"
)

// LoadBalancerStatus is the status of a load balancer
type LoadBalancerStatus struct {
State LoadBalancerState `json:"state"`
}

// GetLoadbalancerStatus returns the status of a load balancer
func GetLoadbalancerStatus(metadataStatuses client.MetadataStatuses, statusNamespaceID gidx.PrefixedID) (*LoadBalancerStatus, error) {
if metadataStatuses.TotalCount > 0 {
for _, s := range metadataStatuses.Edges {
if s.Node.StatusNamespaceID == statusNamespaceID.String() {
status := &LoadBalancerStatus{}

if err := json.Unmarshal(s.Node.Data, status); err != nil {
return nil, fmt.Errorf("%w: %s", ErrInvalidStatusData, err)
}

return status, nil
}
}
}

return nil, ErrStatusNotFound
}
LoadBalancerStateIPAssigned LoadBalancerState = "ip-address.assigned"
LoadBalancerStateIPUnassigned LoadBalancerState = "ip-address.unassigned"
)
87 changes: 0 additions & 87 deletions pkg/metadata/metadata_test.go

This file was deleted.

0 comments on commit b0fe1cc

Please sign in to comment.