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

Provide a 'LastRefresh' field for OCI discoveries #138

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions config/cli_discovery_sources_it_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ currentContext:
- oci:
name: default
image: "/:"
lastrefresh: 2023-12-04 11:45:53 -0500 EST
unknown: cli-unknown
- local:
name: admin-local
Expand Down Expand Up @@ -150,13 +151,15 @@ current: test-mc
- oci:
name: default
image: "default-image"
lastrefresh: 2023-12-04 11:45:53 -0500 EST
unknown: cli-unknown
- local:
name: admin-local
path: admin
- oci:
name: new-default
image: new-default-image
lastrefresh: 2023-12-04 11:45:53 -0500 EST
contexts:
- name: test-mc
target: kubernetes
Expand Down Expand Up @@ -209,8 +212,9 @@ func TestCLIDiscoverySourceIntegration(t *testing.T) {
// Add new OCI CLI DiscoverySource
ds := &configtypes.PluginDiscovery{
OCI: &configtypes.OCIDiscovery{
Name: "new-default",
Image: "new-default-image",
Name: "new-default",
Image: "new-default-image",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
}
err = SetCLIDiscoverySource(*ds)
Expand All @@ -228,8 +232,9 @@ func TestCLIDiscoverySourceIntegration(t *testing.T) {
// Update existing OCI CLI DiscoverySource
ds = &configtypes.PluginDiscovery{
OCI: &configtypes.OCIDiscovery{
Name: "default",
Image: "default-image",
Name: "default",
Image: "default-image",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
}
err = SetCLIDiscoverySource(*ds)
Expand Down Expand Up @@ -261,6 +266,7 @@ func setupDataWithPatchStrategy() (string, string, string, string) {
- oci:
name: default
image: "/:"
lastrefresh: 2023-12-04 11:45:53 -0500 EST
unknown: cli-unknown
annotation: new-annotation
contextType: k8s
Expand All @@ -275,6 +281,7 @@ func setupDataWithPatchStrategy() (string, string, string, string) {
- oci:
name: default
image: "update-default-image"
lastrefresh: 2023-12-04 11:45:53 -0500 EST
unknown: cli-unknown
contextType: k8s
- local:
Expand All @@ -283,6 +290,7 @@ func setupDataWithPatchStrategy() (string, string, string, string) {
- oci:
name: new-default
image: new-default-image
lastrefresh: 2023-12-04 11:45:53 -0500 EST
`

return "", expectedCfg, cfg2, expectedCfg2
Expand All @@ -307,8 +315,9 @@ func TestCLIDiscoverySourceIntegrationWithPatchStrategy(t *testing.T) {
// Add new OCI CLI DiscoverySource
ds := &configtypes.PluginDiscovery{
OCI: &configtypes.OCIDiscovery{
Name: "new-default",
Image: "new-default-image",
Name: "new-default",
Image: "new-default-image",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
}
err = SetCLIDiscoverySource(*ds)
Expand All @@ -327,8 +336,9 @@ func TestCLIDiscoverySourceIntegrationWithPatchStrategy(t *testing.T) {
// Update existing OCI CLI DiscoverySource
ds = &configtypes.PluginDiscovery{
OCI: &configtypes.OCIDiscovery{
Name: "default",
Image: "update-default-image",
Name: "default",
Image: "update-default-image",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
}
err = SetCLIDiscoverySource(*ds)
Expand Down
126 changes: 80 additions & 46 deletions config/cli_discovery_sources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ func TestGetCLIDiscoverySources(t *testing.T) {
discoveries := []configtypes.PluginDiscovery{
{
OCI: &configtypes.OCIDiscovery{
Name: "test",
Image: "image",
Name: "test",
Image: "image",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
},
}
Expand Down Expand Up @@ -60,8 +61,9 @@ func TestGetCLIDiscoverySource(t *testing.T) {

discovery := &configtypes.PluginDiscovery{
OCI: &configtypes.OCIDiscovery{
Name: "test",
Image: "image",
Name: "test",
Image: "image",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
}

Expand Down Expand Up @@ -125,7 +127,7 @@ func TestSetCLIDiscoverySources(t *testing.T) {
errStr string
}{
{
name: "success add test",
name: "success add test 1",
input: []configtypes.PluginDiscovery{
{
OCI: &configtypes.OCIDiscovery{
Expand All @@ -143,7 +145,7 @@ func TestSetCLIDiscoverySources(t *testing.T) {
total: 2,
},
{
name: "success add test",
name: "success add test 2",
input: []configtypes.PluginDiscovery{
{
Local: &configtypes.LocalDiscovery{
Expand All @@ -155,7 +157,7 @@ func TestSetCLIDiscoverySources(t *testing.T) {
total: 3,
},
{
name: "success add test",
name: "success add test 3",
input: []configtypes.PluginDiscovery{
{
OCI: &configtypes.OCIDiscovery{
Expand Down Expand Up @@ -191,12 +193,26 @@ func TestSetCLIDiscoverySources(t *testing.T) {
total: 3,
},
{
name: "success add default oci",
name: "success add default oci with last refresh 0",
input: []configtypes.PluginDiscovery{
{
OCI: &configtypes.OCIDiscovery{
Name: "default",
Image: "image",
Name: "default",
Image: "image",
LastRefresh: "0", // The CLI uses "0" to reset the LastRefresh field
},
},
},
total: 3,
},
{
name: "success add default oci full last refresh time",
input: []configtypes.PluginDiscovery{
{
OCI: &configtypes.OCIDiscovery{
Name: "default",
Image: "image",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
},
},
Expand Down Expand Up @@ -288,8 +304,9 @@ func TestDeleteCLIDiscoverySource(t *testing.T) {
src: []configtypes.PluginDiscovery{
{
OCI: &configtypes.OCIDiscovery{
Name: "test",
Image: "image",
Name: "test",
Image: "image",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
},
},
Expand All @@ -302,8 +319,9 @@ func TestDeleteCLIDiscoverySource(t *testing.T) {
src: []configtypes.PluginDiscovery{
{
OCI: &configtypes.OCIDiscovery{
Name: "test",
Image: "image",
Name: "test",
Image: "image",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
},
},
Expand All @@ -315,14 +333,16 @@ func TestDeleteCLIDiscoverySource(t *testing.T) {
src: []configtypes.PluginDiscovery{
{
OCI: &configtypes.OCIDiscovery{
Name: "test",
Image: "image",
Name: "test",
Image: "image",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
},
{
OCI: &configtypes.OCIDiscovery{
Name: "test2",
Image: "image2",
Name: "test2",
Image: "image2",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
},
},
Expand All @@ -334,8 +354,9 @@ func TestDeleteCLIDiscoverySource(t *testing.T) {
src: []configtypes.PluginDiscovery{
{
OCI: &configtypes.OCIDiscovery{
Name: "test",
Image: "image",
Name: "test",
Image: "image",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
},
{
Expand Down Expand Up @@ -383,8 +404,9 @@ func TestIntegrationSetGetDeleteCLIDiscoverySource(t *testing.T) {
sources := []configtypes.PluginDiscovery{
{
OCI: &configtypes.OCIDiscovery{
Name: "default",
Image: "image",
Name: "default",
Image: "image",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
},
}
Expand Down Expand Up @@ -486,8 +508,9 @@ func TestSetCLIDiscoverySourceWithDefaultAndDefaultLocal(t *testing.T) {
input: []configtypes.PluginDiscovery{
{
OCI: &configtypes.OCIDiscovery{
Name: "default-test",
Image: "image",
Name: "default-test",
Image: "image",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
},
},
Expand All @@ -498,8 +521,9 @@ func TestSetCLIDiscoverySourceWithDefaultAndDefaultLocal(t *testing.T) {
input: []configtypes.PluginDiscovery{
{
OCI: &configtypes.OCIDiscovery{
Name: "default",
Image: "image",
Name: "default",
Image: "image",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
},
},
Expand All @@ -510,8 +534,9 @@ func TestSetCLIDiscoverySourceWithDefaultAndDefaultLocal(t *testing.T) {
input: []configtypes.PluginDiscovery{
{
OCI: &configtypes.OCIDiscovery{
Name: "default-local",
Image: "image",
Name: "default-local",
Image: "image",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
},
},
Expand All @@ -523,8 +548,9 @@ func TestSetCLIDiscoverySourceWithDefaultAndDefaultLocal(t *testing.T) {
input: []configtypes.PluginDiscovery{
{
OCI: &configtypes.OCIDiscovery{
Name: "default",
Image: "updatedImage",
Name: "default",
Image: "updatedImage",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
},
},
Expand All @@ -536,8 +562,9 @@ func TestSetCLIDiscoverySourceWithDefaultAndDefaultLocal(t *testing.T) {
input: []configtypes.PluginDiscovery{
{
OCI: &configtypes.OCIDiscovery{
Name: "default-local",
Image: "updatedImage",
Name: "default-local",
Image: "updatedImage",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
},
},
Expand All @@ -549,8 +576,9 @@ func TestSetCLIDiscoverySourceWithDefaultAndDefaultLocal(t *testing.T) {
input: []configtypes.PluginDiscovery{
{
OCI: &configtypes.OCIDiscovery{
Name: "default",
Image: "updatedImage",
Name: "default",
Image: "updatedImage",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
},
{
Expand All @@ -567,14 +595,16 @@ func TestSetCLIDiscoverySourceWithDefaultAndDefaultLocal(t *testing.T) {
},
{
OCI: &configtypes.OCIDiscovery{
Name: "default",
Image: "updatedImage2",
Name: "default",
Image: "updatedImage2",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
},
{
OCI: &configtypes.OCIDiscovery{
Name: "test-oci1",
Image: "updatedImage",
Name: "test-oci1",
Image: "updatedImage",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
},
{
Expand Down Expand Up @@ -628,8 +658,9 @@ func TestSetCLIDiscoverySourceMultiTypes(t *testing.T) {
input: []configtypes.PluginDiscovery{
{
OCI: &configtypes.OCIDiscovery{
Name: "default",
Image: "defaultImage",
Name: "default",
Image: "defaultImage",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
},
{
Expand All @@ -646,14 +677,16 @@ func TestSetCLIDiscoverySourceMultiTypes(t *testing.T) {
},
{
OCI: &configtypes.OCIDiscovery{
Name: "default",
Image: "defaultImage2",
Name: "default",
Image: "defaultImage2",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
},
{
OCI: &configtypes.OCIDiscovery{
Name: "test-oci1",
Image: "updatedImage",
Name: "test-oci1",
Image: "updatedImage",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
},
{
Expand All @@ -670,8 +703,9 @@ func TestSetCLIDiscoverySourceMultiTypes(t *testing.T) {
},
{
OCI: &configtypes.OCIDiscovery{
Name: "test-oci2",
Image: "updatedImage",
Name: "test-oci2",
Image: "updatedImage",
LastRefresh: "2023-12-04 11:45:53 -0500 EST",
},
},
},
Expand Down
Loading