forked from openshift/machine-config-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openshift#125 from gabemontero/improve-version-status
Improve version status
- Loading branch information
Showing
8 changed files
with
100 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package framework | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
configv1 "github.com/openshift/api/config/v1" | ||
configv1client "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1" | ||
) | ||
|
||
const ( | ||
clusterVersionName = "version" | ||
) | ||
|
||
func addCompomentOverride(overrides []configv1.ComponentOverride, override configv1.ComponentOverride) ([]configv1.ComponentOverride, bool) { | ||
for i, o := range overrides { | ||
if o.Group == override.Group && o.Kind == override.Kind && | ||
o.Namespace == override.Namespace && o.Name == override.Name { | ||
if overrides[i].Unmanaged == override.Unmanaged { | ||
return overrides, false | ||
} | ||
overrides[i].Unmanaged = override.Unmanaged | ||
return overrides, true | ||
} | ||
} | ||
return append(overrides, override), true | ||
} | ||
|
||
// DisableCVOForOperator disables the samples operator deployment so we can modify the version env | ||
func DisableCVOForOperator(operatorClient *configv1client.ConfigV1Client) error { | ||
cv, err := operatorClient.ClusterVersions().Get(clusterVersionName, metav1.GetOptions{}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
var changed bool | ||
cv.Spec.Overrides, changed = addCompomentOverride(cv.Spec.Overrides, configv1.ComponentOverride{ | ||
Kind: "Deployment", | ||
Namespace: "openshift-cluster-samples-operator", | ||
Name: "cluster-samples-operator", | ||
Unmanaged: true, | ||
}) | ||
if !changed { | ||
return nil | ||
} | ||
if _, err := operatorClient.ClusterVersions().Update(cv); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |