Skip to content

Refactoring Context #4081

Closed
Closed
@adisky

Description

@adisky

Some ideas to refactor context

  • Only make available single context function outside package, as with multiple functions it behaves differently
    everywhere
    https://github.com/openshift/odo/blob/master/pkg/odo/genericclioptions/context.go#L31
    add parameters to specify devfile/s2i, or if possible move the devfile/s2i detection to context,
    internally detect if clusterAccess is required for the command or not.

  • Avoid using util.LogErrorAndExit(err, "") at every where in the code. All other functions to return proper errors to NewContext function.
    call LogErrorAndExit from NewContext only by checking the errors and responding with proper wrapped message.
    This way we can properly handle errors from cluster(forbidden/timeout) and make it work for those commands that does not require cluster access.

Acceptance Criteria

  • Unify Context functions to one function -> NewContext()
    It will also include detection of s2i or devfile component in context and return context accordingly.
  • Segregate functions into separate files, so that each utility function visible clearly. (at some places we are rewriting the code that is available as function in context package)
  • Make sure some functionalities available only via context route e.g init config/envinfo, resolve app/project and remove their recurring occurrences
  • Add Annotations to the commands that does not require cluster access and ignore client initialization error for them.
  • Consolidate error handling at one place in the context package to have consistency in errors returned to the users.
  • Move the localConfigProvider interface to some common package and extend it in way that all localConfig/Envinfo data get accessed through it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/refactoringIssues or PRs related to code refactoringtriage/needs-informationIndicates an issue needs more information in order to work on it.

    Type

    No type

    Projects

    Status

    Done ✅

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions