Skip to content

Commit f586aaf

Browse files
Merge pull request #1250 from benluddy/fix-release-gitignore-pattern
Fix overly broad .gitignore pattern that was excluding a vendored pac…
2 parents 5fd545c + f0ecf53 commit f586aaf

File tree

7 files changed

+373
-0
lines changed

7 files changed

+373
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,3 +452,5 @@ e2e.namespace
452452
minikube.kubeconfig
453453
apiserver.crt
454454
apiserver.key
455+
456+
!vendor/**
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*
2+
Copyright The Helm Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package release
18+
19+
import (
20+
"helm.sh/helm/v3/pkg/time"
21+
)
22+
23+
// HookEvent specifies the hook event
24+
type HookEvent string
25+
26+
// Hook event types
27+
const (
28+
HookPreInstall HookEvent = "pre-install"
29+
HookPostInstall HookEvent = "post-install"
30+
HookPreDelete HookEvent = "pre-delete"
31+
HookPostDelete HookEvent = "post-delete"
32+
HookPreUpgrade HookEvent = "pre-upgrade"
33+
HookPostUpgrade HookEvent = "post-upgrade"
34+
HookPreRollback HookEvent = "pre-rollback"
35+
HookPostRollback HookEvent = "post-rollback"
36+
HookTest HookEvent = "test"
37+
)
38+
39+
func (x HookEvent) String() string { return string(x) }
40+
41+
// HookDeletePolicy specifies the hook delete policy
42+
type HookDeletePolicy string
43+
44+
// Hook delete policy types
45+
const (
46+
HookSucceeded HookDeletePolicy = "hook-succeeded"
47+
HookFailed HookDeletePolicy = "hook-failed"
48+
HookBeforeHookCreation HookDeletePolicy = "before-hook-creation"
49+
)
50+
51+
func (x HookDeletePolicy) String() string { return string(x) }
52+
53+
// HookAnnotation is the label name for a hook
54+
const HookAnnotation = "helm.sh/hook"
55+
56+
// HookWeightAnnotation is the label name for a hook weight
57+
const HookWeightAnnotation = "helm.sh/hook-weight"
58+
59+
// HookDeleteAnnotation is the label name for the delete policy for a hook
60+
const HookDeleteAnnotation = "helm.sh/hook-delete-policy"
61+
62+
// Hook defines a hook object.
63+
type Hook struct {
64+
Name string `json:"name,omitempty"`
65+
// Kind is the Kubernetes kind.
66+
Kind string `json:"kind,omitempty"`
67+
// Path is the chart-relative path to the template.
68+
Path string `json:"path,omitempty"`
69+
// Manifest is the manifest contents.
70+
Manifest string `json:"manifest,omitempty"`
71+
// Events are the events that this hook fires on.
72+
Events []HookEvent `json:"events,omitempty"`
73+
// LastRun indicates the date/time this was last run.
74+
LastRun HookExecution `json:"last_run,omitempty"`
75+
// Weight indicates the sort order for execution among similar Hook type
76+
Weight int `json:"weight,omitempty"`
77+
// DeletePolicies are the policies that indicate when to delete the hook
78+
DeletePolicies []HookDeletePolicy `json:"delete_policies,omitempty"`
79+
}
80+
81+
// A HookExecution records the result for the last execution of a hook for a given release.
82+
type HookExecution struct {
83+
// StartedAt indicates the date/time this hook was started
84+
StartedAt time.Time `json:"started_at,omitempty"`
85+
// CompletedAt indicates the date/time this hook was completed.
86+
CompletedAt time.Time `json:"completed_at,omitempty"`
87+
// Phase indicates whether the hook completed successfully
88+
Phase HookPhase `json:"phase"`
89+
}
90+
91+
// A HookPhase indicates the state of a hook execution
92+
type HookPhase string
93+
94+
const (
95+
// HookPhaseUnknown indicates that a hook is in an unknown state
96+
HookPhaseUnknown HookPhase = "Unknown"
97+
// HookPhaseRunning indicates that a hook is currently executing
98+
HookPhaseRunning HookPhase = "Running"
99+
// HookPhaseSucceeded indicates that hook execution succeeded
100+
HookPhaseSucceeded HookPhase = "Succeeded"
101+
// HookPhaseFailed indicates that hook execution failed
102+
HookPhaseFailed HookPhase = "Failed"
103+
)
104+
105+
// Strng converts a hook phase to a printable string
106+
func (x HookPhase) String() string { return string(x) }
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Copyright The Helm Authors.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
*/
15+
16+
package release
17+
18+
import (
19+
"helm.sh/helm/v3/pkg/time"
20+
)
21+
22+
// Info describes release information.
23+
type Info struct {
24+
// FirstDeployed is when the release was first deployed.
25+
FirstDeployed time.Time `json:"first_deployed,omitempty"`
26+
// LastDeployed is when the release was last deployed.
27+
LastDeployed time.Time `json:"last_deployed,omitempty"`
28+
// Deleted tracks when this object was deleted.
29+
Deleted time.Time `json:"deleted"`
30+
// Description is human-friendly "log entry" about this release.
31+
Description string `json:"description,omitempty"`
32+
// Status is the current state of the release
33+
Status Status `json:"status,omitempty"`
34+
// Contains the rendered templates/NOTES.txt if available
35+
Notes string `json:"notes,omitempty"`
36+
}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/*
2+
Copyright The Helm Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package release
18+
19+
import (
20+
"math/rand"
21+
22+
"helm.sh/helm/v3/pkg/chart"
23+
"helm.sh/helm/v3/pkg/time"
24+
)
25+
26+
// MockHookTemplate is the hook template used for all mock release objects.
27+
var MockHookTemplate = `apiVersion: v1
28+
kind: Job
29+
metadata:
30+
annotations:
31+
"helm.sh/hook": pre-install
32+
`
33+
34+
// MockManifest is the manifest used for all mock release objects.
35+
var MockManifest = `apiVersion: v1
36+
kind: Secret
37+
metadata:
38+
name: fixture
39+
`
40+
41+
// MockReleaseOptions allows for user-configurable options on mock release objects.
42+
type MockReleaseOptions struct {
43+
Name string
44+
Version int
45+
Chart *chart.Chart
46+
Status Status
47+
Namespace string
48+
}
49+
50+
// Mock creates a mock release object based on options set by MockReleaseOptions. This function should typically not be used outside of testing.
51+
func Mock(opts *MockReleaseOptions) *Release {
52+
date := time.Unix(242085845, 0).UTC()
53+
54+
name := opts.Name
55+
if name == "" {
56+
name = "testrelease-" + string(rand.Intn(100))
57+
}
58+
59+
version := 1
60+
if opts.Version != 0 {
61+
version = opts.Version
62+
}
63+
64+
namespace := opts.Namespace
65+
if namespace == "" {
66+
namespace = "default"
67+
}
68+
69+
ch := opts.Chart
70+
if opts.Chart == nil {
71+
ch = &chart.Chart{
72+
Metadata: &chart.Metadata{
73+
Name: "foo",
74+
Version: "0.1.0-beta.1",
75+
AppVersion: "1.0",
76+
},
77+
Templates: []*chart.File{
78+
{Name: "templates/foo.tpl", Data: []byte(MockManifest)},
79+
},
80+
}
81+
}
82+
83+
scode := StatusDeployed
84+
if len(opts.Status) > 0 {
85+
scode = opts.Status
86+
}
87+
88+
info := &Info{
89+
FirstDeployed: date,
90+
LastDeployed: date,
91+
Status: scode,
92+
Description: "Release mock",
93+
Notes: "Some mock release notes!",
94+
}
95+
96+
return &Release{
97+
Name: name,
98+
Info: info,
99+
Chart: ch,
100+
Config: map[string]interface{}{"name": "value"},
101+
Version: version,
102+
Namespace: namespace,
103+
Hooks: []*Hook{
104+
{
105+
Name: "pre-install-hook",
106+
Kind: "Job",
107+
Path: "pre-install-hook.yaml",
108+
Manifest: MockHookTemplate,
109+
LastRun: HookExecution{},
110+
Events: []HookEvent{HookPreInstall},
111+
},
112+
},
113+
Manifest: MockManifest,
114+
}
115+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
Copyright The Helm Authors.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
*/
15+
16+
package release
17+
18+
import "helm.sh/helm/v3/pkg/chart"
19+
20+
// Release describes a deployment of a chart, together with the chart
21+
// and the variables used to deploy that chart.
22+
type Release struct {
23+
// Name is the name of the release
24+
Name string `json:"name,omitempty"`
25+
// Info provides information about a release
26+
Info *Info `json:"info,omitempty"`
27+
// Chart is the chart that was released.
28+
Chart *chart.Chart `json:"chart,omitempty"`
29+
// Config is the set of extra Values added to the chart.
30+
// These values override the default values inside of the chart.
31+
Config map[string]interface{} `json:"config,omitempty"`
32+
// Manifest is the string representation of the rendered template.
33+
Manifest string `json:"manifest,omitempty"`
34+
// Hooks are all of the hooks declared for this release.
35+
Hooks []*Hook `json:"hooks,omitempty"`
36+
// Version is an int which represents the version of the release.
37+
Version int `json:"version,omitempty"`
38+
// Namespace is the kubernetes namespace of the release.
39+
Namespace string `json:"namespace,omitempty"`
40+
}
41+
42+
// SetStatus is a helper for setting the status on a release.
43+
func (r *Release) SetStatus(status Status, msg string) {
44+
r.Info.Status = status
45+
r.Info.Description = msg
46+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
Copyright The Helm Authors.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
*/
15+
16+
package release
17+
18+
// UninstallReleaseResponse represents a successful response to an uninstall request.
19+
type UninstallReleaseResponse struct {
20+
// Release is the release that was marked deleted.
21+
Release *Release `json:"release,omitempty"`
22+
// Info is an uninstall message
23+
Info string `json:"info,omitempty"`
24+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
Copyright The Helm Authors.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
*/
15+
16+
package release
17+
18+
// Status is the status of a release
19+
type Status string
20+
21+
// Describe the status of a release
22+
// NOTE: Make sure to update cmd/helm/status.go when adding or modifying any of these statuses.
23+
const (
24+
// StatusUnknown indicates that a release is in an uncertain state.
25+
StatusUnknown Status = "unknown"
26+
// StatusDeployed indicates that the release has been pushed to Kubernetes.
27+
StatusDeployed Status = "deployed"
28+
// StatusUninstalled indicates that a release has been uninstalled from Kubernetes.
29+
StatusUninstalled Status = "uninstalled"
30+
// StatusSuperseded indicates that this release object is outdated and a newer one exists.
31+
StatusSuperseded Status = "superseded"
32+
// StatusFailed indicates that the release was not successfully deployed.
33+
StatusFailed Status = "failed"
34+
// StatusUninstalling indicates that a uninstall operation is underway.
35+
StatusUninstalling Status = "uninstalling"
36+
// StatusPendingInstall indicates that an install operation is underway.
37+
StatusPendingInstall Status = "pending-install"
38+
// StatusPendingUpgrade indicates that an upgrade operation is underway.
39+
StatusPendingUpgrade Status = "pending-upgrade"
40+
// StatusPendingRollback indicates that an rollback operation is underway.
41+
StatusPendingRollback Status = "pending-rollback"
42+
)
43+
44+
func (x Status) String() string { return string(x) }

0 commit comments

Comments
 (0)