Skip to content

Commit

Permalink
OCM-12069 | (feat): Add cluster migrations with examples
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVulaj committed Jan 21, 2025
1 parent be9d26c commit 027fe8d
Show file tree
Hide file tree
Showing 27 changed files with 25,442 additions and 21,962 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Hard tabs are required rather than spaces.

To use any updates to the [ocm-api-model](https://github.com/openshift-online/ocm-api-model), the version
must be incremented for consumption in ocm-sdk-go generation. The version is defined by the latest git tag.
The version is also defined in the ocm-api-model/CHANGES.md file.
The version is also defined in the ocm-api-model/CHANGES.md file and version.go file.

Once all changes to the OCM API Model have been committed to the main branch, submit a separate change with
an update to ocm-api-model/CHANGES.md. This update should indicate the version and describe the changes
Expand All @@ -53,7 +53,7 @@ included with the version update. The following is an example update to version
- Add `config_managed` attribute to the `RoleBinding` type.
```

Submit an MR with the CHANGES.md modification and review/merge.
Submit an MR with the CHANGES.md and version.go modifications and review/merge.

Finally, create and submit a new tag with the new version following the below example:

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export PATH := $(LOCAL_BIN_PATH):$(PATH)
export CGO_ENABLED=0

# Details of the model to use:
model_version:=v0.0.406
model_version:=v0.0.407
model_url:=https://github.com/openshift-online/ocm-api-model.git

# Details of the metamodel to use:
Expand Down
8 changes: 8 additions & 0 deletions clustersmgmt/v1/cluster_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,14 @@ func (c *ClusterClient) MetricQueries() *MetricQueriesClient {
)
}

// Migrations returns the target 'cluster_migrations' resource.
func (c *ClusterClient) Migrations() *ClusterMigrationsClient {
return NewClusterMigrationsClient(
c.transport,
path.Join(c.path, "migrations"),
)
}

// NodePools returns the target 'node_pools' resource.
//
// Reference to the resource that manages the collection of node pool resources.
Expand Down
162 changes: 162 additions & 0 deletions clustersmgmt/v1/cluster_migration_builder.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
/*
Copyright (c) 2020 Red Hat, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// IMPORTANT: This file has been generated automatically, refrain from modifying it manually as all
// your changes will be lost when the file is generated again.

package v1 // github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1

import (
time "time"
)

// ClusterMigrationBuilder contains the data and logic needed to build 'cluster_migration' objects.
//
// Representation of a cluster migration.
type ClusterMigrationBuilder struct {
bitmap_ uint32
id string
href string
clusterID string
creationTimestamp time.Time
sdnToOvn *SdnToOvnClusterMigrationBuilder
state ClusterMigrationState
type_ ClusterMigrationType
updatedTimestamp time.Time
}

// NewClusterMigration creates a new builder of 'cluster_migration' objects.
func NewClusterMigration() *ClusterMigrationBuilder {
return &ClusterMigrationBuilder{}
}

// Link sets the flag that indicates if this is a link.
func (b *ClusterMigrationBuilder) Link(value bool) *ClusterMigrationBuilder {
b.bitmap_ |= 1
return b
}

// ID sets the identifier of the object.
func (b *ClusterMigrationBuilder) ID(value string) *ClusterMigrationBuilder {
b.id = value
b.bitmap_ |= 2
return b
}

// HREF sets the link to the object.
func (b *ClusterMigrationBuilder) HREF(value string) *ClusterMigrationBuilder {
b.href = value
b.bitmap_ |= 4
return b
}

// Empty returns true if the builder is empty, i.e. no attribute has a value.
func (b *ClusterMigrationBuilder) Empty() bool {
return b == nil || b.bitmap_&^1 == 0
}

// ClusterID sets the value of the 'cluster_ID' attribute to the given value.
func (b *ClusterMigrationBuilder) ClusterID(value string) *ClusterMigrationBuilder {
b.clusterID = value
b.bitmap_ |= 8
return b
}

// CreationTimestamp sets the value of the 'creation_timestamp' attribute to the given value.
func (b *ClusterMigrationBuilder) CreationTimestamp(value time.Time) *ClusterMigrationBuilder {
b.creationTimestamp = value
b.bitmap_ |= 16
return b
}

// SdnToOvn sets the value of the 'sdn_to_ovn' attribute to the given value.
//
// Details for `SdnToOvn` cluster migrations.
func (b *ClusterMigrationBuilder) SdnToOvn(value *SdnToOvnClusterMigrationBuilder) *ClusterMigrationBuilder {
b.sdnToOvn = value
if value != nil {
b.bitmap_ |= 32
} else {
b.bitmap_ &^= 32
}
return b
}

// State sets the value of the 'state' attribute to the given value.
//
// The state of the cluster migration.
func (b *ClusterMigrationBuilder) State(value ClusterMigrationState) *ClusterMigrationBuilder {
b.state = value
b.bitmap_ |= 64
return b
}

// Type sets the value of the 'type' attribute to the given value.
//
// Type of cluster migration.
func (b *ClusterMigrationBuilder) Type(value ClusterMigrationType) *ClusterMigrationBuilder {
b.type_ = value
b.bitmap_ |= 128
return b
}

// UpdatedTimestamp sets the value of the 'updated_timestamp' attribute to the given value.
func (b *ClusterMigrationBuilder) UpdatedTimestamp(value time.Time) *ClusterMigrationBuilder {
b.updatedTimestamp = value
b.bitmap_ |= 256
return b
}

// Copy copies the attributes of the given object into this builder, discarding any previous values.
func (b *ClusterMigrationBuilder) Copy(object *ClusterMigration) *ClusterMigrationBuilder {
if object == nil {
return b
}
b.bitmap_ = object.bitmap_
b.id = object.id
b.href = object.href
b.clusterID = object.clusterID
b.creationTimestamp = object.creationTimestamp
if object.sdnToOvn != nil {
b.sdnToOvn = NewSdnToOvnClusterMigration().Copy(object.sdnToOvn)
} else {
b.sdnToOvn = nil
}
b.state = object.state
b.type_ = object.type_
b.updatedTimestamp = object.updatedTimestamp
return b
}

// Build creates a 'cluster_migration' object using the configuration stored in the builder.
func (b *ClusterMigrationBuilder) Build() (object *ClusterMigration, err error) {
object = new(ClusterMigration)
object.id = b.id
object.href = b.href
object.bitmap_ = b.bitmap_
object.clusterID = b.clusterID
object.creationTimestamp = b.creationTimestamp
if b.sdnToOvn != nil {
object.sdnToOvn, err = b.sdnToOvn.Build()
if err != nil {
return
}
}
object.state = b.state
object.type_ = b.type_
object.updatedTimestamp = b.updatedTimestamp
return
}
Loading

0 comments on commit 027fe8d

Please sign in to comment.