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

Refactor: Make Options More Readable #1186

Merged
merged 5 commits into from
Oct 18, 2022

Conversation

daniel-hutao
Copy link
Member

@daniel-hutao daniel-hutao commented Oct 18, 2022

Pre-Checklist

Note: please complete ALL items in the following checklist.

  • I have read through the CONTRIBUTING.md documentation.
  • My code has the necessary comments and documentation (if needed).
  • I have added relevant tests

Description

  1. Create/Update/Read/Delete function params and return values refactoring.
  2. outputs refactoring.

Related Issues

N/A

New Behavior (screenshots if needed)

Config

  • config-harbor.yaml
---
# core config
varFile: "" # If not empty, use the specified external variables config file
toolFile: "" # If not empty, use the specified external tools config file
state: # state config, backend can be local or s3
  backend: local
  options:
    stateFile: devstream.state

---
tools:
# name of the tool
- name: harbor
  # id of the tool instance
  instanceID: default
  # format: name.instanceID; If specified, dtm will make sure the dependency is applied first before handling this tool.
  dependsOn: [ ]
  # options for the plugin
  options:
    repo:
      name: harbor
      # url of the Helm repo, use self host helm config beacuse official helm does'nt support namespace config
      url: https://helm.goharbor.io
    # Helm chart information
    chart:
      # local path of the chart; if chartPath != "", repo.name and repo.url will be ignored. e.g. "foo.tgz", "./foo.tgz", "/tmp/foo.tgz"
      chartPath: ""
      # name of the chart
      chartName: harbor/harbor
      # k8s namespace where Harbor will be installed
      namespace: harbor
      # release name of the chart
      releaseName: harbor
      # whether to wait for the release to be deployed or not
      wait: true
      # the time to wait for any individual Kubernetes operation (like Jobs for hooks). This defaults to 5m0s
      timeout: 10m
      # whether to perform a CRD upgrade during installation
      upgradeCRDs: true
      valuesYaml: |
        expose:
          type: nodePort
          tls:
            enabled: false
        chartmuseum:
          enabled: false
        clair:
          enabled: false
        notary:
          enabled: false
        trivy:
          enabled: false

Apply Once

  • apply ./dtm apply -f config-harbor.yaml -y
2022-10-18 14:11:53 ℹ [INFO]  Apply started.
2022-10-18 14:11:53 ℹ [INFO]  Using dir </Users/danielhu/.devstream/plugins> to store plugins.
2022-10-18 14:11:53 ℹ [INFO]  Using local backend. State file: devstream.state.
2022-10-18 14:11:53 ℹ [INFO]  Tool (harbor/default) found in config but doesn't exist in the state, will be created.
2022-10-18 14:11:53 ℹ [INFO]  Start executing the plan.
2022-10-18 14:11:53 ℹ [INFO]  Changes count: 1.
2022-10-18 14:11:53 ℹ [INFO]  -------------------- [  Processing progress: 1/1.  ] --------------------
2022-10-18 14:11:53 ℹ [INFO]  Processing: (harbor/default) -> Create ...
2022-10-18 14:11:55 ℹ [INFO]  Creating or updating helm chart ...
2022/10/18 14:11:58 checking 30 resources for changes
2022/10/18 14:11:58 Created a new Secret called "harbor-core" in harbor
...
2022/10/18 14:16:27 Deployment is not ready: harbor/harbor-jobservice. 0 out of 1 expected pods are ready
2022/10/18 14:16:30 release installed successfully: harbor/harbor-1.10.1
2022-10-18 14:16:30 ✔ [SUCCESS]  Tool (harbor/default) Create done.
2022-10-18 14:16:30 ℹ [INFO]  -------------------- [  Processing done.  ] --------------------
2022-10-18 14:16:30 ✔ [SUCCESS]  All plugins applied successfully.
2022-10-18 14:16:30 ✔ [SUCCESS]  Apply finished.

State

  • state
harbor_default:
  name: harbor
  instanceID: default
  dependsOn: []
  options:
    chart:
      chartName: harbor/harbor
      chartPath: ""
      namespace: harbor
      releaseName: harbor
      timeout: 10m
      upgradeCRDs: true
      valuesYaml: |
        expose:
          type: nodePort
          tls:
            enabled: false
        chartmuseum:
          enabled: false
        clair:
          enabled: false
        notary:
          enabled: false
        trivy:
          enabled: false
      wait: true
    repo:
      name: harbor
      url: https://helm.goharbor.io
  resourceStatus:
    workflows: |
      deployment:
        - name: harbor-core
          ready: true
        - name: harbor-jobservice
          ready: true
        - name: harbor-nginx
          ready: true
        - name: harbor-portal
          ready: true
        - name: harbor-registry
          ready: true
      statefulset:
        - name: harbor-database
          ready: true
        - name: harbor-redis
          ready: true
      daemonset: []

Apply Twice

2022-10-18 14:18:01 ℹ [INFO]  Apply started.
2022-10-18 14:18:01 ℹ [INFO]  Using dir </Users/danielhu/.devstream/plugins> to store plugins.
2022-10-18 14:18:01 ℹ [INFO]  Using local backend. State file: devstream.state.
2022-10-18 14:18:01 ℹ [INFO]  No changes done since last apply. There is nothing to do.
2022-10-18 14:18:01 ✔ [SUCCESS]  Apply finished.

