-
Notifications
You must be signed in to change notification settings - Fork 24
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 #73 from tsuru/feat/cache-orchestration
Add support to cache snapshot
- Loading branch information
Showing
19 changed files
with
1,082 additions
and
125 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
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,30 @@ | ||
// Copyright 2020 tsuru authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package v1alpha1 | ||
|
||
const ( | ||
teamOwnerLabel = "rpaas.extensions.tsuru.io/team-owner" | ||
) | ||
|
||
func (i *RpaasInstance) SetTeamOwner(team string) { | ||
newLabels := map[string]string{teamOwnerLabel: team} | ||
i.Labels = mergeMap(i.Labels, newLabels) | ||
i.Annotations = mergeMap(i.Annotations, newLabels) | ||
i.Spec.PodTemplate.Labels = mergeMap(i.Spec.PodTemplate.Labels, newLabels) | ||
} | ||
|
||
func (i *RpaasInstance) TeamOwner() string { | ||
return i.Labels[teamOwnerLabel] | ||
} | ||
|
||
func mergeMap(a, b map[string]string) map[string]string { | ||
if a == nil { | ||
return b | ||
} | ||
for k, v := range b { | ||
a[k] = v | ||
} | ||
return a | ||
} |
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,35 @@ | ||
// Copyright 2020 tsuru authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_SetTeamOwner(t *testing.T) { | ||
instance := &RpaasInstance{} | ||
instance.SetTeamOwner("team-one") | ||
expected := map[string]string{teamOwnerLabel: "team-one"} | ||
assert.Equal(t, expected, instance.Labels) | ||
assert.Equal(t, expected, instance.Annotations) | ||
assert.Equal(t, expected, instance.Spec.PodTemplate.Labels) | ||
|
||
instance.SetTeamOwner("team-two") | ||
expected = map[string]string{teamOwnerLabel: "team-two"} | ||
assert.Equal(t, expected, instance.Labels) | ||
assert.Equal(t, expected, instance.Annotations) | ||
assert.Equal(t, expected, instance.Spec.PodTemplate.Labels) | ||
} | ||
|
||
func Test_GetTeamOwner(t *testing.T) { | ||
instance := &RpaasInstance{} | ||
owner := instance.TeamOwner() | ||
assert.Equal(t, "", owner) | ||
instance.SetTeamOwner("team-one") | ||
owner = instance.TeamOwner() | ||
assert.Equal(t, "team-one", owner) | ||
} |
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
Oops, something went wrong.