Skip to content

Commit

Permalink
dev: renaming NO_RESOURCE_REQUESTS (PROJQUAY-3054)
Browse files Browse the repository at this point in the history
Using SKIP_RESOURCE_REQUESTS makes more sense.
  • Loading branch information
ricardomaraschini committed Jan 14, 2022
1 parent a0a5380 commit 18df5fb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
16 changes: 8 additions & 8 deletions controllers/quay/quayregistry_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ const (
// QuayRegistryReconciler reconciles a QuayRegistry object
type QuayRegistryReconciler struct {
client.Client
Log logr.Logger
Scheme *runtime.Scheme
EventRecorder record.EventRecorder
WatchNamespace string
Mtx *sync.Mutex
Requeue ctrl.Result
NoResourceRequests bool
Log logr.Logger
Scheme *runtime.Scheme
EventRecorder record.EventRecorder
WatchNamespace string
Mtx *sync.Mutex
Requeue ctrl.Result
SkipResourceRequests bool
}

// manageQuayDeletion makes sure that we process a QuayRegistry once it is flagged for
Expand Down Expand Up @@ -476,7 +476,7 @@ func (r *QuayRegistryReconciler) Reconcile(ctx context.Context, req ctrl.Request

log.Info("inflating QuayRegistry into Kubernetes objects")
deploymentObjects, err := kustomize.Inflate(
quayContext, updatedQuay, configBundle, log, r.NoResourceRequests,
quayContext, updatedQuay, configBundle, log, r.SkipResourceRequests,
)
if err != nil {
return r.reconcileWithCondition(
Expand Down
18 changes: 9 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func main() {

// if this environment variable is set the operator removes all resource requirements
// (requests and limits), this is useful for development purposes.
nores := os.Getenv("NO_RESOURCE_REQUESTS") == "true"
skipres := os.Getenv("SKIP_RESOURCE_REQUESTS") == "true"

ctrl.SetLogger(zap.New(zap.UseDevMode(true)))

Expand All @@ -92,14 +92,14 @@ func main() {

var mtx sync.Mutex
if err = (&quaycontroller.QuayRegistryReconciler{
Client: mgr.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("QuayRegistry"),
Scheme: mgr.GetScheme(),
EventRecorder: mgr.GetEventRecorderFor("quayregistry-controller"),
WatchNamespace: namespace,
Mtx: &mtx,
Requeue: ctrl.Result{RequeueAfter: 10 * time.Second},
NoResourceRequests: nores,
Client: mgr.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("QuayRegistry"),
Scheme: mgr.GetScheme(),
EventRecorder: mgr.GetEventRecorderFor("quayregistry-controller"),
WatchNamespace: namespace,
Mtx: &mtx,
Requeue: ctrl.Result{RequeueAfter: 10 * time.Second},
SkipResourceRequests: skipres,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "QuayRegistry")
os.Exit(1)
Expand Down
4 changes: 2 additions & 2 deletions pkg/kustomize/kustomize.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ func Inflate(
quay *v1.QuayRegistry,
bundle *corev1.Secret,
log logr.Logger,
nores bool,
skipres bool,
) ([]client.Object, error) {
// Each managed component brings its own generated `config.yaml` fields which are
// accumulated under the key <component>.config.yaml and then added to the base `Secret`.
Expand Down Expand Up @@ -561,7 +561,7 @@ func Inflate(
}

for index, resource := range resources {
obj, err := middleware.Process(quay, resource, nores)
obj, err := middleware.Process(quay, resource, skipres)
if err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/middleware/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ const (
)

// Process applies any additional middleware steps to a managed k8s object that cannot be
// accomplished using the Kustomize toolchain. if nores is set all resource requests are
// accomplished using the Kustomize toolchain. if skipres is set all resource requests are
// trimmed from the objects thus deploying quay with a much smaller footprint.
func Process(quay *v1.QuayRegistry, obj client.Object, nores bool) (client.Object, error) {
func Process(quay *v1.QuayRegistry, obj client.Object, skipres bool) (client.Object, error) {
objectMeta, err := meta.Accessor(obj)
if err != nil {
return nil, err
Expand Down Expand Up @@ -70,7 +70,7 @@ func Process(quay *v1.QuayRegistry, obj client.Object, nores bool) (client.Objec
}
}

if nores {
if skipres {
// if we are deploying without resource requests we have to remove them
var noresources corev1.ResourceRequirements
for i := range dep.Spec.Template.Spec.Containers {
Expand Down Expand Up @@ -133,7 +133,7 @@ func Process(quay *v1.QuayRegistry, obj client.Object, nores bool) (client.Objec
return pvc, nil
}

if job, ok := obj.(*batchv1.Job); ok && nores {
if job, ok := obj.(*batchv1.Job); ok && skipres {
// if we are deploying without resource requests we have to remove them
var noresources corev1.ResourceRequirements
for i := range job.Spec.Template.Spec.Containers {
Expand Down

0 comments on commit 18df5fb

Please sign in to comment.