Delete

  • ./dtm delete -f config-harbor.yaml -y
2022-10-18 14:18:18 ℹ [INFO]  Delete started.
2022-10-18 14:18:18 ℹ [INFO]  Using dir </Users/danielhu/.devstream/plugins> to store plugins.
2022-10-18 14:18:18 ℹ [INFO]  Using local backend. State file: devstream.state.
2022-10-18 14:18:18 ℹ [INFO]  Tool (harbor/default) will be deleted.
2022-10-18 14:18:18 ℹ [INFO]  Start executing the plan.
2022-10-18 14:18:18 ℹ [INFO]  Changes count: 1.
2022-10-18 14:18:18 ℹ [INFO]  -------------------- [  Processing progress: 1/1.  ] --------------------
2022-10-18 14:18:18 ℹ [INFO]  Processing: (harbor/default) -> Delete ...
2022-10-18 14:18:19 ℹ [INFO]  Uninstalling harbor helm chart.
2022/10/18 14:18:19 uninstall: Deleting harbor
2022/10/18 14:18:21 Starting delete for "harbor-registry" Service
2022/10/18 14:18:21 Starting delete for "harbor-jobservice" Service
2022/10/18 14:18:21 Starting delete for "harbor-portal" Service
2022/10/18 14:18:21 Starting delete for "harbor-redis" Service
2022/10/18 14:18:21 Starting delete for "harbor-core" Service
2022/10/18 14:18:21 Starting delete for "harbor" Service
2022/10/18 14:18:21 Starting delete for "harbor-database" Service
2022/10/18 14:18:21 Starting delete for "harbor-redis" StatefulSet
2022/10/18 14:18:21 Starting delete for "harbor-database" StatefulSet
2022/10/18 14:18:21 Starting delete for "harbor-registry" Deployment
2022/10/18 14:18:21 Starting delete for "harbor-jobservice" Deployment
2022/10/18 14:18:21 Starting delete for "harbor-nginx" Deployment
2022/10/18 14:18:21 Starting delete for "harbor-portal" Deployment
2022/10/18 14:18:21 Starting delete for "harbor-core" Deployment
2022/10/18 14:18:21 Starting delete for "harbor-nginx" ConfigMap
2022/10/18 14:18:21 Starting delete for "harbor-registryctl" ConfigMap
2022/10/18 14:18:21 Starting delete for "harbor-core" ConfigMap
2022/10/18 14:18:21 Starting delete for "harbor-portal" ConfigMap
2022/10/18 14:18:21 Starting delete for "harbor-registry" ConfigMap
2022/10/18 14:18:21 Starting delete for "harbor-jobservice" ConfigMap
2022/10/18 14:18:21 Starting delete for "harbor-jobservice-env" ConfigMap
2022/10/18 14:18:21 Starting delete for "harbor-registryctl" Secret
2022/10/18 14:18:21 Starting delete for "harbor-database" Secret
2022/10/18 14:18:21 Starting delete for "harbor-core" Secret
2022/10/18 14:18:21 Starting delete for "harbor-registry" Secret
2022/10/18 14:18:21 Starting delete for "harbor-registry-htpasswd" Secret
2022/10/18 14:18:21 Starting delete for "harbor-jobservice" Secret
2022/10/18 14:18:21 purge requested for harbor
2022/10/18 14:18:21 release uninstalled, response: &{0x14001040000 These resources were kept due to the resource policy:
[PersistentVolumeClaim] harbor-jobservice-scandata
[PersistentVolumeClaim] harbor-jobservice
[PersistentVolumeClaim] harbor-registry
}
2022-10-18 14:18:21 ℹ [INFO]  Prepare to delete 'harbor_default' from States.
2022-10-18 14:18:21 ✔ [SUCCESS]  Tool (harbor/default) delete done.
2022-10-18 14:18:21 ℹ [INFO]  -------------------- [  Processing done.  ] --------------------
2022-10-18 14:18:21 ✔ [SUCCESS]  All plugins deleted successfully.
2022-10-18 14:18:21 ✔ [SUCCESS]  Delete finished.

…sourceStatus

Signed-off-by: Daniel Hu <tao.hu@merico.dev>
Signed-off-by: Daniel Hu <tao.hu@merico.dev>
@daniel-hutao daniel-hutao marked this pull request as ready for review October 18, 2022 06:20
@daniel-hutao daniel-hutao requested review from IronCore864 and a team as code owners October 18, 2022 06:20
internal/pkg/develop/plugin/template/delete.go Outdated Show resolved Hide resolved
internal/pkg/statemanager/state.go Outdated Show resolved Hide resolved
Signed-off-by: Daniel Hu <tao.hu@merico.dev>
Copy link
Member

@aFlyBird0 aFlyBird0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@daniel-hutao daniel-hutao merged commit 641a6f5 into devstream-io:main Oct 18, 2022
@daniel-hutao daniel-hutao deleted the refactor-ht branch October 18, 2022 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants