Skip to content

Commit

Permalink
Add Resource Tags
Browse files Browse the repository at this point in the history
  • Loading branch information
spjmurray committed Nov 27, 2024
1 parent e320c99 commit 4c551f6
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 99 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ require (
github.com/go-chi/chi/v5 v5.1.0
github.com/oapi-codegen/runtime v1.1.1
github.com/spf13/pflag v1.0.5
github.com/unikorn-cloud/core v0.1.77
github.com/unikorn-cloud/identity v0.2.44
github.com/unikorn-cloud/region v0.1.45
github.com/unikorn-cloud/core v0.1.85
github.com/unikorn-cloud/identity v0.2.45
github.com/unikorn-cloud/region v0.1.46
go.opentelemetry.io/otel/sdk v1.31.0
k8s.io/api v0.31.1
k8s.io/apimachinery v0.31.1
Expand All @@ -18,6 +18,7 @@ require (
)

require (
github.com/Masterminds/semver/v3 v3.3.0 // indirect
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
Expand Down Expand Up @@ -50,7 +51,6 @@ require (
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/masterminds/semver v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
Expand Down
18 changes: 8 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0=
github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk=
github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ=
github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk=
Expand Down Expand Up @@ -92,8 +92,6 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/masterminds/semver v1.5.0 h1:hTxJTTY7tjvnWMrl08O6u3G6BLlKVwxSz01lVac9P8U=
github.com/masterminds/semver v1.5.0/go.mod h1:s7KNT9fnd7edGzwwP7RBX4H0v/CYd5qdOLfkL1V75yg=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down Expand Up @@ -135,12 +133,12 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/unikorn-cloud/core v0.1.77 h1:DHxIOuS5RAZylzxHF/kUt955TdmE5kJiY/Z2yqC0/e0=
github.com/unikorn-cloud/core v0.1.77/go.mod h1:S9AF4PwTQljImb9w0P2jKjzRe8fLM+rx+ZbxrAHw/yE=
github.com/unikorn-cloud/identity v0.2.44 h1:tXV/qsJ77Dkx8ba8gnBFXHWUgBNsJ2oo/5TjnyhkH7U=
github.com/unikorn-cloud/identity v0.2.44/go.mod h1:JMbS6iTYzt0OVt5AkqZys3WVnpLabGvUl8kGWcxzFZI=
github.com/unikorn-cloud/region v0.1.45 h1:qpUwB+s/SEZNHZqwHTYovtWUVdJB2AKEl06NbiIwnOw=
github.com/unikorn-cloud/region v0.1.45/go.mod h1:QqWLEfB8bNRIUAU7h5JjkQsjyJdTV+2ltDYksRjKMds=
github.com/unikorn-cloud/core v0.1.85 h1:S4B0nr0jhxF8SCsKyCRVwcx8+kJsI8fQVONLJDf9aic=
github.com/unikorn-cloud/core v0.1.85/go.mod h1:wEKzCwAnIyTbo27l++Wl+gK95TAxMsFS3y3jbFB03aw=
github.com/unikorn-cloud/identity v0.2.45 h1:YFmw3uunwdZMuYiimv4lfU6s7iTtYoc22xJqLTrlOVg=
github.com/unikorn-cloud/identity v0.2.45/go.mod h1:WzNNv05ReDMLfWsOtq53uzhX2GU2nXDw76Bdsf3BPnM=
github.com/unikorn-cloud/region v0.1.46 h1:LzyrBRej40YeOMr54zL2emkrqY1ypgOyYG8hDledlCU=
github.com/unikorn-cloud/region v0.1.46/go.mod h1:cofPuJjseRKE95xAqNa23nSL7/+LDXOBxNIHwwODpys=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/unikorn/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ type ComputeCluster struct {
type ComputeClusterSpec struct {
// Pause, if true, will inhibit reconciliation.
Pause bool `json:"pause,omitempty"`
// Tags are aribrary user data.
Tags unikornv1core.TagList `json:"tags,omitempty"`
// Region to provision the cluster in.
RegionID string `json:"regionId"`
// Network defines the Compute networking.
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/unikorn/v1alpha1/zz_generated.deepcopy.go

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

131 changes: 66 additions & 65 deletions pkg/openapi/schema.go

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

12 changes: 6 additions & 6 deletions pkg/provisioners/managers/cluster/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,16 @@ func (p *Provisioner) deleteIdentity(ctx context.Context, client regionapi.Clien
return nil
}

func (p *Provisioner) getPhysicalNetwork(ctx context.Context, client regionapi.ClientWithResponsesInterface) (*regionapi.PhysicalNetworkRead, error) {
func (p *Provisioner) getNetwork(ctx context.Context, client regionapi.ClientWithResponsesInterface) (*regionapi.NetworkRead, error) {
log := log.FromContext(ctx)

physicalNetworkID, ok := p.cluster.Annotations[coreconstants.PhysicalNetworkAnnotation]
networkID, ok := p.cluster.Annotations[coreconstants.PhysicalNetworkAnnotation]
if !ok {
//nolint: nilnil
return nil, nil
}

response, err := client.GetApiV1OrganizationsOrganizationIDProjectsProjectIDIdentitiesIdentityIDPhysicalnetworksPhysicalNetworkIDWithResponse(ctx, p.cluster.Labels[coreconstants.OrganizationLabel], p.cluster.Labels[coreconstants.ProjectLabel], p.cluster.Annotations[coreconstants.IdentityAnnotation], physicalNetworkID)
response, err := client.GetApiV1OrganizationsOrganizationIDProjectsProjectIDIdentitiesIdentityIDNetworksNetworkIDWithResponse(ctx, p.cluster.Labels[coreconstants.OrganizationLabel], p.cluster.Labels[coreconstants.ProjectLabel], p.cluster.Annotations[coreconstants.IdentityAnnotation], networkID)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -211,7 +211,7 @@ func (p *Provisioner) identityOptions(ctx context.Context, client regionapi.Clie
return nil, err
}

physicalNetwork, err := p.getPhysicalNetwork(ctx, client)
network, err := p.getNetwork(ctx, client)
if err != nil {
return nil, err
}
Expand All @@ -221,8 +221,8 @@ func (p *Provisioner) identityOptions(ctx context.Context, client regionapi.Clie
Cloud: *identity.Spec.Openstack.Cloud,
ServerGroupID: identity.Spec.Openstack.ServerGroupId,
ProviderNetwork: &computeprovisioners.ClusterOpenstackProviderOptions{
NetworkID: physicalNetwork.Spec.Openstack.NetworkId,
SubnetID: physicalNetwork.Spec.Openstack.SubnetId,
NetworkID: network.Spec.Openstack.NetworkId,
SubnetID: network.Spec.Openstack.SubnetId,
},
}

Expand Down
Loading

0 comments on commit 4c551f6

Please sign in to comment.