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

feat: CC Scope #361

Merged
merged 3 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions api/cloud-control/v1beta1/providerType.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package v1beta1
type ProviderType string

const (
ProviderGCP = ProviderType("gcp")
ProviderAzure = ProviderType("azure")
ProviderAws = ProviderType("aws")
ProviderGCP = ProviderType("gcp")
ProviderAzure = ProviderType("azure")
ProviderAws = ProviderType("aws")
ProviderOpenStack = ProviderType("openstack")
)
25 changes: 25 additions & 0 deletions api/cloud-control/v1beta1/scope_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,31 @@ type ScopeInfo struct {

// +optional
Aws *AwsScope `json:"aws,omitempty"`

// +optional
OpenStack *OpenStackScope `json:"openstack,omitempty"`
}

type OpenStackScope struct {
VpcNetwork string `json:"vpcNetwork"`
DomainName string `json:"domainName"`
TenantName string `json:"tenantName"`

Network OpenStackNetwork `json:"network"`
}

type OpenStackNetwork struct {
// +optional
Nodes string `json:"nodes,omitempty"`

// +optional
Pods string `json:"pods,omitempty"`

// +optional
Services string `json:"services,omitempty"`

// +optional
Zones []string `json:"zones,omitempty"`
}

type GcpScope struct {
Expand Down
2 changes: 2 additions & 0 deletions pkg/kcp/scope/createScope.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ func createScope(ctx context.Context, st composed.State) (error, context.Context
return createScopeAzure(ctx, state)
case cloudcontrolv1beta1.ProviderAws:
return createScopeAws(ctx, state)
case cloudcontrolv1beta1.ProviderOpenStack:
return createScopeOpenStack(ctx, state)
}

err := fmt.Errorf("unable to handle unknown provider '%s'", state.provider)
Expand Down
41 changes: 41 additions & 0 deletions pkg/kcp/scope/createScopeOpenStack.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package scope

import (
"context"
"github.com/elliotchance/pie/v2"
cloudcontrolv1beta1 "github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
"github.com/kyma-project/cloud-manager/pkg/composed"
"k8s.io/utils/ptr"
)

func createScopeOpenStack(ctx context.Context, st composed.State) (error, context.Context) {
state := st.(*State)

var zones []string
for _, worker := range state.shoot.Spec.Provider.Workers {
zones = append(zones, worker.Zones...)
}
zones = pie.Unique(zones)
zones = pie.Sort(zones)
scope := &cloudcontrolv1beta1.Scope{
Spec: cloudcontrolv1beta1.ScopeSpec{
Scope: cloudcontrolv1beta1.ScopeInfo{
OpenStack: &cloudcontrolv1beta1.OpenStackScope{
VpcNetwork: commonVpcName(state.shootNamespace, state.shootName), // ???
DomainName: state.credentialData["domainName"],
TenantName: state.credentialData["tenantName"],
Network: cloudcontrolv1beta1.OpenStackNetwork{
Nodes: ptr.Deref(state.shoot.Spec.Networking.Nodes, ""),
Pods: ptr.Deref(state.shoot.Spec.Networking.Pods, ""),
Services: ptr.Deref(state.shoot.Spec.Networking.Services, ""),
Zones: zones,
},
},
},
},
}

state.SetObj(scope)

return nil, nil
}
Loading